mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-26 02:42:58 +02:00
Added memory and cpu util graphs for services
Changed collectd config git-svn-id: http://svn.ipfire.org/svn/ipfire/branches/2.1/trunk@1266 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8
This commit is contained in:
@@ -48,6 +48,7 @@ $cgigraphs[1] = '' unless defined $cgigraphs[1];
|
||||
|
||||
if ($cgigraphs[1] =~ /(load)/) {&Graphs::updateloadgraph ("hour");&Graphs::updateloadgraph ("week");&Graphs::updateloadgraph ("month");&Graphs::updateloadgraph ("year");}
|
||||
if ($cgigraphs[1] =~ /(cpu)/) {&Graphs::updatecpugraph ("hour");&Graphs::updatecpugraph ("week");&Graphs::updatecpugraph ("month");&Graphs::updatecpugraph ("year");}
|
||||
if ($cgigraphs[1] =~ /(processes)/) {&Graphs::updateprocessesgraph ("hour");&Graphs::updateprocessesgraph ("week");&Graphs::updateprocessesgraph ("month");&Graphs::updateprocessesgraph ("year");}
|
||||
if ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs::updatememgraph ("hour");&Graphs::updatememgraph ("week");&Graphs::updatememgraph ("month");&Graphs::updatememgraph ("year");}
|
||||
if ($cgigraphs[1] =~ /disk/){
|
||||
my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
|
||||
@@ -70,7 +71,7 @@ if ($cgigraphs[1] =~ /(network|green|blue|orange|red|ipsec|lq)/) {
|
||||
|
||||
&Header::openbigbox('100%', 'left');
|
||||
|
||||
if ($cgigraphs[1] =~ /(green|blue|orange|red|ipsec|lq|cpu|memory|swap|disk|load|fwhits)/) {
|
||||
if ($cgigraphs[1] =~ /(green|blue|orange|red|ipsec|lq|cpu|memory|swap|disk|load|fwhits|processes)/) {
|
||||
my $graph = $cgigraphs[1];
|
||||
my $graphname = ucfirst(lc($cgigraphs[1]));
|
||||
&Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
|
||||
|
||||
@@ -554,6 +554,7 @@ END
|
||||
200;imq0;icmp;;;;;
|
||||
203;imq0;esp;;;;;
|
||||
203;imq0;tcp;;;;1194;
|
||||
203;imq0;udp;;;;1194;
|
||||
203;imq0;udp;;4500;;4500;
|
||||
203;imq0;udp;;500;;500;
|
||||
204;imq0;tcp;;;;80;
|
||||
|
||||
@@ -28,6 +28,7 @@ use strict;
|
||||
require '/var/ipfire/general-functions.pl';
|
||||
require "${General::swroot}/lang.pl";
|
||||
require "${General::swroot}/header.pl";
|
||||
require "${General::swroot}/graphs.pl";
|
||||
|
||||
#workaround to suppress a warning when a variable is used only once
|
||||
my @dummy = ( ${Header::colourred} );
|
||||
@@ -41,6 +42,8 @@ my %mainsettings = ();
|
||||
my %netsettings=();
|
||||
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
|
||||
|
||||
&Graphs::updateprocessesgraph ("day");
|
||||
|
||||
my %cgiparams=();
|
||||
# Maps a nice printable name to the changing part of the pid file, which
|
||||
# is also the name of the program
|
||||
@@ -141,7 +144,7 @@ my @pak = `find /opt/pakfire/db/installed/meta-* | cut -d"-" -f2`;
|
||||
foreach (@pak)
|
||||
{
|
||||
chomp($_);
|
||||
|
||||
|
||||
# Check which of the paks are services
|
||||
my @svc = `find /etc/init.d/$_ | cut -d"/" -f4`;
|
||||
foreach (@svc)
|
||||
@@ -154,7 +157,7 @@ foreach (@pak)
|
||||
if ($_ ne "alsa")
|
||||
{
|
||||
$lines++;
|
||||
if ($lines % 2)
|
||||
if ($lines % 2)
|
||||
{
|
||||
print "<tr bgcolor='$color{'color22'}'>";
|
||||
}
|
||||
@@ -169,7 +172,7 @@ foreach (@pak)
|
||||
print "<td align='center'><A HREF=services.cgi?$_!stop><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></A></td> ";
|
||||
my $status = &isrunningaddon($_);
|
||||
$status =~ s/\\[[0-1]\;[0-9]+m//g;
|
||||
|
||||
|
||||
chomp($status);
|
||||
print "$status";
|
||||
print "</tr>";
|
||||
@@ -179,6 +182,32 @@ foreach (@pak)
|
||||
|
||||
print "</table></div>\n";
|
||||
|
||||
&Header::closebox();
|
||||
|
||||
&Header::openbox('100%', 'center', "$Lang::tr{'processes'} $Lang::tr{'graph'}");
|
||||
if (-e "$Header::graphdir/processes-day.png") {
|
||||
my $ftime = localtime((stat("$Header::graphdir/processes-day.png"))[9]);
|
||||
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
|
||||
print "<a href='/cgi-bin/graphs.cgi?graph=processes'>";
|
||||
print "<img alt='' src='/graphs/processes-day.png' border='0' />";
|
||||
print "</a>";
|
||||
} else {
|
||||
print $Lang::tr{'no information available'};
|
||||
}
|
||||
print "<br />\n";
|
||||
&Header::closebox();
|
||||
|
||||
&Header::openbox('100%', 'center', "$Lang::tr{'processes'} $Lang::tr{'memory'} $Lang::tr{'graph'}");
|
||||
if (-e "$Header::graphdir/processesmem-day.png") {
|
||||
my $ftime = localtime((stat("$Header::graphdir/processesmem-day.png"))[9]);
|
||||
print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
|
||||
print "<a href='/cgi-bin/graphs.cgi?graph=processesmem'>";
|
||||
print "<img alt='' src='/graphs/processesmem-day.png' border='0' />";
|
||||
print "</a>";
|
||||
} else {
|
||||
print $Lang::tr{'no information available'};
|
||||
}
|
||||
print "<br />\n";
|
||||
&Header::closebox();
|
||||
&Header::closebigbox();
|
||||
&Header::closepage();
|
||||
@@ -197,7 +226,7 @@ sub isautorun
|
||||
if ($init ne '') {
|
||||
$status = "<td align='center'><A HREF=services.cgi?$_!enable><img alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' border='0' width='16' height='16' /></A></td>";
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
@@ -240,7 +269,7 @@ sub isrunningaddon
|
||||
my $testcmd = '';
|
||||
my $exename;
|
||||
my @memory;
|
||||
|
||||
|
||||
my $testcmd = `/usr/local/bin/addonctrl $_ status`;
|
||||
|
||||
if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){
|
||||
@@ -249,9 +278,9 @@ sub isrunningaddon
|
||||
|
||||
my @pid = split(/\s/,$testcmd);
|
||||
$status .="<td align='center'>$pid[0]</td>";
|
||||
|
||||
|
||||
my $memory = 0;
|
||||
|
||||
|
||||
foreach (@pid){
|
||||
chomp($_);
|
||||
if (open(FILE, "/proc/$_/statm")){
|
||||
|
||||
Reference in New Issue
Block a user