git-svn-id: http://www.observium.org/svn/observer/trunk@118 61d68cd4-352d-0410-923a-c4978735b2b8

This commit is contained in:
Adam Amstrong
2007-11-23 11:37:28 +00:00
parent 9a6d196f32
commit 89b6a9bf1a
28 changed files with 1275 additions and 1379 deletions
+66 -20
View File
@@ -9,9 +9,34 @@ include("snom.php");
include("graphing.php");
include("print-functions.php");
function strgen ($length = 8)
{
$entropy = array(0,1,2,3,4,5,6,7,8,9,'a','A','b','B','c','C','d','D','e',
'E','f','F','g','G','h','H','i','I','j','J','k','K','l','L','m','M','n',
'N','o','O','p','P','q','Q','r','R','s','S','t','T','u','U','v','V','w',
'W','x','X','y','Y','z','Z');
$string = "";
for ($i=0; $i<$length; $i++)
{
$key = mt_rand(0,61);
$string .= $entropy[$key];
}
return $string;
}
function interfacepermitted($interface_id) {
return devicepermitted(mysql_result(mysql_query("SELECT device_id FROM interface WHERE interface_id = '$interface_id'"),0));
}
function devicepermitted($device_id) {
global $_SESSION;
if($_SESSION['level'] > "5") { $allowed = true;
if($_SESSION['userlevel'] >= "5") { $allowed = true;
} elseif ( @mysql_result(mysql_query("SELECT * FROM devices_perms WHERE `user_id` = '" . $_SESSION['user_id'] . "' AND `device_id` = $device_id"), 0) > '0' ) {
$allowed = true;
} else { $allowed = false; }
@@ -34,13 +59,25 @@ function formatStorage($size) {
return round($size, 2).$ext;
}
function arguments($argv) {
$_ARG = array();
foreach ($argv as $arg) {
if (ereg('--([^=]+)=(.*)',$arg,$reg)) {
$_ARG[$reg[1]] = $reg[2];
} elseif(ereg('-([a-zA-Z0-9])',$arg,$reg)) {
$_ARG[$reg[1]] = 'true';
}
}
return $_ARG;
}
function percent_colour($perc)
{
$r = min(255, 5 * ($perc - 50));
$b = max(0, 255 - (5 * $perc));
$r = min(255, 5 * ($perc - 25));
$b = max(0, 255 - (5 * ($perc + 25)));
return sprintf('#%02x%02x%02x', $r, 0, $b);
return sprintf('#%02x%02x%02x', $r, $b, $b);
}
function percent_colour_old($perc) {
@@ -72,10 +109,10 @@ function truncate($substring, $max = 50, $rep = '...') {
function interface_rates ($interface) {
global $rrdtool;
global $config;
$rrdfile = "rrd/" . $interface['hostname'] . "." . $interface['ifIndex'] . ".rrd";
$data = trim(`$rrdtool fetch -s -600s -e now $rrdfile AVERAGE | grep : | cut -d" " -f 2,3 | grep e`);
# $data = trim(`$rrdtool fetch -s -301s -e -300s $rrdfile AVERAGE | grep : | cut -d" " -f 2,3`);
$cmd = $config['rrdtool']." fetch -s -600s -e now ".$rrdfile." AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e";
$data = trim(`$cmd`);
foreach( explode("\n", $data) as $entry) {
list($in, $out) = split(" ", $entry);
$rate['in'] = $in * 8;
@@ -86,9 +123,10 @@ function interface_rates ($interface) {
function interface_errors ($interface) {
global $rrdtool;
global $config;
$rrdfile = "rrd/" . $interface['hostname'] . "." . $interface['ifIndex'] . ".rrd";
$data = trim(`$rrdtool fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d" " -f 4,5`);
$cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d\" \" -f 4,5";
$data = trim(`$cmd`);
foreach( explode("\n", $data) as $entry) {
list($in, $out) = explode(" ", $entry);
$in_errors += ($in * 300);
@@ -111,24 +149,27 @@ function geteventicon ($message) {
}
function generateiflink($interface, $text=0,$type=bits) {
global $twoday;
global $now;
global $twoday; global $now; global $config; global $day;
if(!$text) { $text = fixIfName($interface['ifDescr']); }
if(!$type) { $type = 'bits'; }
$class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
$graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$twoday&to=$now&width=400&height=120&type=" . $type;
$graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=120&type=" . $type;
$link = "<a class=$class href='?page=interface&id=" . $interface['interface_id'] . "' ";
$link .= "onmouseover=\"return overlib('<img src=\'$graph_url\'>');\" onmouseout=\"return nd();\">$text</a>";
$link .= "onmouseover=\"return overlib('<div class=list-large>" . $interface['hostname'] . " - " . $interface['ifDescr'] . "</div><div>";
$link .= $interface['ifAlias'] . "</div><img src=\'$graph_url\'>'".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">$text</a>";
return $link;
}
function generatedevicelink($device, $text=0) {
global $twoday;
global $now;
function generatedevicelink($device, $text=0, $start=0, $end=0) {
global $twoday; global $day; global $now; global $config;
if(!$start) { $start = $day; }
if(!$end) { $end = $now; }
$class = devclass($device);
if(!$text) { $text = $device['hostname']; }
$graph_url = "graph.php?host=" . $device[device_id] . "&from=$twoday&to=$now&width=400&height=120&type=cpu";
$link = "<a class=$class href='?page=device&id=" . $device['device_id'] . "' onmouseover=\"return overlib('<img src=\'$graph_url\'>');\" onmouseout=\"return nd();\">$text</a>";
$graph_url = "graph.php?host=" . $device[device_id] . "&from=$start&to=$end&width=400&height=120&type=cpu";
$link = "<a class=$class href='?page=device&id=" . $device['device_id'] . "' ";
$link .= "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - CPU Load</div>";
$link .= "<img src=\'$graph_url\'>'".$config['overlib_defaults'].", LEFT);\" onmouseout=\"return nd();\">$text</a>";
return $link;
}
@@ -376,6 +417,8 @@ function fixiftype ($type) {
$type = str_replace("propVirtual", "Ethernet VLAN", $type);
$type = str_replace("ethernetCsmacd", "Ethernet", $type);
$type = str_replace("l2vlan", "Ethernet VLAN", $type);
$type = str_replace("frameRelay", "Frame Relay", $type);
$type = str_replace("propPointToPointSerial", "PointToPoint Serial", $type);
return ($type);
}
@@ -406,7 +449,6 @@ function fixIOSFeatures($features){
$features = str_replace("ADVSECURITYK9", "Advanced Security Crypto", $features);
$features = str_replace("K91P", "Provider Crypto", $features);
$features = str_replace("K4P", "Provider Crypto", $features);
$features = str_replace("ADVIPSERVICESK9_WAN", "Adv IP Services Crypto + WAN", $features);
$features = str_replace("ADVIPSERVICESK9", "Adv IP Services Crypto", $features);
$features = str_replace("ADVIPSERVICES", "Adv IP Services", $features);
$features = str_replace("IK9P", "IP Plus Crypto", $features);
@@ -418,17 +460,20 @@ function fixIOSFeatures($features){
$features = str_replace("IPBASE", "IP Base", $features);
$features = str_replace("IPSERVICE", "IP Services", $features);
$features = preg_replace("/^P$/", "Service Provider", $features);
$features = str_replace("JK9S", "Enterprise Plus Crypto", $features);
$features = str_replace("IK9S", "IP Plus Crypto", $features);
$features = str_replace("I6Q4L2", "Layer 2", $features);
$features = str_replace("I6K2L2Q4", "Layer 2 Crypto", $features);
$features = str_replace("C3H2S", "Layer 2 SI/EI", $features);
$features = str_replace("_WAN", " + WAN", $features);
return $features;
}
function fixIOSHardware($hardware){
$hardware = preg_replace("/C([0-9]+)/", "Cisco \\1", $hardware);
$hardware = str_replace("cat4000","Catalyst 4000", $hardware);
$hardware = preg_replace("/CISCO([0-9]+)/", "Cisco \\1", $hardware);
$hardware = str_replace("cat4000","Cisco Catalyst 4000", $hardware);
$hardware = str_replace("s3223_rp","Cisco Catalyst 6500 SUP32", $hardware);
$hardware = str_replace("s222_rp","Cisco Catalyst 6500 SUP2", $hardware);
$hardware = str_replace("c6sup2_rp","Cisco Catalyst 6500 SUP2", $hardware);
@@ -437,6 +482,7 @@ function fixIOSHardware($hardware){
$hardware = str_replace("C3200XL", "Cisco Catalyst 3200XL", $hardware);
$hardware = str_replace("C3550", "Cisco Catalyst 3550", $hardware);
$hardware = str_replace("C2950", "Cisco Catalyst 2950", $hardware);
$hardware = str_replace("C7301", "Cisco 7301", $hardware);
return $hardware;
}
+27 -15
View File
@@ -4,6 +4,8 @@ function pollDevice() {
global $device;
global $community;
global $config;
$rrdtool = $config['rrdtool'];
$id = $device['id'];
$hostname = $device['hostname'];
$hardware = $device['hardware'];
@@ -13,36 +15,46 @@ function pollDevice() {
$os = $device['location'];
$temprrd = "rrd/" . $hostname . "-temp.rrd";
$tempgraph = "public_html/graphs/" . $hostname . "-temp.png";
$cpurrd = "rrd/" . $hostname . "-cpu.rrd";
$cpugraph = "public_html/graphs/" . $hostname . "-cpu.png";
$memrrd = "rrd/" . $hostname . "-mem.rrd";
$memgraph = "public_html/graphs/" . $hostname . "-mem.png";
list ($cpu5m, $cpu5s) = explode("\n", `snmpget -O qv -v2c -c $community $hostname 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0`);
$tempgraph = "public_html/graphs/" . $device['hostname'] . "-temp.png";
$cpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
$cpugraph = "public_html/graphs/" . $device['hostname'] . "-cpu.png";
$memrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
$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`);
$cpu5m = $cpu5m + 0;
$cpu5s = $cpu5s + 0;
list ($tempin1, $tempout1) = explode("\n", `snmpget -O qv -v2c -c $community $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`);
$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`);
$tempin1 = $tempin1 +0;
$tempout1 = $tempout1 + 0;
list ($memfreeio, $memfreeproc, $memusedio, $memusedproc) = explode("\n", `snmpget -O qv -v2c -c $community $hostname .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`);
echo("$hostname\n");
$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`);
echo($device['hostname'] . "\n");
$memfreeio = $memfreeio + 0;
$memfreeproc = $memfreeproc + 0;
$memusedio = $memusedio + 0;
$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`;
$rrdcreate = `$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`;
$rrdcreate = `$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`;
$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`;
}
`rrdtool update $temprrd N:$tempin1:$tempout1`;
`rrdtool update $cpurrd N:$cpu5s:$cpu5m`;
`rrdtool update $memrrd N:$$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal`;
`$rrdtool update $temprrd N:$tempin1:$tempout1`;
`$rrdtool update $cpurrd N:$cpu5s:$cpu5m`;
`$rrdtool update $memrrd N:$$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal`;
}
?>
+436 -572
View File
File diff suppressed because it is too large Load Diff
+11 -9
View File
@@ -4,7 +4,10 @@ function pollDeviceIOS() {
global $device;
global $community;
global $config;
$rrdtool = &$config['rrdtool'];
$id = $device['device_id'];
$hostname = $device['hostname'];
$hardware = $device['hardware'];
$version = $device['version'];
@@ -13,12 +16,11 @@ function pollDeviceIOS() {
$os = $device['location'];
$temprrd = "rrd/" . $hostname . "-temp.rrd";
$tempgraph = "public_html/graphs/" . $hostname . "-temp.png";
$cpurrd = "rrd/" . $hostname . "-cpu.rrd";
$cpugraph = "public_html/graphs/" . $hostname . "-cpu.png";
$memrrd = "rrd/" . $hostname . "-mem.rrd";
$memgraph = "public_html/graphs/" . $hostname . "-mem.png";
list ($cpu5m, $cpu5s) = explode("\n", `snmpget -O qv -v2c -c $community $hostname 1.3.6.1.4.1.9.2.1.58.0 1.3.6.1.4.1.9.2.1.56.0`);
$cpu5m = $cpu5m + 0;
$cpu5s = $cpu5s + 0;
list ($tempin1, $tempout1) = explode("\n", `snmpget -O qv -v2c -c $community $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`);
@@ -38,7 +40,7 @@ function pollDeviceIOS() {
$memusedproc = $memusedproc + 0;
$memtotal = $memfreeio + $memfreeproc + $memusedio + $memusedproc;
if (!is_file($cpurrd)) {
$rrdcreate = `rrdtool create $cpurrd --step 300 \
$rrdcreate = `$rrdtool create $cpurrd --step 300 \
DS:LOAD5S:GAUGE:600:-1:100 \
DS:LOAD5M:GAUGE:600:-1:100 \
RRA:AVERAGE:0.5:1:2000 \
@@ -51,7 +53,7 @@ function pollDeviceIOS() {
RRA:MAX:0.5:288:2000`;
}
if (!is_file($temprrd)) {
$rrdcreate = `rrdtool create $temprrd --step 300 \
$rrdcreate = `$rrdtool create $temprrd --step 300 \
DS:TEMPIN1:GAUGE:600:-25:100 \
DS:TEMPOUT1:GAUGE:600:-25:100 \
RRA:AVERAGE:0.5:1:2000 \
@@ -64,7 +66,7 @@ function pollDeviceIOS() {
RRA:MAX:0.5:288:2000`;
}
if (!is_file($memrrd)) {
$rrdcreate = `rrdtool create $memrrd --step 300 \
$rrdcreate = `$rrdtool create $memrrd --step 300 \
DS:IOFREE:GAUGE:600:0:U \
DS:IOUSED:GAUGE:600:-1:U \
DS:PROCFREE:GAUGE:600:0:U \
@@ -80,9 +82,9 @@ function pollDeviceIOS() {
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`;
`$rrdtool update $temprrd N:$tempin1:$tempout1`;
`$rrdtool update $cpurrd N:$cpu5s:$cpu5m`;
`$rrdtool update $memrrd N:$memfreeio:$memusedio:$memfreeproc:$memusedproc:$memtotal`;
}
?>
+30 -33
View File
@@ -1,19 +1,12 @@
<?php
$id = $device['device_id'];
$hostname = $device['hostname'];
$loadrrd = "rrd/" . $hostname . "-load.rrd";
$loadgraph = "public_html/graphs/" . $hostname . "-load.png";
$cpurrd = "rrd/" . $hostname . "-cpu.rrd";
$cpugraph = "public_html/graphs/" . $hostname . "-cpu.png";
$memrrd = "rrd/" . $hostname . "-mem.rrd";
$memgraph = "public_html/graphs/" . $hostname . "-mem.png";
$sysrrd = "rrd/" . $hostname . "-sys.rrd";
$sysgraph = "public_html/graphs/" . $hostname . "-sys.png";
$loadrrd = "rrd/" . $device['hostname'] . "-load.rrd";
$cpurrd = "rrd/" . $device['hostname'] . "-cpu.rrd";
$memrrd = "rrd/" . $device['hostname'] . "-mem.rrd";
$sysrrd = "rrd/" . $device['hostname'] . "-sys.rrd";
## Check Disks
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '$id'");
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '" . $device['device_id'] . "'");
while ($dr = mysql_fetch_array($dq)) {
$hrStorageIndex = $dr['hrStorageIndex'];
$hrStorageAllocationUnits = $dr['hrStorageAllocationUnits'];
@@ -25,7 +18,7 @@ while ($dr = mysql_fetch_array($dq)) {
$perc = round($used / $hrStorageSize * 100, 2);
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
$storerrd = "rrd/" . $hostname . "-storage-" . $filedesc . ".rrd";
$storerrd = "rrd/" . $device['hostname'] . "-storage-" . $filedesc . ".rrd";
if (!is_file($storerrd)) {
`rrdtool create $storerrd \
--step 300 \
@@ -44,6 +37,20 @@ while ($dr = mysql_fetch_array($dq)) {
rrd_update($storerrd, "N:$hrStorageSize:$used:$perc");
mysql_query("UPDATE `storage` SET `hrStorageUsed` = '$used_units', `storage_perc` = '$perc' WHERE storage_id = '" . $dr['storage_id'] . "'");
if($dr['storage_perc'] < '40' && $perc >= '40') {
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'] . " is " . $perc;
$msg .= " at " . date('l dS F Y h:i:s A');
mail($email, "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $dr['hrStorageDescr'] . "/n");
}
}
## Set OIDs
@@ -148,26 +155,16 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
rrd_update($loadrrd, "N:$load1:$load5:$load10");
rrd_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
if($device['courier']) {
include("includes/polling/courierstats.inc.php");
}
if($device['postfix']) {
include("includes/polling/mailstats.inc.php");
}
if($device['apache']) {
$apacherrd = "rrd/" . $hostname . "-apache.rrd";
if(!is_file($apacherrd)) {
$woo= `rrdtool create $apacherrd \
DS:bits:COUNTER:600:U:10000000 \
DS:hits:COUNTER:600:U:10000000 \
RRA:AVERAGE:0.5:1:800 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:800 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797`;
}
list($ahits,$abits) = explode("\n", `./get-apache.sh $hostname`);
$abits = $abits * 8;
rrd_update($apacherrd,"N:$abits:$ahits");
} // end apache
include("includes/polling/apachestats.inc.php");
}
} // end Non-m0n0wall
+17 -6
View File
@@ -4,10 +4,11 @@ $query = "SELECT * FROM temperature WHERE temp_host = '" . $device['device_id']
$temp_data = mysql_query($query);
while($temperature = mysql_fetch_array($temp_data)) {
$temp_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $temperature['temp_oid'];
echo($temp_cmd);
$temp_cmd = "snmpget -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $temperature['temp_oid'];
$temp = `$temp_cmd`;
echo("Checking temp " . $temperature['temp_descr'] . "... ");
$temprrd = addslashes("rrd/" . $device['hostname'] . "-temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd");
$temprrd = str_replace(")", "_", $temprrd);
$temprrd = str_replace("(", "_", $temprrd);
@@ -23,18 +24,28 @@ while($temperature = mysql_fetch_array($temp_data)) {
RRA:AVERAGE:0.5:12:2400`;
}
$temp = str_replace("\"", "", $temp);
$temp = trim(str_replace("\"", "", $temp));
if($temperature['temp_tenths']) { $temp = $temp / 10; }
echo("$temprrd N:$temp");
echo($temp . "C\n");
$updatecmd = "rrdtool update $temprrd N:$temp";
echo($updatecmd . "\n");
`$updatecmd`;
if($temperature['temp_current'] < $temperature['temp_limit'] && $temp >= $temperature['temp_limit']) {
$updated = ", `service_changed` = '" . time() . "' ";
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'] . " is " . $temp . " (Limit " . $temperature['temp_limit'];
$msg .= ") at " . date('l dS F Y h:i:s A');
mail($email, "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $temperature['temp_descr'] . "/n");
}
mysql_query("UPDATE temperature SET temp_current = '$temp' WHERE temp_id = '$temperature[temp_id]'");
}
?>
+24 -19
View File
@@ -2,7 +2,7 @@
function cpugraphHP ($rrd, $graph , $from, $to, $width, $height)
{
global $rrdtool, $installdir, $mono_font;
global $config,$rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
@@ -21,7 +21,7 @@ function cpugraphHP ($rrd, $graph , $from, $to, $width, $height)
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$opts = array_merge($config['rrdgraph_defaults'], $$optsa, $optsb);
$ret = rrd_graph("$imgfile", $opts, count($opts));
@@ -36,29 +36,34 @@ function cpugraphHP ($rrd, $graph , $from, $to, $width, $height)
function memgraphHP ($rrd, $graph , $from, $to, $width, $height, $title, $vertical)
{
global $rrdtool, $installdir, $mono_font;
global $config,$rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$memrrd = $database;
$opts = "--start $from \
--alt-autoscale-max \
--width $width --height $height \
-l 0 -E \
-b 1024 \
DEF:TOTAL=$memrrd:TOTAL:AVERAGE \
DEF:FREE=$memrrd:FREE:AVERAGE \
DEF:USED=$memrrd:USED:AVERAGE \
AREA:USED#ee9900:Used \
AREA:FREE#FAFDCE:Free:STACK \
LINE1.5:TOTAL#cc0000:";
$opts = array("--start", "$from", "--alt-autoscale-max", "--width", "$width", "--height", "$height",
"-l", "0", "-E", "-b", "1024",
"DEF:TOTAL=$memrrd:TOTAL:AVERAGE",
"DEF:FREE=$memrrd:FREE:AVERAGE",
"DEF:USED=$memrrd:USED:AVERAGE",
"AREA:USED#ee9900:Used",
"AREA:FREE#FAFDCE:Free:STACK",
"LINE1.5:TOTAL#cc0000:");
if($width <= "300") {$opts .= "\
--font LEGEND:7:$mono_font \
--font AXIS:6:$mono_font \
--font-render-mode normal";}
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($config['rrdgraph_defaults'], $$opts, $optsb);
`$rrdtool graph $imgfile $opts`;
$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;
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
<?php
function callsgraphSNOM ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical ,"--alt-autoscale-max",
@@ -18,7 +18,7 @@ function callsgraphSNOM ($rrd, $graph, $from, $to, $width, $height, $title, $ver
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$opts = array_merge($config['rrdgraph_defaults'], $optsa, $optsb);
$ret = rrd_graph("$imgfile", $opts, count($opts));
+336 -545
View File
@@ -3,631 +3,422 @@
// Start Graphing Functions
function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $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 "; }
$range = $to - $from;
$points_per_sample = 3;
$xpoints = '540';
$step = $range*$points_per_sample/$xpoints;
$rrd_virus = "rrd/" . $rrd . "-mail_virus.rrd";
$rrd = "rrd/" . $rrd . "-mail.rrd";
$imgfile = "graphs/" . "$graph";
$optsa = array(
"-E",
"--lower-limit", "0",
"--units-exponent", "0",
"--title", $title,
"--vertical-label", $vertical,
"-l 0",
"--width", $width, "--height", $height,
"--start", $from, "--end", $to,
"DEF:rejected=$rrd:rejected:AVERAGE",
"DEF:mrejected=$rrd:rejected:MAX",
"CDEF:rrejected=rejected,60,*",
"CDEF:drejected=rejected,UN,0,rejected,IF,$step,*",
"CDEF:srejected=PREV,UN,drejected,PREV,IF,drejected,+",
"CDEF:rmrejected=mrejected,60,*",
"DEF:bounced=$rrd:bounced:AVERAGE",
"DEF:mbounced=$rrd:bounced:MAX",
"CDEF:rbounced=bounced,60,*",
"CDEF:dbounced=bounced,UN,0,bounced,IF,$step,*",
"CDEF:sbounced=PREV,UN,dbounced,PREV,IF,dbounced,+",
"CDEF:rmbounced=mbounced,60,*",
"DEF:virus=$rrd_virus:virus:AVERAGE",
"DEF:mvirus=$rrd_virus:virus:MAX",
"CDEF:rvirus=virus,60,*",
"CDEF:dvirus=virus,UN,0,virus,IF,$step,*",
"CDEF:svirus=PREV,UN,dvirus,PREV,IF,dvirus,+",
"CDEF:rmvirus=mvirus,60,*",
"DEF:spam=$rrd_virus:spam:AVERAGE",
"DEF:mspam=$rrd_virus:spam:MAX",
"CDEF:rspam=spam,60,*",
"CDEF:dspam=spam,UN,0,spam,IF,$step,*",
"CDEF:sspam=PREV,UN,dspam,PREV,IF,dspam,+",
"CDEF:rmspam=mspam,60,*",
"LINE2:rrejected#cc0000:reject",
'GPRINT:srejected:MAX:tot\: %6.0lf msgs',
'GPRINT:rrejected:AVERAGE:avg\: %5.2lf/min',
'GPRINT:rmrejected:MAX:max\: %3.0lf/min\l',
"AREA:rbounced#0000cc:bounce",
'GPRINT:sbounced:MAX:tot\: %6.0lf msgs',
'GPRINT:rbounced:AVERAGE:avg\: %5.2lf/min',
'GPRINT:rmbounced:MAX:max\: %3.0lf/min\l',
"STACK:rvirus#000000:virus ",
'GPRINT:svirus:MAX:tot\: %6.0lf msgs',
'GPRINT:rvirus:AVERAGE:avg\: %5.2lf/min',
'GPRINT:rmvirus:MAX:max\: %3.0lf/min\l',
"STACK:rspam#00cc00:spam ",
'GPRINT:sspam:MAX:tot\: %6.0lf msgs',
'GPRINT:rspam:AVERAGE:avg\: %5.2lf/min',
'GPRINT:rmspam:MAX:max\: %3.0lf/min\l');
$database = "rrd/" . $rrd . "-mailstats.rrd";
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$options .= " DEF:rejected=$database:reject:AVERAGE";
$options .= " DEF:mrejected=$database:reject:MAX";
$options .= " CDEF:rrejected=rejected,60,*";
$options .= " CDEF:drejected=rejected,UN,0,rejected,IF,$step,*";
$options .= " CDEF:srejected=PREV,UN,drejected,PREV,IF,drejected,+";
$options .= " CDEF:rmrejected=mrejected,60,*";
$options .= " DEF:bounced=$database:bounced:AVERAGE";
$options .= " DEF:mbounced=$database:bounced:MAX";
$options .= " CDEF:rbounced=bounced,60,*";
$options .= " CDEF:dbounced=bounced,UN,0,bounced,IF,$step,*";
$options .= " CDEF:sbounced=PREV,UN,dbounced,PREV,IF,dbounced,+";
$options .= " CDEF:rmbounced=mbounced,60,*";
$options .= " DEF:virus=$database:virus:AVERAGE";
$options .= " DEF:mvirus=$database:virus:MAX";
$options .= " CDEF:rvirus=virus,60,*";
$options .= " CDEF:dvirus=virus,UN,0,virus,IF,$step,*";
$options .= " CDEF:svirus=PREV,UN,dvirus,PREV,IF,dvirus,+";
$options .= " CDEF:rmvirus=mvirus,60,*";
$options .= " DEF:spam=$database:spam:AVERAGE";
$options .= " DEF:mspam=$database:spam:MAX";
$options .= " CDEF:rspam=spam,60,*";
$options .= " CDEF:dspam=spam,UN,0,spam,IF,$step,*";
$options .= " CDEF:sspam=PREV,UN,dspam,PREV,IF,dspam,+";
$options .= " CDEF:rmspam=mspam,60,*";
$options .= " COMMENT:Errors\ \ \ \ \ \ \ Total\ \ \ \ \ \ Average\ \ \ \ \ Maximum\\\\n";
$options .= " LINE1.25:rrejected#cc0000:reject";
$options .= " GPRINT:srejected:MAX:\ %6.0lf";
$options .= " GPRINT:rrejected:AVERAGE:\ \ %5.2lf/min";
$options .= " GPRINT:rmrejected:MAX:\ %5.2lf/min\\\\l";
$options .= " AREA:rbounced#0000cc:bounce";
$options .= " GPRINT:sbounced:MAX:\ %6.0lf";
$options .= " GPRINT:rbounced:AVERAGE:\ \ %5.2lf/min";
$options .= " GPRINT:rmbounced:MAX:\ %5.2lf/min\\\\l";
$options .= " STACK:rvirus#000000:virus\ ";
$options .= " GPRINT:svirus:MAX:\ %6.0lf";
$options .= " GPRINT:rvirus:AVERAGE:\ \ %5.2lf/min";
$options .= " GPRINT:rmvirus:MAX:\ %5.2lf/min\\\\l";
$options .= " STACK:rspam#00cc00:spam\ \ ";
$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`;
return $imgfile;
}
function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$points_per_sample = 3;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $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 "; }
$range = $to - $from;
$points_per_sample = 3;
$xpoints = '540';
$step = $range*$points_per_sample/$xpoints;
$rrd = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array(
"-E",
"--lower-limit", "0",
"--units-exponent", "0",
"--title", $title,
"--vertical-label", $vertical,
"-l 0",
"--width", $width, "--height", $height,
"--start",
$from, "--end", $to,
"DEF:sent=$rrd:sent:AVERAGE",
"DEF:msent=$rrd:sent:MAX",
"CDEF:rsent=sent,60,*",
"CDEF:rmsent=msent,60,*",
"CDEF:dsent=sent,UN,0,sent,IF,$step,*",
"CDEF:ssent=PREV,UN,dsent,PREV,IF,dsent,+",
"DEF:recv=$rrd:recv:AVERAGE",
"DEF:mrecv=$rrd:recv:MAX",
"CDEF:rrecv=recv,60,*",
"CDEF:rmrecv=mrecv,60,*",
"CDEF:drecv=recv,UN,0,recv,IF,$step,*",
"CDEF:srecv=PREV,UN,drecv,PREV,IF,drecv,+",
"AREA:rsent#00c000:sent",
"LINE1:rsent#005000:",
"GPRINT:ssent:MAX:Tot\: %5.0lf msgs",
"GPRINT:rsent:AVERAGE:Avg\: %4.2lf/min",
"GPRINT:rmsent:MAX:Max\: %3.0lf/min\l",
"LINE1.5:rrecv#cc0000:rcvd",
"GPRINT:srecv:MAX:Tot\: %5.0lf msgs",
"GPRINT:rrecv:AVERAGE:Avg\: %4.2lf/min",
"GPRINT:rmrecv:MAX:Max\: %3.0lf/min\l");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$options .= " DEF:sent=$rrd:sent:AVERAGE";
$options .= " DEF:msent=$rrd:sent:MAX";
$options .= " CDEF:rsent=sent,60,*";
$options .= " CDEF:rmsent=msent,60,*";
$options .= " CDEF:dsent=sent,UN,0,sent,IF,$step,*";
$options .= " CDEF:ssent=PREV,UN,dsent,PREV,IF,dsent,+";
$options .= " DEF:recv=$rrd:rcvd:AVERAGE";
$options .= " DEF:mrecv=$rrd:rcvd:MAX";
$options .= " CDEF:rrecv=recv,60,*";
$options .= " CDEF:rmrecv=mrecv,60,*";
$options .= " CDEF:drecv=recv,UN,0,recv,IF,$step,*";
$options .= " CDEF:srecv=PREV,UN,drecv,PREV,IF,drecv,+";
$options .= " COMMENT:Mails\ \ \ \ \ \ Total\ \ \ \ \ \ \ Average\ \ \ \ \ Maximum\\\\n";
$options .= " AREA:rsent#00c000:sent";
$options .= " LINE1.25:rsent#005000:";
$options .= " GPRINT:ssent:MAX:\ \ %6.0lf";
$options .= " GPRINT:rsent:AVERAGE:\ \ %5.2lf/min";
$options .= " GPRINT:rmsent:MAX:\ %5.2lf/min\\\\l";
$options .= " LINE1.25:rrecv#cc0000:rcvd";
$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`;
return $imgfile;
}
function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical)
{
global $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array (
"--start", $from, "--end", $to,
"-b 1024",
"-E",
"-v", $vertical,
"--title", $title,
"-l 0",
"--width", $width, "--height", $height,
"DEF:atotalswap=$database:totalswap:AVERAGE",
"DEF:aavailswap=$database:availswap:AVERAGE",
"DEF:atotalreal=$database:totalreal:AVERAGE",
"DEF:aavailreal=$database:availreal:AVERAGE",
"DEF:atotalfree=$database:totalfree:AVERAGE",
"DEF:ashared=$database:shared:AVERAGE",
"DEF:abuffered=$database:buffered:AVERAGE",
"DEF:acached=$database:cached:AVERAGE",
"CDEF:totalswap=atotalswap,1024,*",
"CDEF:availswap=aavailswap,1024,*",
"CDEF:totalreal=atotalreal,1024,*",
"CDEF:availreal=aavailreal,1024,*",
"CDEF:totalfree=atotalfree,1024,*",
"CDEF:shared=ashared,1024,*",
"CDEF:buffered=abuffered,1024,*",
"CDEF:cached=acached,1024,*",
"CDEF:usedreal=totalreal,availreal,-",
"CDEF:usedswap=totalswap,availswap,-",
"CDEF:cusedswap=usedswap,-1,*",
"CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+",
"COMMENT:Bytes Current Average Maximum\\n",
"LINE1:usedreal#d0b080:",
"AREA:usedreal#f0e0a0:used",
"GPRINT:usedreal:LAST: %7.2lf %s",
"GPRINT:usedreal:AVERAGE:%7.2lf %s",
"GPRINT:usedreal:MAX:%7.2lf %s\\n",
"STACK:availreal#e5e5e5:free",
"GPRINT:availreal:LAST: %7.2lf %s",
"GPRINT:availreal:AVERAGE:%7.2lf %s",
"GPRINT:availreal:MAX:%7.2lf %s\\n",
"LINE1:usedreal#d0b080:",
"AREA:shared#afeced::",
"AREA:buffered#cc0000::STACK",
"AREA:cached#ffaa66::STACK",
"LINE1.25:shared#008fea:shared",
"GPRINT:shared:LAST: %7.2lf %s",
"GPRINT:shared:AVERAGE:%7.2lf %s",
"GPRINT:shared:MAX:%7.2lf %s\\n",
"LINE1.25:buffered#ff1a00:buffers:STACK",
"GPRINT:buffered:LAST:%7.2lf %s",
"GPRINT:buffered:AVERAGE:%7.2lf %s",
"GPRINT:buffered:MAX:%7.2lf %s\\n",
"LINE1.25:cached#ea8f00:cached:STACK",
"GPRINT:cached:LAST: %7.2lf %s",
"GPRINT:cached:AVERAGE:%7.2lf %s",
"GPRINT:cached:MAX:%7.2lf %s\\n",
"LINE1:totalreal#050505:",
"AREA:cusedswap#C3D9FF:swap",
"LINE1.25:cusedswap#356AA0:",
"GPRINT:usedswap:LAST: %7.2lf %s",
"GPRINT:usedswap:AVERAGE:%7.2lf %s",
"GPRINT:usedswap:MAX:%7.2lf %s\\n",
"LINE1:totalreal#050505:total",
"GPRINT:totalreal:AVERAGE: %7.2lf %s");
function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $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 "; }
$options .= " DEF:atotalswap=$database:totalswap:AVERAGE";
$options .= " DEF:aavailswap=$database:availswap:AVERAGE";
$options .= " DEF:atotalreal=$database:totalreal:AVERAGE";
$options .= " DEF:aavailreal=$database:availreal:AVERAGE";
$options .= " DEF:atotalfree=$database:totalfree:AVERAGE";
$options .= " DEF:ashared=$database:shared:AVERAGE";
$options .= " DEF:abuffered=$database:buffered:AVERAGE";
$options .= " DEF:acached=$database:cached:AVERAGE";
$options .= " CDEF:totalswap=atotalswap,1024,*";
$options .= " CDEF:availswap=aavailswap,1024,*";
$options .= " CDEF:totalreal=atotalreal,1024,*";
$options .= " CDEF:availreal=aavailreal,1024,*";
$options .= " CDEF:totalfree=atotalfree,1024,*";
$options .= " CDEF:shared=ashared,1024,*";
$options .= " CDEF:buffered=abuffered,1024,*";
$options .= " CDEF:cached=acached,1024,*";
$options .= " CDEF:usedreal=totalreal,availreal,-";
$options .= " CDEF:usedswap=totalswap,availswap,-";
$options .= " CDEF:cusedswap=usedswap,-1,*";
$options .= " CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+";
$options .= " COMMENT:Bytes\ \ \ \ \ \ \ Current\ \ \ \ Average\ \ \ \ \ Maximum\\n";
$options .= " LINE1:usedreal#d0b080:";
$options .= " AREA:usedreal#f0e0a0:used";
$options .= " GPRINT:usedreal:LAST:\ \ \ %7.2lf%sB";
$options .= " GPRINT:usedreal:AVERAGE:%7.2lf%sB";
$options .= " GPRINT:usedreal:MAX:%7.2lf%sB\\\\n";
$options .= " STACK:availreal#e5e5e5:free";
$options .= " GPRINT:availreal:LAST:\ \ \ %7.2lf%sB";
$options .= " GPRINT:availreal:AVERAGE:%7.2lf%sB";
$options .= " GPRINT:availreal:MAX:%7.2lf%sB\\\\n";
$options .= " LINE1:usedreal#d0b080:";
$options .= " AREA:shared#afeced::";
$options .= " AREA:buffered#cc0000::STACK";
$options .= " AREA:cached#ffaa66::STACK";
$options .= " LINE1.25:shared#008fea:shared";
$options .= " GPRINT:shared:LAST:\ %7.2lf%sB";
$options .= " GPRINT:shared:AVERAGE:%7.2lf%sB";
$options .= " GPRINT:shared:MAX:%7.2lf%sB\\\\n";
$options .= " LINE1.25:buffered#ff1a00:buffers:STACK";
$options .= " GPRINT:buffered:LAST:%7.2lf%sB";
$options .= " GPRINT:buffered:AVERAGE:%7.2lf%sB";
$options .= " GPRINT:buffered:MAX:%7.2lf%sB\\\\n";
$options .= " LINE1.25:cached#ea8f00:cached:STACK";
$options .= " GPRINT:cached:LAST:\ %7.2lf%sB";
$options .= " GPRINT:cached:AVERAGE:%7.2lf%sB";
$options .= " GPRINT:cached:MAX:%7.2lf%sB\\\\n";
$options .= " LINE1:totalreal#050505:";
$options .= " AREA:cusedswap#C3D9FF:swap";
$options .= " LINE1.25:cusedswap#356AA0:";
$options .= " GPRINT:usedswap:LAST:\ \ \ %7.2lf%sB";
$options .= " GPRINT:usedswap:AVERAGE:%7.2lf%sB";
$options .= " GPRINT:usedswap:MAX:%7.2lf%sB\\\\n";
$options .= " LINE1:totalreal#050505:total";
$options .= " GPRINT:totalreal:AVERAGE:\ \ %7.2lf%sB";
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$thing = `$rrdtool graph $imgfile $options`;
return $imgfile;
}
function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array(
"--title", $title,
"--start",
$from, "--end", $to,
"-E",
"-v", $vertical,
"--rigid",
"--alt-autoscale-max",
"-l 0",
"--width", $width, "--height", $height,
"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,+,+",
"COMMENT:Load Average Current Average Maximum\\n",
"AREA:a#ffeeaa:1 Min:",
"LINE1:a#c5aa00:",
"GPRINT:a:LAST: %7.2lf",
"GPRINT:a:AVERAGE: %7.2lf",
"GPRINT:a:MAX: %7.2lf\\n",
"LINE1.25:b#ea8f00:5 Min:",
"GPRINT:b:LAST: %7.2lf",
"GPRINT:b:AVERAGE: %7.2lf",
"GPRINT:b:MAX: %7.2lf\\n",
"LINE1.25:c#cc0000:15 Min",
"GPRINT:c:LAST: %7.2lf",
"GPRINT:c:AVERAGE: %7.2lf",
"GPRINT:c:MAX: %7.2lf\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $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:1min=$database:1min:AVERAGE";
$options .= " DEF:5min=$database:5min:AVERAGE";
$options .= " DEF:15min=$database:15min:AVERAGE";
$options .= " CDEF:a=1min,100,/";
$options .= " CDEF:b=5min,100,/";
$options .= " CDEF:c=15min,100,/";
$options .= " CDEF:cdefd=a,b,c,+,+";
$options .= " COMMENT:Load\ Average\ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n";
$options .= " AREA:a#ffeeaa:1\ Min:";
$options .= " LINE1:a#c5aa00:";
$options .= " GPRINT:a:LAST:\ \ \ \ %7.2lf";
$options .= " GPRINT:a:AVERAGE:\ \ %7.2lf";
$options .= " GPRINT:a:MAX:\ \ %7.2lf\\\\n";
$options .= " LINE1.25:b#ea8f00:5\ Min:";
$options .= " GPRINT:b:LAST:\ \ \ \ %7.2lf";
$options .= " GPRINT:b:AVERAGE:\ \ %7.2lf";
$options .= " GPRINT:b:MAX:\ \ %7.2lf\\\\n";
$options .= " LINE1.25:c#cc0000:15\ Min";
$options .= " GPRINT:c:LAST:\ \ \ %7.2lf";
$options .= " GPRINT:c:AVERAGE:\ \ %7.2lf";
$options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
return $imgfile;
}
function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array(
"--title", $title,
"--start",
$from, "--end", $to,
"-E",
"-v", $vertical,
"--rigid",
"--alt-autoscale-max",
"-l 0",
"--width", $width, "--height", $height,
"DEF:users=$database:users:AVERAGE",
"COMMENT:Users Cur Ave Min Max\\n",
"AREA:users#CDEB8B:",
"LINE1.25:users#008C00: ",
"GPRINT:users:LAST: %6.2lf",
"GPRINT:users:AVERAGE:%6.2lf",
"GPRINT:users:MIN:%6.2lf",
"GPRINT:users:MAX:%6.2lf\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$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 "; }
$options .= " DEF:users=$database:users:AVERAGE";
$options .= " COMMENT:Users\ \ \ \ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n";
$options .= " AREA:users#CDEB8B:";
$options .= " LINE1.25:users#008C00:\ ";
$options .= " GPRINT:users:LAST:\ \ \ \ %6.2lf";
$options .= " GPRINT:users:AVERAGE:%6.2lf";
$options .= " GPRINT:users:MIN:%6.2lf";
$options .= " GPRINT:users:MAX:%6.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
return $imgfile;
}
function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array(
"--title", $title,
"--start", $from, "--end", $to,
"-E",
"-v", $vertical,
"--rigid",
"--alt-autoscale-max",
"-l 0",
"--width", $width, "--height", $height,
"DEF:procs=$database:procs:AVERAGE",
"DEF:maxprocs=$database:procs:MAX",
"COMMENT:Processes Cur Ave Min Max\\n",
"AREA:procs#C3D9FF:",
"LINE1.25:procs#356AA0: ",
"GPRINT:procs:LAST: %6.2lf",
"GPRINT:procs:AVERAGE:%6.2lf",
"GPRINT:procs:MIN:%6.2lf",
"GPRINT:procs:MAX:%6.2lf\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$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 "; }
$options .= " DEF:procs=$database:procs:AVERAGE";
$options .= " COMMENT:Processes\ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n";
$options .= " AREA:procs#CDEB8B:";
$options .= " LINE1.25:procs#008C00:\ ";
$options .= " GPRINT:procs:LAST:\ \ \ \ %6.2lf";
$options .= " GPRINT:procs:AVERAGE:%6.2lf";
$options .= " GPRINT:procs:MIN:%6.2lf";
$options .= " GPRINT:procs:MAX:%6.2lf\\\\n";
$thing = `$rrdtool graph $imgfile $options`;
return $imgfile;
$opts = array_merge($optsa, $optsb);
$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 cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array(
"--title", $title,
"--start",
$from, "--end", $to,
"-E",
"-v", $vertical,
"--rigid",
"--alt-autoscale-max",
"-l 0",
"--width", $width, "--height", $height,
"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#c02020: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#008f00:nice: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#ea8f00:system: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#f5f5e5:idle:STACK",
"GPRINT:idle_perc:LAST: Cur\:%3.0lf%%",
"GPRINT:idle_perc:AVERAGE: Avg\:%3.0lf%%",
"GPRINT:idle_perc:MAX: Max\:%3.0lf%%\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$ret = rrd_graph("$imgfile", $opts, count($opts));
if( !is_array($ret) ) {
# $err = rrd_error();
return FALSE;
} else {
return $imgfile;
}
$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:user=$database:user:AVERAGE";
$options .= " DEF:nice=$database:nice:AVERAGE";
$options .= " DEF:system=$database:system:AVERAGE";
$options .= " DEF:idle=$database:idle:AVERAGE";
$options .= " CDEF:total=user,nice,system,idle,+,+,+";
$options .= " CDEF:user_perc=user,total,/,100,*";
$options .= " CDEF:nice_perc=nice,total,/,100,*";
$options .= " CDEF:system_perc=system,total,/,100,*";
$options .= " CDEF:idle_perc=idle,total,/,100,*";
$options .= " COMMENT:Usage\ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ Maximum\\\\n";
$options .= " AREA:user_perc#c02020:user";
$options .= " GPRINT:user_perc:LAST:\ \ \ \ \ %5.2lf%%";
$options .= " GPRINT:user_perc:AVERAGE:\ \ \ %5.2lf%%";
$options .= " GPRINT:user_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$options .= " AREA:nice_perc#008f00:nice:STACK";
$options .= " GPRINT:nice_perc:LAST:\ \ \ \ \ %5.2lf%%";
$options .= " GPRINT:nice_perc:AVERAGE:\ \ \ %5.2lf%%";
$options .= " GPRINT:nice_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$options .= " AREA:system_perc#ea8f00:system:STACK";
$options .= " GPRINT:system_perc:LAST:\ \ \ %5.2lf%%";
$options .= " GPRINT:system_perc:AVERAGE:\ \ \ %5.2lf%%";
$options .= " GPRINT:system_perc:MAX:\ \ \ %5.2lf%%\\\\n";
$options .= " AREA:idle_perc#f5f5e5:idle:STACK";
$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`;
return $imgfile;
}
function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $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 "; }
$points_per_sample = 3;
$range = $to - $from;
$rrd = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array(
"-E",
"--lower-limit", "0",
"--units-exponent", "0",
"--title", $title,
"--vertical-label", $vertical,
"-l 0",
"--width", $width, "--height", $height,
"--start", $from, "--end", $to,
"DEF:pop3d_login=$rrd:pop3d_login:AVERAGE",
"DEF:mpop3d_login=$rrd:pop3d_login:MAX",
"DEF:imapd_login=$rrd:imapd_login:AVERAGE",
"DEF:mimapd_login=$rrd:imapd_login:MAX",
"CDEF:rpop3d_login=pop3d_login,60,*",
"CDEF:vpop3d_login=pop3d_login,UN,0,pop3d_login,IF,$range,*",
"CDEF:rmpop3d_login=mpop3d_login,60,*",
"CDEF:rimapd_login=imapd_login,60,*",
"CDEF:vimapd_login=imapd_login,UN,0,imapd_login,IF,$range,*",
"CDEF:rmimapd_login=mimapd_login,60,*",
"DEF:pop3d_ssl_login=$rrd:pop3d_ssl_login:AVERAGE",
"DEF:mpop3d_ssl_login=$rrd:pop3d_ssl_login:MAX",
"DEF:imapd_ssl_login=$rrd:imapd_ssl_login:AVERAGE",
"DEF:mimapd_ssl_login=$rrd:imapd_ssl_login:MAX",
"CDEF:rpop3d_ssl_login=pop3d_ssl_login,60,*",
"CDEF:vpop3d_ssl_login=pop3d_ssl_login,UN,0,pop3d_ssl_login,IF,$range,*",
"CDEF:rmpop3d_ssl_login=mpop3d_ssl_login,60,*",
"CDEF:rimapd_ssl_login=imapd_ssl_login,60,*",
"CDEF:rmimapd_ssl_login=mimapd_ssl_login,60,*",
"CDEF:vimapd_ssl_login=imapd_ssl_login,UN,0,imapd_ssl_login,IF,$range,*",
'LINE1.5:rpop3d_login#BB0000:pop3',
'GPRINT:vpop3d_login:AVERAGE: tot\: %5.0lf',
'GPRINT:rpop3d_login:AVERAGE:avg\: %4.0lf/min',
'GPRINT:rmpop3d_login:MAX:max\: %4.0lf/min\l',
'LINE1.5:rimapd_login#009900:imap',
'GPRINT:vimapd_login:AVERAGE: tot\: %5.0lf',
'GPRINT:rimapd_login:AVERAGE:avg\: %4.0lf/min',
'GPRINT:rmimapd_login:MAX:max\: %4.0lf/min\l',
'LINE1.5:rpop3d_ssl_login#000000:pop3-ssl',
'GPRINT:vpop3d_ssl_login:AVERAGE:tot\: %5.0lf',
'GPRINT:rpop3d_ssl_login:AVERAGE:avg\: %4.0lf/min',
'GPRINT:rmpop3d_ssl_login:MAX:max\: %4.0lf/min\l',
'LINE1.5:rimapd_ssl_login#000099:imap-ssl',
'GPRINT:vimapd_ssl_login:AVERAGE:tot\: %5.0lf',
'GPRINT:rimapd_ssl_login:AVERAGE:avg\: %4.0lf/min',
'GPRINT:rmimapd_ssl_login:MAX:max\: %4.0lf/min\l');
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$options .= " DEF:pop3d_login=$database:pop3:AVERAGE";
$options .= " DEF:mpop3d_login=$database:pop3:MAX";
$options .= " DEF:imapd_login=$database:imap:AVERAGE";
$options .= " DEF:mimapd_login=$database:imap:MAX";
$options .= " CDEF:rpop3d_login=pop3d_login,60,*";
$options .= " CDEF:vpop3d_login=pop3d_login,UN,0,pop3d_login,IF,$range,*";
$options .= " CDEF:rmpop3d_login=mpop3d_login,60,*";
$options .= " CDEF:rimapd_login=imapd_login,60,*";
$options .= " CDEF:vimapd_login=imapd_login,UN,0,imapd_login,IF,$range,*";
$options .= " CDEF:rmimapd_login=mimapd_login,60,*";
$options .= " DEF:pop3d_ssl_login=$database:pop3ssl:AVERAGE";
$options .= " DEF:mpop3d_ssl_login=$database:pop3ssl:MAX";
$options .= " DEF:imapd_ssl_login=$database:imapssl:AVERAGE";
$options .= " DEF:mimapd_ssl_login=$database:imapssl:MAX";
$options .= " CDEF:rpop3d_ssl_login=pop3d_ssl_login,60,*";
$options .= " CDEF:vpop3d_ssl_login=pop3d_ssl_login,UN,0,pop3d_ssl_login,IF,$range,*";
$options .= " CDEF:rmpop3d_ssl_login=mpop3d_ssl_login,60,*";
$options .= " CDEF:rimapd_ssl_login=imapd_ssl_login,60,*";
$options .= " CDEF:rmimapd_ssl_login=mimapd_ssl_login,60,*";
$options .= " CDEF:vimapd_ssl_login=imapd_ssl_login,UN,0,imapd_ssl_login,IF,$range,*";
$options .= " COMMENT:Logins\ \ \ \ \ \ \ \ \ Total\ \ \ \ Average\ \ \ \ Maximum\\\\n";
$options .= " LINE1.25:rpop3d_login#BB0000:pop3";
$options .= " GPRINT:vpop3d_login:AVERAGE:\ \ \ \ \ %6.0lf";
$options .= " GPRINT:rpop3d_login:AVERAGE:%5.2lf/min";
$options .= " GPRINT:rmpop3d_login:MAX:%5.2lf/min\\\\l";
$options .= " LINE1.25:rimapd_login#009900:imap";
$options .= " GPRINT:vimapd_login:AVERAGE:\ \ \ \ \ %6.0lf";
$options .= " GPRINT:rimapd_login:AVERAGE:%5.2lf/min";
$options .= " GPRINT:rmimapd_login:MAX:%5.2lf/min\\\\l";
$options .= " LINE1.25:rpop3d_ssl_login#000000:pop3-ssl";
$options .= " GPRINT:vpop3d_ssl_login:AVERAGE:\ %6.0lf";
$options .= " GPRINT:rpop3d_ssl_login:AVERAGE:%5.2lf/min";
$options .= " GPRINT:rmpop3d_ssl_login:MAX:%5.2lf/min\\\\l";
$options .= " LINE1.25:rimapd_ssl_login#000099:imap-ssl";
$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`;
return $imgfile;
}
function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical ,"--alt-autoscale-max",
"-l 0",
"-E",
"--title", $title,
"DEF:hits=$database:hits:AVERAGE",
"COMMENT: Current Average Maximum\\n",
"AREA:hits#ff9933:",
"LINE1.25:hits#FF6600:Hits",
"GPRINT:hits:LAST: %6.2lf/sec",
"GPRINT:hits:AVERAGE:%6.2lf/sec",
"GPRINT:hits:MAX:%6.2lf/sec\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$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 "; }
$options .= " DEF:hits=$database:hits:AVERAGE";
$options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ Maximum\\\\n";
$options .= " AREA:hits#ff9933:";
$options .= " LINE1.25:hits#FF6600:Hits";
$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`;
return $imgfile;
}
function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
"-l 0",
"-E",
"-b 1024",
"--title", $title);
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $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 "; }
$hostname = gethostbyid($device);
$iter = "1";
$sql = mysql_query("SELECT * FROM storage where storage_id = '$id'");
$optsa[] = "COMMENT: Size Used %age\l";
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Size\ \ \ \ \ \ Used\ \ \ \ %age\l";
while($fs = mysql_fetch_array($sql)) {
$hostname = gethostbyid($fs['host_id']);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; $iter = "0"; }
$descr = str_pad($fs[hrStorageDescr], 16);
$descr = substr($descr,0,16);
$descr = str_pad($fs[hrStorageDescr], 14);
$descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$optsa[] = "DEF:$fs[storage_id]=rrd/$hostname-storage-$text.rrd:used:AVERAGE";
$optsa[] = "DEF:$fs[storage_id]s=rrd/$hostname-storage-$text.rrd:size:AVERAGE";
$optsa[] = "DEF:$fs[storage_id]p=rrd/$hostname-storage-$text.rrd:perc:AVERAGE";
$optsa[] = "LINE1.25:$fs[storage_id]p#" . $colour . ":$descr";
$optsa[] = "GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB";
$optsa[] = "GPRINT:$fs[storage_id]:LAST:%6.2lf%SB";
$optsa[] = "GPRINT:$fs[storage_id]p:LAST:%3.0lf%%\l";
$options .= " DEF:$fs[storage_id]=rrd/$hostname-storage-$text.rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=rrd/$hostname-storage-$text.rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=rrd/$hostname-storage-$text.rrd:perc:AVERAGE";
$options .= " LINE1.25:$fs[storage_id]p#" . $colour . ":'$descr'";
$options .= " GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB";
$options .= " GPRINT:$fs[storage_id]:LAST:%6.2lf%SB";
$options .= " GPRINT:$fs[storage_id]p:LAST:%5.2lf%%\\\\l";
$iter++;
}
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$thing = `$rrdtool graph $imgfile $options`;
return $imgfile;
}
function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max",
"-l 0",
"-E",
"-b 1024",
"--title", $title);
$hostname = gethostbyid($device);
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $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 "; }
$hostname = gethostbyid($device);
$iter = "1";
$sql = mysql_query("SELECT * FROM storage where host_id = '$device'");
$optsa[] = "COMMENT: Size Used %age\l";
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Size\ \ \ \ \ \ Used\ \ \ \ %age\l";
while($fs = mysql_fetch_array($sql)) {
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; $iter = "0"; }
$descr = str_pad($fs[hrStorageDescr], 16);
$descr = substr($descr,0,16);
$descr = str_pad($fs[hrStorageDescr], 14);
$descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$optsa[] = "DEF:$fs[storage_id]=rrd/$hostname-storage-$text.rrd:used:AVERAGE";
$optsa[] = "DEF:$fs[storage_id]s=rrd/$hostname-storage-$text.rrd:size:AVERAGE";
$optsa[] = "DEF:$fs[storage_id]p=rrd/$hostname-storage-$text.rrd:perc:AVERAGE";
$optsa[] = "LINE1.25:$fs[storage_id]p#" . $colour . ":$descr";
$optsa[] = "GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB";
$optsa[] = "GPRINT:$fs[storage_id]:LAST:%6.2lf%SB";
$optsa[] = "GPRINT:$fs[storage_id]p:LAST:%3.0lf%%\l";
$options .= " DEF:$fs[storage_id]=rrd/$hostname-storage-$text.rrd:used:AVERAGE";
$options .= " DEF:$fs[storage_id]s=rrd/$hostname-storage-$text.rrd:size:AVERAGE";
$options .= " DEF:$fs[storage_id]p=rrd/$hostname-storage-$text.rrd:perc:AVERAGE";
$options .= " LINE1.25:$fs[storage_id]p#" . $colour . ":'$descr'";
$options .= " GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB";
$options .= " GPRINT:$fs[storage_id]:LAST:%6.2lf%SB";
$options .= " GPRINT:$fs[storage_id]p:LAST:%5.2lf%%\\\\l";
$iter++;
}
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$thing = `$rrdtool graph $imgfile $options`;
return $imgfile;
}
function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $rrdtool, $installdir, $mono_font;
global $config, $rrdtool, $installdir, $mono_font;
$database = "rrd/" . $rrd;
$imgfile = "graphs/" . "$graph";
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical,"--alt-autoscale-max",
"-l 0",
"-E",
"--title", $title,
"DEF:bits=$database:bits:AVERAGE",
"COMMENT: Current Average Maximum\\n",
"AREA:bits#cccc00:",
"LINE1.25:bits#999900:Bits",
"GPRINT:bits:LAST:%6.2lf%sbps",
"GPRINT:bits:AVERAGE:%6.2lf%sbps",
"GPRINT:bits:MAX:%6.2lf%sbps\\n");
if($width <= "300") {$optsb = array("--font", "LEGEND:7:$mono_font",
"--font", "AXIS:6:$mono_font",
"--font-render-mode", "normal");}
$opts = array_merge($optsa, $optsb);
$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;
}
$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 "; }
$options .= " DEF:bits=$database:bits:AVERAGE";
$options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ Maximum\\\\n";
$options .= " AREA:bits#cccc00:";
$options .= " LINE1.25:bits#9900:Bits";
$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`;
return $imgfile;
}