Projet

Général

Profil

Révision 90ec5e16

ID90ec5e16ada2d862372beee6d0475f276279f660
Parent 4a7a0de1
Enfant dc35afc1

Ajouté par nagyrobi il y a plus de 12 ans

Create hdsentinel

Multigraph plugin to monitor harddrive temperature, condition, performance and estimated remaining lifetime through HDSentinel.

Voir les différences:

plugins/disk/hdsentinel
1
#!/bin/bash
2
# -*- sh -*-
3
#
4
# Multigraph plugin to monitor harddrive temperature, condition, 
5
# performance and estimated remaining lifetime through HDSentinel.
6
#
7
# To use, download the latest HDSentinel for Linux x86 or x64 from
8
# http://www.hdsentinel.com/hard_disk_sentinel_linux.php
9
# Unzip to /usr/local/bin/, make executable (chmod +x HDSentinel)
10
# in /etc/munin/plugin-conf.d/munin-node add the following lines
11
#
12
#  [hdsentinel]
13
#  user root
14
#  group root
15
#
16
# Copy this plugin to /usr/share/munin/plugins, and symlink it to
17
# /etc/munin/plugins, and then restart node.
18
#
19
#%# family=contrib
20

  
21
HDSPATH=/usr/local/bin/HDSentinel
22

  
23
if [ "$1" = "autoconf" ]; then
24
        if [ -x "$HDSPATH" ]; then
25
                echo yes
26
                exit 0
27
        else
28
                echo no
29
                exit 0
30
        fi
31
fi
32

  
33
HDSOUT=`$HDSPATH`
34
LIN=''
35
SPC=' '
36
NLN='\n'
37

  
38
OLDIFS=$IFS
39
IFS=$'\n'
40
for line in $HDSOUT; do
41
        if [[ "$line" == */dev* ]] ; then
42
                LIN=$LIN$line
43
        fi
44

  
45
  if [[ "$line" == *Temperature* ]] || [[ "$line" == *Health* ]] || [[ "$line" == *Performance* ]] ; then
46
		LIN=$LIN$SPC$line
47
	fi
48

  
49
        if [[ "$line" == *lifetime* ]] ; then
50
                LIN=$LIN$SPC$line$NLN
51
        fi
52

  
53
done
54
SLD=`echo -e $LIN`
55

  
56
echo 'multigraph hdsentinel_temps'
57
if [ "$1" = "config" ]; then
58
	echo 'graph_title HDSentinel Drive Temperature'
59
	echo 'graph_vlabel Degrees Celsius'
60
	echo 'graph_args --base 1000 -l 0'
61
	echo 'graph_category sensors'
62
	echo 'graph_info Temperatures calculated by HDSentinel from SMART'
63
fi
64
for linf in $SLD; do
65
	DEV=`echo $linf | awk '{printf $4}' | awk '{printf substr($0,6)}'`
66
	echo -n $DEV
67
	if [ "$1" = "config" ]; then
68
		echo '_temp.label '$DEV
69
                echo $DEV'_temp.warning 55'
70
                echo $DEV'_temp.critical 70'
71
	else
72
		echo -n '_temp.value '
73
		TEMP=`echo $linf | awk '{print $7}'`
74
        	if [[ "$TEMP" == *Unknown* ]] || [[ "$line" == "" ]] ; then
75
	                TEMP='U'
76
        	fi
77
		echo $TEMP
78
	fi
79
done
80
echo
81

  
82
echo 'multigraph hdsentinel_health'
83
if [ "$1" = "config" ]; then
84
        echo 'graph_title HDSentinel Drive Health'
85
        echo 'graph_vlabel %'
86
        echo 'graph_args --base 1000 -l 0 --lower-limit 0 --upper-limit 100'
87
        echo 'graph_category disk'
88
        echo 'graph_info Drive health in percent calculated by HDSentinel from SMART'
89
fi
90
for linf in $SLD; do
91
        DEV=`echo $linf | awk '{printf $4}' | awk '{printf substr($0,6)}'`
92
        echo -n $DEV
93
        if [ "$1" = "config" ]; then
94
                echo '_heal.label '$DEV
95
		echo $DEV'_heal.warning 100:'
96
                echo $DEV'_heal.critical 75:'
97
        else
98
	        echo -n '_heal.value '
99
        	HEAL=`echo $linf | awk '{print $11}'`
100
        	if [[ "$HEAL" == *Unknown* ]] || [[ "$HEAL" == "" ]] ; then
101
                	HEAL='U'
102
        	fi
103
        	echo $HEAL
104
	fi
105
done
106
echo
107

  
108
echo 'multigraph hdsentinel_performance'
109
if [ "$1" = "config" ]; then
110
        echo 'graph_title HDSentinel Drive Performance'
111
        echo 'graph_vlabel %'
112
        echo 'graph_args --base 1000 -l 0 --lower-limit 0 --upper-limit 100'
113
        echo 'graph_category disk'
114
        echo 'graph_info Drive performance calculated by HDSentinel from SMART'
115
fi
116
for linf in $SLD; do
117
        DEV=`echo $linf | awk '{printf $4}' | awk '{printf substr($0,6)}'`
118
        echo -n $DEV
119
        if [ "$1" = "config" ]; then
120
                echo '_perf.label '$DEV
121
                echo $DEV'_perf.warning 85:'
122
                echo $DEV'_perf.critical 60:'
123
        else
124
        	echo -n '_perf.value '
125
        	PERF=`echo $linf | awk '{print $15}'`
126
        	if [[ "$PERF" == *Unknown* ]] || [[ "$PERF" == "" ]] ; then
127
                	PERF='U'
128
        	fi
129
        	echo $PERF
130
	fi
131
done
132
echo
133

  
134
echo 'multigraph hdsentinel_lifetime'
135
if [ "$1" = "config" ]; then
136
        echo 'graph_title HDSentinel Estimated Drive Lifetime'
137
        echo 'graph_vlabel days'
138
        echo 'graph_args --base 1000 -l 0'
139
        echo 'graph_category disk'
140
        echo 'graph_info Drive estimated remaining lifetime calculated by HDSentinel from SMART'
141
fi
142
for linf in $SLD; do
143
        DEV=`echo $linf | awk '{printf $4}' | awk '{printf substr($0,6)}'`
144
        echo -n $DEV
145
        if [ "$1" = "config" ]; then
146
                echo '_life.label '$DEV
147
                echo $DEV'_life.warning 180:'
148
		echo $DEV'_life.critical 90:'
149
        else
150
        	echo -n '_life.value '
151
        	LIFE=`echo $linf | awk 'match($0,"lifetime: "){print substr($0,RSTART+10)}' | tr -dc '[0-9]'`
152
        	if [[ "$LIFE" == *Unknown* ]] || [[ "$LIFE" == "" ]] ; then
153
                	LIFE='U'
154
        	fi
155
        	echo $LIFE
156
	fi
157
done
158
echo
159
IFS=$OLDIFS
160
unset IFS

Formats disponibles : Unified diff