717 lines
33 KiB
Plaintext
717 lines
33 KiB
Plaintext
|
#!/usr/bin/perl -T
|
||
|
|
||
|
#----------------------------------------------------------------------
|
||
|
# heading : Administration
|
||
|
# description : System Monitor
|
||
|
# navigation : 4000 4050
|
||
|
#
|
||
|
# copyright (C) 2002 Shad L. Lords <slords@mail.com>
|
||
|
# copyright (C) 2001 Eneo Tecnologia SC. <jjptapia@eresmas.com>
|
||
|
# Distributed under the GPL license.
|
||
|
#----------------------------------------------------------------------
|
||
|
|
||
|
package esmith;
|
||
|
|
||
|
#use strict;
|
||
|
use CGI ':all';
|
||
|
use CGI::Carp qw(fatalsToBrowser);
|
||
|
|
||
|
use esmith::cgi;
|
||
|
use esmith::config;
|
||
|
use esmith::util;
|
||
|
use esmith::db;
|
||
|
|
||
|
BEGIN
|
||
|
{
|
||
|
$ENV {'PATH'} = '';
|
||
|
$ENV {'SHELL'} = '/bin/bash';
|
||
|
delete $ENV {'ENV'};
|
||
|
}
|
||
|
esmith::util::setRealToEffective ();
|
||
|
|
||
|
$scriptname = 'sysmon';
|
||
|
|
||
|
$RRDDIR = '/var/lib/rrd';
|
||
|
$RRDFILE = 'sysmon';
|
||
|
$HOSTFILE = 'host_';
|
||
|
$IFACEFILE = 'iface_';
|
||
|
$SENSORSFILE = 'sensors';
|
||
|
$UPSFILE = 'ups';
|
||
|
|
||
|
my %conf;
|
||
|
tie %conf, 'esmith::config';
|
||
|
my $hosts = db_get_prop(\%conf, $RRDFILE, 'hosts') || "gateway";
|
||
|
my $pingscale = db_get_prop(\%conf, $RRDFILE, 'pingscale') || "300";
|
||
|
my $maxping = db_get_prop(\%conf, $RRDFILE, 'maxping') || "400";
|
||
|
$maxping -= 0.01;
|
||
|
|
||
|
$sechour = 24000;
|
||
|
$secday = 120000;
|
||
|
$secweek = 720000;
|
||
|
$secmonth = 2880000;
|
||
|
$secyear = 34560000;
|
||
|
|
||
|
$graphwidth = 401;
|
||
|
$graphheight = 160;
|
||
|
|
||
|
$TITLE = 'System Monitor';
|
||
|
$MINUTE = 'Minute';
|
||
|
$HOUR = 'Hour';
|
||
|
$HOURLY = 'Hourly';
|
||
|
$DAY = 'Day';
|
||
|
$DAILY = 'Daily';
|
||
|
$WEEKLY = 'Weekly';
|
||
|
$MONTHLY = 'Monthly';
|
||
|
$GRAPH = 'Graph';
|
||
|
$YEARLY = 'Yearly';
|
||
|
$MAXIMAL = 'Maximal';
|
||
|
$AVERAGE = 'Average';
|
||
|
$CURRENT = 'Current';
|
||
|
|
||
|
$CPU = "CPU";
|
||
|
$LOADCPU = "Load/CPU";
|
||
|
$MEM = "Memory";
|
||
|
$TEMP = "Temp";
|
||
|
$UPS = "UPS";
|
||
|
$PROCQUE = "Proc/Que";
|
||
|
$HD = "Drives";
|
||
|
$VOLTAGE = "Volt";
|
||
|
$FAN = "Fan";
|
||
|
$UPTIME = "Uptime";
|
||
|
|
||
|
my $RRDCMD = "/usr/bin/rrdtool graph - -a 'PNG' -w '600' -h '250' --color 'SHADEA#ffffff' --color 'SHADEB#ffffff' --color 'BACK#ffffff' --color 'CANVAS#ffffff' -r -E -M ";
|
||
|
|
||
|
$CPU_GRAPH = "-b '1000' -l '0' ";
|
||
|
$CPU_GRAPH .= "-t 'CPU<D> Utilitization' ";
|
||
|
$CPU_GRAPH .= "-v 'CPU (%)' ";
|
||
|
$CPU_GRAPH .= "'DEF:avgsystem=$RRDDIR/$RRDFILE.rrd:system<D>:AVERAGE' ";
|
||
|
$CPU_GRAPH .= "'DEF:maxsystem=$RRDDIR/$RRDFILE.rrd:system<D>:MAX' ";
|
||
|
$CPU_GRAPH .= "'DEF:avguser=$RRDDIR/$RRDFILE.rrd:user<D>:AVERAGE' ";
|
||
|
$CPU_GRAPH .= "'DEF:maxuser=$RRDDIR/$RRDFILE.rrd:user<D>:MAX' ";
|
||
|
$CPU_GRAPH .= "'DEF:avgiowait=$RRDDIR/$RRDFILE.rrd:iowait<D>:AVERAGE' ";
|
||
|
$CPU_GRAPH .= "'DEF:maxiowait=$RRDDIR/$RRDFILE.rrd:iowait<D>:MAX' ";
|
||
|
$CPU_GRAPH .= "'DEF:avgnice=$RRDDIR/$RRDFILE.rrd:nice<D>:AVERAGE' ";
|
||
|
$CPU_GRAPH .= "'DEF:maxnice=$RRDDIR/$RRDFILE.rrd:nice<D>:MAX' ";
|
||
|
$CPU_GRAPH .= "'CDEF:avgadjsystem=avgsystem,100,*' ";
|
||
|
$CPU_GRAPH .= "'CDEF:maxadjsystem=maxsystem,100,*' ";
|
||
|
$CPU_GRAPH .= "'CDEF:avgadjuser=avguser,100,*' ";
|
||
|
$CPU_GRAPH .= "'CDEF:maxadjuser=maxuser,100,*' ";
|
||
|
$CPU_GRAPH .= "'CDEF:avgadjiowait=avgiowait,100,*' ";
|
||
|
$CPU_GRAPH .= "'CDEF:maxadjiowait=maxiowait,100,*' ";
|
||
|
$CPU_GRAPH .= "'CDEF:avgadjnice=avgnice,100,*' ";
|
||
|
$CPU_GRAPH .= "'CDEF:maxadjnice=maxnice,100,*' ";
|
||
|
$CPU_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg\\n' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjuser:LAST:%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjuser:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:maxadjuser:MAX:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$CPU_GRAPH .= "'AREA:avgadjuser#009900:\\tUser (%)\\n' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjnice:LAST:%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjnice:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:maxadjnice:MAX:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$CPU_GRAPH .= "'AREA:avgadjnice#FFFF00:\\tNice (%)\\n:STACK' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjsystem:LAST:%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjsystem:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:maxadjsystem:MAX:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$CPU_GRAPH .= "'AREA:avgadjsystem#000080:\\tSystem (%)\\n:STACK' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjiowait:LAST:%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:avgadjiowait:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'GPRINT:maxadjiowait:MAX:\\t%6.2lf\\g' ";
|
||
|
$CPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$CPU_GRAPH .= "'AREA:avgadjiowait#FF0000:\\tIO Wait (%)\\n:STACK' ";
|
||
|
|
||
|
$LOADCPU_GRAPH = "-b '1000' -l '0' ";
|
||
|
$LOADCPU_GRAPH .= "-t 'System Load / %CPU' ";
|
||
|
$LOADCPU_GRAPH .= "-v 'Load*30 / %CPU' ";
|
||
|
$LOADCPU_GRAPH .= "'DEF:avgload=$RRDDIR/$RRDFILE.rrd:ldavg-1:AVERAGE' ";
|
||
|
$LOADCPU_GRAPH .= "'DEF:maxload=$RRDDIR/$RRDFILE.rrd:ldavg-1:MAX' ";
|
||
|
$LOADCPU_GRAPH .= "'DEF:avgtotalcpu=$RRDDIR/$RRDFILE.rrd:total:AVERAGE' ";
|
||
|
$LOADCPU_GRAPH .= "'DEF:maxtotalcpu=$RRDDIR/$RRDFILE.rrd:total:MAX' ";
|
||
|
$LOADCPU_GRAPH .= "'CDEF:avgadjload=avgload,30,*' ";
|
||
|
$LOADCPU_GRAPH .= "'CDEF:maxadjload=maxload,30,*' ";
|
||
|
$LOADCPU_GRAPH .= "'CDEF:diffadjload=maxadjload,avgadjload,-' ";
|
||
|
$LOADCPU_GRAPH .= "'CDEF:avgadjtotalcpu=avgtotalcpu,100,*' ";
|
||
|
$LOADCPU_GRAPH .= "'CDEF:maxadjtotalcpu=maxtotalcpu,100,*' ";
|
||
|
$LOADCPU_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg<\\tPeak>\\n' ";
|
||
|
$LOADCPU_GRAPH .= "'GPRINT:avgload:LAST:%6.3lf\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'GPRINT:avgload:AVERAGE:\\t%6.3lf\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'GPRINT:maxload:MAX:\\t%6.3lf\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'AREA:avgadjload#00FF00:\\t{Load\\n}<\\g>' ";
|
||
|
$LOADCPU_GRAPH .= "<'AREA:diffadjload#006400:\\tLoad\\n:STACK'> ";
|
||
|
$LOADCPU_GRAPH .= "'GPRINT:avgadjtotalcpu:LAST:%6.2lf\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'GPRINT:avgadjtotalcpu:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'GPRINT:maxadjtotalcpu:MAX:\\t%6.2lf\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$LOADCPU_GRAPH .= "'LINE1:avgadjtotalcpu#1000FF:\\t{CPU (%)\\n}<\\g>' ";
|
||
|
$LOADCPU_GRAPH .= "<'LINE1:maxadjtotalcpu#000080:\\tCPU (%)\\n'> ";
|
||
|
$LOADCPU_MAX = 'week month year';
|
||
|
|
||
|
$PROCQUE_GRAPH = "-b '1000' -l '0' ";
|
||
|
$PROCQUE_GRAPH .= "-t 'System Processes / Run Queue' ";
|
||
|
$PROCQUE_GRAPH .= "-v 'Processes / Queue*10' ";
|
||
|
$PROCQUE_GRAPH .= "'DEF:avgplist=$RRDDIR/$RRDFILE.rrd:plist-sz:AVERAGE' ";
|
||
|
$PROCQUE_GRAPH .= "'DEF:maxplist=$RRDDIR/$RRDFILE.rrd:plist-sz:MAX' ";
|
||
|
$PROCQUE_GRAPH .= "'DEF:avgrunq=$RRDDIR/$RRDFILE.rrd:runq-sz:AVERAGE' ";
|
||
|
$PROCQUE_GRAPH .= "'DEF:maxrunq=$RRDDIR/$RRDFILE.rrd:runq-sz:MAX' ";
|
||
|
$PROCQUE_GRAPH .= "'CDEF:avgadjrunq=avgrunq,10,*' ";
|
||
|
$PROCQUE_GRAPH .= "'CDEF:maxadjrunq=maxrunq,10,*' ";
|
||
|
$PROCQUE_GRAPH .= "'CDEF:diffplist=maxplist,avgplist,-' ";
|
||
|
$PROCQUE_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg<\\tPeak>\\n' ";
|
||
|
$PROCQUE_GRAPH .= "'GPRINT:avgplist:LAST:%6.1lf\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'GPRINT:avgplist:AVERAGE:\\t%6.1lf\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'GPRINT:maxplist:MAX:\\t%6.1lf\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'AREA:avgplist#00FF00:\\t{Processes\\n}<\\g>' ";
|
||
|
$PROCQUE_GRAPH .= "<'AREA:diffplist#006400:\\tProcesses\\n:STACK'> ";
|
||
|
$PROCQUE_GRAPH .= "'GPRINT:avgrunq:LAST:%6.2lf\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'GPRINT:avgrunq:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'GPRINT:maxrunq:MAX:\\t%6.2lf\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$PROCQUE_GRAPH .= "'LINE1:avgadjrunq#1000FF:\\t{Run Queue\\n}<\\g>' ";
|
||
|
$PROCQUE_GRAPH .= "<'LINE1:maxadjrunq#000080:\\tRun Queue\\n'> ";
|
||
|
$PROCQUE_MAX = 'week month year';
|
||
|
|
||
|
$MEM_GRAPH = "-b '1024' -l '0' ";
|
||
|
$MEM_GRAPH .= "-t 'Memory Utilization' ";
|
||
|
$MEM_GRAPH .= "-v 'Bytes' ";
|
||
|
$MEM_GRAPH .= "'DEF:minmemused=$RRDDIR/$RRDFILE.rrd:memused:MIN' ";
|
||
|
$MEM_GRAPH .= "'DEF:avgmemused=$RRDDIR/$RRDFILE.rrd:memused:AVERAGE' ";
|
||
|
$MEM_GRAPH .= "'DEF:maxmemused=$RRDDIR/$RRDFILE.rrd:memused:MAX' ";
|
||
|
$MEM_GRAPH .= "'DEF:minmembuffers=$RRDDIR/$RRDFILE.rrd:buffers:MIN' ";
|
||
|
$MEM_GRAPH .= "'DEF:avgmembuffers=$RRDDIR/$RRDFILE.rrd:buffers:AVERAGE' ";
|
||
|
$MEM_GRAPH .= "'DEF:maxmembuffers=$RRDDIR/$RRDFILE.rrd:buffers:MAX' ";
|
||
|
$MEM_GRAPH .= "'DEF:minmemcached=$RRDDIR/$RRDFILE.rrd:cached:MIN' ";
|
||
|
$MEM_GRAPH .= "'DEF:avgmemcached=$RRDDIR/$RRDFILE.rrd:cached:AVERAGE' ";
|
||
|
$MEM_GRAPH .= "'DEF:maxmemcached=$RRDDIR/$RRDFILE.rrd:cached:MAX' ";
|
||
|
$MEM_GRAPH .= "'DEF:minmemfree=$RRDDIR/$RRDFILE.rrd:memfree:MIN' ";
|
||
|
$MEM_GRAPH .= "'DEF:avgmemfree=$RRDDIR/$RRDFILE.rrd:memfree:AVERAGE' ";
|
||
|
$MEM_GRAPH .= "'DEF:maxmemfree=$RRDDIR/$RRDFILE.rrd:memfree:MAX' ";
|
||
|
$MEM_GRAPH .= "'DEF:minswapused=$RRDDIR/$RRDFILE.rrd:swpused:MIN' ";
|
||
|
$MEM_GRAPH .= "'DEF:avgswapused=$RRDDIR/$RRDFILE.rrd:swpused:AVERAGE' ";
|
||
|
$MEM_GRAPH .= "'DEF:maxswapused=$RRDDIR/$RRDFILE.rrd:swpused:MAX' ";
|
||
|
$MEM_GRAPH .= "'CDEF:minmemactualfree=minmemfree,minmembuffers,-,minmemcached,-' ";
|
||
|
$MEM_GRAPH .= "'CDEF:avgmemactualfree=avgmemfree,avgmembuffers,-,avgmemcached,-' ";
|
||
|
$MEM_GRAPH .= "'CDEF:maxmemactualfree=maxmemfree,maxmembuffers,-,maxmemcached,-' ";
|
||
|
$MEM_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmemused:LAST:%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:minmemused:MIN:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmemused:AVERAGE:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:maxmemused:MAX:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$MEM_GRAPH .= "'AREA:avgmemused#000080:\\tUsed (bytes)\\n' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmembuffers:LAST:%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:minmembuffers:MIN:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmembuffers:AVERAGE:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:maxmembuffers:MAX:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$MEM_GRAPH .= "'AREA:avgmembuffers#1000FF:\\tBuffers (bytes)\\n:STACK' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmemcached:LAST:%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:minmemcached:MIN:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmemcached:AVERAGE:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:maxmemcached:MAX:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$MEM_GRAPH .= "'AREA:avgmemcached#006600:\\tCache (bytes)\\n:STACK' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmemactualfree:LAST:%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:minmemactualfree:MIN:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgmemactualfree:AVERAGE:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:maxmemactualfree:MAX:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$MEM_GRAPH .= "'AREA:avgmemactualfree#00FF00:\\tFree (bytes)\\n:STACK' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgswapused:LAST:%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:minswapused:MIN:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:avgswapused:AVERAGE:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'GPRINT:maxswapused:MAX:\\t%5.0lf%S\\g' ";
|
||
|
$MEM_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$MEM_GRAPH .= "'LINE2:avgswapused#FF0000:\\tSwap (bytes)\\n' ";
|
||
|
|
||
|
$HD_GRAPH = "-b '1024' -l '0' ";
|
||
|
$HD_GRAPH .= "-t 'Hard Drive Usage' ";
|
||
|
$HD_GRAPH .= "-v 'Bytes' ";
|
||
|
$HD_GRAPH .= "'DEF:minhdused=$RRDDIR/$RRDFILE.rrd:hdused:MIN' ";
|
||
|
$HD_GRAPH .= "'DEF:avghdused=$RRDDIR/$RRDFILE.rrd:hdused:AVERAGE' ";
|
||
|
$HD_GRAPH .= "'DEF:maxhdused=$RRDDIR/$RRDFILE.rrd:hdused:MAX' ";
|
||
|
$HD_GRAPH .= "'DEF:minhdfree=$RRDDIR/$RRDFILE.rrd:hdfree:MIN' ";
|
||
|
$HD_GRAPH .= "'DEF:avghdfree=$RRDDIR/$RRDFILE.rrd:hdfree:AVERAGE' ";
|
||
|
$HD_GRAPH .= "'DEF:maxhdfree=$RRDDIR/$RRDFILE.rrd:hdfree:MAX' ";
|
||
|
$HD_GRAPH .= "'CDEF:diffhdused=maxhdused,avghdused,-' ";
|
||
|
$HD_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' ";
|
||
|
$HD_GRAPH .= "'GPRINT:avghdused:LAST:%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'GPRINT:minhdused:MIN:\\t%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'GPRINT:avghdused:AVERAGE:\\t%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'GPRINT:maxhdused:MAX:\\t%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$HD_GRAPH .= "'AREA:avghdused#000080:\\tUsed (bytes)\\n' ";
|
||
|
$HD_GRAPH .= "'GPRINT:avghdfree:LAST:%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'GPRINT:minhdfree:MIN:\\t%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'GPRINT:avghdfree:AVERAGE:\\t%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'GPRINT:maxhdfree:MAX:\\t%5.0lf%S\\g' ";
|
||
|
$HD_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$HD_GRAPH .= "'AREA:avghdfree#00FF00:\\tFree (bytes)\\n:STACK' ";
|
||
|
|
||
|
$UPTIME_GRAPH = "-b '1000' -l '0' ";
|
||
|
$UPTIME_GRAPH .= "-t 'Uptime' ";
|
||
|
$UPTIME_GRAPH .= "-v 'Days' ";
|
||
|
$UPTIME_GRAPH .= "'DEF:avguptime=$RRDDIR/$RRDFILE.rrd:uptime:AVERAGE' ";
|
||
|
$UPTIME_GRAPH .= "'DEF:maxuptime=$RRDDIR/$RRDFILE.rrd:uptime:MAX' ";
|
||
|
$UPTIME_GRAPH .= "'CDEF:avgdays=avguptime,86400,/' ";
|
||
|
$UPTIME_GRAPH .= "'CDEF:maxdays=maxuptime,86400,/' ";
|
||
|
$UPTIME_GRAPH .= "'COMMENT:Current\\tAverage\\tMaximum\\tAvg\\n' ";
|
||
|
$UPTIME_GRAPH .= "'GPRINT:avgdays:LAST:%6.1lf\\g' ";
|
||
|
$UPTIME_GRAPH .= "'GPRINT:avgdays:AVERAGE:\\t%6.1lf\\g' ";
|
||
|
$UPTIME_GRAPH .= "'GPRINT:maxdays:MAX:\\t%6.1lf\\g' ";
|
||
|
$UPTIME_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$UPTIME_GRAPH .= "'AREA:avgdays#00FF00:\\tUptime (days)\\n' ";
|
||
|
$UPTIME_GRAPH .= "'LINE1:avgdays#1000FF' ";
|
||
|
|
||
|
$LATENCY_GRAPH = "-b '1000' -l '0' ";
|
||
|
$LATENCY_GRAPH = "-t 'Latency / Packet Loss (<D>)' ";
|
||
|
$LATENCY_GRAPH .= "-v 'ms / % (${pingscale}ms = 100%)' ";
|
||
|
$LATENCY_GRAPH .= "'DEF:minlatency=$RRDDIR/$HOSTFILE<D>.rrd:median:MIN' ";
|
||
|
$LATENCY_GRAPH .= "'DEF:avglatency=$RRDDIR/$HOSTFILE<D>.rrd:median:AVERAGE' ";
|
||
|
$LATENCY_GRAPH .= "'DEF:maxlatency=$RRDDIR/$HOSTFILE<D>.rrd:median:MAX' ";
|
||
|
$LATENCY_GRAPH .= "'DEF:minloss=$RRDDIR/$HOSTFILE<D>.rrd:loss:MIN' ";
|
||
|
$LATENCY_GRAPH .= "'DEF:avgloss=$RRDDIR/$HOSTFILE<D>.rrd:loss:AVERAGE' ";
|
||
|
$LATENCY_GRAPH .= "'DEF:maxloss=$RRDDIR/$HOSTFILE<D>.rrd:loss:MAX' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:minmslatency=minlatency,1000,*' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:avgmslatency=avglatency,1000,*' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:maxmslatency=maxlatency,1000,*' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:avgadjlatency=avglatency,${maxping},1000,/,MIN' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:maxadjlatency=maxlatency,${maxping},1000,/,MIN' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:diffadjlatency=maxadjlatency,avgadjlatency,-' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:avgadjloss=avgloss,25000,/,${pingscale},*' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:maxadjloss=maxloss,25000,/,${pingscale},*' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:minrealloss=minloss,.25000,/,' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:avgrealloss=avgloss,.25000,/,' ";
|
||
|
$LATENCY_GRAPH .= "'CDEF:maxrealloss=maxloss,.25000,/,' ";
|
||
|
$LATENCY_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg<\\tPeak>\\n' ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:avgmslatency:LAST:%6.1lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:minmslatency:MIN:\\t%6.1lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:avgmslatency:AVERAGE:\\t%6.1lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:maxmslatency:MAX:\\t%6.1lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$LATENCY_GRAPH .= "'AREA:avgadjlatency#00FF00:\\t{Latency (ms)\\n}<\\g>' ";
|
||
|
$LATENCY_GRAPH .= "<'AREA:diffadjlatency#006400:\\tLatency (ms)\\n:STACK'> ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:avgrealloss:LAST:%6.2lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:minrealloss:MIN:\\t%6.2lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:avgrealloss:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'GPRINT:maxrealloss:MAX:\\t%6.2lf\\g' ";
|
||
|
$LATENCY_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$LATENCY_GRAPH .= "'LINE1:avgadjloss#1000FF:\\t{Loss (%)\\n}<\\g>' ";
|
||
|
$LATENCY_GRAPH .= "<'LINE1:maxadjloss#000080:\\tLoss (%)\\n'> ";
|
||
|
$LATENCY_MAX = 'week month year';
|
||
|
|
||
|
$IFACE_GRAPH = "-b '1024' -l '0' ";
|
||
|
$IFACE_GRAPH = "-t 'Ethernet Traffic (<D>)' ";
|
||
|
$IFACE_GRAPH .= "-v 'kB/s' ";
|
||
|
$IFACE_GRAPH .= "'DEF:minbin=$RRDDIR/$IFACEFILE<D>.rrd:rxkB:MIN' ";
|
||
|
$IFACE_GRAPH .= "'DEF:avgbin=$RRDDIR/$IFACEFILE<D>.rrd:rxkB:AVERAGE' ";
|
||
|
$IFACE_GRAPH .= "'DEF:maxbin=$RRDDIR/$IFACEFILE<D>.rrd:rxkB:MAX' ";
|
||
|
$IFACE_GRAPH .= "'DEF:minbout=$RRDDIR/$IFACEFILE<D>.rrd:txkB:MIN' ";
|
||
|
$IFACE_GRAPH .= "'DEF:avgbout=$RRDDIR/$IFACEFILE<D>.rrd:txkB:AVERAGE' ";
|
||
|
$IFACE_GRAPH .= "'DEF:maxbout=$RRDDIR/$IFACEFILE<D>.rrd:txkB:MAX' ";
|
||
|
$IFACE_GRAPH .= "'CDEF:diffbin=maxbin,avgbin,-' ";
|
||
|
$IFACE_GRAPH .= "'COMMENT: ' ";
|
||
|
$IFACE_GRAPH .= "'AREA:avgbin#00FF00:Inbound' ";
|
||
|
$IFACE_GRAPH .= "<'STACK:diffbin#006400: '> ";
|
||
|
$IFACE_GRAPH .= "{'COMMENT: '} ";
|
||
|
$IFACE_GRAPH .= "'LINE1:avgbout#1000FF:Outbound' ";
|
||
|
$IFACE_GRAPH .= "<'LINE1:maxbout#000080: '> ";
|
||
|
$IFACE_GRAPH .= "'COMMENT:\\n' ";
|
||
|
$IFACE_GRAPH .= "'COMMENT: Max\\: ' ";
|
||
|
$IFACE_GRAPH .= "'GPRINT:maxbin:MAX:%6.2lf %skB/s' ";
|
||
|
$IFACE_GRAPH .= "'GPRINT:maxbout:MAX:< > %6.2lf %skB/s' ";
|
||
|
$IFACE_GRAPH .= "'COMMENT:\\n' ";
|
||
|
$IFACE_GRAPH .= "'COMMENT: Avg\\: ' ";
|
||
|
$IFACE_GRAPH .= "'GPRINT:avgbin:AVERAGE:%6.2lf %skB/s' ";
|
||
|
$IFACE_GRAPH .= "'GPRINT:avgbout:AVERAGE:< > %6.2lf %skB/s' ";
|
||
|
$IFACE_GRAPH .= "'COMMENT:\\n' ";
|
||
|
$IFACE_GRAPH .= "'COMMENT:Last\\: ' ";
|
||
|
$IFACE_GRAPH .= "'GPRINT:avgbin:LAST:%6.2lf %skB/s' ";
|
||
|
$IFACE_GRAPH .= "'GPRINT:avgbout:LAST:< > %6.2lf %skB/s' ";
|
||
|
$IFACE_MAX = 'week month year';
|
||
|
|
||
|
$VOLTAGE_GRAPH = "-b '1000' ";
|
||
|
$VOLTAGE_GRAPH .= "-t 'System Sensors (Voltage)' ";
|
||
|
$VOLTAGE_GRAPH .= "-v 'Volts' ";
|
||
|
my @color = ('CC0099', 'FF99CC', '0000FF', '8B4513', 'DAA520', 'FF0000', 'FFFF00','0000FF', '999999', '000000');
|
||
|
my $sensortest = `/usr/bin/rrdtool fetch $RRDDIR/$SENSORSFILE.rrd AVERAGE -s -0 |/usr/bin/head -n1| /usr/bin/tr -s ' '| /usr/bin/tr -d '\n'`;
|
||
|
my @sensorarr = split / /, $sensortest;
|
||
|
my %params = map { $_ => 1 } @sensorarr;
|
||
|
my $isvolt = "";
|
||
|
for (my $i=0; $i <= 8; $i++) {
|
||
|
if(exists($params{"in$i"})) {
|
||
|
$VOLTAGE_GRAPH .= "'DEF:minin$i=$RRDDIR/$SENSORSFILE.rrd:in$i:MIN' ";
|
||
|
$VOLTAGE_GRAPH .= "'DEF:avgin$i=$RRDDIR/$SENSORSFILE.rrd:in$i:AVERAGE' ";
|
||
|
$VOLTAGE_GRAPH .= "'DEF:maxin$i=$RRDDIR/$SENSORSFILE.rrd:in$i:MAX' ";
|
||
|
$VOLTAGE_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' " if $i == 0;
|
||
|
$VOLTAGE_GRAPH .= "'GPRINT:avgin$i:LAST:%6.2lf\\g' ";
|
||
|
$VOLTAGE_GRAPH .= "'GPRINT:minin$i:MIN:\\t%6.2lf\\g' ";
|
||
|
$VOLTAGE_GRAPH .= "'GPRINT:avgin$i:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$VOLTAGE_GRAPH .= "'GPRINT:maxin$i:MAX:\\t%6.2lf\\g' ";
|
||
|
$VOLTAGE_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$VOLTAGE_GRAPH .= "'LINE2:avgin0#".$color[$i].":\\tVoltage $i (V)\\n' ";
|
||
|
$isvolt=1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$FAN_GRAPH = "-b '1000' ";
|
||
|
$FAN_GRAPH .= "-t 'System Sensors (Fans)' ";
|
||
|
$FAN_GRAPH .= "-v 'RPM' ";
|
||
|
my $isfan = "";
|
||
|
for (my $i=1; $i <= 3; $i++) {
|
||
|
if(exists($params{"fan$i"})) {
|
||
|
$FAN_GRAPH .= "'DEF:minfan$i=$RRDDIR/$SENSORSFILE.rrd:fan$i:MIN' ";
|
||
|
$FAN_GRAPH .= "'DEF:avgfan$i=$RRDDIR/$SENSORSFILE.rrd:fan$i:AVERAGE' ";
|
||
|
$FAN_GRAPH .= "'DEF:maxfan$i=$RRDDIR/$SENSORSFILE.rrd:fan$i:MAX' ";
|
||
|
$FAN_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' " if $i == 1;
|
||
|
$FAN_GRAPH .= "'GPRINT:avgfan$i:LAST:%6.2lf\\g' ";
|
||
|
$FAN_GRAPH .= "'GPRINT:minfan$i:MIN:\\t%6.2lf\\g' ";
|
||
|
$FAN_GRAPH .= "'GPRINT:avgfan$i:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$FAN_GRAPH .= "'GPRINT:maxfan$i:MAX:\\t%6.2lf\\g' ";
|
||
|
$FAN_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$FAN_GRAPH .= "'LINE2:avgfan$i#".$color[$i].":\\tFan $i (rpm)\\n' ";
|
||
|
$isfan=1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
$TEMP_GRAPH = "-b '1000' ";
|
||
|
$TEMP_GRAPH .= "-t 'System Sensors (Temperature)' ";
|
||
|
$TEMP_GRAPH .= "-v '°C' ";
|
||
|
my $istemp = "";
|
||
|
for (my $i=0; $i <= 8; $i++) {
|
||
|
if(exists($params{"temp$i"})) {
|
||
|
$TEMP_GRAPH .= "'DEF:mintemp$i=$RRDDIR/$SENSORSFILE.rrd:temp$i:MIN' ";
|
||
|
$TEMP_GRAPH .= "'DEF:avgtemp$i=$RRDDIR/$SENSORSFILE.rrd:temp$i:AVERAGE' ";
|
||
|
$TEMP_GRAPH .= "'DEF:maxtemp$i=$RRDDIR/$SENSORSFILE.rrd:temp$i:MAX' ";
|
||
|
$TEMP_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' " if $i == 0;
|
||
|
$TEMP_GRAPH .= "'GPRINT:avgtemp$i:LAST:%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:mintemp$i:MIN:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:avgtemp$i:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:maxtemp$i:MAX:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$TEMP_GRAPH .= "'LINE2:avgtemp$i#".$color[$i].":\\tTemp $i (°C)\\n' ";
|
||
|
$istemp=1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( -e "$RRDDIR/${UPSFILE}1.rrd" )
|
||
|
{
|
||
|
$TEMP_GRAPH .= "'DEF:minups1temp=$RRDDIR/${UPSFILE}1.rrd:u_temperature:MIN' ";
|
||
|
$TEMP_GRAPH .= "'DEF:avgups1temp=$RRDDIR/${UPSFILE}1.rrd:u_temperature:AVERAGE' ";
|
||
|
$TEMP_GRAPH .= "'DEF:maxups1temp=$RRDDIR/${UPSFILE}1.rrd:u_temperature:MAX' ";
|
||
|
}
|
||
|
if ( -e "$RRDDIR/${UPSFILE}2.rrd" )
|
||
|
{
|
||
|
$TEMP_GRAPH .= "'DEF:minups2temp=$RRDDIR/${UPSFILE}2.rrd:u_temperature:MIN' ";
|
||
|
$TEMP_GRAPH .= "'DEF:avgups2temp=$RRDDIR/${UPSFILE}2.rrd:u_temperature:AVERAGE' ";
|
||
|
$TEMP_GRAPH .= "'DEF:maxups2temp=$RRDDIR/${UPSFILE}2.rrd:u_temperature:MAX' ";
|
||
|
}
|
||
|
|
||
|
if ( -e "$RRDDIR/${UPSFILE}1.rrd" ) {
|
||
|
$TEMP_GRAPH .= "'GPRINT:avgups1temp:LAST:%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:minups1temp:MIN:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:avgups1temp:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:maxups1temp:MAX:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$TEMP_GRAPH .= "'LINE2:avgups1temp#999999:\\tUPS 1 (°C)\\n' ";
|
||
|
}
|
||
|
|
||
|
if ( -e "$RRDDIR/${UPSFILE}2.rrd" ) {
|
||
|
$TEMP_GRAPH .= "'GPRINT:avgups2temp:LAST:%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:minups2temp:MIN:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:avgups2temp:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'GPRINT:maxups2temp:MAX:\\t%6.2lf\\g' ";
|
||
|
$TEMP_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$TEMP_GRAPH .= "'LINE2:avgups2temp#333333:\\tUPS 2 (°C)\\n' ";
|
||
|
}
|
||
|
|
||
|
$UPS_GRAPH = "-b '1000' -l '0' ";
|
||
|
$UPS_GRAPH .= "-t 'UPS<D> Statistics' ";
|
||
|
$UPS_GRAPH .= "-v 'V / % / Minutes / °C' ";
|
||
|
$UPS_GRAPH .= "'DEF:minlinev=$RRDDIR/$UPSFILE<D>.rrd:i_voltage:MIN' ";
|
||
|
$UPS_GRAPH .= "'DEF:avglinev=$RRDDIR/$UPSFILE<D>.rrd:i_voltage:AVERAGE' ";
|
||
|
$UPS_GRAPH .= "'DEF:maxlinev=$RRDDIR/$UPSFILE<D>.rrd:i_voltage:MAX' ";
|
||
|
$UPS_GRAPH .= "'DEF:minloadpct=$RRDDIR/$UPSFILE<D>.rrd:u_load:MIN' ";
|
||
|
$UPS_GRAPH .= "'DEF:avgloadpct=$RRDDIR/$UPSFILE<D>.rrd:u_load:AVERAGE' ";
|
||
|
$UPS_GRAPH .= "'DEF:maxloadpct=$RRDDIR/$UPSFILE<D>.rrd:u_load:MAX' ";
|
||
|
$UPS_GRAPH .= "'DEF:minbcharge=$RRDDIR/$UPSFILE<D>.rrd:b_charge:MIN' ";
|
||
|
$UPS_GRAPH .= "'DEF:avgbcharge=$RRDDIR/$UPSFILE<D>.rrd:b_charge:AVERAGE' ";
|
||
|
$UPS_GRAPH .= "'DEF:maxbcharge=$RRDDIR/$UPSFILE<D>.rrd:b_charge:MAX' ";
|
||
|
$UPS_GRAPH .= "'DEF:mintimeleft=$RRDDIR/$UPSFILE<D>.rrd:b_runtime:MIN' ";
|
||
|
$UPS_GRAPH .= "'DEF:avgtimeleft=$RRDDIR/$UPSFILE<D>.rrd:b_runtime:AVERAGE' ";
|
||
|
$UPS_GRAPH .= "'DEF:maxtimeleft=$RRDDIR/$UPSFILE<D>.rrd:b_runtime:MAX' ";
|
||
|
$UPS_GRAPH .= "'DEF:minbattv=$RRDDIR/$UPSFILE<D>.rrd:b_voltage:MIN' ";
|
||
|
$UPS_GRAPH .= "'DEF:avgbattv=$RRDDIR/$UPSFILE<D>.rrd:b_voltage:AVERAGE' ";
|
||
|
$UPS_GRAPH .= "'DEF:maxbattv=$RRDDIR/$UPSFILE<D>.rrd:b_voltage:MAX' ";
|
||
|
$UPS_GRAPH .= "'DEF:minitemp=$RRDDIR/$UPSFILE<D>.rrd:u_temperature:MIN' ";
|
||
|
$UPS_GRAPH .= "'DEF:avgitemp=$RRDDIR/$UPSFILE<D>.rrd:u_temperature:AVERAGE' ";
|
||
|
$UPS_GRAPH .= "'DEF:maxitemp=$RRDDIR/$UPSFILE<D>.rrd:u_temperature:MAX' ";
|
||
|
$UPS_GRAPH .= "'COMMENT:Current\\tMinimum\\tAverage\\tMaximum\\tAvg\\n' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avglinev:LAST:%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:minlinev:MIN:\\t%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avglinev:AVERAGE:\\t%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:maxlinev:MAX:\\t%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$UPS_GRAPH .= "'LINE2:avglinev#0000FF:\\tIncoming (V)\\n' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgbattv:LAST:%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:minbattv:MIN:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgbattv:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:maxbattv:MAX:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$UPS_GRAPH .= "'LINE2:avgbattv#DAA520:\\tBattery (V)\\n' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgbcharge:LAST:%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:minbcharge:MIN:\\t%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgbcharge:AVERAGE:\\t%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:maxbcharge:MAX:\\t%6.1lf\\g' ";
|
||
|
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$UPS_GRAPH .= "'LINE2:avgbcharge#FF0000:\\tCharge (%)\\n' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgtimeleft:LAST:%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:mintimeleft:MIN:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgtimeleft:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:maxtimeleft:MAX:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$UPS_GRAPH .= "'LINE2:avgtimeleft#999999:\\tRuntime (min)\\n' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgloadpct:LAST:%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:minloadpct:MIN:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgloadpct:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:maxloadpct:MAX:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$UPS_GRAPH .= "'LINE2:avgloadpct#8B4513:\\tLoad (%)\\n' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgitemp:LAST:%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:minitemp:MIN:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:avgitemp:AVERAGE:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'GPRINT:maxitemp:MAX:\\t%6.2lf\\g' ";
|
||
|
$UPS_GRAPH .= "'COMMENT:\\t\\g' ";
|
||
|
$UPS_GRAPH .= "'LINE2:avgitemp#333333:\\tTemp (°C)\\n' ";
|
||
|
|
||
|
$CGI::POST_MAX=1024 * 100;
|
||
|
$CGI::DISABLE_UPLOADS = 1;
|
||
|
|
||
|
my $q = new CGI;
|
||
|
|
||
|
my @hosts = ();
|
||
|
my @hostfiles = `/bin/ls $RRDDIR/$HOSTFILE*.rrd`;
|
||
|
foreach(@hostfiles)
|
||
|
{
|
||
|
if (/$HOSTFILE([^\/]+).rrd$/)
|
||
|
{
|
||
|
push(@hosts,$1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
my @interfaces = ();
|
||
|
my @ifacefiles = `/bin/ls $RRDDIR/$IFACEFILE*.rrd`;
|
||
|
foreach(@ifacefiles)
|
||
|
{
|
||
|
if (/$IFACEFILE([^\/]+).rrd$/)
|
||
|
{
|
||
|
push(@interfaces,$1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (! grep (/^state$/, $q->param))
|
||
|
{
|
||
|
$q->param(-name=>"time",value=>"day");
|
||
|
&showGeneral ($q);
|
||
|
&generateFoot($q);
|
||
|
}
|
||
|
elsif ($q->param('state') eq "detailed")
|
||
|
{
|
||
|
&showDetailed ($q);
|
||
|
&generateFoot($q);
|
||
|
}
|
||
|
elsif ($q->param('state') eq "general")
|
||
|
{
|
||
|
&showGeneral ($q);
|
||
|
&generateFoot($q);
|
||
|
}
|
||
|
elsif ($q->param('state') eq "gif")
|
||
|
{
|
||
|
&showGif ($q);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
}
|
||
|
|
||
|
sub showGeneral ($)
|
||
|
{
|
||
|
my ($q) = @_;
|
||
|
my ($typeGraph, $time);
|
||
|
# untaint the parameters
|
||
|
if ( $q->param("typegraph") =~ /^([\w]+)$/ ) { $typeGraph = $1; } else { $typeGraph = 'CPU'; }
|
||
|
if ( $q->param("time") =~ /^([\w]+)$/ ) { $time = $1; } else { $time = 'day'; }
|
||
|
|
||
|
my $key;
|
||
|
|
||
|
if ($time eq "hour") { $header = "'$HOURLY' $GRAPH (1 $MINUTE $AVERAGE)<br>"; }
|
||
|
elsif ($time eq "day") { $header = "'$DAILY' $GRAPH (5 $MINUTE $AVERAGE)<br>"; }
|
||
|
elsif ($time eq "week") { $header = "'$WEEKLY' $GRAPH (30 $MINUTE $AVERAGE)<br>"; }
|
||
|
elsif ($time eq "month") { $header = "'$MONTHLY' $GRAPH (2 $HOUR $AVERAGE)<br>"; }
|
||
|
elsif ($time eq "year") { $header = "'$YEARLY' $GRAPH (1 $DAY $AVERAGE)<br>"; }
|
||
|
|
||
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf, "$TITLE");
|
||
|
print "<meta http-equiv=\"refresh\" content=\"300\">";
|
||
|
|
||
|
print "<table border=0 cellspacing=0 cellpadding=0>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=hour"}, "$HOURLY") . "</b></td><td width=20></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=day"}, "$DAILY") . "</b></td><td width=20></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=week"}, "$WEEKLY") . "</b></td><td width=20></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=month"}, "$MONTHLY") . "</b></td><td width=20></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=general&time=year"}, "$YEARLY") . "</b></td><td width=20></td>";
|
||
|
print "</table>";
|
||
|
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=CPU"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=CPU&time=$time\">"));
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=LOADCPU"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=LOADCPU&time=$time\">"));
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=MEM"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=MEM&time=$time\">"));
|
||
|
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||
|
{
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=TEMP"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=TEMP&time=$time\">")) if $istemp;
|
||
|
}
|
||
|
if ( -e "$RRDDIR/${UPSFILE}1.rrd")
|
||
|
{
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=1"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=UPS&time=$time&data=1\">"));
|
||
|
}
|
||
|
if ( -e "$RRDDIR/${UPSFILE}2.rrd")
|
||
|
{
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=2"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=UPS&time=$time&data=2\">"));
|
||
|
}
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=PROCQUE"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=PROCQUE&time=$time\">"));
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=HD"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=HD&time=$time\">"));
|
||
|
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||
|
{
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=VOLTAGE"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=VOLTAGE&time=$time\">")) if $isvolt;
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=FAN"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=FAN&time=$time\">")) if $isfan;
|
||
|
}
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=UPTIME"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=UPTIME&time=$time\">"));
|
||
|
if ($hosts ne "none")
|
||
|
{
|
||
|
foreach $key (@hosts)
|
||
|
{
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=LATENCY&data=$key"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=LATENCY&data=$key&time=$time\">"));
|
||
|
}
|
||
|
}
|
||
|
foreach $key (@interfaces)
|
||
|
{
|
||
|
print $q->p($q->a ({href => "${scriptname}?state=detailed&typegraph=IFACE&data=$key"},"$header<IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=IFACE&data=$key&time=$time\">"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
sub showDetailed($)
|
||
|
{
|
||
|
my ($q) = @_;
|
||
|
my ($typeGraph, $data);
|
||
|
# untaint the parameters
|
||
|
if ( $q->param("typegraph") =~ /^([\w]+)$/ ) { $typeGraph = $1; } else { $typeGraph = 'CPU'; }
|
||
|
if ( $q->param("data") =~ /^([.-\w]+)$/ ) { $data = $1; } else { $data = ''; }
|
||
|
|
||
|
my ($key,$title);
|
||
|
|
||
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf, "$TITLE");
|
||
|
|
||
|
print "<meta http-equiv=\"refresh\" content=\"300\">";
|
||
|
|
||
|
print "<table>";
|
||
|
print "<tr><td align=right><b>System:</b></td><td><table border=0 cellspacing=0 cellpadding=0>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=CPU"}, $CPU) . "</b></td><td width=10></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=LOADCPU"}, $LOADCPU) . "</b></td><td width=10></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=MEM"}, $MEM) . "</b></td><td width=10></td>";
|
||
|
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||
|
{
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=TEMP"}, $TEMP) . "</b></td><td width=10></td>";
|
||
|
}
|
||
|
if ( -e "$RRDDIR/${UPSFILE}1.rrd")
|
||
|
{
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=1"}, $UPS.'1') . "</b></td><td width=10></td>";
|
||
|
}
|
||
|
if ( -e "$RRDDIR/${UPSFILE}2.rrd")
|
||
|
{
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=UPS&data=2"}, $UPS.'2') . "</b></td><td width=10></td>";
|
||
|
}
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=PROCQUE"}, $PROCQUE) . "</b></td><td width=10></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=HD"}, $HD) . "</b></td><td width=10></td>";
|
||
|
if ( -e "$RRDDIR/$SENSORSFILE.rrd")
|
||
|
{
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=VOLTAGE"}, $VOLTAGE) . "</b></td><td width=10></td>";
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=FAN"}, $FAN) . "</b></td><td width=10></td>";
|
||
|
}
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=UPTIME"}, $UPTIME) . "</b></td><td width=10></td>";
|
||
|
print "</table></td></tr>";
|
||
|
|
||
|
if ($hosts ne "none")
|
||
|
{
|
||
|
print "<td align=right><b>Hosts:</b></td><td><table border=0 cellspacing=0 cellpadding=0>";
|
||
|
foreach $key (@hosts)
|
||
|
{
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=LATENCY&data=$key"}, "$key") . "</b></td><td width=10></td>";
|
||
|
}
|
||
|
print "</table></td></tr>";
|
||
|
}
|
||
|
if ($#interfaces >= 0)
|
||
|
{
|
||
|
print "<td align=right><b>Interfaces:</b></td><td><table border=0 cellspacing=0 cellpadding=0>";
|
||
|
foreach $key (@interfaces)
|
||
|
{
|
||
|
print "<td><b>" . $q->a ({href => "${scriptname}?state=detailed&typegraph=IFACE&data=$key"}, $key) . "</b></td><td width=10></td>";
|
||
|
}
|
||
|
print "</table></td></tr>";
|
||
|
}
|
||
|
print "</table>";
|
||
|
|
||
|
print $q->p ($q->a ({href => "${scriptname}?state=general&time=hour"},"'$HOURLY' $GRAPH (1 $MINUTE $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=hour\">"));
|
||
|
print $q->p ($q->a ({href => "${scriptname}?state=general&time=day"},"'$DAILY' $GRAPH (5 $MINUTE $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=day\">"));
|
||
|
print $q->p ($q->a ({href => "${scriptname}?state=general&time=week"},"'$WEEKLY' $GRAPH (30 $MINUTE $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=week\">"));
|
||
|
print $q->p ($q->a ({href => "${scriptname}?state=general&time=month"},"'$MONTHLY' $GRAPH (2 $HOUR $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=month\">"));
|
||
|
print $q->p ($q->a ({href => "${scriptname}?state=general&time=year"},"'$YEARLY' $GRAPH (1 $DAY $AVERAGE)<br><IMG BORDER=0 SRC=\"${scriptname}?state=gif&typegraph=$typeGraph&data=$data&time=year\">"));
|
||
|
}
|
||
|
|
||
|
sub showGif($)
|
||
|
{
|
||
|
my ($q) = @_;
|
||
|
my ($typeGraph, $data, $time);
|
||
|
# untaint the parameters
|
||
|
if ( $q->param("typegraph") =~ /^([\w]+)$/ ) { $typeGraph = $1; } else { $typeGraph = 'CPU'; }
|
||
|
if ( $q->param("data") =~ /^([.-\w]+)$/ ) { $data = $1; } else { $data = ''; }
|
||
|
if ( $q->param("time") =~ /^([\w]+)$/ ) { $time = $1; } else { $time = 'day'; }
|
||
|
|
||
|
$rrdtime = ${"sec".$time} || $time;
|
||
|
|
||
|
my $rrd = "$RRDCMD -s '-$rrdtime' ${$typeGraph.'_GRAPH'}";
|
||
|
$rrd =~ s/\<D\>/$data/g;
|
||
|
|
||
|
if (${$typeGraph.'_MAX'} =~ /$time/)
|
||
|
{
|
||
|
$rrd =~ s/\{.*?\}//g;
|
||
|
$rrd =~ s/[\<\>]//g;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$rrd =~ s/\<.*?\>//g;
|
||
|
$rrd =~ s/[\{\}]//g;
|
||
|
}
|
||
|
|
||
|
if ($q->param("debug") eq "show")
|
||
|
{
|
||
|
esmith::cgi::genHeaderNonCacheable ($q, \%conf, "$TITLE");
|
||
|
print "$rrd";
|
||
|
exit;
|
||
|
}
|
||
|
|
||
|
print $q->header(-type=>'image/gif',-expires=>"+60s");
|
||
|
open(IMGIF,"$rrd |");
|
||
|
binmode STDOUT;
|
||
|
while(<IMGIF>)
|
||
|
{print;}
|
||
|
close(IMGIF);
|
||
|
}
|
||
|
|
||
|
sub generateFoot($)
|
||
|
{
|
||
|
my ($q) = @_;
|
||
|
esmith::cgi::genFooter ($q);
|
||
|
print $q->end_html;
|
||
|
}
|