Adding CPU usage to the GUI menu bar counters

Is there a way to add the CPU usage next to the traffic in/out counters on the IPFire GUI web page?
Couldn’t find an option for it so I assume this will mean hacking a config file somewhere…

And yes, I am aware that there are many types of CPU ‘usage’ so basically anything that isn’t CPU idle (i.e. Usage=1-(IdleCPU)).

Thanks.

Hi,

this is possible in theory, but I am afraid you will have to patch speed.cgi in order to do so.

Feel free to submit working patches to the development mailing list. Please refer to this wiki section for additional information on developing.

Thanks, and best regards,
Peter Müller

2 Likes

One suggestion is to collect data from /proc/stat for "cpu " (there is a blank space after cpu) and do some simple calc. I might try to patch speed.cgi although I don’t know Perl but if I follow the TX, RX example, it might be doable. An interesting challenge …

Example:

grep 'cpu ' /proc/stat

    | awk '{cpu_usage=($2+$4)*100/($2+$4+$5)} END {print cpu_usage "%"}'

Well, I decided to look into this even though I don’t know Perl. To simplify matters, /proc/loadavg provides the load average on the system like top (1 min, 5 min, 15 min). My notes:

  1. Modify /srv/web/ipfire/cgi-bin/speed.cgi

line 77, add

my @avg = &General::system_output("cat", "/proc/loadavg");
my @usage = split(" ", $avg[0]);
pop(@usage); pop(@usage);
$load = join(' ',@usage[0..2]);

line 93, add <load>$load</load>

If you run https://ipfire:444/cgi-bin/speed.cgi you will see the XML file and the load tag

  1. Modify /srv/web/ipfire/html/themes/ipfire/include/js/refreshinetinfo.js

add line 46: var load = $("load", xml).text();

  1. No idea how to add the load before the Traffic: rxb and txb info.

Paul

2 Likes