RRDtool for creating graph
For creating graph of HDD temperature we can use rrdtool (original script is here)
How to install:
1. ipkg install rrdtool perl and setup cron like desribed on this forum
2.
Code:
sudo rrdtool create /opt/var/lib/rrd/hddtemp_hda.rrd -s 300 DS:hda:GAUGE:600:0:100 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
3. Then create hddtemp.pl and copy it to /opt/etc/cron.5mins
Code:
#!/opt/bin/perl
#
# Copyright Martin Pot 2003
# http://martybugs.net/linux/hddtemp.cgi
use RRDs;
# define location of rrdtool binary
my $rrdtool = '/opt/bin/rrdtool';
# define location of rrdtool databases
my $rrd = '/opt/var/lib/rrd';
# define location of images
my $img = '/shares/MYVOLUME1/MYSHARE1/images/';
# define image size parameters
my $size = '-h 80 -w 600';
## HDD Temperatures #########################
# get hdd temp for master drive on secondary IDE channel
my $hda=`/opt/bin/hddtemp -f /opt/share/misc/hddtemp.db -n /dev/ide/host2/bus0/target0/lun0/disc`;
# remove eol chars and white space
$hda =~ s/[\n ]//g;
print "hda temp: $hda degrees C\n";
# insert value into rrd
`$rrdtool update $rrd/hddtemp_hda.rrd -t hda N:$hda`;
################################################
# daily hdd temp graph
RRDs::graph "$img/hddtemp-day.png",
"--lazy",
"-t", "HDD Temperatures",
"-h", "200", "-w", "600",
"-a", "PNG",
"-v", "degrees C",
"DEF:hda=$rrd/hddtemp_hda.rrd:hda:AVERAGE",
"LINE2:hda#0000FF:hda 160Gb-Hitachi",
"GPRINT:hda:MIN: Min hda\\: %2.lf",
"GPRINT:hda:LAST: Current hda\\: %2.lf degrees C\\n";
if ($ERROR = RRDs::error) { print "$0: unable to generate graph: $ERROR\n"; }
# weekly system load graph
RRDs::graph "$img/hddtemp-week.png",
"-s", "-1week", "--lazy",
"-t", "HDD Temperatures",
"-h", "200", "-w", "600",
"-a", "PNG",
"-v", "degrees C",
"DEF:hda=$rrd/hddtemp_hda.rrd:hda:AVERAGE",
"LINE2:hda#0000FF:hda 120Gb-SYS-Seagate",
"GPRINT:hda:MIN: Min hda\\: %2.lf",
"GPRINT:hda:MAX: Max hda\\: %2.lf",
"GPRINT:hda:LAST: Current hda\\: %2.lf degrees C\\n";
if ($ERROR = RRDs::error) { print "$0: unable to generate graph: $ERROR\n"; }
# monthly system load graph
RRDs::graph "$img/hddtemp-month.png",
"-s", "-1month", "--lazy",
"-t", "HDD Temperatures",
"-h", "200", "-w", "600",
"-a", "PNG",
"-v", "degrees C",
"DEF:hda=$rrd/hddtemp_hda.rrd:hda:AVERAGE",
"LINE2:hda#0000FF:hda 120Gb-SYS",
"GPRINT:hda:MIN: Min hda\\: %2.lf",
"GPRINT:hda:MAX: Max hda\\: %2.lf",
"GPRINT:hda:LAST: Current hda\\: %2.lf degrees C\\n";
if ($ERROR = RRDs::error) { print "$0: unable to generate graph: $ERROR\n"; }
# yearly system load graph
RRDs::graph "$img/hddtemp-year.png",
"-s", "-1year", "--lazy",
"-t", "HDD Temperatures",
"-h", "200", "-w", "600",
"-a", "PNG",
"-v", "degrees C",
"DEF:hda=$rrd/hddtemp_hda.rrd:hda:AVERAGE",
"LINE2:hda#0000FF:hda 120Gb-SYS-Seagate",
"GPRINT:hda:MIN: Min hda\\: %2.lf",
"GPRINT:hda:MAX: Max hda\\: %2.lf",
"GPRINT:hda:LAST: Current hda\\: %2.lf degrees C\\n";
if ($ERROR = RRDs::error) { print "$0: unable to generate graph: $ERROR\n"; }
4. Change path to store images in string to somewhere in your webserver directory for accessing outside:
Code:
my $img = '/shares/MYVOLUME1/MYSHARE1/images/';
5. Now you can see graph of temperature of your disk. Images update every 5 mins with cron.
http://www.denv.info:81/rrdtool/hddtemp-day.png
http://www.denv.info:81/rrdtool/hddtemp-week.png
re Seagate Free Agent Desktop temperature linux
Quote:
Originally Posted by
Denmike
HDDTemp is not working via USB. Only pata, sata, scsi and sas interfaces are supported, but only directly.
For Seagate Free Agent (using smartctl in linux):
# smartctl -d sat /dev/sdb --all -T permissive
for me:
smartctl -d sat /dev/sdb --all -T permissive | grep 194 | cut -d: -f3 | awk '{print $11}'
prints the disk temperature
Check temp periodically and email if too hot...
Would anyone be interested in a how-to on this? It wasn't complicated, but it's handy for those warm days when my girlfriend forgets to open a window :)
Memory leak with digitemp and rrd
I'm losing 4-8 MB of memory with the attached script using this firmware on a WL-500GP v2. Since I'm running it every two minutes from cron, it eats up my memory in a day and the router either reboots or becomes inaccessible and have to cut the power.
I'm not an experienced Linux user. Tried ps aux, it doesn't show a change over time. Tried to call digitemp and rrdupdate from command line, no memory leak happens then.
Could you gurus take a look at my script and point out any suspicious lines or show me more ways to investigate this? TIA.
Code:
#!/bin/sh
log="/opt/var/log/temperature.log"
err_log="/opt/var/log/digitemp.log"
home="/opt/var/lib/rrd/digitemp"
date=`date "+%Y-%m-%d %H:%M:%S"`
t=`/opt/bin/digitemp_DS2490 -q -a -o"%R %4.1C" -c ${home}/.digitemprc`
# Loop, read each valua and add it to the database. Odd values are sensor ID. E$
i=1
echo -n "$date" >> $log
for LINE in $t ; do
let "odd = $i % 2"
if [ $odd -eq 1 ]; then
Sensor=$LINE
else
Temperature=$LINE
# heartbeat on every 60s ( 1min.)
# 1:1500 -> 1500 sample per every 1min -> 25h ( 1 day + 1 hour )
# 5:2160 -> 2100 sample per every 5min -> 180h ( 1 week + 0.5 day$
# 15:3024 -> 3024 sample per every 15min -> 756h ( 1 month + 0.5 day$
# 240:2190 -> 2190 sample per every 4h -> 8760h ( 365 days)
if [ ! -e ${home}/${Sensor}.rrd ]; then
echo "Creating new database for Sensor $Sensor " >> $err_log
/opt/bin/rrdtool create ${home}/${Sensor}.rrd \
--step 60 \
DS:temp:GAUGE:300:-40:100 \
RRA:AVERAGE:0.5:1:1500 \
RRA:AVERAGE:0.5:5:2160 \
RRA:AVERAGE:0.5:15:3024 \
RRA:AVERAGE:0.5:240:2190
fi
echo -n ",${Sensor},${Temperature}" >> $log
/opt/bin/rrdupdate ${home}/${Sensor}.rrd N:${Temperature}
fi
let i=i+1
done
echo "" >> $log
Run results:
Code:
[admin@WL500 digitemp]$ free
total used free shared buffers
Mem: 30324 27108 3216 0 6032
Swap: 62712 0 62712
Total: 93036 27108 65928
[admin@WL500 digitemp]$ /opt/usr/bin/temp.sh
[admin@WL500 digitemp]$ free
total used free shared buffers
Mem: 30324 27112 3212 0 6036
Swap: 62712 0 62712
Total: 93036 27112 65924
[admin@WL500 digitemp]$ /opt/usr/bin/temp.sh
[admin@WL500 digitemp]$ free
total used free shared buffers
Mem: 30324 27128 3196 0 6048
Swap: 62712 0 62712
Total: 93036 27128 65908
[admin@WL500 digitemp]$
Code:
[admin@WL500 digitemp]$ /opt/bin/procps-ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
admin 1 0.0 2.1 2384 648 ? S Feb25 0:01 /sbin/init
admin 2 0.0 0.0 0 0 ? S Feb25 0:00 [keventd]
admin 3 0.2 0.0 0 0 ? RN Feb25 3:56 [ksoftirqd_CPU]
admin 4 0.0 0.0 0 0 ? S Feb25 0:00 [kswapd]
admin 5 0.0 0.0 0 0 ? S Feb25 0:00 [bdflush]
admin 6 0.0 0.0 0 0 ? S Feb25 0:00 [kupdated]
admin 7 0.0 0.0 0 0 ? S Feb25 0:00 [mtdblockd]
admin 61 0.0 1.0 2692 332 ? S Feb25 0:01 telnetd
admin 66 0.0 1.5 1944 468 ? S Feb25 0:07 httpd vlan1
admin 67 0.0 1.8 1936 552 ? Ss Feb25 0:01 nas /tmp/nas.la
admin 70 0.0 1.1 2684 360 ? S Feb25 0:00 klogd
nobody 73 0.0 1.6 968 496 ? S Feb25 0:01 [dnsmasq]
admin 74 0.0 1.3 2688 400 ? S Feb25 0:00 syslogd -m 0 -O
admin 75 0.0 0.0 0 0 ? S Feb25 0:00 [khubd]
admin 85 0.0 0.9 956 276 ? Ss Feb25 0:00 lpd
admin 87 0.0 0.8 804 260 ? Ss Feb25 0:00 p9100d -f /dev/
admin 89 0.0 1.1 2376 344 ? Ss Feb25 0:00 rcamdmain
admin 94 0.0 0.0 0 0 ? S Feb25 0:02 [usb-storage-0]
admin 95 0.0 0.0 0 0 ? S Feb25 0:00 [scsi_eh_0]
admin 111 0.0 1.4 2696 432 ? S Feb25 0:00 udhcpc -i vlan1
admin 112 0.0 2.2 2068 684 ? Ss Feb25 0:02 pppd file /tmp/
admin 114 0.0 1.0 1452 312 ? Ss Feb25 0:00 infosvr br0
admin 115 0.0 1.5 2384 468 ? Ss Feb25 0:00 watchdog
admin 118 0.0 1.1 2376 344 ? Ss Feb25 0:00 ntp
admin 135 0.0 0.0 0 0 ? S Feb25 0:00 [kjournald]
admin 146 0.0 1.2 944 384 ? Ss Feb25 0:00 /opt/sbin/cron
admin 157 0.0 4.6 3948 1400 ? S Feb25 0:00 /opt/sbin/light
admin 168 0.0 1.9 2728 584 pts/0 Ss Feb25 0:00 -sh
admin 21154 0.0 1.6 1452 512 pts/0 R+ 08:05 0:00 /opt/bin/procps