RRD CPU Graphs from MBMON (not Coretemp) on a X700
-
Hi Everyone,
I've just setup pfsense on my X700 and I have installed mbmon and have managed to display the CPU temperature on the system status webpage thanks to Redrep's post http://forum.pfsense.org/index.php/topic,39595.0.html .
I want to get the CPU temperature into an RRD Graph, similar to what coltect has achieved in the post below but with it fed by mbmon - http://forum.pfsense.org/index.php/topic,42388.msg218851.html#msg218851
I have tried modifying the code lines to drop back to a single core to suit the PIII 866 CPU I'm using in my X700 (the original Celeron 1.2 got cooked) but the RRD Graph page won't draw the temperature graphs, reporting "There has been an error creating the graphs. Please check your systemlogs for further details." … and the system log shows lots of errors like this:
php: /status_rrd_graph_img.php: Failed to create graph with error code 1, the error is: ERROR: No DS called 'cputemp' in '/var/db/rrd/system-temperature.rrd'/usr/bin/nice -n20 /usr/local/bin/rrdtool graph /tmp/system-temperature.rrd-week.png --start 1358322941 --end 1358927741 --vertical-label "degrees, celcius" --color SHADEA#eeeeee --color SHADEB#eeeeee --title "
hostname
- System :: Temperature - 1 week - 1 hour LAST" --height 200 --width 620 DEF:"cputemp=/var/db/rrd/system-temperature.rrd:cputemp:LAST" LINE2:"cputemp#990000:cputemp" COMMENT:"\n" COMMENT:" minimum average maximum current\n" COMMENT:"Cputemp. " GPRINT:"cputemp:MIN:%7.2lf %s " GPRINT:"cputemp:AVERAGE:%7.2lf %s " GPRINT:"cputemp:MAX:%7.2lf %s " GPRINT:"cputemp:LAST:%7.2lf %S " COMMENT:"\n" COMMENT:"date +"%b %d %H\:%M\:%S %Y"
"My rrd.inc file currently looks like this:
/* Cpu Temp, create CPU Temperature database */ if(! file_exists("$rrddbpath$ifname$cputemp")) { $rrdcreate = "$rrdtool create $rrddbpath$ifname$cputemp --step $rrdcputempinterval "; $rrdcreate .= "DS:cpu0temp:GAUGE:$cputempvalid:-273:5000 "; $rrdcreate .= "RRA:MIN:0.5:1:1000 "; $rrdcreate .= "RRA:MIN:0.5:5:1000 "; $rrdcreate .= "RRA:MIN:0.5:60:1000 "; $rrdcreate .= "RRA:MIN:0.5:720:3000 "; $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; $rrdcreate .= "RRA:MAX:0.5:1:1000 "; $rrdcreate .= "RRA:MAX:0.5:5:1000 "; $rrdcreate .= "RRA:MAX:0.5:60:1000 "; $rrdcreate .= "RRA:MAX:0.5:720:3000 "; $rrdcreate .= "RRA:LAST:0.5:1:1000 "; $rrdcreate .= "RRA:LAST:0.5:5:1000 "; $rrdcreate .= "RRA:LAST:0.5:60:1000 "; $rrdcreate .= "RRA:LAST:0.5:720:3000 "; create_new_rrd($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ if($g['booting']) { mwexec("$rrdtool update $rrddbpath$ifname$cputemp N:U:U:U:U:U"); } /* the CPU Temperature gathering function */ $rrdupdatesh .= "CPUTEMP=`$mbmon -T 1 -c 1"; $rrdupdatesh .= " $awk '{getline cpu0temp;printf "; $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cputemp N:\${CPUTEMP}\n"; /* end CPU Temp gathering */
And my status_rrd_graph_img.php looks like this:
elseif((strstr($curdatabase, "-temperature.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for memory usage stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end "; $graphcmd .= "--vertical-label \"degrees, celcius\" "; $graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee "; $graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} LAST\" "; $graphcmd .= "--height 200 --width 620 "; $graphcmd .= "DEF:\"cpu0temp=$rrddbpath$curdatabase:cpu0temp:LAST\" "; $graphcmd .= "LINE2:\"cpu0temp#{$colormemory[0]}:cpu0temp\" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t minimum average maximum current\\n\" "; $graphcmd .= "COMMENT:\"Cpu0temp. \" "; $graphcmd .= "GPRINT:\"cpu0temp:MIN:%7.2lf %s \" "; $graphcmd .= "GPRINT:\"cpu0temp:AVERAGE:%7.2lf %s \" "; $graphcmd .= "GPRINT:\"cpu0temp:MAX:%7.2lf %s \" "; $graphcmd .= "GPRINT:\"cpu0temp:LAST:%7.2lf %S \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" "; }
If I run```
mbmon -T 1 -c 1Incidently, when I first tried to set this up, all references to cpu0temp were entered as cputemp but this didn't work either. If anyone out there can shed some light as to what I've done wrong it'd be much appreciated. Cheers, Dave
-
I've made a bit of progress. The RRD temperature graphs now display in the web GUI without throwing errors everywhere but there's still no data being written to them.
rrd.inc is now looking like this… (this is where I think I still have something wrong)
/* Cpu Temp, create CPU Temperature database */ if(! file_exists("$rrddbpath$ifname$cputemp")) { $rrdcreate = "$rrdtool create $rrddbpath$ifname$cputemp --step $rrdcputempinterval "; $rrdcreate .= "DS:cputemp:GAUGE:$cputempvalid:-273:5000 "; $rrdcreate .= "RRA:MIN:0.5:1:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 "; $rrdcreate .= "RRA:MAX:0.5:1:1000 "; $rrdcreate .= "RRA:LAST:0.5:1:1000 "; create_new_rrd($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ if($g['booting']) { mwexec("$rrdtool update $rrddbpath$ifname$cputemp N:U:U:U:U:U"); } /* the CPU Temperature gathering function */ $rrdupdatesh .= "CPUTEMP=`$mbmon -I -c1 -T 1 | "; $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cputemp N:\${CPUTEMP}\n"; /* end CPU Temp gathering */
And status_rrd_graph_img.php now looks like this…
elseif((strstr($curdatabase, "-temperature.rrd")) && (file_exists("$rrddbpath$curdatabase"))) { /* define graphcmd for memory usage stats */ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png "; $graphcmd .= "--start $start --end $end "; $graphcmd .= "--vertical-label \"degrees, celcius\" "; $graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee "; $graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} LAST\" "; $graphcmd .= "--height 200 --width 620 "; $graphcmd .= "DEF:\"cputemp=$rrddbpath$curdatabase:cputemp:LAST\" "; $graphcmd .= "LINE2:\"cputemp#{$colormemory[0]}:cputemp\" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t minimum average maximum current\\n\" "; $graphcmd .= "COMMENT:\"Cputemp. \" "; $graphcmd .= "GPRINT:\"cputemp:MIN:%7.2lf %s \" "; $graphcmd .= "GPRINT:\"cputemp:AVERAGE:%7.2lf %s \" "; $graphcmd .= "GPRINT:\"cputemp:MAX:%7.2lf %s \" "; $graphcmd .= "GPRINT:\"cputemp:LAST:%7.2lf %S \" "; $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" "; }
Any suggestions?
Cheers,
Dave -
davothegreat, got it working? My RRD Graph show 0C :(
-
No, I never got it to work properly. Kind of hoped someone here could provide a bit more assistance but I understand the Firebox hardware is very old and probably not included under any modern development paths.
If anyone out there has gotten this to work, please shed some light. I'm happy to poke around in the configs if it's of any help since my Firebox runs my home network and not a business.
The CPU temperature does appear to report ok on the system homepage but of course this only provides the current temperature.
Cheers,
Dave -
This has got to be simple syntax problem. The fact that the X700 is quite old is not a valid excuse. ;)
It must be possible to feed the output of mbmon into RRDtool.
Steve
-
Looks like your code is trying to pipe the output of mbmon to rrdtool update but that's not how it works as far as I can see.
Compare it with the CPUstats code:/* the CPU stats gathering function. */ $rrdupdatesh .= "CPU=`$cpustats | cut -f1-4 -d':'`\n"; /* Using ps uxaH will count all processes including system threads. Top was undercounting. */ $rrdupdatesh .= "PROCS=`ps uxaH | wc -l | awk '{print \$1;}'`\n"; $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$proc N:\${CPU}:\${PROCS}\n";
Looks like the CPU temp function should be more like:
/* the CPU Temperature gathering function */ $rrdupdatesh .= "CPUTEMP=`$mbmon -I -c1 -T1 `\n"; $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cputemp N:\${CPUTEMP}\n"; /* end CPU Temp gathering */
Have you setup the required variables at the start of rrd.inc?
I'm no expert at this though. ::)
Steve
-
Umm I've completely forgotten what I'd done now. The code came from another thread that did this with the other temp monitoring tool which I tried (and failed) to modify to suit mbmon. I do recall though that mbmon was producing values and writing them to the graphing file but that the graph displayed no information, suggesting its formatting was incorrect.
I'll spend a bit of time tonight and reinstate what I had before and work from there.
Cheers,
Dave -
Solved at last!
I forgot about getting this to work until I updated to 2.1 yesterday and decided to have another crack at it and now it works like a bought one.
To get it working, install the mbmon package and then edit /etc/inc/rrd.inc with the following changes:
After $mem = "-memory.rrd"; paste in the following text…
$cputemp = "-temperature.rrd"; $rrdcputempinterval = 60; $cputempvalid = $rrdcputempinterval * 2;
After /* End Memory statistics */ paste in the following text…
/* CPU Temperature */ /* Cpu Temp, create CPU Temperature database */ if(! file_exists("$rrddbpath$ifname$cputemp")) { $rrdcreate = "$rrdtool create $rrddbpath$ifname$cputemp --step $rrdcputempinterval "; $rrdcreate .= "DS:Temperature:GAUGE:$cputempvalid:0:100 "; $rrdcreate .= "RRA:MIN:0.5:1:1000 "; $rrdcreate .= "RRA:MIN:0.5:5:1000 "; $rrdcreate .= "RRA:MIN:0.5:60:1000 "; $rrdcreate .= "RRA:MIN:0.5:720:3000 "; $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 "; $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 "; $rrdcreate .= "RRA:MAX:0.5:1:1000 "; $rrdcreate .= "RRA:MAX:0.5:5:1000 "; $rrdcreate .= "RRA:MAX:0.5:60:1000 "; $rrdcreate .= "RRA:MAX:0.5:720:3000 "; $rrdcreate .= "RRA:LAST:0.5:1:1000 "; $rrdcreate .= "RRA:LAST:0.5:5:1000 "; $rrdcreate .= "RRA:LAST:0.5:60:1000 "; $rrdcreate .= "RRA:LAST:0.5:720:3000 "; create_new_rrd($rrdcreate); } /* enter UNKNOWN values in the RRD so it knows we rebooted. */ if($g['booting']) { mwexec("$rrdtool update $rrddbpath$ifname$cputemp N:U:U:U:U:U"); } /* the CPU Temperature gathering function */ $rrdupdatesh .= "CPUTEMP=`/usr/local/bin/mbmon -i -T 1 -c 1`\n"; $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cputemp N:\${CPUTEMP}\n"; /* end CPU Temp gathering */
Note: the characters surrounding```
/usr/local/bin/mbmon -I -T 1 -c 1Save rrd.inc and then edit /usr/local/www/status_rrd_graph_img.php After the block of text containing /* define graphcmd for memory usage stats */ paste in the following text…
elseif((strstr($curdatabase, "-temperature.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for cpu temperature stats */
$graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
$graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label "degrees, celcius" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title "hostname
- {$prettydb} - {$hperiod} - {$havg} LAST" ";
$graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:"Temperature=$rrddbpath$curdatabase:Temperature:LAST" ";
$graphcmd .= "LINE2:"Temperature#{$colormemory[0]}:Temperature" ";
$graphcmd .= "COMMENT:"\n" ";
$graphcmd .= "COMMENT:"\t\t minimum average maximum current\n" ";
$graphcmd .= "COMMENT:"Temperature. " ";
$graphcmd .= "GPRINT:"Temperature:MIN:%7.2lf %s " ";
$graphcmd .= "GPRINT:"Temperature:AVERAGE:%7.2lf %s " ";
$graphcmd .= "GPRINT:"Temperature:MAX:%7.2lf %s " ";
$graphcmd .= "GPRINT:"Temperature:LAST:%7.2lf %S " ";
$graphcmd .= "COMMENT:"\n" ";
$graphcmd .= "COMMENT:"\t\t\t\t\t\t\t\t\t\t\t\t\tdate +\"%b %d %H\:%M\:%S %Y\"
" ";Save status_rrd_graph_img.php then SSH into the Firebox and restart the web configurator (menu option 11). Wait a couple of minutes and you should start seeing temperature data being graphed under Status -> RRD Graphs -> System -> Temperature. Thanks to all who posted before me with related ideas and responses to this thread. I should have figured this out ages ago, I just got lazy. Hope this helps someone. Cheers, Dave
-
Nice! I'll have to give this a try.
Steve
-
Steve Did you get it working ?.
I had a go at it on a mini ITX single core and a dual core with HT but the data is not showing up in the graphs , at least the Graphs are now there.
I was not able to install the mbmon package as they are not in the package download area but I have the Thermal sensors showing in the dashboard so I guess it is part of the 2.1 CD install now.Any thoughts are most welcome
-
Daimler,
Your hardware sounds a lot newer than mine and I'm pretty sure folks on newer hardware use coretemp instead of mbmon. The hardware in these fireboxes is geriatric so we've got no choice but to use mbmon. Give coretemp a try.
Cheers,
Dave -
Yep. ^ exactly.
If it's showing in the dash it's probably already using coretemp (or the amd equivalent).
If you can't load mbmon then the above code definitely won't work. There's another thread that covers using coretemp for a similar purpose I think.Steve