Remove folder attic/

This commit is contained in:
laf
2014-01-14 16:22:27 +00:00
parent 776e4a0d6a
commit 2b1828b8b9
11 changed files with 0 additions and 938 deletions
-51
View File
@@ -1,51 +0,0 @@
<?php
$query = "SELECT * FROM entPhysical WHERE device_id = '" . $device['device_id'] . "' AND entPhysicalClass = 'sensor'";
$sensors = mysql_query($query);
while ($sensor = mysql_fetch_assoc($sensors))
{
echo("Checking Entity Sensor " . $sensor['entPhysicalName'] . " - " . $sensor['cempsensorName']);
$oid = $sensor['entPhysicalIndex'];
$sensor_cmd = $config['snmpget'] . " -M ".$config['mibdir']." -m CISCO-ENTITY-SENSOR-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$sensor_cmd .= " entSensorValue.$oid entSensorStatus.$oid";
$sensor_data = trim(shell_exec($sensor_cmd));
# echo("$sensor_data");
list($entSensorValue, $entSensorStatus) = explode("\n", $sensor_data);
$rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ces-" . $oid . ".rrd");
if (!is_file($rrd))
{
rrdtool_create($rrd,"--step 300 \
DS:value:GAUGE:600:-1000:U \
RRA:AVERAGE:0.5:1:2304 \
RRA:AVERAGE:0.5:6:1536 \
RRA:AVERAGE:0.5:24:2268 \
RRA:AVERAGE:0.5:288:1890 \
RRA:MAX:0.5:1:2304 \
RRA:MAX:0.5:6:1536 \
RRA:MAX:0.5:24:2268 \
RRA:MAX:0.5:288:1890 \
RRA:MIN:0.5:1:2304 \
RRA:MIN:0.5:6:1536 \
RRA:MIN:0.5:24:2268 \
RRA:MIN:0.5:288:1890");
}
$entSensorValue = entPhysical_scale($entSensorValue, $sensor['entSensorScale']);
$updatecmd = $config['rrdtool'] ." update $rrd N:$entSensorValue";
shell_exec($updatecmd);
$update_query = "UPDATE `entPhysical` SET entSensorValue='$entSensorValue', entSensorStatus='$entSensorStatus' WHERE `entPhysical_id` = '".$sensor['entPhysical_id']."'";
mysql_query($update_query);
echo($entSensorValue . " - " . $entSensorStatus . "\n");
}
?>
-35
View File
@@ -1,35 +0,0 @@
<?php
$sensor = mysql_fetch_assoc(mysql_query("SELECT * FROM entPhysical as E, devices as D WHERE entPhysical_id = '".mres($_GET['a'])."' and D.device_id = E.device_id"));
switch ($sensor['entSensorType'])
{
case 'celsius':
case 'watts':
case 'voltsDC':
case 'dBm':
case 'amperes':
$scale_min = "0";
break;
}
include("includes/graphs/common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $sensor['hostname'] . "/" . safename("ces-" . $sensor['entPhysicalIndex'] . ".rrd");
$type = str_pad($sensor['entSensorType'], 8);
$type = substr($type,0,8);
$rrd_options .= " DEF:avg=$rrd_filename:value:AVERAGE";
$rrd_options .= " DEF:min=$rrd_filename:value:MIN";
$rrd_options .= " DEF:max=$rrd_filename:value:MAX";
$rrd_options .= " COMMENT:' Last Min Max Ave\\n'";
$rrd_options .= " AREA:max#a5a5a5";
$rrd_options .= " AREA:min#ffffff";
$rrd_options .= " LINE1.25:avg#aa2200:'".$type."'";
$rrd_options .= " GPRINT:avg:AVERAGE:%5.2lf%s";
$rrd_options .= " GPRINT:max:MAX:%5.2lf%s";
$rrd_options .= " GPRINT:max:MAX:%5.2lf%s";
$rrd_options .= " GPRINT:avg:LAST:%5.2lf%s";
?>
-39
View File
@@ -1,39 +0,0 @@
<?php
print_optionbar_start();
unset ($sep);
$query = mysql_query("SELECT `entSensorType` FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entSensorType != '' AND entSensorType NOT LIKE 'No%' GROUP BY `entSensorType` ORDER BY `entSensorType`");
while ($data = mysql_fetch_assoc($query))
{
$type = $data['entSensorType'];
if (!$_GET['opta']) { $_GET['opta'] = $type; }
echo($sep);
if ($_GET['opta'] == $type) { echo("<strong>"); }
echo("<a href='device/" . $device['device_id'] . "/ciscosensors/" . $type . "/'>" . htmlspecialchars($type) ."</a>\n");
if ($_GET['opta'] == $type) { echo("</strong>"); }
$sep = ' | ';
}
unset ($sep);
print_optionbar_end();
$query = mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$device['device_id']."' and entSensorType = '".$_GET['opta']."' ORDER BY `entPhysicalName`");
while ($data = mysql_fetch_assoc($query))
{
if ($data['entSensorMeasuredEntity'])
{
$measured = mysql_fetch_assoc(mysql_query("SELECT * FROM entPhysical WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '".$data['entSensorMeasuredEntity']."'"));
}
echo("<div><h3>".$measured['entPhysicalName']." ".$data['entPhysicalName']."</h3>");
$graph_type = "cisco_entity_sensor";
$args = "&a=".$data['entPhysical_id'];
include("includes/print-device-graph.php");
echo("</div>");
}
?>
@@ -1,13 +0,0 @@
<?php
$total = mysql_result(mysql_query("SELECT count(*) FROM `bgpPeers`"),0);
$up = mysql_result(mysql_query("SELECT count(*) FROM `bgpPeers` WHERE `bgpPeerState` = 'established'"),0);
$stop = mysql_result(mysql_query("SELECT count(*) FROM `bgpPeers` WHERE `bgpPeerAdminStatus` = 'stop'"),0);
echo('
<div>
<span style="device-list">Sessions: '.$total.' Up: '.$up.' Down: '.($total-$up) . ($stop != 0 ? ' ( Shutdown: '.$stop.' )' : '') . '</span>
</div>');
?>
-162
View File
@@ -1,162 +0,0 @@
<?php
/* FIXME: dead file */
if ($device['os_group'] == "ios") {
$portifIndex = array();
$cmd = ($device['snmpver'] == 'v1' ? $config['snmpwalk'] : $config['snmpbulkwalk']) . " -M ".$config['mibdir']. " -CI -m CISCO-STACK-MIB -O q -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portIfIndex";
#echo("$cmd");
$portifIndex_output = trim(shell_exec($cmd));
foreach (explode("\n", $portifIndex_output) as $entry){
$entry = str_replace("CISCO-STACK-MIB::portIfIndex.", "", $entry);
list($slotport, $ifIndex) = explode(" ", $entry);
$portifIndex[$ifIndex] = $slotport;
}
if ($debug) { print_r($portifIndex); }
}
$interface_query = mysql_query("SELECT * FROM `ports` $where");
while ($interface = mysql_fetch_assoc($interface_query)) {
if (!$device) { $device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $interface['device_id'] . "'")); }
unset($ifAdminStatus, $ifOperStatus, $ifAlias, $ifDescr);
$interface['hostname'] = $device['hostname'];
$interface['device_id'] = $device['device_id'];
if ($device['status'] == '1') {
unset($update);
unset($update_query);
unset($seperator);
echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n");
$snmp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_cmd .= " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ifAlias." . $interface['ifIndex'] . " ifName." . $interface['ifIndex'];
$snmp_cmd .= " ifDescr." . $interface['ifIndex'];
$snmp_output = trim(shell_exec($snmp_cmd));
$snmp_output = str_replace("No Such Object available on this agent at this OID", "", $snmp_output);
$snmp_output = str_replace("No Such Instance currently exists at this OID", "", $snmp_output);
$snmp_output = str_replace("\"", "", $snmp_output);
list($ifAdminStatus, $ifOperStatus, $ifAlias, $ifName, $ifDescr) = explode("\n", $snmp_output);
$ifAdminStatus = translate_ifAdminStatus ($ifAdminStatus);
$ifOperStatus = translate_ifOperStatus ($ifOperStatus);
if ($ifAlias == " ") { $ifAlias = str_replace(" ", "", $ifAlias); }
$ifAlias = trim(str_replace("\"", "", $ifAlias));
$ifAlias = trim($ifAlias);
$ifDescr = trim(str_replace("\"", "", $ifDescr));
$ifDescr = trim($ifDescr);
$ifIndex = $interface['ifIndex'];
if ($portifIndex[$ifIndex]) {
if ($device['os'] == "CatOS") {
$cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-STACK-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portName." . $portifIndex[$ifIndex];
$ifAlias = trim(shell_exec($cmd));
}
}
if ($config['os'][$device[os]]['ifname']) { $ifDescr = $ifName; }
$rrdfile = $host_rrd . "/" . safename($interface['ifIndex'] . ".rrd");
if (!is_file($rrdfile)) {
rrdtool_create($rrdfile,"DS:INOCTETS:COUNTER:600:0:12500000000 \
DS:OUTOCTETS:COUNTER:600:0:12500000000 \
DS:INERRORS:COUNTER:600:0:12500000000 \
DS:OUTERRORS:COUNTER:600:0:12500000000 \
DS:INUCASTPKTS:COUNTER:600:0:12500000000 \
DS:OUTUCASTPKTS:COUNTER:600:0:12500000000 \
DS:INNUCASTPKTS:COUNTER:600:0:12500000000 \
DS:OUTNUCASTPKTS:COUNTER:600:0:12500000000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797");
}
if (file_exists("includes/polling/interface-" . $device['os'] . ".php") ) { include("includes/polling/interface-" . $device['os'] . ".php"); }
if ($interface['ifDescr'] != $ifDescr && $ifDescr != "" ) {
$update .= $seperator . "`ifDescr` = '$ifDescr'";
$seperator = ", ";
eventlog("ifDescr -> $ifDescr", $interface['device_id'], $interface['port_id']);
}
if ($interface['ifName'] != $ifName && $ifName != "" ) {
$update .= $seperator . "`ifName` = '$ifName'";
$seperator = ", ";
eventlog("ifName -> $ifName", $interface['device_id'], $interface['port_id']);
}
if ($interface['ifAlias'] != $ifAlias && $ifAlias != "" ) {
$update .= $seperator . "`ifAlias` = '".mres($ifAlias)."'";
$seperator = ", ";
eventlog("ifAlias -> $ifAlias", $interface['device_id'], $interface['port_id']);
}
if ($interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) {
$update .= $seperator . "`ifOperStatus` = '$ifOperStatus'";
$seperator = ", ";
eventlog("Interface went $ifOperStatus", $interface['device_id'], $interface['port_id']);
}
if ($interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) {
$update .= $seperator . "`ifAdminStatus` = '$ifAdminStatus'";
$seperator = ", ";
if ($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; }
eventlog("Interface $admin", $interface['device_id'], $interface['port_id']);
}
if ($update) {
$update_query = "UPDATE `ports` SET ";
$update_query .= $update;
$update_query .= " WHERE `port_id` = '" . $interface['port_id'] . "'";
#echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n");
$update_result = mysql_query($update_query);
} else {
# echo("Not Updating : " . $device['hostname'] ." $ifDescr ( " . $interface['ifDescr'] . " )\n\n");
}
if ($ifOperStatus == "up") {
$snmp_data_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_data_cmd .= " ifHCInOctets." . $interface['ifIndex'] . " ifHCOutOctets." . $interface['ifIndex'] . " ifInErrors." . $interface['ifIndex'];
$snmp_data_cmd .= " ifOutErrors." . $interface['ifIndex'] . " ifInUcastPkts." . $interface['ifIndex'] . " ifOutUcastPkts." . $interface['ifIndex'];
$snmp_data_cmd .= " ifInNUcastPkts." . $interface['ifIndex'] . " ifOutNUcastPkts." . $interface['ifIndex'];
$snmp_data = shell_exec($snmp_data_cmd);
$snmp_data = str_replace("Wrong Type (should be Counter32): ","", $snmp_data);
$snmp_data = str_replace("No Such Instance currently exists at this OID","", $snmp_data);
list($ifHCInOctets, $ifHCOutOctets, $ifInErrors, $ifOutErrors, $ifInUcastPkts, $ifOutUcastPkts, $ifInNUcastPkts, $ifOutNUcastPkts) = explode("\n", $snmp_data);
if ($ifHCInOctets == "" || strpos($ifHCInOctets, "No") !== FALSE ) {
$octets_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$octets_cmd .= " ifInOctets." . $interface['ifIndex'] . " ifOutOctets." . $interface['ifIndex'];
$octets = shell_exec($octets_cmd);
list ($ifHCInOctets, $ifHCOutOctets) = explode("\n", $octets);
}
$woo = "N:$ifHCInOctets:$ifHCOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts";
$ret = rrdtool_update("$rrdfile", $woo);
} else {
#echo("Interface " . $device['hostname'] . " " . $interface['ifDescr'] . " is down\n");
}
}
$rates = interface_rates ($rrdfile);
mysql_query("UPDATE `ports` SET in_rate = '" . $rates['in'] . "', out_rate = '" . $rates['out'] . "' WHERE port_id= '" . $interface['port_id'] . "'");
}
unset($portifIndex);
?>
-63
View File
@@ -1,63 +0,0 @@
#!/usr/bin/env php
<?php
include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
$device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` LIKE '%" . $argv[1] . "' AND disabled = '0' ORDER BY `device_id` DESC");
while ($device = mysql_fetch_assoc($device_query))
{
$port = $device['port'];
echo($device['hostname']. " ");
if (isPingable($device['hostname']))
{
$pos = snmp_get($device, "sysDescr.0", "-Oqv", "SNMPv2-MIB");
echo($device['protocol'].":".$device['hostname'].":".$device['port']." - ".$device['community']." ".$device['snmpver'].": ");
if ($pos == '')
{
$status='0';
} else {
$status='1';
}
} else {
$status='0';
}
if ($status == '1')
{
echo("Up\n");
} else {
echo("Down\n");
}
if ($status != $device['status'])
{
mysql_query("UPDATE `devices` SET `status`= '$status' WHERE `device_id` = '" . $device['device_id'] . "'");
if ($status == '1')
{
$stat = "Up";
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')");
if ($config['alerts']['email']['enable'])
{
notify($device, "Device Up: " . $device['hostname'], "Device Up: " . $device['hostname']);
}
} else {
$stat = "Down";
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')");
if ($config['alerts']['email']['enable'])
{
notify($device, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname']);
}
}
log_event("Device status changed to $stat", $device, strtolower($stat));
echo("Status Changed!\n");
}
}
?>
-46
View File
@@ -1,46 +0,0 @@
<?php
// FIXME there's a delete port function in the functions... merge?!
function delete_port($port_id)
{
$ipaddrs = mysql_query("SELECT * FROM `ipaddr` WHERE `port_id` = '$port_id'");
while ($ipaddr = mysql_fetch_assoc($ipaddrs))
{
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr']);
mysql_query("DELETE FROM addr WHERE id = '".$addr['id']."'");
echo("</div>");
}
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `port_id` = '$port_id'");
while ($ip6addr = mysql_fetch_assoc($ip6addrs))
{
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']);
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
echo("</div>");
}
$ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `port_id` = '$port_id'");
while ($ip6addr = mysql_fetch_assoc($ip6addrs))
{
echo("<div style='padding-left:8px; font-weight: normal;'>Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']);
mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'");
echo("</div>");
}
mysql_query("DELETE FROM `pseudowires` WHERE `port_id` = '$port_id'");
mysql_query("DELETE FROM `mac_accounting` WHERE `port_id` = '$port_id'");
mysql_query("DELETE FROM `links` WHERE `local_port_id` = '$port_id'");
mysql_query("DELETE FROM `links` WHERE `remote_port_id` = '$port_id'");
mysql_query("DELETE FROM `ports_perms` WHERE `port_id` = '$port_id'");
mysql_query("DELETE FROM `ports` WHERE `port_id` = '$port_id'");
}
$ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'");
while ($port = mysql_fetch_assoc($ports))
{
echo("<div style='font-weight: bold;'>Deleting port " . $port['port_id'] . " - " . $port['ifDescr']);
delete_port($port['port_id']);
echo("</div>");
}
?>
-26
View File
@@ -1,26 +0,0 @@
#!/usr/bin/php
<?php
include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
$search = $argv[1] . "$";
$data = trim(`cat ips-scanned.txt | grep alive | cut -d" " -f 1 | egrep $search`);
foreach (explode("\n", $data) as $ip)
{
$snmp = shell_exec("snmpget -t 0.2 -v2c -c ".$config['community']." $ip sysName.0");
if (strstr($snmp, "STRING"))
{
$hostname = trim(str_replace("SNMPv2-MIB::sysName.0 = STRING: ","", $snmp));
if (mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE hostname = '$hostname'"),0) == '0')
{
if (gethostbyname($hostname) == gethostbyname($hostname.".".$config['mydomain'])) { $hostname = $hostname . ".".$config['mydomain']; }
addHost($hostname, $community, 'v2c');
echo("Adding $hostname \n");
}
}
}
?>
-65
View File
@@ -1,65 +0,0 @@
<?php
$class = 'temperature';
$unit = 'C';
$query = "SELECT * FROM sensors WHERE sensor_class='$class' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$sensor_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($sensor_data))
{
echo("Checking temp " . $sensor['sensor_descr'] . "... ");
for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading
{
if ($debug) echo("Attempt $i ");
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
$sensor_value = trim(str_replace("\"", "", $sensor_value));
if ($sensor_value != 9999) break; # TME sometimes sends 999.9 when it is right in the middle of an update;
sleep(1); # Give the TME some time to reset
}
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
$rrd_file = get_sensor_rrd($device, $sensor);
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
RRA:AVERAGE:0.5:24:775 \
RRA:AVERAGE:0.5:288:797 \
RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 \
RRA:MAX:0.5:24:775 \
RRA:MAX:0.5:288:797\
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797");
}
echo("$sensor_value $unit\n");
rrdtool_update($rrd_file,"N:$sensor_value");
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'])
{
$msg = "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . " (Limit " . $sensor['sensor_limit'] . ")";
notify($device, "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Temperature ' . $sensor['sensor_descr'] . " over threshold: " . $sensor_value . " " . html_entity_decode('&deg;') . "$unit (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('&deg;') . "$unit)", $device, $class, $sensor['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'");
}
?>
-386
View File
@@ -1,386 +0,0 @@
<?php
// FIXME not used, do we still need this?
function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
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 = $config['rrd_dir'] . "/" . $rrd . "-mailstats.rrd";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
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 = $config['rrd_dir'] . "/" . $rrd;
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024";
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";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
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";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$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:".$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:";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$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:".$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:";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config;
$database = $config['rrd_dir'] . "/" . $rrd;
$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:".$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";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
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";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
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:";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024 -l 0";
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'");
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Size\ \ \ \ \ \ Used\ \ \ \ %age\l";
while($fs = mysql_fetch_array($sql)) {
$hostname = gethostbyid($fs['device_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[storage_descr], 14);
$descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['storage_descr']);
$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";
$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++;
}
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0";
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:";
$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";
shell_exec($config['rrdtool'] . " graph $graph $options");
return $graph;
}
-52
View File
@@ -1,52 +0,0 @@
<?php
$class = 'voltage';
$class_text = "Voltage";
$unit = 'V';
foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `poller_type` = 'snmp'", array($class, $device['device_id'])) as $sensor)
{
echo("Checking ".$class." " . $sensor['sensor_descr'] . ": ");
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
$rrd_file = get_sensor_rrd($device, $sensor);
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400");
}
echo("$sensor_value $unit\n");
rrdtool_update($rrd_file,"N:$sensor_value");
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value <= $sensor['sensor_limit_low'])
{
$msg = $class_text . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit'] . "$unit)";
notify($device, $class_text . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event($class_text.' '.$sensor['sensor_descr'] . " under threshold: " . $sensor_value . " $unit (< " . $sensor['sensor_limit_low'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'])
{
$msg = $class_text." Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit'] .= "$unit)";
notify($device, $class_text . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event($class_text." ". $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
dbUpdate(array('sensor_current' => $sensor_value), 'sensors', '`sensor_id` = ', array($sensor['sensor_id']));
}
?>