Projet

Général

Profil

Révision 8c86c4e4

ID8c86c4e41ea27a286f6a5f2a5c91b7ec2dcd4ed8
Parent e7454e63
Enfant 0ddf1ea4

Ajouté par Marcello Romani il y a presque 14 ans

Show device name in config

Voir les différences:

plugins/other/hddtemp
1 1
#!/bin/sh
2

  
3
# ^--- Ubuntu-Users may have to change this to /bin/bash or create a symlink...
4

  
5
# Plugin: hddtemp
6
# Author: Philipp Giebel (spam@stimpyrama.org)
7
# Version: 0.2
8 2
#
9
# Munin (http://munin.projects.linpro.no/) Plugin for checking HDD
10
# Temperatures using hddtemp (https://savannah.nongnu.org/projects/hddtemp/)
11
# 
12
# Requirements: * HDDTemp (https://savannah.nongnu.org/projects/hddtemp/)
13
#               * NetCat (http://netcat.sourceforge.net/)
3
# Plugin to monitor harddrive temperatures through SMART.
14 4
#
5
# This plugin is an alternative to hddtemp_smartctl, which is
6
# the preferred one.
15 7
#
16
# Changelog: v0.1 - initial release
17
#            v0.2 - . added "autoconf"
18
#                   . added warning- and critical-levels
19
#                   . added config-check
20
#                   . replaced backticks with "$()"
21
#                   . fixed parser-bug (added "g" to sed)
22

  
23
##### CONFIGURATION START #####################################################
24

  
25
HOST="127.0.0.1"    # ip or hostname of host running hddtempd (e.g: 127.0.0.1)
26
PORT=7634           # port of hddtempd
27
NC=$(which nc)      # full path to netcat (e.g: /bin/nc)
28
SED=$(which sed)    # full path to sed (e.g: /usr/bin/sed)
29
WARN=50             # warning temperature
30
CRIT=60             # critical temperature
31

  
32
##### CONFIGURATION END #######################################################
8
# client-conf.d/-options:
9
# 	
10
# 	drives		-- List drives to monitor. E.g. "hda hdc".
11
#
12
# $Log$
13
# Revision 1.4.2.1  2005/01/25 21:00:01  jimmyo
14
# Added plugin generic/hddtemp_smartctl, made by Lupe Christoph. Made it the default hddtemp plugin.
15
#
16
# Revision 1.4  2004/11/10 16:00:39  jimmyo
17
# Applied patch from Nicolas Stransky to generic/hddtemp, to fetch temp more elegantly (SF#1052845).
18
#
19
# Revision 1.3  2004/05/20 19:02:36  jimmyo
20
# Set categories on a bunch of plugins
21
#
22
# Revision 1.2  2004/01/29 19:39:00  jimmyo
23
# Generic plugins now use printf instead of echo -n, as this is more portable (SF#885564)
24
#
25
# Revision 1.1  2004/01/02 18:50:00  jimmyo
26
# Renamed occurrances of lrrd -> munin
27
#
28
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
29
# Import of LRRD CVS tree after renaming to Munin
30
#
31
# Revision 1.2  2003/12/18 19:16:00  jimmyo
32
# Changes from Alexandre
33
#
34
# Revision 1.1  2003/12/18 19:04:37  jimmyo
35
# New plugin: Alexandre Dupouy contributed "hddtemp".
36
#
37
#
38
#%# family=contrib
33 39

  
34
if [ -x "$NC" ]
35
then
36
	if [ -x "$SED" ]
37
	then
38
		output=$($NC $HOST $PORT | $SED 's/||/|^|/g')
39
	fi
40
fi
40
HDDTEMP=/usr/sbin/hddtemp
41 41

  
42
if [ -z "$output" ]
43
then
44
	echo "hddtemp: Configuration needed"
45
	exit 1
42
if [ "$1" = "autoconf" ]; then
43
        if [ -x "$HDDTEMP" ]; then
44
                echo yes
45
                exit 0
46
        else
47
                echo no
48
                exit 1
49
        fi
46 50
fi
47 51

  
48
if [ "$1" == "config" ]
49
then
50
	part=$(echo $output | cut -d"^" -f1)
51
	unit=$(echo $part |cut -d"|" -f5)
52
	echo "graph_title HDD Temperatures"
53
	echo "graph_category Disk"
54
	echo "graph_vlabel ? $unit"
55
	echo "graph_hlabel ? $unit"
56
	echo "graph_args --base 1000 -l 0"
57
	echo "graph_scale no"
52
if [ "$1" = "config" ]; then
58 53

  
59
        part="start"
60
        count=0
61

  
62
        while [ -n "$part" ]
63
        do
64
                count=$((count+1))
65
                part=$(echo $output | cut -d"^" -f$count)
66
                if [ -n "$part" ]
67
                then
68
			dev=$(echo $part | cut -d"|" -f2 |cut -d"/" -f3)
69
			desc=$(echo $part |cut -d"|" -f3)
70
			order="$order $dev"
71
			echo "$dev.info $dev temperature ($desc)"
72
			echo "$dev.label $dev"
73
			echo "$dev.warning $WARN"
74
			echo "$dev.critical $CRIT"
75
		fi
76
	done
77
	echo "graph_order$order"
78
	echo "graph_info Harddisk Temperatures"
79
elif [ "$1" == "autoconf" ]
80
then
81
	if [ -x "$NC" ]
82
	then
83
		if [ -x "$SED" ]
84
		then
85
			check=$($NC $HOST $PORT | $SED 's/||/|^|/g')
86
			if [ -n "$check" ]
87
			then
88
				echo "yes"
89
			else
90
				echo "no"
91
			fi
92
		else
93
			echo "no"
94
		fi
95
	else
96
		echo "no"
97
	fi		
98
else
99
	part="start"
100
	count=0
101
	
102
	while [ -n "$part" ]
103
	do
104
		count=$((count+1))
105
		part=$(echo $output | cut -d"^" -f$count)
106
		if [ -n "$part" ]
107
		then
108
			dev=$(echo $part | cut -d"|" -f2 |cut -d"/" -f3)
109
			temp=$(echo $part |cut -d"|" -f4)
110
			echo "$dev.value $temp"
111
		fi
112
	done
54
        echo 'graph_title HDD temperature'
55
        echo 'graph_args --base 1000 -l 0'
56
        echo 'graph_vlabel temp in ?C'
57
        echo 'graph_category sensors'
58
        #for a in $drives ; do echo $a.label $a ; done
59
        for a in $drives ; do echo $a.label $a `hddtemp -q /dev/$a | cut -d: -f 2` ; done
60
        exit 0
113 61
fi
114 62

  
63
for a in $drives ; do printf "$a.value $(hddtemp -n -q /dev/$a)\n" ; done
64

  

Formats disponibles : Unified diff