add some ipv6 niceness

git-svn-id: http://www.observium.org/svn/observer/trunk@228 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-04-10 14:52:51 +00:00
parent 844268c1ad
commit b40c2b4cf9
16 changed files with 1004 additions and 448 deletions

View File

@@ -6,13 +6,13 @@
include("config.php");
include("includes/functions.php");
#$query = "SELECT *,A.id as id FROM ipaddr AS A, interfaces as I, devices as D
# WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'";
$query = "SELECT *,A.id as id FROM ipaddr AS A, interfaces as I, devices as D
WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'";
$data = mysql_query($query);
while($row = mysql_fetch_array($data)) {
$mask = trim(`$ipcalc $row[addr]/$row[cidr] | grep Netmask: | cut -d " " -f 4`);
$mask = trim(shell_exec($config['ipcalc'] . " ".$row['addr']."/".$row['cidr']." | grep Netmask: | cut -d \" \" -f 4"));
$response = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname] ipAdEntIfIndex.$row[addr] | cut -d " " -f 2`);
$maskcheck = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname] ipAdEntNetMask.$row[addr] | cut -d " " -f 2`);
if($response == $row['ifIndex'] && $mask == $maskcheck) {
@@ -22,8 +22,8 @@ while($row = mysql_fetch_array($data)) {
}
}
#$query = "SELECT * FROM interfaces AS I, devices as D
# WHERE I.device_id = D.device_id AND D.status = '1'";
$query = "SELECT * FROM interfaces AS I, devices as D
WHERE I.device_id = D.device_id AND D.status = '1'";
$data = mysql_query($query);
while($row = mysql_fetch_array($data)) {
$index = $row[ifIndex];
@@ -40,8 +40,8 @@ while($row = mysql_fetch_array($data)) {
}
}
#echo(mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces`"), 0) . " interfaces at start\n");
#$interface_query = mysql_query("SELECT interface_id,device_id FROM `interfaces`");
echo(mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces`"), 0) . " interfaces at start\n");
$interface_query = mysql_query("SELECT interface_id,device_id FROM `interfaces`");
while ($interface = mysql_fetch_array($interface_query)) {
$device_id = $interface['device_id'];
$interface_id = $interface['interface_id'];
@@ -52,8 +52,8 @@ while ($interface = mysql_fetch_array($interface_query)) {
}
echo(mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces`"), 0) . " interfaces at end\n");
#echo(mysql_result(mysql_query("SELECT COUNT(id) FROM `links`"), 0) . " links at start\n");
#$link_query = mysql_query("SELECT id,src_if,dst_if FROM `links`");
echo(mysql_result(mysql_query("SELECT COUNT(id) FROM `links`"), 0) . " links at start\n");
$link_query = mysql_query("SELECT id,src_if,dst_if FROM `links`");
while ($link = mysql_fetch_array($link_query)) {
$id = $link['id'];
$src = $link['src_if'];

View File

@@ -3,7 +3,7 @@
include("config.php");
include("includes/functions.php");
`rm ips.txt && touch ips.txt`;
shell_exec("rm ips.txt && touch ips.txt");
$handle = fopen("ips.txt", "w+");
@@ -12,7 +12,7 @@ while ($data = mysql_fetch_array($query)) {
$cidr = $data['cidr'];
list ($network, $bits) = split("/", $cidr);
if($bits != '32' && $bits != '32' && $bits > '22') {
$broadcast = trim(`$ipcalc $cidr | grep Broadcast | cut -d" " -f 2`);
$broadcast = trim(shell_exec($config['ipcalc']." $cidr | grep Broadcast | cut -d\" \" -f 2"));
$ip = ip2long($network) + '1';
$end = ip2long($broadcast);
while($ip < $end) {

View File

@@ -61,6 +61,7 @@ function popUp(URL) {
} else {
echo("Not logged in!");
}
if( Net_IPv6::checkIPv6($_SERVER['REMOTE_ADDR'])) { echo(" via <b>IPv6</b>"); } else { echo(" via <b>IPv4</b>"); }
?>
</td></tr>
</table>

View File

@@ -10,7 +10,7 @@
list($oid,$ifIndex) = explode(" ", $data);
$mask = shell_exec($config['snmpget']." -O qv -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." ipAdEntNetMask.$oid");
$mask = trim($mask);
$network = trim(`$ipcalc $oid/$mask | grep Network | cut -d" " -f 4`);
$network = trim(shell_exec ($config['ipcalc'] . " $oid/$mask | grep Network | cut -d" " -f 4"));
list($net,$cidr) = explode("/", $network);
$cidr = trim($cidr);
if($mask == "255.255.255.255") { $cidr = "32"; $network = "$oid/$cidr"; }

View File

@@ -2,6 +2,8 @@
include("common.php");
include("ipv6.php");
include("generic.php");
include("ios.php");
include("unix.php");
@@ -15,7 +17,6 @@ include("cisco-entities.php");
include("syslog.php");
function write_dev_attrib($device_id, $attrib_type, $attrib_value) {
$count_sql = "SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . $device_id . "' AND `attrib_type` = '$attrib_type'";
@@ -53,8 +54,8 @@ function shorthost($hostname, $len=16) {
}
function rrdtool_update($rrdfile, $rrdupdate) {
global $rrdtool;
return `$rrdtool update $rrdfile $rrdupdate`;
global $config;
return shell_exec($config['rrdtool'] . " update $rrdfile $rrdupdate");
}
function getHostOS($hostname, $community, $snmpver) {
@@ -460,8 +461,8 @@ function isSNMPable($hostname, $community, $snmpver) {
}
function isPingable($hostname) {
global $fping;
$status = `$fping $hostname`;
global $config;
$status = shell_exec($config['fping'] . " $hostname");
if(strstr($status, "alive")) {
return TRUE;
} else {

View File

@@ -5,8 +5,7 @@ function pollDevice() {
global $device;
global $community;
global $config;
$rrdtool = $config['rrdtool'];
$id = $device['id'];
$id = $device['device_id'];
$hostname = $device['hostname'];
$hardware = $device['hardware'];
$version = $device['version'];
@@ -22,20 +21,20 @@ function pollDevice() {
$memgraph = "public_html/graphs/" . $device['hostname'] . "-mem.png";
$cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname']." 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0";
list ($cpu5m, $cpu5s) = explode("\n", `$cmd`);
list ($cpu5m, $cpu5s) = explode("\n", shell_exec($cmd));
$cpu5m = $cpu5m + 0;
$cpu5s = $cpu5s + 0;
$cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname']." .1.3.6.1.4.1.9.9.13.1.3.1.3.1 .1.3.6.1.4.1.9.9.13.1.3.1.3.2";
list ($tempin1, $tempout1) = explode("\n", `$cmd`);
list ($tempin1, $tempout1) = explode("\n", shell_exec($cmd));
$tempin1 = $tempin1 +0;
$tempout1 = $tempout1 + 0;
$cmd = $config['snmpget'] . " -O qv -v2c -c ".$community." ".$device['hostname'];
$cmd .= " .1.3.6.1.4.1.9.9.48.1.1.1.6.2 .1.3.6.1.4.1.9.9.48.1.1.1.6.1 .1.3.6.1.4.1.9.9.48.1.1.1.5.2 .1.3.6.1.4.1.9.9.48.1.1.1.5.1";
list ($memfreeio, $memfreeproc, $memusedio, $memusedproc) = explode("\n", `$cmd`);
list ($memfreeio, $memfreeproc, $memusedio, $memusedproc) = explode("\n", shell_exec($cmd));
echo($device['hostname'] . "\n");
$memfreeio = $memfreeio + 0;
@@ -44,17 +43,17 @@ function pollDevice() {
$memusedproc = $memusedproc + 0;
$memtotal = $memfreeio + $memfreeproc + $memusedio + $memusedproc;
if (!is_file($cpurrd)) {
$rrdcreate = `$rrdtool create $cpurrd --step 300 DS:LOAD5S:GAUGE:600:-1:100 DS:LOAD5M:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200`;
shell_exec($config['rrdtool'] . " create $cpurrd --step 300 DS:LOAD5S:GAUGE:600:-1:100 DS:LOAD5M:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200");
}
if (!is_file($temprrd)) {
$rrdcreate = `$rrdtool create $temprrd --step 300 DS:TEMPIN1:GAUGE:600:-1:100 DS:TEMPOUT1:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200`;
shell_exec($config['rrdtool'] . " create $temprrd --step 300 DS:TEMPIN1:GAUGE:600:-1:100 DS:TEMPOUT1:GAUGE:600:-1:100 RRA:AVERAGE:0.5:1:1200");
}
if (!is_file($memrrd)) {
$rrdcreate = `$rrdtool create $memrrd --step 300 DS:IOFREE:GAUGE:600:0:500000000 DS:IOUSED:GAUGE:600:-1:500000000 DS:PROCFREE:GAUGE:600:0:500000000 DS:PROCUSED:GAUGE:600:-1:500000000 DS:MEMTOTAL:GAUGE:600:-1:500000000 RRA:AVERAGE:0.5:1:1200`;
shell_exec($config['rrdtool'] . " create $memrrd --step 300 DS:IOFREE:GAUGE:600:0:500000000 DS:IOUSED:GAUGE:600:-1:500000000 DS:PROCFREE:GAUGE:600:0:500000000 DS:PROCUSED:GAUGE:600:-1:500000000 DS:MEMTOTAL:GAUGE:600:-1:500000000 RRA:AVERAGE:0.5:1:1200");
}
`$rrdtool update $temprrd N:$tempin1:$tempout1`;
`$rrdtool update $cpurrd N:$cpu5s:$cpu5m`;
`$rrdtool update $memrrd N:$$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal`;
shell_exec($config['rrdtool'] . " update $temprrd N:$tempin1:$tempout1");
shell_exec($config['rrdtool'] . " update $cpurrd N:$cpu5s:$cpu5m");
shell_exec($config['rrdtool'] . " update $memrrd N:$$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal");
}
?>

View File

@@ -2,9 +2,10 @@
include("graphing/screenos.php");
include("graphing/fortigate.php");
include("graphing/windows.php");
function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height";
if($height < "33") { $options .= " --only-graph"; }
@@ -38,16 +39,16 @@ function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:outbits:LAST:%6.2lf%s";
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:outbits:MAX:%6.2lf%s";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal"; }
$thing = `$rrdtool graph $imgfile $options`;
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; }
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {
$options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal ";
$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal ";
}
$hostname = gethostbyid($device);
$imgfile = "graphs/" . "$graph";
@@ -100,16 +101,16 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic
$opt = str_replace(" ","\ ", $opt);
$options .= " $opt";
}
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max ";
$options .= " -l 0 -E -b 1024 --title '$title' ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$hostname = gethostbyid($device);
$imgfile = "graphs/" . "$graph";
$iter = "1";
@@ -130,18 +131,18 @@ function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $
$options .= " GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lf\<EFBFBD>C\\\l ";
$iter++;
}
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_device_bits ($device, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; }
$hostname = gethostbyid($device);
$query = mysql_query("SELECT `ifIndex` FROM `interfaces` WHERE `device_id` = '$device' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%' AND `ifType` != 'l2vlan'");
if($width <= "300") { $options .= "--font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= "--font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$pluses = "";
while($int = mysql_fetch_row($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . $int[0] . ".rrd")) {
@@ -171,18 +172,18 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:outbits:LAST:%6.2lf%s ";
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s ";
$options .= " GPRINT:outbits:MAX:%6.2lf%s ";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; }
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:inoctets=$database:INOCTETS:AVERAGE";
$options .= " DEF:outoctets=$database:OUTOCTETS:AVERAGE";
$options .= " CDEF:octets=inoctets,outoctets,+";
@@ -214,16 +215,16 @@ function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
$options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function pktsgraph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:INUCASTPKTS:AVERAGE";
$options .= " DEF:out=$database:OUTUCASTPKTS:AVERAGE";
$options .= " CDEF:dout=out,-1,*";
@@ -238,16 +239,16 @@ function pktsgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:out:LAST:%6.2lf%spps";
$options .= " GPRINT:out:AVERAGE:%6.2lf%spps";
$options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function errorgraph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:INERRORS:AVERAGE";
$options .= " DEF:out=$database:OUTERRORS:AVERAGE";
$options .= " CDEF:dout=out,-1,*";
@@ -262,16 +263,16 @@ function errorgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:out:LAST:%6.2lf%spps";
$options .= " GPRINT:out:AVERAGE:%6.2lf%spps";
$options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function nucastgraph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:INNUCASTPKTS:AVERAGE";
$options .= " DEF:out=$database:OUTNUCASTPKTS:AVERAGE";
$options .= " CDEF:dout=out,-1,*";
@@ -286,16 +287,16 @@ function nucastgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:out:LAST:%6.2lf%spps";
$options .= " GPRINT:out:AVERAGE:%6.2lf%spps";
$options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:in=$database:bgpPeerInUpdates:AVERAGE";
$options .= " DEF:out=$database:bgpPeerOutUpdates:AVERAGE";
$options .= " CDEF:dout=out,-1,*";
@@ -310,33 +311,33 @@ function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) {
$options .= " GPRINT:out:LAST:%6.2lf%sU/s";
$options .= " GPRINT:out:AVERAGE:%6.2lf%sU/s";
$options .= " GPRINT:out:MAX:%6.2lf%sU/s\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function cpugraph ($rrd, $graph , $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:5s=$database:LOAD5S:AVERAGE";
$options .= " DEF:5m=$database:LOAD5M:AVERAGE";
$options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n";
$options .= " AREA:5m#ffee99: LINE1.25:5m#aa2200:Load\ %";
$options .= " GPRINT:5m:LAST:%6.2lf\ GPRINT:5m:AVERAGE:%6.2lf\ ";
$options .= " GPRINT:5m:MAX:%6.2lf\ GPRINT:5m:AVERAGE:%6.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:uptime=$database:uptime:AVERAGE";
$options .= " CDEF:cuptime=uptime,86400,/";
$options .= " COMMENT:Days\ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n";
@@ -344,18 +345,18 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti
$options .= " LINE1.25:cuptime#36393D:";
$options .= " GPRINT:cuptime:LAST:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\ ";
$options .= " GPRINT:cuptime:MAX:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "-l 0 --alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:MEMTOTAL=$database:MEMTOTAL:AVERAGE";
$options .= " DEF:IOFREE=$database:IOFREE:AVERAGE";
$options .= " DEF:IOUSED=$database:IOUSED:AVERAGE";
@@ -376,17 +377,17 @@ function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical
$options .= " GPRINT:FREE:MAX:%6.2lf%s";
$options .= " GPRINT:FREE:AVERAGE:%6.2lf%s\\\\l";
$options .= " LINE1:MEMTOTAL#000000:";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function ip_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:ipForwDatagrams=$database:ipForwDatagrams:AVERAGE";
$options .= " DEF:ipInDelivers=$database:ipInDelivers:AVERAGE";
$options .= " DEF:ipInReceives=$database:ipInReceives:AVERAGE";
@@ -423,17 +424,17 @@ function ip_graph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:ipOutNoRoutes:LAST:%6.2lf%s";
$options .= " GPRINT:ipOutNoRoutes:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:ipOutNoRoutes:MAX:\ %6.2lf%s\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function icmp_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
$options .= " DEF:icmpOutMsgs=$database:icmpOutMsgs:AVERAGE";
$options .= " DEF:icmpInErrors=$database:icmpInErrors:AVERAGE";
$options .= " DEF:icmpOutErrors=$database:icmpOutErrors:AVERAGE";
@@ -441,50 +442,50 @@ function icmp_graph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " DEF:icmpOutEchos=$database:icmpOutEchos:AVERAGE";
$options .= " DEF:icmpInEchoReps=$database:icmpInEchoReps:AVERAGE";
$options .= " DEF:icmpOutEchoReps=$database:icmpOutEchoReps:AVERAGE";
$options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\n";
$options .= " LINE1.25:icmpInMsgs#00cc00:InMsgs ";
$options .= " GPRINT:icmpInMsgs:LAST:%6.2lf%s";
$options .= " GPRINT:icmpInMsgs:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpInMsgs:MAX:\ %6.2lf%s\\\n";
$options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\\n";
$options .= " LINE1.25:icmpInMsgs#00cc00:InMsgs ";
$options .= " GPRINT:icmpInMsgs:LAST:\ \ \ \ \ %6.2lf%s";
$options .= " GPRINT:icmpInMsgs:AVERAGE:\ \ %6.2lf%s";
$options .= " GPRINT:icmpInMsgs:MAX:\ %6.2lf%s\\\\n";
$options .= " LINE1.25:icmpOutMsgs#006600:OutMsgs ";
$options .= " GPRINT:icmpOutMsgs:LAST:%6.2lf%s";
$options .= " GPRINT:icmpOutMsgs:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpOutMsgs:MAX:\ %6.2lf%s\\\n";
$options .= " GPRINT:icmpOutMsgs:LAST:\ \ \ \ %6.2lf%s";
$options .= " GPRINT:icmpOutMsgs:AVERAGE:\ \ %6.2lf%s";
$options .= " GPRINT:icmpOutMsgs:MAX:\ %6.2lf%s\\\\n";
$options .= " LINE1.25:icmpInErrors#cc0000:InErrors ";
$options .= " GPRINT:icmpInErrors:LAST:%6.2lf%s";
$options .= " GPRINT:icmpInErrors:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpInErrors:MAX:\ %6.2lf%s\\\n";
$options .= " GPRINT:icmpInErrors:LAST:\ \ \ %6.2lf%s";
$options .= " GPRINT:icmpInErrors:AVERAGE:\ \ %6.2lf%s";
$options .= " GPRINT:icmpInErrors:MAX:\ %6.2lf%s\\\\n";
$options .= " LINE1.25:icmpOutErrors#660000:OutErrors ";
$options .= " GPRINT:icmpOutErrors:LAST:%6.2lf%s";
$options .= " GPRINT:icmpOutErrors:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpOutErrors:MAX:\ %6.2lf%s\\\n";
$options .= " GPRINT:icmpOutErrors:LAST:\ \ %6.2lf%s";
$options .= " GPRINT:icmpOutErrors:AVERAGE:\ \ %6.2lf%s";
$options .= " GPRINT:icmpOutErrors:MAX:\ %6.2lf%s\\\\n";
$options .= " LINE1.25:icmpInEchos#0066cc:InEchos ";
$options .= " GPRINT:icmpInEchos:LAST:%6.2lf%s";
$options .= " GPRINT:icmpInEchos:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpInEchos:MAX:\ %6.2lf%s\\\n";
$options .= " GPRINT:icmpInEchos:LAST:\ \ \ \ %6.2lf%s";
$options .= " GPRINT:icmpInEchos:AVERAGE:\ \ %6.2lf%s";
$options .= " GPRINT:icmpInEchos:MAX:\ %6.2lf%s\\\\n";
$options .= " LINE1.25:icmpOutEchos#003399:OutEchos ";
$options .= " GPRINT:icmpOutEchos:LAST:%6.2lf%s";
$options .= " GPRINT:icmpOutEchos:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpOutEchos:MAX:\ %6.2lf%s\\\n";
$options .= " GPRINT:icmpOutEchos:LAST:\ \ \ %6.2lf%s";
$options .= " GPRINT:icmpOutEchos:AVERAGE:\ \ %6.2lf%s";
$options .= " GPRINT:icmpOutEchos:MAX:\ %6.2lf%s\\\\n";
$options .= " LINE1.25:icmpInEchoReps#cc00cc:InEchoReps ";
$options .= " GPRINT:icmpInEchoReps:LAST:%6.2lf%s";
$options .= " GPRINT:icmpInEchoReps:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpInEchoReps:MAX:\ %6.2lf%s\\\n";
$options .= " GPRINT:icmpInEchoReps:LAST:\ %6.2lf%s";
$options .= " GPRINT:icmpInEchoReps:AVERAGE:\ \ %6.2lf%s";
$options .= " GPRINT:icmpInEchoReps:MAX:\ %6.2lf%s\\\\n";
$options .= " LINE1.25:icmpOutEchoReps#990099:OutEchoReps";
$options .= " GPRINT:icmpOutEchoReps:LAST:%6.2lf%s";
$options .= " GPRINT:icmpOutEchoReps:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:icmpOutEchoReps:MAX:\ %6.2lf%s\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$options .= " GPRINT:icmpOutEchoReps:MAX:\ %6.2lf%s\\\\n";
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function tcp_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
$options .= " DEF:tcpActiveOpens=$database:tcpActiveOpens:AVERAGE";
$options .= " DEF:tcpPassiveOpens=$database:tcpPassiveOpens:AVERAGE";
$options .= " DEF:tcpAttemptFails=$database:tcpAttemptFails:AVERAGE";
@@ -521,17 +522,17 @@ function tcp_graph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:tcpRetransSegs:LAST:%6.2lf%s";
$options .= " GPRINT:tcpRetransSegs:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:tcpRetransSegs:MAX:\ %6.2lf%s\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function udp_graph ($rrd, $graph, $from, $to, $width, $height) {
global $config, $rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE";
$options .= " DEF:udpInDatagrams=$database:udpInDatagrams:AVERAGE";
$options .= " DEF:udpOutDatagrams=$database:udpOutDatagrams:AVERAGE";
$options .= " DEF:udpInErrors=$database:udpInErrors:AVERAGE";
@@ -553,7 +554,7 @@ function udp_graph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:udpNoPorts:LAST:%6.2lf%s";
$options .= " GPRINT:udpNoPorts:AVERAGE:\ %6.2lf%s";
$options .= " GPRINT:udpNoPorts:MAX:\ %6.2lf%s\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}

251
includes/graphing/windows.php Executable file
View File

@@ -0,0 +1,251 @@
<?
function memgraphWin ($rrd, $graph, $from="-2d")
{
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array (
"--start",
$from,
"-v MB",
"-b 1000",
"--rigid",
"--title", "Memory Usage",
"--alt-autoscale-max",
"-l 0",
"--width", "335", "--height", "100",
"DEF:totalswap=$database:totalswap:AVERAGE",
"DEF:availswap=$database:availswap:AVERAGE",
"DEF:totalreal=$database:totalreal:AVERAGE",
"DEF:availreal=$database:availreal:AVERAGE",
"DEF:totalfree=$database:totalfree:AVERAGE",
"DEF:shared=$database:shared:AVERAGE",
"DEF:buffered=$database:buffered:AVERAGE",
"DEF:cached=$database:cached:AVERAGE",
"CDEF:usedreal=totalreal,availreal,-",
"CDEF:usedswap=totalswap,availswap,-",
"CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+",
"AREA:usedreal#ee8000:used",
"GPRINT:usedreal:LAST: Cur\:%8.2lf %s",
"GPRINT:usedreal:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:usedreal:MAX: Max\:%8.2lf %s\\n",
"STACK:shared#ec9900:shared",
"GPRINT:shared:LAST: Cur\:%8.2lf %s",
"GPRINT:shared:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:shared:MAX: Max\:%8.2lf %s\\n",
"STACK:availreal#eacc00:free",
"GPRINT:availreal:LAST: Cur\:%8.2lf %s",
"GPRINT:availreal:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:availreal:MAX: Max\:%8.2lf %s\\n",
"STACK:buffered#cc0000:buffers",
"GPRINT:buffered:LAST:Cur\:%8.2lf %s",
"GPRINT:buffered:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:buffered:MAX: Max\:%8.2lf %s\\n",
"STACK:cached#9fa4ee:cached",
"GPRINT:cached:LAST: Cur\:%8.2lf %s",
"GPRINT:cached:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:cached:MAX: Max\:%8.2lf %s\\n",
"STACK:usedswap#afeced:swap",
"GPRINT:usedswap:LAST: Cur\:%8.2lf %s",
"GPRINT:usedswap:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:usedswap:MAX: Max\:%8.2lf %s",
"LINE1:totalreal#050505:total");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function loadgraphWin ($rrd, $graph, $from="-2d") {
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"--title", "Load Averages",
"--start",
$from,
"-v Load",
"--rigid",
"--alt-autoscale-max",
"-l 0",
"--width", "335", "--height", "100",
"DEF:1min=$database:1min:AVERAGE",
"DEF:5min=$database:5min:AVERAGE",
"DEF:15min=$database:15min:AVERAGE",
"CDEF:a=1min,100,/",
"CDEF:b=5min,100,/",
"CDEF:c=15min,100,/",
"CDEF:cdefd=a,b,c,+,+",
"AREA:a#eacc00:1 Minute:",
"LINE1:a#c5aa00:",
"GPRINT:a:LAST: Cur\:%8.2lf %s",
"GPRINT:a:AVERAGE: Ave\:%8.2lf %s",
"GPRINT:a:MAX: Max\:%8.2lf %s\\n",
"LINE1.5:b#ea8f00:5 Minute:",
"GPRINT:b:LAST: Cur\:%8.2lf %s",
"GPRINT:b:AVERAGE: Ave\:%8.2lf %s",
"GPRINT:b:MAX: Max\:%8.2lf %s\\n",
"LINE1.5:c#cc0000:15 Minute",
"GPRINT:c:LAST:Cur\:%8.2lf %s",
"GPRINT:c:AVERAGE: Ave\:%8.2lf %s",
"GPRINT:c:MAX: Max\:%8.2lf %s\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function usersgraphWin ($rrd, $graph, $from="-2d") {
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"--title", "Logged on Users",
"--vertical-label", "Users",
"-l 0",
"--width", "335", "--height", "100",
"--start",
$from,
"DEF:users=$database:users:AVERAGE",
"AREA:users#eacc00:users",
"LINE1.5:users#cc0000:",
"GPRINT:users:LAST: Cur\:%3.0lf %s",
"GPRINT:users:AVERAGE: Avg\:%3.0lf %s",
"GPRINT:users:MIN: Min\:%3.0lf %s",
"GPRINT:users:MAX: Max\:%3.0lf %s\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function procsgraphWin ($rrd, $graph, $from="-2d") {
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"-v # Processes",
"--title", "Running Processes",
"--vertical-label", "procs",
"-l 0",
"--width", "335", "--height", "100",
"--start",
$from,
"DEF:procs=$database:procs:AVERAGE",
"AREA:procs#eacc00:Processes",
"LINE1.5:procs#cc0000:",
"GPRINT:procs:LAST: Cur\:%3.0lf %s",
"GPRINT:procs:AVERAGE: Avg\:%3.0lf %s",
"GPRINT:procs:MIN: Min\:%3.0lf %s",
"GPRINT:procs:MAX: Max\:%3.0lf %s\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function cpugraphWin ($rrd, $graph, $from="-2d") {
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"-v CPU Utilization",
"--title", "Processor Usage",
"-u 100",
"--rigid",
"--vertical-label", "Load (%)",
"-l 0",
"--width", "335", "--height", "100",
"--start",
$from,
"DEF:user=$database:user:AVERAGE",
"DEF:nice=$database:nice:AVERAGE",
"DEF:system=$database:system:AVERAGE",
"DEF:idle=$database:idle:AVERAGE",
"CDEF:total=user,nice,system,idle,+,+,+",
"CDEF:user_perc=user,total,/,100,*",
"CDEF:nice_perc=nice,total,/,100,*",
"CDEF:system_perc=system,total,/,100,*",
"CDEF:idle_perc=idle,total,/,100,*",
"AREA:user_perc#eacc00:user",
"GPRINT:user_perc:LAST: Cur\:%3.0lf%%",
"GPRINT:user_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:user_perc:MAX: Max\:%3.0lf%%\\n",
"AREA:nice_perc#ea8f00:system:STACK",
"GPRINT:nice_perc:LAST:Cur\:%3.0lf%%",
"GPRINT:nice_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:nice_perc:MAX: Max\:%3.0lf%%\\n",
"AREA:system_perc#ff3932:nice:STACK",
"GPRINT:system_perc:LAST: Cur\:%3.0lf%%",
"GPRINT:system_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:system_perc:MAX: Max\:%3.0lf%%\\n",
"AREA:idle_perc#fafdce:idle:STACK",
"GPRINT:idle_perc:LAST: Cur\:%3.0lf%%",
"GPRINT:idle_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:idle_perc:MAX: Max\:%3.0lf%%\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
return FALSE;
} else {
return $imgfile;
}
}
function storagegraphWin ($rrd, $graph, $from="-2d", $descr)
{
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array (
"--start",
$from,
"-v MB",
"-b 1024",
"--rigid",
"--title", $descr,
"--alt-autoscale-max",
"-l 0",
"--width", "335", "--height", "100",
"DEF:size=$database:size:AVERAGE",
"DEF:used=$database:used:AVERAGE",
"AREA:size#80ee80:Total",
"GPRINT:size:LAST:Cur\:%8.2lf %s",
"GPRINT:size:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:size:MAX: Max\:%8.2lf %s\\n",
"AREA:used#ec9900:Used",
"GPRINT:used:LAST: Cur\:%8.2lf %s",
"GPRINT:used:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:used:MAX: Max\:%8.2lf %s\\n",
"LINE1:size#000000:");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
?>

View File

@@ -5,7 +5,6 @@ function pollDeviceIOS() {
global $device;
global $community;
global $config;
$rrdtool = &$config['rrdtool'];
$id = $device['device_id'];
$hostname = $device['hostname'];
@@ -40,7 +39,7 @@ function pollDeviceIOS() {
$memusedproc = $memusedproc + 0;
$memtotal = $memfreeio + $memfreeproc + $memusedio + $memusedproc;
if (!is_file($cpurrd)) {
$rrdcreate = `$rrdtool create $cpurrd --step 300 \
$rrdcreate = shell_exec($config['rrdtool'] . " create $cpurrd --step 300 \
DS:LOAD5S:GAUGE:600:-1:100 \
DS:LOAD5M:GAUGE:600:-1:100 \
RRA:AVERAGE:0.5:1:2000 \
@@ -50,10 +49,10 @@ function pollDeviceIOS() {
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000`;
RRA:MAX:0.5:288:2000");
}
if (!is_file($temprrd)) {
$rrdcreate = `$rrdtool create $temprrd --step 300 \
$rrdcreate = shell_exec($config['rrdtool'] . " create $temprrd --step 300 \
DS:TEMPIN1:GAUGE:600:-25:100 \
DS:TEMPOUT1:GAUGE:600:-25:100 \
RRA:AVERAGE:0.5:1:2000 \
@@ -63,10 +62,10 @@ function pollDeviceIOS() {
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000`;
RRA:MAX:0.5:288:2000");
}
if (!is_file($memrrd)) {
$rrdcreate = `$rrdtool create $memrrd --step 300 \
$rrdcreate = shell_exec($config['rrdtool'] . " create $memrrd --step 300 \
DS:IOFREE:GAUGE:600:0:U \
DS:IOUSED:GAUGE:600:-1:U \
DS:PROCFREE:GAUGE:600:0:U \
@@ -79,12 +78,12 @@ function pollDeviceIOS() {
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000`;
RRA:MAX:0.5:288:2000");
}
`$rrdtool update $temprrd N:$tempin1:$tempout1`;
`$rrdtool update $cpurrd N:$cpu5s:$cpu5m`;
`$rrdtool update $memrrd N:$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal`;
shell_exec($config['rrdtool'] . " update $temprrd N:$tempin1:$tempout1");
shell_exec($config['rrdtool'] . " update $cpurrd N:$cpu5s:$cpu5m");
shell_exec($config['rrdtool'] . " update $memrrd N:$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal");
}
?>

561
includes/ipv6.php Normal file
View File

@@ -0,0 +1,561 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* This file contains the implementation of the Net_IPv6 class
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to the New BSD license, that is
* available through the world-wide-web at http://www.opensource.org/licenses/bsd-license.php
* If you did not receive a copy of the new BSDlicense and are unable
* to obtain it through the world-wide-web, please send a note to
* license@php.net so we can mail you a copy immediately
*
* @category Net
* @package Net_IPv6
* @author Alexander Merz <alexander.merz@web.de>
* @copyright 2003-2005 The PHP Group
* @license http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: IPv6.php,v 1.15 2007/11/16 00:22:28 alexmerz Exp $
* @link http://pear.php.net/package/Net_IPv6
*/
// {{{ constants
/**
* Error message if netmask bits was not found
* @see isInNetmask
*/
define("NET_IPV6_NO_NETMASK_MSG", "Netmask length not found");
/**
* Error code if netmask bits was not found
* @see isInNetmask
*/
define("NET_IPV6_NO_NETMASK", 10);
/**
* Address Type: Unassigned (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_UNASSIGNED", 1);
/**
* Address Type: Reserved (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_RESERVED", 11);
/**
* Address Type: Reserved for NSAP Allocation (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_RESERVED_NSAP", 12);
/**
* Address Type: Reserved for IPX Allocation (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_RESERVED_IPX", 13);
/**
* Address Type: Reserved for Geographic-Based Unicast Addresses (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_RESERVED_UNICAST_GEOGRAPHIC", 14);
/**
* Address Type: Provider-Based Unicast Address (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_UNICAST_PROVIDER", 22);
/**
* Address Type: Multicast Addresses (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_MULTICAST", 31);
/**
* Address Type: Link Local Use Addresses (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_LOCAL_LINK", 42);
/**
* Address Type: Link Local Use Addresses (RFC 1884, Section 2.3)
* @see getAddressType()
*/
define("NET_IPV6_LOCAL_SITE", 43);
/**
* Address Type: address can not assigned to a specific type
* @see getAddressType()
*/
define("NET_IPV6_UNKNOWN_TYPE", 1001);
// }}}
// {{{ Net_IPv6
/**
* Class to validate and to work with IPv6 addresses.
*
* @category Net
* @package Net_IPv6
* @author Alexander Merz <alexander.merz@web.de>
* @copyright 2003-2005 The PHP Group
* @license http://www.opensource.org/licenses/bsd-license.php
* @version CVS: $Id: IPv6.php,v 1.15 2007/11/16 00:22:28 alexmerz Exp $
* @link http://pear.php.net/package/Net_IPv6
* @author elfrink at introweb dot nl
* @author Josh Peck <jmp at joshpeck dot org>
*/
class Net_IPv6 {
// {{{ removeNetmaskBits()
/**
* Removes a possible existing netmask specification at an IP addresse.
*
* @param String $ip the (compressed) IP as Hex representation
* @return String the IP without netmask length
* @since 1.1.0
* @access public
* @static
*/
function removeNetmaskSpec($ip) {
$addr = $ip;
if(false !== strpos($ip, '/')) {
$elements = explode('/', $ip);
if(2 == count($elements)) {
$addr = $elements[0];
}
}
return $addr;
}
/**
* Returns a possible existing netmask specification at an IP addresse.
*
* @param String $ip the (compressed) IP as Hex representation
* @return String the netmask spec
* @since 1.1.0
* @access public
* @static
*/
function getNetmaskSpec($ip) {
$spec = '';
if(false !== strpos($ip, '/')) {
$elements = explode('/', $ip);
if(2 == count($elements)) {
$spec = $elements[1];
}
}
return $spec;
}
// }}}
// {{{ getNetmask()
/**
* Calculates the network prefix based on the netmask bits.
*
* @param String $ip the (compressed) IP in Hex format
* @param int $bits if the number of netmask bits is not part of the IP
* you must provide the number of bits
* @return String the network prefix
* @since 1.1.0
* @access public
* @static
*/
function getNetmask($ip, $bits = null) {
if(null==$bits) {
$elements = explode('/', $ip);
if(2 == count($elements)) {
$addr = $elements[0];
$bits = $elements[1];
} else {
require_once 'PEAR.php';
return PEAR::raiseError(NET_IPV6_NO_NETMASK_MSG, NET_IPV6_NO_NETMASK);
}
} else {
$addr = $ip;
}
$addr = Net_IPv6::uncompress($addr);
$binNetmask = str_repeat('1', $bits).str_repeat('0', 128 - $bits);
return Net_IPv6::_bin2Ip(Net_IPv6::_ip2Bin($addr) & $binNetmask);
}
// }}}
// {{{ isInNetmask()
/**
* Checks if an (compressed) IP is in a specific address space.
*
* IF the IP does not contains the number of netmask bits (F8000::FFFF/16)
* then you have to use the $bits parameter.
*
* @param String $ip the IP to check (eg. F800::FFFF)
* @param String $netmask the netmask (eg F800::)
* @param int $bits the number of netmask bits to compare, if not given in $ip
* @return boolean true if $ip is in the netmask
* @since 1.1.0
* @access public
* @static
*/
function isInNetmask($ip, $netmask, $bits=null) {
// try to get the bit count
if(null == $bits) {
$elements = explode('/', $ip);
if(2 == count($elements)) {
$ip = $elements[0];
$bits = $elements[1];
} else if(null == $bits) {
$elements = explode('/', $netmask);
if(2 == count($elements)) {
$netmask = $elements[0];
$bits = $elements[1];
}
if(null == $bits) {
require_once 'PEAR.php';
return PEAR::raiseError(NET_IPV6_NO_NETMASK_MSG, NET_IPV6_NO_NETMASK);
}
}
}
$binIp = Net_IPv6::_ip2Bin(Net_IPv6::removeNetmaskSpec($ip));
$binNetmask = Net_IPv6::_ip2Bin(Net_IPv6::removeNetmaskSpec($netmask));
if(null != $bits && "" != $bits && 0 == strncmp( $binNetmask, $binIp, $bits)) {
return true;
}
return false;
}
// }}}
// {{{ getAddressType()
/**
* Returns the type of an IPv6 address.
*
* RFC 1883, Section 2.3 describes several types of addresses in
* the IPv6 addresse space.
* Several addresse types are markers for reserved spaces and as consequence
* a subject to change.
*
* @param String $ip the IP address in Hex format, compressed IPs are allowed
* @return int one of the addresse type constants
* @access public
* @since 1.1.0
* @static
*
* @see NET_IPV6_UNASSIGNED
* @see NET_IPV6_RESERVED
* @see NET_IPV6_RESERVED_NSAP
* @see NET_IPV6_RESERVED_IPX
* @see NET_IPV6_RESERVED_UNICAST_GEOGRAPHIC
* @see NET_IPV6_UNICAST_PROVIDER
* @see NET_IPV6_MULTICAST
* @see NET_IPV6_LOCAL_LINK
* @see NET_IPV6_LOCAL_SITE
* @see NET_IPV6_UNKNOWN_TYPE
*/
function getAddressType($ip) {
$ip = Net_IPv6::removeNetmaskSpec($ip);
$binip = Net_IPv6::_ip2Bin($ip);
if(0 == strncmp('1111111010', $binip, 10)) {
return NET_IPV6_LOCAL_LINK;
} else if(0 == strncmp('1111111011', $binip, 10)) {
return NET_IPV6_LOCAL_SITE;
} else if (0 == strncmp('111111100', $binip, 9)) {
return NET_IPV6_UNASSIGNED;
} else if (0 == strncmp('11111111', $binip, 8)) {
return NET_IPV6_MULTICAST;
} else if (0 == strncmp('00000000', $binip, 8)) {
return NET_IPV6_RESERVED;
} else if (0 == strncmp('00000001', $binip, 8) ||
0 == strncmp('1111110', $binip, 7)) {
return NET_IPV6_UNASSIGNED;
} else if (0 == strncmp('0000001', $binip, 7)) {
return NET_IPV6_RESERVED_NSAP;
} else if (0 == strncmp('0000010', $binip, 7)) {
return NET_IPV6_RESERVED_IPX;;
} else if (0 == strncmp('0000011', $binip, 7) ||
0 == strncmp('111110', $binip, 6) ||
0 == strncmp('11110', $binip, 5) ||
0 == strncmp('00001', $binip, 5) ||
0 == strncmp('1110', $binip, 4) ||
0 == strncmp('0001', $binip, 4) ||
0 == strncmp('001', $binip, 3) ||
0 == strncmp('011', $binip, 3) ||
0 == strncmp('101', $binip, 3) ||
0 == strncmp('110', $binip, 3)) {
return NET_IPV6_UNASSIGNED;
} else if (0 == strncmp('010', $binip, 3)) {
return NET_IPV6_UNICAST_PROVIDER;
} else if (0 == strncmp('100', $binip, 3)) {
return NET_IPV6_RESERVED_UNICAST_GEOGRAPHIC;
}
return NET_IPV6_UNKNOWN_TYPE;
}
// }}}
// {{{ Uncompress()
/**
* Uncompresses an IPv6 adress
*
* RFC 2373 allows you to compress zeros in an adress to '::'. This
* function expects an valid IPv6 adress and expands the '::' to
* the required zeros.
*
* Example: FF01::101 -> FF01:0:0:0:0:0:0:101
* ::1 -> 0:0:0:0:0:0:0:1
*
* @access public
* @see Compress()
* @static
* @param string $ip a valid IPv6-adress (hex format)
* @return string the uncompressed IPv6-adress (hex format)
*/
function Uncompress($ip) {
$netmask = Net_IPv6::getNetmaskSpec($ip);
$uip = Net_IPv6::removeNetmaskSpec($ip);
$c1 = -1;
$c2 = -1;
if (false !== strpos($uip, '::') ) {
list($ip1, $ip2) = explode('::', $uip);
if(""==$ip1) {
$c1 = -1;
} else {
$pos = 0;
if(0 < ($pos = substr_count($ip1, ':'))) {
$c1 = $pos;
} else {
$c1 = 0;
}
}
if(""==$ip2) {
$c2 = -1;
} else {
$pos = 0;
if(0 < ($pos = substr_count($ip2, ':'))) {
$c2 = $pos;
} else {
$c2 = 0;
}
}
if(strstr($ip2, '.')) {
$c2++;
}
if(-1 == $c1 && -1 == $c2) { // ::
$uip = "0:0:0:0:0:0:0:0";
} else if(-1==$c1) { // ::xxx
$fill = str_repeat('0:', 7-$c2);
$uip = str_replace('::', $fill, $uip);
} else if(-1==$c2) { // xxx::
$fill = str_repeat(':0', 7-$c1);
$uip = str_replace('::', $fill, $uip);
} else { // xxx::xxx
$fill = str_repeat(':0:', 6-$c2-$c1);
$uip = str_replace('::', $fill, $uip);
$uip = str_replace('::', ':', $uip);
}
}
if('' != $netmask) {
$uip = $uip.'/'.$netmask;
}
return $uip;
}
// }}}
// {{{ Compress()
/**
* Compresses an IPv6 adress
*
* RFC 2373 allows you to compress zeros in an adress to '::'. This
* function expects an valid IPv6 adress and compresses successive zeros
* to '::'
*
* Example: FF01:0:0:0:0:0:0:101 -> FF01::101
* 0:0:0:0:0:0:0:1 -> ::1
*
* @access public
* @see Uncompress()
* @static
* @param string $ip a valid IPv6-adress (hex format)
* @return string the compressed IPv6-adress (hex format)
* @author elfrink at introweb dot nl
*/
function Compress($ip) {
$netmask = Net_IPv6::getNetmaskSpec($ip);
$ip = Net_IPv6::removeNetmaskSpec($ip);
if (!strstr($ip, '::')) {
$ipp = explode(':',$ip);
for($i=0; $i<count($ipp); $i++) {
$ipp[$i] = dechex(hexdec($ipp[$i]));
}
$cip = ':' . join(':',$ipp) . ':';
preg_match_all("/(:0)+/", $cip, $zeros);
if (count($zeros[0])>0) {
$match = '';
foreach($zeros[0] as $zero) {
if (strlen($zero) > strlen($match))
$match = $zero;
}
$cip = preg_replace('/' . $match . '/', ':', $cip, 1);
}
$cip = preg_replace('/((^:)|(:$))/', '' ,$cip);
$cip = preg_replace('/((^:)|(:$))/', '::' ,$cip);
}
if('' != $netmask) {
$cip = $cip.'/'.$netmask;
}
return $cip;
}
// }}}
// {{{ SplitV64()
/**
* Splits an IPv6 adress into the IPv6 and a possible IPv4 part
*
* RFC 2373 allows you to note the last two parts of an IPv6 adress as
* an IPv4 compatible adress
*
* Example: 0:0:0:0:0:0:13.1.68.3
* 0:0:0:0:0:FFFF:129.144.52.38
*
* @access public
* @static
* @param string $ip a valid IPv6-adress (hex format)
* @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format)
*/
function SplitV64($ip) {
$ip = Net_IPv6::removeNetmaskSpec($ip);
$ip = Net_IPv6::Uncompress($ip);
if (strstr($ip, '.')) {
$pos = strrpos($ip, ':');
$ip{$pos} = '_';
$ipPart = explode('_', $ip);
return $ipPart;
} else {
return array($ip, "");
}
}
// }}}
// {{{ checkIPv6()
/**
* Checks an IPv6 adress
*
* Checks if the given IP is IPv6-compatible
*
* @access public
* @static
* @param string $ip a valid IPv6-adress
* @return boolean true if $ip is an IPv6 adress
*/
function checkIPv6($ip) {
$ip = Net_IPv6::removeNetmaskSpec($ip);
$ipPart = Net_IPv6::SplitV64($ip);
$count = 0;
if (!empty($ipPart[0])) {
$ipv6 =explode(':', $ipPart[0]);
for ($i = 0; $i < count($ipv6); $i++) {
$dec = hexdec($ipv6[$i]);
$hex = strtoupper(preg_replace("/^[0]{1,3}(.*[0-9a-fA-F])$/", "\\1", $ipv6[$i]));
if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex == strtoupper(dechex($dec))) {
$count++;
}
}
if (8 == $count) {
return true;
} elseif (6 == $count and !empty($ipPart[1])) {
$ipv4 = explode('.',$ipPart[1]);
$count = 0;
for ($i = 0; $i < count($ipv4); $i++) {
if ($ipv4[$i] >= 0 && (integer)$ipv4[$i] <= 255 && preg_match("/^\d{1,3}$/", $ipv4[$i])) {
$count++;
}
}
if (4 == $count) {
return true;
}
} else {
return false;
}
} else {
return false;
}
}
// }}}
// {{{ _ip2Bin()
/**
* Converts an IPv6 address from Hex into Binary representation.
*
* @param String $ip the IP to convert (a:b:c:d:e:f:g:h), compressed IPs are allowed
* @return String the binary representation
* @access private
@ @since 1.1.0
*/
function _ip2Bin($ip) {
$binstr = '';
$ip = Net_IPv6::removeNetmaskSpec($ip);
$ip = Net_IPv6::Uncompress($ip);
$parts = explode(':', $ip);
foreach($parts as $v) {
$str = base_convert($v, 16, 2);
$binstr .= str_pad($str, 16, '0', STR_PAD_LEFT);
}
return $binstr;
}
// }}}
// {{{ _bin2Ip()
/**
* Converts an IPv6 address from Binary into Hex representation.
*
* @param String $ip the IP as binary
* @return String the uncompressed Hex representation
* @access private
@ @since 1.1.0
*/
function _bin2Ip($bin) {
$ip = "";
if(strlen($bin)<128) {
$bin = str_pad($str, 128, '0', STR_PAD_LEFT);
}
$parts = str_split($bin, "16");
foreach($parts as $v) {
$str = base_convert($v, 2, 16);
$ip .= $str.":";
}
$ip = substr($ip, 0,-1);
return $ip;
}
// }}}
}
// }}}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* c-hanging-comment-ender-p: nil
* End:
*/
?>

View File

@@ -36,7 +36,7 @@ while ($dr = mysql_fetch_array($dq)) {
if (!is_file($storage_rrd)) {
`rrdtool create $storage_rrd \
shell_exec($config['rrdtool'] . " create $storage_rrd \
--step 300 \
DS:size:GAUGE:600:0:U \
DS:used:GAUGE:600:0:U \
@@ -48,7 +48,7 @@ while ($dr = mysql_fetch_array($dq)) {
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
}
rrdtool_update($storage_rrd, "N:$hrStorageSize:$used:$perc");
mysql_query("UPDATE `storage` SET `hrStorageUsed` = '$used_units', `storage_perc` = '$perc' WHERE storage_id = '" . $dr['storage_id'] . "'");
@@ -90,8 +90,6 @@ list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $Usa
$cpuUsage = $UsageUser + $UsageSystem;
echo("\n CPU : $cpuUsage = $UsageUser + $UsageSystem; \n");
if(mysql_result(mysql_query("SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'"),0)) {
$update_usage = mysql_query("UPDATE devices_attribs SET attrib_value = '$cpuUsage' WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'");
} else {
@@ -100,7 +98,7 @@ if(mysql_result(mysql_query("SELECT COUNT(*) FROM devices_attribs WHERE `device_
## Create CPU RRD if it doesn't already exist
if (!is_file($cpurrd)) {
`rrdtool create $cpurrd \
shell_exec($config['rrdtool'] . " create $cpurrd \
--step 300 \
DS:user:COUNTER:600:0:U \
DS:system:COUNTER:600:0:U \
@@ -113,7 +111,7 @@ if (!is_file($cpurrd)) {
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
}
rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
@@ -121,7 +119,7 @@ rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
## If the device isn't monowall or pfsense, monitor all the pretty things
if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSense" ) {
if (!is_file($sysrrd)) {
`rrdtool create $sysrrd \
shell_exec($config['rrdtool'] . " create $sysrrd \
--step 300 \
DS:users:GAUGE:600:0:U \
DS:procs:GAUGE:600:0:U \
@@ -132,11 +130,11 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
}
if (!is_file($memrrd)) {
`rrdtool create $memrrd \
shell_exec($config['rrdtool'] . " create $memrrd \
--step 300 \
DS:totalswap:GAUGE:600:0:10000000000 \
DS:availswap:GAUGE:600:0:10000000000 \
@@ -153,11 +151,11 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
} // end create mem rrd
if(!is_file($loadrrd)) {
`$rrdtool create $loadrrd \
shell_exec($config['rrdtool'] . " create $loadrrd \
--step 300 \
DS:1min:GAUGE:600:0:5000 \
DS:5min:GAUGE:600:0:5000 \
@@ -169,7 +167,7 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
} // end create load rrd
$mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";

View File

@@ -2,7 +2,7 @@
function cpugraphHP ($rrd, $graph , $from, $to, $width, $height)
{
global $config,$rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
@@ -18,8 +18,8 @@ function cpugraphHP ($rrd, $graph , $from, $to, $width, $height)
"GPRINT:load:MIN:Min\:%3.2lf",
"GPRINT:load:MAX:Max\:%3.2lf\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
if($width <= "300") {$optsb = array("--font", "LEGEND:7:".$config['mono_font']."",
"--font", "AXIS:6:".$config['mono_font']."",
"--font-render-mode", "normal");}
$opts = array_merge($config['rrdgraph_defaults'], $$optsa, $optsb);
@@ -36,7 +36,7 @@ function cpugraphHP ($rrd, $graph , $from, $to, $width, $height)
function memgraphHP ($rrd, $graph , $from, $to, $width, $height, $title, $vertical)
{
global $config,$rrdtool, $installdir, $mono_font;
global $config, $installdir;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$memrrd = $database;
@@ -49,8 +49,8 @@ function memgraphHP ($rrd, $graph , $from, $to, $width, $height, $title, $vertic
"AREA:FREE#FAFDCE:Free:STACK",
"LINE1.5:TOTAL#cc0000:");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
if($width <= "300") {$optsb = array("--font", "LEGEND:7:".$config['mono_font']."",
"--font", "AXIS:6:".$config['mono_font']."",
"--font-render-mode", "normal");}
$opts = array_merge($config['rrdgraph_defaults'], $$opts, $optsb);

View File

@@ -1,8 +1,8 @@
<?php
function callsgraphSNOM ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical ,"--alt-autoscale-max",
"-l 0",
@@ -14,8 +14,8 @@ function callsgraphSNOM ($rrd, $graph, $from, $to, $width, $height, $title, $ver
"GPRINT:calls:LAST:Cu\: %2.0lf/min",
"GPRINT:calls:AVERAGE:Av\: %2.0lf/min",
"GPRINT:calls:MAX:Mx\: %2.0lf/min\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
if($width <= "300") {$optsb = array("--font", "LEGEND:7:".$config['mono_font']."",
"--font", "AXIS:6:".$config['mono_font']."",
"--font-render-mode", "normal");}
$opts = array_merge($config['rrdgraph_defaults'], $optsa, $optsb);

View File

@@ -1,18 +1,18 @@
<?php
function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$range = $to - $from;
$points_per_sample = 3;
$xpoints = '540';
$step = $range*$points_per_sample/$xpoints;
$database = $rrd_dir . "/" . $rrd . "-mailstats.rrd";
$database = $config['rrd_dir'] . "/" . $rrd . "-mailstats.rrd";
$options .= " DEF:rejected=$database:reject:AVERAGE";
$options .= " DEF:mrejected=$database:reject:MAX";
@@ -55,22 +55,22 @@ function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title,
$options .= " GPRINT:sspam:MAX:\ %6.0lf";
$options .= " GPRINT:rspam:AVERAGE:\ \ %5.2lf/min";
$options .= " GPRINT:rmspam:MAX:\ %5.2lf/min\\\\l";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$range = $to - $from;
$points_per_sample = 3;
$xpoints = '540';
$step = $range*$points_per_sample/$xpoints;
$rrd = $rrd_dir . "/" . $rrd;
$rrd = $config['rrd_dir'] . "/" . $rrd;
$options .= " DEF:sent=$rrd:sent:AVERAGE";
$options .= " DEF:msent=$rrd:sent:MAX";
$options .= " CDEF:rsent=sent,60,*";
@@ -93,16 +93,16 @@ function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
$options .= " GPRINT:srecv:MAX:\ \ %6.0lf";
$options .= " GPRINT:rrecv:AVERAGE:\ \ %5.2lf/min";
$options .= " GPRINT:rmrecv:MAX:\ %5.2lf/min\\\\l";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:atotalswap=$database:totalswap:AVERAGE";
$options .= " DEF:aavailswap=$database:availswap:AVERAGE";
$options .= " DEF:atotalreal=$database:totalreal:AVERAGE";
@@ -158,17 +158,17 @@ function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $verti
$options .= " LINE1:totalreal#050505:total";
$options .= " GPRINT:totalreal:AVERAGE:\ \ %7.2lf%sB";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:1min=$database:1min:AVERAGE";
$options .= " DEF:5min=$database:5min:AVERAGE";
$options .= " DEF:15min=$database:15min:AVERAGE";
@@ -190,18 +190,18 @@ function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vert
$options .= " GPRINT:c:LAST:\ \ \ %7.2lf";
$options .= " GPRINT:c:AVERAGE:\ \ %7.2lf";
$options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:users=$database:users:AVERAGE";
$options .= " COMMENT:Users\ \ \ \ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n";
$options .= " AREA:users#CDEB8B:";
@@ -210,17 +210,17 @@ function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
$options .= " GPRINT:users:AVERAGE:%6.2lf";
$options .= " GPRINT:users:MIN:%6.2lf";
$options .= " GPRINT:users:MAX:%6.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:procs=$database:procs:AVERAGE";
$options .= " COMMENT:Processes\ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n";
$options .= " AREA:procs#CDEB8B:";
@@ -229,7 +229,7 @@ function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
$options .= " GPRINT:procs:AVERAGE:%6.2lf";
$options .= " GPRINT:procs:MIN:%6.2lf";
$options .= " GPRINT:procs:MAX:%6.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
@@ -237,12 +237,12 @@ function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver
function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "-l 0 --alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:user=$database:user:AVERAGE";
$options .= " DEF:nice=$database:nice:AVERAGE";
$options .= " DEF:system=$database:system:AVERAGE";
@@ -269,17 +269,17 @@ function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $verti
$options .= " GPRINT:idle_perc:LAST:\ \ \ \ \ %5.2lf%%";
$options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%";
$options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$points_per_sample = 3;
$range = $to - $from;
$options .= " DEF:pop3d_login=$database:pop3:AVERAGE";
@@ -319,16 +319,16 @@ function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $v
$options .= " GPRINT:vimapd_ssl_login:AVERAGE:\ %6.0lf";
$options .= " GPRINT:rimapd_ssl_login:AVERAGE:%5.2lf/min";
$options .= " GPRINT:rmimapd_ssl_login:MAX:%5.2lf/min\\\\l";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:hits=$database:hits:AVERAGE";
$options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ Maximum\\\\n";
$options .= " AREA:hits#ff9933:";
@@ -336,15 +336,15 @@ function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title,
$options .= " GPRINT:hits:LAST:\ %6.2lf/sec";
$options .= " GPRINT:hits:AVERAGE:%6.2lf/sec";
$options .= " GPRINT:hits:MAX:%6.2lf/sec\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
global $config, $installdir;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024 -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$hostname = gethostbyid($device);
$iter = "1";
$sql = mysql_query("SELECT * FROM storage where storage_id = '$id'");
@@ -357,7 +357,7 @@ function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertica
$descr = str_pad($fs[hrStorageDescr], 14);
$descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$rrd = $rrd_dir . "/$hostname/storage-$text.rrd";
$rrd = $config['rrd_dir'] . "/$hostname/storage-$text.rrd";
$options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE";
@@ -367,17 +367,17 @@ function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertica
$options .= " GPRINT:$fs[storage_id]p:LAST:%5.2lf%%\\\\l";
$iter++;
}
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024 -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$hostname = gethostbyid($device);
$iter = "1";
$sql = mysql_query("SELECT * FROM storage where host_id = '$device'");
@@ -390,7 +390,7 @@ function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title,
$descr = str_pad($fs[hrStorageDescr], 14);
$descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$rrd = $rrd_dir . "/$hostname/storage-$text.rrd";
$rrd = $config['rrd_dir'] . "/$hostname/storage-$text.rrd";
$options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE";
@@ -400,16 +400,16 @@ function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title,
$options .= " GPRINT:$fs[storage_id]p:LAST:%5.2lf%%\\\\l";
$iter++;
}
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font, $rrd_dir;
$database = $rrd_dir . "/" . $rrd;
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:bits=$database:bits:AVERAGE";
$options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ Maximum\\\\n";
$options .= " AREA:bits#cccc00:";
@@ -417,6 +417,6 @@ function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title,
$options .= " GPRINT:bits:LAST:\ %6.2lf/sec";
$options .= " GPRINT:bits:AVERAGE:%6.2lf/sec";
$options .= " GPRINT:bits:MAX:%6.2lf/sec\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}

View File

@@ -3,9 +3,6 @@
function pollDeviceWin() {
global $device;
global $community;
global $rrdtool;
$id = $device['device_id'];
$hostname = $device['hostname'];
$hardware = $device['hardware'];
$version = $device['version'];
@@ -29,7 +26,7 @@ function pollDeviceWin() {
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users) = explode("\n", $s);
if (!is_file($cpurrd)) {
`rrdtool create $cpurrd \
shell_exec($config['rrdtool'] . " create $cpurrd \
--step 300 \
DS:user:COUNTER:600:0:U \
DS:system:COUNTER:600:0:U \
@@ -42,11 +39,11 @@ function pollDeviceWin() {
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
}
if (!is_file($sysrrd)) {
`rrdtool create $sysrrd \
shell_exec($config['rrdtool'] . " create $sysrrd \
--step 300 \
DS:users:GAUGE:600:0:U \
DS:procs:GAUGE:600:0:U \
@@ -57,11 +54,11 @@ function pollDeviceWin() {
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
}
if (!is_file($memrrd)) {
`rrdtool create $memrrd \
shell_exec($config['rrdtool'] . " create $memrrd \
--step 300 \
DS:totalswap:GAUGE:600:0:10000000000 \
DS:availswap:GAUGE:600:0:10000000000 \
@@ -78,11 +75,11 @@ function pollDeviceWin() {
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
}
if(!is_file($loadrrd)) {
`$rrdtool create $loadrrd \
shell_exec($config['rrdtool'] . " create $loadrrd \
--step 300 \
DS:1min:GAUGE:600:0:5000 \
DS:5min:GAUGE:600:0:5000 \
@@ -94,7 +91,7 @@ function pollDeviceWin() {
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:800 \
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800`;
RRA:MAX:0.5:288:800");
}
$mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
@@ -113,255 +110,4 @@ function pollDeviceWin() {
rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
}
function memgraphWin ($rrd, $graph, $from="-2d")
{
global $rrdtool;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array (
"--start",
$from,
"-v MB",
"-b 1000",
"--rigid",
"--title", "Memory Usage",
"--alt-autoscale-max",
"-l 0",
"--width", "335", "--height", "100",
"DEF:totalswap=$database:totalswap:AVERAGE",
"DEF:availswap=$database:availswap:AVERAGE",
"DEF:totalreal=$database:totalreal:AVERAGE",
"DEF:availreal=$database:availreal:AVERAGE",
"DEF:totalfree=$database:totalfree:AVERAGE",
"DEF:shared=$database:shared:AVERAGE",
"DEF:buffered=$database:buffered:AVERAGE",
"DEF:cached=$database:cached:AVERAGE",
"CDEF:usedreal=totalreal,availreal,-",
"CDEF:usedswap=totalswap,availswap,-",
"CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+",
"AREA:usedreal#ee8000:used",
"GPRINT:usedreal:LAST: Cur\:%8.2lf %s",
"GPRINT:usedreal:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:usedreal:MAX: Max\:%8.2lf %s\\n",
"STACK:shared#ec9900:shared",
"GPRINT:shared:LAST: Cur\:%8.2lf %s",
"GPRINT:shared:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:shared:MAX: Max\:%8.2lf %s\\n",
"STACK:availreal#eacc00:free",
"GPRINT:availreal:LAST: Cur\:%8.2lf %s",
"GPRINT:availreal:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:availreal:MAX: Max\:%8.2lf %s\\n",
"STACK:buffered#cc0000:buffers",
"GPRINT:buffered:LAST:Cur\:%8.2lf %s",
"GPRINT:buffered:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:buffered:MAX: Max\:%8.2lf %s\\n",
"STACK:cached#9fa4ee:cached",
"GPRINT:cached:LAST: Cur\:%8.2lf %s",
"GPRINT:cached:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:cached:MAX: Max\:%8.2lf %s\\n",
"STACK:usedswap#afeced:swap",
"GPRINT:usedswap:LAST: Cur\:%8.2lf %s",
"GPRINT:usedswap:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:usedswap:MAX: Max\:%8.2lf %s",
"LINE1:totalreal#050505:total");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function loadgraphWin ($rrd, $graph, $from="-2d") {
global $rrdtool;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"--title", "Load Averages",
"--start",
$from,
"-v Load",
"--rigid",
"--alt-autoscale-max",
"-l 0",
"--width", "335", "--height", "100",
"DEF:1min=$database:1min:AVERAGE",
"DEF:5min=$database:5min:AVERAGE",
"DEF:15min=$database:15min:AVERAGE",
"CDEF:a=1min,100,/",
"CDEF:b=5min,100,/",
"CDEF:c=15min,100,/",
"CDEF:cdefd=a,b,c,+,+",
"AREA:a#eacc00:1 Minute:",
"LINE1:a#c5aa00:",
"GPRINT:a:LAST: Cur\:%8.2lf %s",
"GPRINT:a:AVERAGE: Ave\:%8.2lf %s",
"GPRINT:a:MAX: Max\:%8.2lf %s\\n",
"LINE1.5:b#ea8f00:5 Minute:",
"GPRINT:b:LAST: Cur\:%8.2lf %s",
"GPRINT:b:AVERAGE: Ave\:%8.2lf %s",
"GPRINT:b:MAX: Max\:%8.2lf %s\\n",
"LINE1.5:c#cc0000:15 Minute",
"GPRINT:c:LAST:Cur\:%8.2lf %s",
"GPRINT:c:AVERAGE: Ave\:%8.2lf %s",
"GPRINT:c:MAX: Max\:%8.2lf %s\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function usersgraphWin ($rrd, $graph, $from="-2d") {
global $rrdtool;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"--title", "Logged on Users",
"--vertical-label", "Users",
"-l 0",
"--width", "335", "--height", "100",
"--start",
$from,
"DEF:users=$database:users:AVERAGE",
"AREA:users#eacc00:users",
"LINE1.5:users#cc0000:",
"GPRINT:users:LAST: Cur\:%3.0lf %s",
"GPRINT:users:AVERAGE: Avg\:%3.0lf %s",
"GPRINT:users:MIN: Min\:%3.0lf %s",
"GPRINT:users:MAX: Max\:%3.0lf %s\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function procsgraphWin ($rrd, $graph, $from="-2d") {
global $rrdtool;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"-v # Processes",
"--title", "Running Processes",
"--vertical-label", "procs",
"-l 0",
"--width", "335", "--height", "100",
"--start",
$from,
"DEF:procs=$database:procs:AVERAGE",
"AREA:procs#eacc00:Processes",
"LINE1.5:procs#cc0000:",
"GPRINT:procs:LAST: Cur\:%3.0lf %s",
"GPRINT:procs:AVERAGE: Avg\:%3.0lf %s",
"GPRINT:procs:MIN: Min\:%3.0lf %s",
"GPRINT:procs:MAX: Max\:%3.0lf %s\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
function cpugraphWin ($rrd, $graph, $from="-2d") {
global $rrdtool;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array(
"-v CPU Utilization",
"--title", "Processor Usage",
"-u 100",
"--rigid",
"--vertical-label", "Load (%)",
"-l 0",
"--width", "335", "--height", "100",
"--start",
$from,
"DEF:user=$database:user:AVERAGE",
"DEF:nice=$database:nice:AVERAGE",
"DEF:system=$database:system:AVERAGE",
"DEF:idle=$database:idle:AVERAGE",
"CDEF:total=user,nice,system,idle,+,+,+",
"CDEF:user_perc=user,total,/,100,*",
"CDEF:nice_perc=nice,total,/,100,*",
"CDEF:system_perc=system,total,/,100,*",
"CDEF:idle_perc=idle,total,/,100,*",
"AREA:user_perc#eacc00:user",
"GPRINT:user_perc:LAST: Cur\:%3.0lf%%",
"GPRINT:user_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:user_perc:MAX: Max\:%3.0lf%%\\n",
"AREA:nice_perc#ea8f00:system:STACK",
"GPRINT:nice_perc:LAST:Cur\:%3.0lf%%",
"GPRINT:nice_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:nice_perc:MAX: Max\:%3.0lf%%\\n",
"AREA:system_perc#ff3932:nice:STACK",
"GPRINT:system_perc:LAST: Cur\:%3.0lf%%",
"GPRINT:system_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:system_perc:MAX: Max\:%3.0lf%%\\n",
"AREA:idle_perc#fafdce:idle:STACK",
"GPRINT:idle_perc:LAST: Cur\:%3.0lf%%",
"GPRINT:idle_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:idle_perc:MAX: Max\:%3.0lf%%\\n");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
return FALSE;
} else {
return $imgfile;
}
}
function storagegraphWin ($rrd, $graph, $from="-2d", $descr)
{
global $rrdtool;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$opts = array (
"--start",
$from,
"-v MB",
"-b 1024",
"--rigid",
"--title", $descr,
"--alt-autoscale-max",
"-l 0",
"--width", "335", "--height", "100",
"DEF:size=$database:size:AVERAGE",
"DEF:used=$database:used:AVERAGE",
"AREA:size#80ee80:Total",
"GPRINT:size:LAST:Cur\:%8.2lf %s",
"GPRINT:size:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:size:MAX: Max\:%8.2lf %s\\n",
"AREA:used#ec9900:Used",
"GPRINT:used:LAST: Cur\:%8.2lf %s",
"GPRINT:used:AVERAGE: Avg\:%8.2lf %s",
"GPRINT:used:MAX: Max\:%8.2lf %s\\n",
"LINE1:size#000000:");
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
$err = rrd_error();
echo "rrd_graph() ERROR: $err\n";
return FALSE;
} else {
return $imgfile;
}
}
?>

View File

@@ -22,10 +22,9 @@
$old_mac = $interface['mac'];
$old_up_admin = $interface['up_admin'];
$snmpver = $interface['snmpver'];
$snmp_cmd = "snmpget -O qv -$snmpver -c $community $hostname ifDescr.$ifIndex ifAdminStatus.$ifIndex ifOperStatus.$ifIndex ";
$snmp_cmd = "snmpget -O qv -".$interface['snmpver']." -c ".$interface['community']." ".$interface['hostname']." ifDescr.$ifIndex ifAdminStatus.$ifIndex ifOperStatus.$ifIndex ";
$snmp_cmd .= "ifAlias.$ifIndex 1.3.6.1.2.1.10.7.2.1.$ifIndex ifName.$ifIndex";
$snmp_output = `$snmp_cmd`;
$snmp_output = trim($snmp_output);
$snmp_output = trim(shell_exec($snmp_cmd));
list($ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifDuplex, $ifName) = explode("\n", $snmp_output);
$ifDescr = trim(str_replace("\"", "", $ifDescr));