mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Show device name in config
This commit is contained in:
parent
e7454e6304
commit
8c86c4e41e
@ -1,114 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
# ^--- Ubuntu-Users may have to change this to /bin/bash or create a symlink...
|
||||
|
||||
# Plugin: hddtemp
|
||||
# Author: Philipp Giebel (spam@stimpyrama.org)
|
||||
# Version: 0.2
|
||||
#
|
||||
# Munin (http://munin.projects.linpro.no/) Plugin for checking HDD
|
||||
# Temperatures using hddtemp (https://savannah.nongnu.org/projects/hddtemp/)
|
||||
#
|
||||
# Requirements: * HDDTemp (https://savannah.nongnu.org/projects/hddtemp/)
|
||||
# * NetCat (http://netcat.sourceforge.net/)
|
||||
# Plugin to monitor harddrive temperatures through SMART.
|
||||
#
|
||||
# This plugin is an alternative to hddtemp_smartctl, which is
|
||||
# the preferred one.
|
||||
#
|
||||
# client-conf.d/-options:
|
||||
#
|
||||
# drives -- List drives to monitor. E.g. "hda hdc".
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.4.2.1 2005/01/25 21:00:01 jimmyo
|
||||
# Added plugin generic/hddtemp_smartctl, made by Lupe Christoph. Made it the default hddtemp plugin.
|
||||
#
|
||||
# Revision 1.4 2004/11/10 16:00:39 jimmyo
|
||||
# Applied patch from Nicolas Stransky to generic/hddtemp, to fetch temp more elegantly (SF#1052845).
|
||||
#
|
||||
# Revision 1.3 2004/05/20 19:02:36 jimmyo
|
||||
# Set categories on a bunch of plugins
|
||||
#
|
||||
# Revision 1.2 2004/01/29 19:39:00 jimmyo
|
||||
# Generic plugins now use printf instead of echo -n, as this is more portable (SF#885564)
|
||||
#
|
||||
# Revision 1.1 2004/01/02 18:50:00 jimmyo
|
||||
# Renamed occurrances of lrrd -> munin
|
||||
#
|
||||
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
|
||||
# Import of LRRD CVS tree after renaming to Munin
|
||||
#
|
||||
# Revision 1.2 2003/12/18 19:16:00 jimmyo
|
||||
# Changes from Alexandre
|
||||
#
|
||||
# Revision 1.1 2003/12/18 19:04:37 jimmyo
|
||||
# New plugin: Alexandre Dupouy contributed "hddtemp".
|
||||
#
|
||||
#
|
||||
# Changelog: v0.1 - initial release
|
||||
# v0.2 - . added "autoconf"
|
||||
# . added warning- and critical-levels
|
||||
# . added config-check
|
||||
# . replaced backticks with "$()"
|
||||
# . fixed parser-bug (added "g" to sed)
|
||||
#%# family=contrib
|
||||
|
||||
##### CONFIGURATION START #####################################################
|
||||
HDDTEMP=/usr/sbin/hddtemp
|
||||
|
||||
HOST="127.0.0.1" # ip or hostname of host running hddtempd (e.g: 127.0.0.1)
|
||||
PORT=7634 # port of hddtempd
|
||||
NC=$(which nc) # full path to netcat (e.g: /bin/nc)
|
||||
SED=$(which sed) # full path to sed (e.g: /usr/bin/sed)
|
||||
WARN=50 # warning temperature
|
||||
CRIT=60 # critical temperature
|
||||
|
||||
##### CONFIGURATION END #######################################################
|
||||
|
||||
if [ -x "$NC" ]
|
||||
then
|
||||
if [ -x "$SED" ]
|
||||
then
|
||||
output=$($NC $HOST $PORT | $SED 's/||/|^|/g')
|
||||
fi
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -x "$HDDTEMP" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo no
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$output" ]
|
||||
then
|
||||
echo "hddtemp: Configuration needed"
|
||||
exit 1
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title HDD temperature'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
echo 'graph_vlabel temp in °C'
|
||||
echo 'graph_category sensors'
|
||||
#for a in $drives ; do echo $a.label $a ; done
|
||||
for a in $drives ; do echo $a.label $a `hddtemp -q /dev/$a | cut -d: -f 2` ; done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" == "config" ]
|
||||
then
|
||||
part=$(echo $output | cut -d"^" -f1)
|
||||
unit=$(echo $part |cut -d"|" -f5)
|
||||
echo "graph_title HDD Temperatures"
|
||||
echo "graph_category Disk"
|
||||
echo "graph_vlabel ° $unit"
|
||||
echo "graph_hlabel ° $unit"
|
||||
echo "graph_args --base 1000 -l 0"
|
||||
echo "graph_scale no"
|
||||
|
||||
part="start"
|
||||
count=0
|
||||
|
||||
while [ -n "$part" ]
|
||||
do
|
||||
count=$((count+1))
|
||||
part=$(echo $output | cut -d"^" -f$count)
|
||||
if [ -n "$part" ]
|
||||
then
|
||||
dev=$(echo $part | cut -d"|" -f2 |cut -d"/" -f3)
|
||||
desc=$(echo $part |cut -d"|" -f3)
|
||||
order="$order $dev"
|
||||
echo "$dev.info $dev temperature ($desc)"
|
||||
echo "$dev.label $dev"
|
||||
echo "$dev.warning $WARN"
|
||||
echo "$dev.critical $CRIT"
|
||||
fi
|
||||
done
|
||||
echo "graph_order$order"
|
||||
echo "graph_info Harddisk Temperatures"
|
||||
elif [ "$1" == "autoconf" ]
|
||||
then
|
||||
if [ -x "$NC" ]
|
||||
then
|
||||
if [ -x "$SED" ]
|
||||
then
|
||||
check=$($NC $HOST $PORT | $SED 's/||/|^|/g')
|
||||
if [ -n "$check" ]
|
||||
then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
else
|
||||
part="start"
|
||||
count=0
|
||||
|
||||
while [ -n "$part" ]
|
||||
do
|
||||
count=$((count+1))
|
||||
part=$(echo $output | cut -d"^" -f$count)
|
||||
if [ -n "$part" ]
|
||||
then
|
||||
dev=$(echo $part | cut -d"|" -f2 |cut -d"/" -f3)
|
||||
temp=$(echo $part |cut -d"|" -f4)
|
||||
echo "$dev.value $temp"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
for a in $drives ; do printf "$a.value $(hddtemp -n -q /dev/$a)\n" ; done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user