Custom RRDgraphs



  • Hello All!  :D
    First post and topic.

    my question is, how can I add custom graphs to the RRD Graphs section in pfsense and to be more specific how can I add a graph to monitor my CPU temp.

    Kind regards!



  • To my knowledge, there is no builtin way to graph temperature. However, if you are running a network monitoring system you might be able to add temperature without too much trouble. That I know of, you can use Zabbix (achievable via the pfSense UI) or SNMP (achievable by editing files). I'm sure that there are other monitoring systems that would work as well.

    It should be noted that network monitoring systems require a substantial investment in time and effort to set up, so it probably isn't worth it unless you are already using one.



  • I know that it isn't there by default. The solution is to fetch the temp from the cpu and add an RRDGraph that uses the realtime CPU temp a it's source to build it's graph.

    So is there anybody that has a how to to make custom graphs in PFsense. That will of course not be possible in the web interface.



  • I found this from a couple of years ago. I've not tried it myself, but it appears that it would add a CPU temperature graph using values returned from sysctl.

    https://forum.pfsense.org/index.php?topic=42388.0

    coretemp doesn't need to be installed… if you have an Intel CPU in your box, it can be enabled in System > Advanced settings on the Miscellaneous tab. If you don't have an Intel CPU, I would imagine that ACPI and amdtemp would still return some temperature values... how accurate they might be could be questionable, and they might be different variables than what's given in the code in that topic.



  • I made a patch for 2.3.2  pfSense version for a CPU temperature graph for the above mentioned old thread. I used a lot of it but changed some things. I am not a programmer so things could be better. ;)
    This patch is for a quad core N3700 CPU.

    --- /etc/inc/rrd.inc	2016-08-21 23:05:29.707358000 +0200
    +++ /etc/inc/rrd.inc.modified	2016-08-21 23:44:15.376961000 +0200
    @@ -242,6 +242,7 @@
     	$spamd = "-spamd.rrd";
     	$proc = "-processor.rrd";
     	$mem = "-memory.rrd";
    +	$cputemp = "-temperature.rrd";
     	$mbuf = "-mbuf.rrd";
     	$cellular = "-cellular.rrd";
     	$vpnusers = "-vpnusers.rrd";
    @@ -274,6 +275,7 @@
     	$rrdlbpoolinterval = 60;
     	$rrdprocinterval = 60;
     	$rrdmeminterval = 60;
    +	$rrdcputempinterval = 60;
     	$rrdmbufinterval = 60;
     	$rrdcellularinterval = 60;
     	$rrdvpninterval = 60;
    @@ -291,6 +293,7 @@
     	$lbpoolvalid = $rrdlbpoolinterval * 2;
     	$procvalid = $rrdlbpoolinterval * 2;
     	$memvalid = $rrdmeminterval * 2;
    +	$cputempvalid = $rrdcputempinterval * 2;
     	$mbufvalid = $rrdmbufinterval * 2;
     	$cellularvalid = $rrdcellularinterval * 2;
     	$vpnvalid = $rrdvpninterval * 2;
    @@ -733,6 +736,49 @@
    
     		/* End Memory statistics */
    
    +		/* CPU Temperature */
    +		/* the CPU Temperature gathering function */
    +		/* This is for a Pentium N3700 and coretemp which reports 4 cores */
    +		/* CPU Temp, create the 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 .= "DS:cpu1temp:GAUGE:$cputempvalid:-273:5000 ";
    +			$rrdcreate .= "DS:cpu2temp:GAUGE:$cputempvalid:-273:5000 ";
    +			$rrdcreate .= "DS:cpu3temp:GAUGE:$cputempvalid:-273:5000 ";
    +			$rrdcreate .= "RRA:AVERAGE:0.5:1:1200 ";
    +			$rrdcreate .= "RRA:AVERAGE:0.5:5:720 ";
    +			$rrdcreate .= "RRA:AVERAGE:0.5:60:1860 ";
    +			$rrdcreate .= "RRA:AVERAGE:0.5:1440:2284 ";
    +			$rrdcreate .= "RRA:MIN:0.5:1:1200 ";
    +			$rrdcreate .= "RRA:MIN:0.5:5:720 ";
    +			$rrdcreate .= "RRA:MIN:0.5:60:1860 ";
    +			$rrdcreate .= "RRA:MIN:0.5:1440:2284 ";
    +			$rrdcreate .= "RRA:MAX:0.5:1:1200 ";
    +			$rrdcreate .= "RRA:MAX:0.5:5:720 ";
    +			$rrdcreate .= "RRA:MAX:0.5:60:1860 ";
    +			$rrdcreate .= "RRA:MAX:0.5:1440:2284 ";
    +			$rrdcreate .= "RRA:LAST:0.5:1:1200 ";
    +			$rrdcreate .= "RRA:LAST:0.5:5:720 ";
    +			$rrdcreate .= "RRA:LAST:0.5:60:1860 ";
    +			$rrdcreate .= "RRA:LAST:0.5:1440:2284 ";
    +
    +			create_new_rrd($rrdcreate);
    +			unset($rrdcreate);
    +		}
    +
    +		/* enter UNKNOWN values in the RRD so it knows we rebooted. */
    +		if (platform_booting()) {
    +			mwexec("$rrdtool update $rrddbpath$ifname$cputemp N:U:U:U:U");
    +		}		
    +
    +		/* the CPU Temperature gathering function */
    +		$rrdupdatesh .= "CPUTEMP=`$sysctl -n dev.cpu.0.temperature dev.cpu.1.temperature dev.cpu.2.temperature dev.cpu.3.temperature | ";
    +		$rrdupdatesh .= "cut -c-2 | tr '\n' ':' | sed 's/.$//'`\n";
    +		$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cputemp N:\${CPUTEMP}\n";
    +		
    +		/* end CPU Temperature gathering */
    +
     		/* mbuf, create mbuf statistics database */
     		if (!file_exists("$rrddbpath$ifname$mbuf")) {
     			$rrdcreate = "$rrdtool create $rrddbpath$ifname$mbuf --step $rrdmbufinterval ";
    

    For easy implementation use the "patches" package.



Log in to reply