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:
maniacikarus
2008-03-13 19:29:35 +00:00
parent 99a6f5f9e5
commit 773362c5bf
7 changed files with 123 additions and 157 deletions

View File

@@ -38,8 +38,9 @@ my $value;
my @args = ();
my $count = 0;
my @mbmongraphs = ();
if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){
@mbmongraphs = `ls /var/log/rrd/collectd/localhost/mbmon/`;
my @processesgraph = `ls -dA $rrdlog/collectd/localhost/processes-*/`;
if ( -e "$rrdlog/collectd/localhost/mbmon" ){
@mbmongraphs = `ls $rrdlog/collectd/localhost/mbmon/`;
foreach (@mbmongraphs){
chomp($_);
my @name=split(/\./,$_);my $label = $name[0]; $label=~ s/-//;
@@ -47,7 +48,7 @@ if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){
$mbmonsettings{'LINE-'.$name[0]}="checked";
}
}
&General::readhash("${General::swroot}/mbmon/settings", \%mbmonsettings);
use Encode 'from_to';
@@ -76,8 +77,8 @@ sub updatecpugraph {
"--color", "SHADEB".$color{"color19"},
"--color", "BACK".$color{"color21"},
"-t $Lang::tr{'cpu usage per'} $Lang::tr{$period}");
if ( -e "/var/log/rrd/collectd/localhost/cpu-1/" ){
if ( -e "$rrdlog/collectd/localhost/cpu-1/" ){
push(@command,"DEF:iowait0=$rrdlog/collectd/localhost/cpu-0/cpu-wait.rrd:value:AVERAGE",
"DEF:nice0=$rrdlog/collectd/localhost/cpu-0/cpu-nice.rrd:value:AVERAGE",
"DEF:interrupt0=$rrdlog/collectd/localhost/cpu-0/cpu-interrupt.rrd:value:AVERAGE",
@@ -513,7 +514,7 @@ sub overviewgraph {
if ( $classline[0] eq $qossettings{'DEV'} )
{
$color=random_hex_color(6);
push(@command, "DEF:$classline[1]=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");
push(@command, "DEF:$classline[1]=$rrdlog/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");
if ($count eq "1") {
push(@command, "AREA:$classline[1]$color:Klasse $classline[1] -".sprintf("%15s",$classline[8]));
@@ -621,6 +622,63 @@ sub updatehwfangraph {
print "$ERROR";
}
sub updateprocessesgraph {
my $period = $_[0];
my $count="0";
my @command = ("$graphs/processes-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 125",
"--color", "SHADEA".$color{"color19"},"--color",
"SHADEB".$color{"color19"},"--color",
"BACK".$color{"color21"},
"-t $Lang::tr{'processes'} $Lang::tr{'graph per'} $Lang::tr{$period}");
foreach(@processesgraph){
chomp($_);my @name=split(/\-/,$_);chop($name[1]);
push(@command,"DEF:".$name[1]."user=".$_."ps_cputime.rrd:user:AVERAGE");
push(@command,"DEF:".$name[1]."system=".$_."ps_cputime.rrd:syst:AVERAGE");
push(@command,"CDEF:".$name[1]."=".$name[1]."user,".$name[1]."system,+");}
push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");
foreach(@processesgraph){
chomp($_);my @name=split(/\-/,$_);chop($name[1]);
if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);}
else {push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);}
$count++;}
RRDs::graph (@command);
$ERROR = RRDs::error;
print "$ERROR";
my $count="0";
my @command = ("$graphs/processesmem-$period.png",
"--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org",
"--alt-y-grid", "-w 600", "-h 125",
"--color", "SHADEA".$color{"color19"},"--color",
"SHADEB".$color{"color19"},"--color",
"BACK".$color{"color21"},
"-t $Lang::tr{'processes'} $Lang::tr{'memory'} $Lang::tr{'graph per'} $Lang::tr{$period}");
foreach(@processesgraph){
chomp($_);my @name=split(/\-/,$_);chop($name[1]);
push(@command,"DEF:".$name[1]."=".$_."ps_rss.rrd:value:AVERAGE");}
push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");
foreach(@processesgraph){
chomp($_);my @name=split(/\-/,$_);chop($name[1]);
if ($count eq "0") {push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);}
else {push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);}
$count++;}
RRDs::graph (@command);
$ERROR = RRDs::error;
print "$ERROR";
}
# Generate a random color, used by Qos Graph to be independent from the amount of values
sub random_hex_color {

View File

@@ -12,83 +12,19 @@ TypesDB "/usr/lib/collectd/types.db"
Interval 30
ReadThreads 3
#LoadPlugin apache
#LoadPlugin battery
LoadPlugin cpu
#LoadPlugin cpufreq
#LoadPlugin df
LoadPlugin disk
#LoadPlugin dns
#LoadPlugin email
#LoadPlugin entropy
#LoadPlugin exec
#LoadPlugin hddtemp
LoadPlugin interface
LoadPlugin iptables
#LoadPlugin ipvs
#LoadPlugin irq
LoadPlugin load
#LoadPlugin logfile
LoadPlugin mbmon
#LoadPlugin memcached
LoadPlugin memory
#LoadPlugin multimeter
#LoadPlugin mysql
#LoadPlugin netlink
#LoadPlugin network
#LoadPlugin nfs
#LoadPlugin nginx
#LoadPlugin ntpd
#LoadPlugin nut
#LoadPlugin perl
LoadPlugin ping
#LoadPlugin processes
LoadPlugin processes
LoadPlugin rrdtool
#LoadPlugin sensors
#LoadPlugin serial
LoadPlugin swap
LoadPlugin syslog
#LoadPlugin tape
#LoadPlugin tcpconns
#LoadPlugin unixsock
#LoadPlugin users
#<Plugin apache>
# URL "http://localhost/status?auto"
# User "www-user"
# Password "secret"
# CACert "/etc/ssl/ca.crt"
#</Plugin>
#<Plugin df>
# Device "/dev/hda"
# Device "192.168.0.2:/mnt/nfs"
# MountPoint "/home"
# FSType "ext3"
# IgnoreSelected false
#</Plugin>
#<Plugin dns>
# Interface "eth0"
# IgnoreSource "192.168.0.1"
#</Plugin>
#<Plugin email>
# SocketFile "/usr/var/run/collectd-email"
# SocketGroup "collectd"
# SocketPerms "0770"
# MaxConns 5
#</Plugin>
#<Plugin exec>
# Exec "user:group" "/path/to/exec"
#</Plugin>
#<Plugin hddtemp>
# Host "127.0.0.1"
# Port "7634"
#</Plugin>
<Plugin interface>
Interface "ppp0"
@@ -109,13 +45,6 @@ LoadPlugin syslog
Chain filter FORWARD DROP_Wirelessforward
</Plugin>
#<Plugin irq>
# Irq 7
# Irq 8
# Irq 9
# IgnoreSelected true
#</Plugin>
#<Plugin logfile>
# LogLevel info
# File STDOUT
@@ -126,64 +55,27 @@ LoadPlugin syslog
Port "411"
</Plugin>
#<Plugin memcached>
# Host "127.0.0.1"
# Port "11211"
#</Plugin>
#<Plugin mysql>
# Host "database.serv.er"
# User "db_user"
# Password "secret"
# Database "db_name"
#</Plugin>
#<Plugin netlink>
# Interface "All"
# VerboseInterface "All"
# QDisc "eth0" "pfifo_fast-1:0"
# Class "ppp0" "htb-1:10"
# Filter "ppp0" "u32-1:0"
#</Plugin>
#<Plugin network>
# Server "ff18::efc0:4a42" "25826"
# Server "239.192.74.66" "25826"
# Listen "ff18::efc0:4a42" "25826"
# Listen "239.192.74.66" "25826"
# TimeToLive "128"
# Forward false
# CacheFlush 1800
#</Plugin>
#<Plugin nginx>
# URL "http://localhost/status?auto"
# User "www-user"
# Password "secret"
# CACert "/etc/ssl/ca.crt"
#</Plugin>
#<Plugin ntpd>
# Host "localhost"
# Port 123
#</Plugin>
#<Plugin nut>
# UPS "upsname@hostname:port"
#</Plugin>
#<Plugin perl>
# IncludeDir "/my/include/path"
# BaseName "Collectd::Plugin"
# LoadPlugin foo
#</Plugin>
<Plugin ping>
Host "gateway"
</Plugin>
<Plugin processes>
Process "collectd"
Process "sshd"
Process "smdb"
Process "nmbd"
Process "squid"
Process "squidguard"
Process "pluto"
Process "snort"
Process "openvpn"
Process "qemu"
Process "rtorrent"
Process "mpd"
Process "asterisk"
Process "java"
Process "mysqld"
Process "spamd"
</Plugin>
<Plugin rrdtool>
@@ -192,25 +84,6 @@ LoadPlugin syslog
CacheFlush 900
</Plugin>
#<Plugin sensors>
# Sensor "it8712-isa-0290/temperature-temp1"
# Sensor "it8712-isa-0290/fanspeed-fan3"
# Sensor "it8712-isa-0290/voltage-in8"
# IgnoreSelected false
#</Plugin>
<Plugin syslog>
LogLevel info
</Plugin>
#<Plugin tcpconns>
# ListeningPorts false
# LocalPort "6882"
# RemotePort "80"
#</Plugin>
#<Plugin unixsock>
# SocketFile "/usr/var/run/collectd-unixsock"
# SocketGroup "collectd"
# SocketPerms "0660"
#</Plugin>

View File

@@ -2,6 +2,9 @@ usr/local/bin/wirelessctrl
srv/web/ipfire/cgi-bin/optionsfw.cgi
srv/web/ipfire/cgi-bin/gui.cgi
srv/web/ipfire/cgi-bin/qos.cgi
srv/web/ipfire/cgi-bin/services.cgi
srv/web/ipfire/cgi-bin/graphs.cgi
var/ipfire/langs
var/ipfire/graphs.pl
lib/modules/2.6.16.57-ipfire/kernel/drivers/parport/pt_drv.ko
lib/modules/2.6.16.57-ipfire-smp/kernel/drivers/parport/pt_drv.ko

View File

@@ -4,3 +4,4 @@
extract_files
perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
depmod -a
/etc/init.d/collectd restart

View File

@@ -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'}");

View File

@@ -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;

View File

@@ -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")){