From f7cc362d4d3ae2d72716cf9f19f2cd37e1a00ea3 Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Tue, 11 Dec 2012 22:08:13 +0100 Subject: [PATCH] cleanup hddtemp --- Makefile | 2 +- plugins/hddtemp.c | 12 ++++++------ rrdtool.c | 2 +- sammler.conf | 2 +- sammler.php | 9 +++++++++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 9fc2db0..4c68113 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ WITH_RRD?=yes PLUGINS := ctstat diskstat hwmon load memory mount netdev random rtstat stat uptime vmstat -#PLUGINS += apache mysql conntrack alixusv ts2 diskstandby hddptemp +#PLUGINS += apache mysql conntrack alixusv ts2 diskstandby hddtemp DESTDIR = BINARY_DIR = /usr/local/bin diff --git a/plugins/hddtemp.c b/plugins/hddtemp.c index ebd08fc..f6d9192 100644 --- a/plugins/hddtemp.c +++ b/plugins/hddtemp.c @@ -101,7 +101,7 @@ static int probe(void) /* '|/dev/sda|OCZ-VERTEX3|128|C||/dev/sdb|HDT722525DLA380|SLP|*||/dev/sdc|Generic STORAGE DEVICE|NA|*|' */ - char *tok, *tmp, *resp = resp_buf; + char *tok, *tmp = NULL, *resp = resp_buf; int i = 0; char *device = NULL; int temperature = 0; @@ -114,10 +114,10 @@ static int probe(void) device++; } else if ((i % 4) == 2) { - char *tmp; + char *tmp2; - temperature = strtol(tok, &tmp, 10); - if (*tmp != '\0') + temperature = strtol(tok, &tmp2, 10); + if (*tmp2 != '\0') device = NULL; } else if ((i % 4) == 3) { @@ -185,9 +185,9 @@ static int init(void) return -1; } - int retval = config_get_strtokens("p_hddtemp", "server", ",", 2, init_cb, NULL); + config_get_strtokens("p_hddtemp", "server", ",", 2, init_cb, NULL); - return (retval <= 0) ? -1 : 0; + return 0; } static int fini(void) diff --git a/rrdtool.c b/rrdtool.c index b2d7702..53b8f27 100644 --- a/rrdtool.c +++ b/rrdtool.c @@ -17,6 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#if (WITH_RRD) #include #include #include @@ -33,7 +34,6 @@ #include "logging.h" #include "plugins.h" -#if (WITH_RRD) #define DEFAULT_STEP 10 #define ARGCMAX 64 diff --git a/sammler.conf b/sammler.conf index 9fbaffc..fa21293 100644 --- a/sammler.conf +++ b/sammler.conf @@ -59,4 +59,4 @@ rra RRA:MIN:0.5:4320:1440 RRA:AVERAGE:0.5:4320:1440 RRA:MAX:0.5:4320:1440 #device /dev/sda [p_hddtemp] -server test,127.0.0.1:7634 +#server test,127.0.0.1:7634 diff --git a/sammler.php b/sammler.php index c84f7b8..4d788ad 100644 --- a/sammler.php +++ b/sammler.php @@ -546,6 +546,15 @@ function show_rrd($conf) { 'STACK:b#00CF00:"Standby" '; break; + case 'hddtemp': + $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"Temperature\" ". + "DEF:a={$rrdfile}:temperature:AVERAGE ". + 'CDEF:err=a,UN,INF,UNKN,IF '. + 'AREA:err#FFD0D0 '. + 'AREA:a#00CF00:"Temperature" GPRINT:a:LAST:"Current\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\:%8.2lf %s" GPRINT:a:MAX:"Maximum\:%8.2lf %s\n" '. + 'LINE1:a#404040 '; + break; + case 'hwmon': $cmd .= "--base=1000 --height={$height} --width={$width} --alt-autoscale-max --lower-limit=0 --vertical-label=\"Temperature\" ". "DEF:a={$rrdfile}:temp:AVERAGE ".