mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
revert r1957 patch
git-svn-id: http://www.observium.org/svn/observer/trunk@1960 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
101
addhost.php
101
addhost.php
@@ -7,65 +7,66 @@ include("includes/functions.php");
|
||||
|
||||
if (isset($argv[1]) && $argv[1])
|
||||
{
|
||||
$host = strtolower($argv[1]);
|
||||
$community = $argv[2];
|
||||
$snmpver = strtolower($argv[3]);
|
||||
$host = strtolower($argv[1]);
|
||||
$community = $argv[2];
|
||||
$snmpver = strtolower($argv[3]);
|
||||
|
||||
if (is_numeric($argv[4]))
|
||||
{
|
||||
$port = $argv[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
$port = 161;
|
||||
}
|
||||
if (is_numeric($argv[4]))
|
||||
{
|
||||
$port = $argv[4];
|
||||
}
|
||||
else
|
||||
{
|
||||
$port = 161;
|
||||
}
|
||||
|
||||
if (@!$argv[5])
|
||||
{
|
||||
$transport = 'udp';
|
||||
}
|
||||
else
|
||||
{
|
||||
$transport = $argv[5];
|
||||
}
|
||||
if (@!$argv[5])
|
||||
{
|
||||
$transport = 'udp';
|
||||
}
|
||||
else
|
||||
{
|
||||
$transport = $argv[5];
|
||||
}
|
||||
|
||||
if (!$snmpver) $snmpver = "v2c";
|
||||
if (!$snmpver) $snmpver = "v2c";
|
||||
|
||||
if ($community)
|
||||
{
|
||||
unset($config['snmp']['community']);
|
||||
$config['snmp']['community'][] = $community;
|
||||
}
|
||||
if ($community)
|
||||
{
|
||||
unset($config['snmp']['community']);
|
||||
$config['snmp']['community'][] = $community;
|
||||
}
|
||||
|
||||
list($hostshort) = explode(".", $host);
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' )
|
||||
list($hostshort) = explode(".", $host);
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' )
|
||||
{
|
||||
if (isDomainResolves($argv[1]))
|
||||
{
|
||||
if (isDomainResolves($argv[1]))
|
||||
if (isPingable($argv[1]))
|
||||
{
|
||||
$added = 0;
|
||||
|
||||
foreach ($config['snmp']['community'] as $community)
|
||||
{
|
||||
if (isPingable($argv[1]))
|
||||
$device = deviceArray($host, $community, $snmpver, $port, $transport);
|
||||
|
||||
if (isSNMPable($device))
|
||||
{
|
||||
$snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
|
||||
|
||||
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host)))
|
||||
{
|
||||
$added = 0;
|
||||
$added = createHost ($host, $community, $snmpver, $port, $transport);
|
||||
if($added) { echo($added . "\n"); break; }
|
||||
|
||||
foreach ($config['snmp']['community'] as $community)
|
||||
{
|
||||
$device = deviceArray($host, $community, $snmpver, $port, $transport);
|
||||
} else { echo("Given hostname does not match SNMP-read hostname ($snmphost)!\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
if (isSNMPable($device))
|
||||
{
|
||||
$snmphost = snmp_get($device, "sysName.0", "-Oqv", "SNMPv2-MIB");
|
||||
if ($snmphost == "" || ($snmphost && ($snmphost == $host || $hostshort = $host)))
|
||||
{
|
||||
$added = createHost ($host, $community, $snmpver, $port, $transport);
|
||||
if($added) { echo($added . "\n"); break; }
|
||||
|
||||
} else { echo("Given hostname does not match SNMP-read hostname ($snmphost)!\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
if (!$added) { echo("Could not reach $host with given SNMP community\n"); }
|
||||
} else { echo("Could not ping $host\n"); }
|
||||
} else { echo("Could not resolve $host\n"); }
|
||||
} else { echo("Already got host $host\n"); }
|
||||
if (!$added) { echo("Could not reach $host with given SNMP community\n"); }
|
||||
} else { echo("Could not ping $host\n"); }
|
||||
} else { echo("Could not resolve $host\n"); }
|
||||
} else { echo("Already got host $host\n"); }
|
||||
} else { echo("Add Host Tool\nUsage: ./addhost.php <hostname> [community] [v1|v2c] [port] [" . join("|",$config['snmp']['transports']) . "]\n"); }
|
||||
|
||||
?>
|
||||
?>
|
36
adduser.php
36
adduser.php
@@ -7,38 +7,38 @@ include("includes/functions.php");
|
||||
|
||||
if (file_exists('html/includes/authentication/' . $config['auth_mechanism'] . '.inc.php'))
|
||||
{
|
||||
include('html/includes/authentication/' . $config['auth_mechanism'] . '.inc.php');
|
||||
include('html/includes/authentication/' . $config['auth_mechanism'] . '.inc.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("ERROR: no valid auth_mechanism defined.\n");
|
||||
exit();
|
||||
echo("ERROR: no valid auth_mechanism defined.\n");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (auth_usermanagement())
|
||||
{
|
||||
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]))
|
||||
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]))
|
||||
{
|
||||
if (!user_exists($argv[1]))
|
||||
{
|
||||
if (!user_exists($argv[1]))
|
||||
{
|
||||
if (adduser($argv[1],$argv[2],$argv[3],@$argv[4]))
|
||||
{
|
||||
echo("User ".$argv[1]." added successfully\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("User ".$argv[1]." already exists!\n");
|
||||
}
|
||||
if (adduser($argv[1],$argv[2],$argv[3],@$argv[4]))
|
||||
{
|
||||
echo("User ".$argv[1]." added successfully\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10> [email]\n");
|
||||
echo("User ".$argv[1]." already exists!\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("Add User Tool\nUsage: ./adduser.php <username> <password> <level 1-10> [email]\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("Auth module does not allow adding users!\n");
|
||||
echo("Auth module does not allow adding users!\n");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
18
alerts.php
18
alerts.php
@@ -8,19 +8,19 @@ include("includes/functions.php");
|
||||
$alert_query = mysql_query("SELECT *, A.id as id FROM `alerts` as A, `devices` as D where A.device_id = D.device_id AND alerted = '0'");
|
||||
while ($alert = mysql_fetch_array($alert_query))
|
||||
{
|
||||
$id = $alert['id'];
|
||||
$host = $alert['hostname'];
|
||||
$date = $alert['time_logged'];
|
||||
$msg = $alert['message'];
|
||||
$alert_text .= "$date $host $msg";
|
||||
$id = $alert['id'];
|
||||
$host = $alert['hostname'];
|
||||
$date = $alert['time_logged'];
|
||||
$msg = $alert['message'];
|
||||
$alert_text .= "$date $host $msg";
|
||||
|
||||
mysql_query("UPDATE `alerts` SET alerted = '1' WHERE `id` = '$id'");
|
||||
mysql_query("UPDATE `alerts` SET alerted = '1' WHERE `id` = '$id'");
|
||||
}
|
||||
|
||||
if ($alert_text)
|
||||
{
|
||||
echo("$alert_text");
|
||||
# `echo '$alert_text' | gnokii --sendsms <NUMBER>`;
|
||||
echo("$alert_text");
|
||||
# `echo '$alert_text' | gnokii --sendsms <NUMBER>`;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -15,28 +15,28 @@ $interface_query = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE
|
||||
|
||||
while ($interface = mysql_fetch_array($interface_query))
|
||||
{
|
||||
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
|
||||
if ($errors > '1')
|
||||
{
|
||||
$errored[] = $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta'];
|
||||
}
|
||||
$i++;
|
||||
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
|
||||
if ($errors > '1')
|
||||
{
|
||||
$errored[] = $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta'];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo("Checked $i Interfaces\n");
|
||||
|
||||
if ($errored)
|
||||
{ ## If there are errored ports
|
||||
$i=0;
|
||||
$msg = "Interfaces with errors : \n\n";
|
||||
$i = 0;
|
||||
$msg = "Interfaces with errors : \n\n";
|
||||
|
||||
foreach ($errored as $int)
|
||||
{
|
||||
$msg .= "$int\n"; ## Add a line to the report email warning about them
|
||||
$i++;
|
||||
}
|
||||
## Send the alert email
|
||||
notify($device, "Observium detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
|
||||
foreach ($errored as $int)
|
||||
{
|
||||
$msg .= "$int\n"; ## Add a line to the report email warning about them
|
||||
$i++;
|
||||
}
|
||||
## Send the alert email
|
||||
notify($device, "Observium detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -6,63 +6,65 @@ include("includes/functions.php");
|
||||
|
||||
$sql = "SELECT * FROM devices AS D, services AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
while ($service = mysql_fetch_array($query))
|
||||
{
|
||||
if ($service['status'] = "1")
|
||||
if ($service['status'] = "1")
|
||||
{
|
||||
unset($check, $service_status, $time, $status);
|
||||
$service_status = $service['service_status'];
|
||||
$service_type = strtolower($service['service_type']);
|
||||
$service_param = $service['service_param'];
|
||||
$checker_script = $config['install_dir'] . "/includes/services/" . $service_type . "/check.inc";
|
||||
|
||||
if (is_file($checker_script))
|
||||
{
|
||||
unset($check, $service_status, $time, $status);
|
||||
$service_status = $service['service_status'];
|
||||
$service_type = strtolower($service['service_type']);
|
||||
$service_param = $service['service_param'];
|
||||
$checker_script = $config['install_dir'] . "/includes/services/" . $service_type . "/check.inc";
|
||||
|
||||
if (is_file($checker_script))
|
||||
{
|
||||
include($checker_script);
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = "2";
|
||||
$check = "Error : Script not found ($checker_script)";
|
||||
}
|
||||
|
||||
if ($service_status != $status)
|
||||
{
|
||||
$updated = ", `service_changed` = '" . time() . "' ";
|
||||
if ($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; }
|
||||
if ($status == "1")
|
||||
{
|
||||
$msg = "Service Up: " . $service['service_type'] . " on " . $service['hostname'];
|
||||
$msg .= " at " . date($config['timestamp_format']);
|
||||
notify($device, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg);
|
||||
}
|
||||
elseif ($status == "0")
|
||||
{
|
||||
$msg = "Service Down: " . $service['service_type'] . " on " . $service['hostname'];
|
||||
$msg .= " at " . date($config['timestamp_format']);
|
||||
notify($device, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg);
|
||||
}
|
||||
} else { unset($updated); }
|
||||
|
||||
$update_sql = "UPDATE `services` SET `service_status` = '$status', `service_message` = '" . addslashes($check) . "', `service_checked` = '" . time() . "' $updated WHERE `service_id` = '" . $service['service_id']. "'";
|
||||
mysql_query($update_sql);
|
||||
} else {
|
||||
$status = "0";
|
||||
include($checker_script);
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = "2";
|
||||
$check = "Error : Script not found ($checker_script)";
|
||||
}
|
||||
|
||||
$rrd = $config['rrd_dir'] . "/" . $service['hostname'] . "/" . safename("service-" . $service['service_type'] . "-" . $service['service_id'] . ".rrd");
|
||||
|
||||
if (!is_file($rrd))
|
||||
if ($service_status != $status)
|
||||
{
|
||||
rrdtool_create($rrd,"--step 300 \
|
||||
DS:status:GAUGE:600:0:1 \
|
||||
RRA:AVERAGE:0.5:1:1200 \
|
||||
RRA:AVERAGE:0.5:12:2400");
|
||||
}
|
||||
$updated = ", `service_changed` = '" . time() . "' ";
|
||||
if ($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; }
|
||||
if ($status == "1")
|
||||
{
|
||||
$msg = "Service Up: " . $service['service_type'] . " on " . $service['hostname'];
|
||||
$msg .= " at " . date($config['timestamp_format']);
|
||||
notify($device, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg);
|
||||
}
|
||||
elseif ($status == "0")
|
||||
{
|
||||
$msg = "Service Down: " . $service['service_type'] . " on " . $service['hostname'];
|
||||
$msg .= " at " . date($config['timestamp_format']);
|
||||
notify($device, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg);
|
||||
}
|
||||
} else { unset($updated); }
|
||||
|
||||
if ($status == "1" || $status == "0")
|
||||
{
|
||||
rrdtool_update($rrd,"N:".$status);
|
||||
}
|
||||
$update_sql = "UPDATE `services` SET `service_status` = '$status', `service_message` = '" . addslashes($check) . "', `service_checked` = '" . time() . "' $updated WHERE `service_id` = '" . $service['service_id']. "'";
|
||||
mysql_query($update_sql);
|
||||
} else {
|
||||
$status = "0";
|
||||
}
|
||||
|
||||
$rrd = $config['rrd_dir'] . "/" . $service['hostname'] . "/" . safename("service-" . $service['service_type'] . "-" . $service['service_id'] . ".rrd");
|
||||
|
||||
if (!is_file($rrd))
|
||||
{
|
||||
rrdtool_create($rrd,"--step 300 \
|
||||
DS:status:GAUGE:600:0:1 \
|
||||
RRA:AVERAGE:0.5:1:1200 \
|
||||
RRA:AVERAGE:0.5:12:2400");
|
||||
}
|
||||
|
||||
if ($status == "1" || $status == "0")
|
||||
{
|
||||
rrdtool_update($rrd,"N:".$status);
|
||||
}
|
||||
} # while
|
||||
?>
|
||||
|
||||
?>
|
170
cleanup.php
170
cleanup.php
@@ -8,23 +8,24 @@ include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$query = "SELECT *,A.id as id FROM ipv4_addresses AS A, ports as I, devices as D
|
||||
WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'";
|
||||
WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'";
|
||||
|
||||
$data = mysql_query($query);
|
||||
|
||||
while ($row = mysql_fetch_array($data))
|
||||
{
|
||||
$addr = Net_IPv4::parseAddress($row['ipv4_address']."/".$row['ipv4_prefixlen']);
|
||||
$mask = $addr->netmask;
|
||||
$response = explode(" ", snmp_get($row, "ipAdEntIfIndex.".$row['ipv4_address'], "-Osq"));
|
||||
$response = $response[1];
|
||||
$maskcheck = explode(" ", snmp_get($row, "ipAdEntNetMask.".$row['ipv4_address'], "-Osq"));
|
||||
$maskcheck = $maskcheck[1];
|
||||
$addr = Net_IPv4::parseAddress($row['ipv4_address']."/".$row['ipv4_prefixlen']);
|
||||
$mask = $addr->netmask;
|
||||
$response = explode(" ", snmp_get($row, "ipAdEntIfIndex.".$row['ipv4_address'], "-Osq"));
|
||||
$response = $response[1];
|
||||
$maskcheck = explode(" ", snmp_get($row, "ipAdEntNetMask.".$row['ipv4_address'], "-Osq"));
|
||||
$maskcheck = $maskcheck[1];
|
||||
|
||||
if ($response != $row['ifIndex'] || $mask != $maskcheck)
|
||||
{
|
||||
mysql_query("delete from ipv4_address where id = '".$row['ipv4_address_id']."'");
|
||||
echo("Deleted ".$row['ipv4_address']." from $row[hostname]\n");
|
||||
}
|
||||
if ($response != $row['ifIndex'] || $mask != $maskcheck)
|
||||
{
|
||||
mysql_query("delete from ipv4_address where id = '".$row['ipv4_address_id']."'");
|
||||
echo("Deleted ".$row['ipv4_address']." from $row[hostname]\n");
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM devices WHERE status = '1'";
|
||||
@@ -32,113 +33,120 @@ $query = mysql_query($sql);
|
||||
|
||||
while ($device = mysql_fetch_array($query))
|
||||
{
|
||||
echo($device['hostname'] . " \n\n");
|
||||
echo($device['hostname'] . " \n\n");
|
||||
|
||||
$oids = snmp_walk($device, "ipAddressIfIndex.ipv6", "-Osq");
|
||||
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids);
|
||||
$oids = str_replace("\"", "", $oids); $oids = trim($oids);
|
||||
$oids = snmp_walk($device, "ipAddressIfIndex.ipv6", "-Osq");
|
||||
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids);
|
||||
$oids = str_replace("\"", "", $oids); $oids = trim($oids);
|
||||
|
||||
unset($valid_ips);
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
list($ipv6addr,$ifIndex) = explode(" ", $data);
|
||||
$valid_ips[] = $ipv6addr;
|
||||
}
|
||||
$sql = "SELECT * FROM ip6addr AS A, ports AS I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'";
|
||||
$data = mysql_query($sql);
|
||||
while ($row = mysql_fetch_array($data))
|
||||
unset($valid_ips);
|
||||
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
list($ipv6addr,$ifIndex) = explode(" ", $data);
|
||||
$valid_ips[] = $ipv6addr;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM ip6addr AS A, ports AS I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'";
|
||||
$data = mysql_query($sql);
|
||||
|
||||
while ($row = mysql_fetch_array($data))
|
||||
{
|
||||
echo($row['ipv6_address'] . "\n");
|
||||
unset($valid);
|
||||
foreach ($valid_ips as $valid_ip)
|
||||
{
|
||||
echo($row['ipv6_address'] . "\n");
|
||||
unset($valid);
|
||||
foreach ($valid_ips as $valid_ip)
|
||||
{
|
||||
echo($row['ipv6_address'] . " = $valid_ip ? \n");
|
||||
}
|
||||
echo($row['ipv6_address'] . " = $valid_ip ? \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query = "SELECT * FROM ports AS I, devices as D WHERE I.device_id = D.device_id AND D.status = '1'";
|
||||
$data = mysql_query($query);
|
||||
|
||||
while ($row = mysql_fetch_array($data))
|
||||
{
|
||||
$index = $row['ifIndex'];
|
||||
$index = $row['ifIndex'];
|
||||
|
||||
$response = explode(" ", snmp_get($row, "ifIndex.$index", "-Osq"));
|
||||
$response = $response[1];
|
||||
$response = explode(" ", snmp_get($row, "ifIndex.$index", "-Osq"));
|
||||
$response = $response[1];
|
||||
|
||||
if ($response != $index)
|
||||
{
|
||||
mysql_query("DELETE from ports where interface_id = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `adjacencies` WHERE `interface_id` = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `links` WHERE `local_interface_id` = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `links` WHERE `remote_interface_id` = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `ipaddr` WHERE `interface_id` = '" . $row['interface_id'] . "'");
|
||||
echo("Removed interface " . $row['ifDescr'] . " from " . $row['hostname'] . "<br />");
|
||||
}
|
||||
if ($response != $index)
|
||||
{
|
||||
mysql_query("DELETE from ports where interface_id = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `adjacencies` WHERE `interface_id` = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `links` WHERE `local_interface_id` = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `links` WHERE `remote_interface_id` = '" . $row['interface_id'] . "'");
|
||||
mysql_query("DELETE from `ipaddr` WHERE `interface_id` = '" . $row['interface_id'] . "'");
|
||||
echo("Removed interface " . $row['ifDescr'] . " from " . $row['hostname'] . "<br />");
|
||||
}
|
||||
}
|
||||
|
||||
echo(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports`"), 0) . " ports at start\n");
|
||||
$interface_query = mysql_query("SELECT interface_id,device_id FROM `ports`");
|
||||
|
||||
while ($interface = mysql_fetch_array($interface_query))
|
||||
{
|
||||
$device_id = $interface['device_id'];
|
||||
$interface_id = $interface['interface_id'];
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `device_id` = '$device_id'"), 0) == '0')
|
||||
{
|
||||
mysql_query("delete from ports where `interface_id` = '$interface_id'");
|
||||
echo("Deleting if $interface_id \n");
|
||||
}
|
||||
$device_id = $interface['device_id'];
|
||||
$interface_id = $interface['interface_id'];
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `device_id` = '$device_id'"), 0) == '0')
|
||||
{
|
||||
mysql_query("delete from ports where `interface_id` = '$interface_id'");
|
||||
echo("Deleting if $interface_id \n");
|
||||
}
|
||||
}
|
||||
|
||||
echo(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports`"), 0) . " ports at end\n");
|
||||
|
||||
echo(mysql_result(mysql_query("SELECT COUNT(id) FROM `links`"), 0) . " links at start\n");
|
||||
$link_query = mysql_query("SELECT id,local_interface_id,remote_interface_id FROM `links`");
|
||||
|
||||
while ($link = mysql_fetch_array($link_query))
|
||||
{
|
||||
$id = $link['id'];
|
||||
$src = $link['local_interface_id'];
|
||||
$dst = $link['remote_interface_id'];
|
||||
if (mysql_result(mysql_query("SELECT COUNT(interface_id) FROM `ports` WHERE `interface_id` = '$src'"), 0) == '0' || mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `interface_id` = '$dst'"), 0) == '0')
|
||||
{
|
||||
mysql_query("delete from links where `id` = '$id'");
|
||||
echo("Deleting link $id \n");
|
||||
}
|
||||
$id = $link['id'];
|
||||
$src = $link['local_interface_id'];
|
||||
$dst = $link['remote_interface_id'];
|
||||
if (mysql_result(mysql_query("SELECT COUNT(interface_id) FROM `ports` WHERE `interface_id` = '$src'"), 0) == '0' || mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `interface_id` = '$dst'"), 0) == '0')
|
||||
{
|
||||
mysql_query("delete from links where `id` = '$id'");
|
||||
echo("Deleting link $id \n");
|
||||
}
|
||||
}
|
||||
echo(mysql_result(mysql_query("SELECT COUNT(id) FROM `links`"), 0) . " links at end\n");
|
||||
|
||||
echo(mysql_result(mysql_query("SELECT COUNT(adj_id) FROM `adjacencies`"), 0) . " adjacencies at start\n");
|
||||
$link_query = mysql_query("SELECT * FROM `adjacencies` AS A, `ports` AS I, `devices` AS D, networks AS N WHERE I.interface_id = A.interface_id AND D.device_id = I.device_id AND N.id = A.network_id");
|
||||
|
||||
while ($link = mysql_fetch_array($link_query))
|
||||
{
|
||||
$id = $link['adj_id'];
|
||||
$netid = $link['network_id'];
|
||||
$ifid = $link['interface_id'];
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `interface_id` = '$ifid'"), 0) == '0' || mysql_result(mysql_query("SELECT COUNT(id) FROM `networks` WHERE `id` = '$netid'"), 0) == '0')
|
||||
$id = $link['adj_id'];
|
||||
$netid = $link['network_id'];
|
||||
$ifid = $link['interface_id'];
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `interface_id` = '$ifid'"), 0) == '0' || mysql_result(mysql_query("SELECT COUNT(id) FROM `networks` WHERE `id` = '$netid'"), 0) == '0')
|
||||
{
|
||||
$remove = 1;
|
||||
echo("Removed Interface!\n");
|
||||
}
|
||||
|
||||
list($network, $cidr) = explode("/", $link['cidr']);
|
||||
|
||||
$checksql = "SELECT COUNT(*) FROM `ipaddr` WHERE `interface_id` = '" . $link['interface_id'] . "' AND `cidr` = '$cidr' AND `network` = '$network'";
|
||||
if (mysql_result(mysql_query($checksql),0) == 0) { $remove = 1; }
|
||||
|
||||
# echo($link['if'] . " (" . $link['interface_id'] . ") -> " . $link['cidr'] . " \n");
|
||||
|
||||
if ($link['cidr'] == "") { $remove = 1; echo("Broken CIDR entry!"); }
|
||||
|
||||
if ($remove)
|
||||
{
|
||||
$remove = 1;
|
||||
echo("Removed Interface!\n");
|
||||
mysql_query("delete from adjacencies where `adj_id` = '$id'");
|
||||
echo("Deleting link $id (".$link['cidr']." - ". $link['hostname'] ." - ". $link['ifDescr'] .")\n");
|
||||
}
|
||||
|
||||
list($network, $cidr) = explode("/", $link['cidr']);
|
||||
|
||||
$checksql = "SELECT COUNT(*) FROM `ipaddr` WHERE `interface_id` = '" . $link['interface_id'] . "' AND `cidr` = '$cidr' AND `network` = '$network'";
|
||||
if (mysql_result(mysql_query($checksql),0) == 0) { $remove = 1; }
|
||||
|
||||
# echo($link['if'] . " (" . $link['interface_id'] . ") -> " . $link['cidr'] . " \n");
|
||||
|
||||
if ($link['cidr'] == "") { $remove = 1; echo("Broken CIDR entry!"); }
|
||||
|
||||
if ($remove)
|
||||
{
|
||||
mysql_query("delete from adjacencies where `adj_id` = '$id'");
|
||||
echo("Deleting link $id (".$link['cidr']." - ". $link['hostname'] ." - ". $link['ifDescr'] .")\n");
|
||||
}
|
||||
|
||||
unset($remove);
|
||||
unset($remove);
|
||||
}
|
||||
|
||||
echo(mysql_result(mysql_query("SELECT COUNT(adj_id) FROM `adjacencies`"), 0) . " adjacencies at end\n");
|
||||
|
||||
?>
|
||||
?>
|
@@ -23,12 +23,7 @@ $config['log_file'] = $config['install_dir'] . "/observium.log";
|
||||
#$config['rrdcached'] = "unix:/var/run/rrdcached.sock";
|
||||
|
||||
### Default community
|
||||
$config['snmp']['community'][] = "public";
|
||||
|
||||
### Enable php_snmp
|
||||
# Enable php_snmp functions to make gets faster
|
||||
# Often doesn't work, because jwh can't code for shit,
|
||||
$config['snmp']['internal'] = false;
|
||||
$config['snmp']['community'] = array("public");
|
||||
|
||||
### Authentication Model
|
||||
$config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
|
||||
|
@@ -11,57 +11,57 @@ $db = mysql_select_db($config['db_name'], $link);
|
||||
$query = "SELECT * FROM ipaddr AS A, ports as I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.os = 'ios'";
|
||||
$data = mysql_query($query, $link);
|
||||
while($ip = mysql_fetch_array($data)) {
|
||||
unset($sub);
|
||||
$hostname = $ip['hostname'];
|
||||
unset($sub);
|
||||
$hostname = $ip['hostname'];
|
||||
|
||||
$real_hostname = $hostname;
|
||||
$real_hostname = $hostname;
|
||||
|
||||
$hostname = str_replace(".jtibs.net", "", $hostname);
|
||||
$hostname = str_replace(".wtibs.net", "", $hostname);
|
||||
$hostname = str_replace(".jerseytelecom.net", "", $hostname);
|
||||
$hostname = str_replace(".jtibs.net", "", $hostname);
|
||||
$hostname = str_replace(".wtibs.net", "", $hostname);
|
||||
$hostname = str_replace(".jerseytelecom.net", "", $hostname);
|
||||
|
||||
list($cc, $loc, $host) = explode(".", $hostname);
|
||||
if($host) {
|
||||
$hostname = "$host.$loc.$cc.v4.jerseytelecom.net";
|
||||
} else {
|
||||
$host = $cc; unset ($cc);
|
||||
$hostname = "$host.v4.jerseytelecom.net";
|
||||
}
|
||||
list($cc, $loc, $host) = explode(".", $hostname);
|
||||
if($host) {
|
||||
$hostname = "$host.$loc.$cc.v4.jerseytelecom.net";
|
||||
} else {
|
||||
$host = $cc; unset ($cc);
|
||||
$hostname = "$host.v4.jerseytelecom.net";
|
||||
}
|
||||
|
||||
$interface = $ip['ifDescr'];
|
||||
$address = $ip['addr'];
|
||||
$cidr = $ip['cidr'];
|
||||
$interface = strtolower(makeshortif(fixifname($interface)));
|
||||
$interface = str_replace("/", "-", $interface);
|
||||
$interface = str_replace(":", "_", $interface);
|
||||
list($interface, $sub) = explode(".", $interface);
|
||||
if($sub) {
|
||||
$sub = str_replace(" ", "", $sub);
|
||||
$sub = str_replace("aal5", "", $sub);
|
||||
$interface = "$sub.$interface";
|
||||
}
|
||||
$hostip = trim(gethostbyname($real_hostname));
|
||||
$interface = $ip['ifDescr'];
|
||||
$address = $ip['addr'];
|
||||
$cidr = $ip['cidr'];
|
||||
$interface = strtolower(makeshortif(fixifname($interface)));
|
||||
$interface = str_replace("/", "-", $interface);
|
||||
$interface = str_replace(":", "_", $interface);
|
||||
list($interface, $sub) = explode(".", $interface);
|
||||
if($sub) {
|
||||
$sub = str_replace(" ", "", $sub);
|
||||
$sub = str_replace("aal5", "", $sub);
|
||||
$interface = "$sub.$interface";
|
||||
}
|
||||
$hostip = trim(gethostbyname($real_hostname));
|
||||
|
||||
list($first, $second, $third, $fourth) = explode(".", $address);
|
||||
$revzone = "$third.$second.$first.in-addr.arpa";
|
||||
$reverse = "$fourth.$revzone";
|
||||
$dnsname = "$interface.$hostname";
|
||||
list($first, $second, $third, $fourth) = explode(".", $address);
|
||||
$revzone = "$third.$second.$first.in-addr.arpa";
|
||||
$reverse = "$fourth.$revzone";
|
||||
$dnsname = "$interface.$hostname";
|
||||
|
||||
$dns_list[] = str_pad($revzone, 24) . "|" . str_pad($reverse, 30)."IN ADDR ".str_pad($dnsname, 30);
|
||||
$dns_list[] = str_pad($revzone, 24) . "|" . str_pad($reverse, 30)."IN ADDR ".str_pad($dnsname, 30);
|
||||
|
||||
}
|
||||
|
||||
sort ($dns_list);
|
||||
|
||||
foreach ($dns_list as $entry) {
|
||||
list($zone, $entry) = explode("|", $entry);
|
||||
$zone = trim($zone);
|
||||
list($zone, $entry) = explode("|", $entry);
|
||||
$zone = trim($zone);
|
||||
|
||||
if($zone != $oldzone) { echo("\n$$zone\n------------------------------\n"); }
|
||||
if($zone != $oldzone) { echo("\n$$zone\n------------------------------\n"); }
|
||||
|
||||
echo("$entry \n");
|
||||
echo("$entry \n");
|
||||
|
||||
$oldzone = $zone;
|
||||
$oldzone = $zone;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -15,143 +15,143 @@ $db = mysql_select_db($config['db_name'], $link);
|
||||
$query = "SELECT * FROM ipaddr AS A, ports as I, devices as D WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.hostname LIKE '%.vostron.net' AND D.hostname NOT LIKE '%.cust.%' AND D.os = 'ios'";
|
||||
$data = mysql_query($query, $link);
|
||||
while($ip = mysql_fetch_array($data)) {
|
||||
unset($sub);
|
||||
$hostname = $ip['hostname'];
|
||||
unset($sub);
|
||||
$hostname = $ip['hostname'];
|
||||
|
||||
$real_hostname = $hostname;
|
||||
$real_hostname = $hostname;
|
||||
|
||||
$hostname = str_replace(".vostron.net", "", $hostname);
|
||||
list($loc, $host) = explode("-", $hostname);
|
||||
if($host) {
|
||||
$hostname = "$host.$loc.v4.vostron.net";
|
||||
} else {
|
||||
$host = $loc; unset ($loc);
|
||||
$hostname = "$host.v4.vostron.net";
|
||||
}
|
||||
$hostname = str_replace(".vostron.net", "", $hostname);
|
||||
list($loc, $host) = explode("-", $hostname);
|
||||
if($host) {
|
||||
$hostname = "$host.$loc.v4.vostron.net";
|
||||
} else {
|
||||
$host = $loc; unset ($loc);
|
||||
$hostname = "$host.v4.vostron.net";
|
||||
}
|
||||
|
||||
$interface = $ip['ifDescr'];
|
||||
$address = $ip['addr'];
|
||||
$cidr = $ip['cidr'];
|
||||
$interface = strtolower(makeshortif(fixifname($interface)));
|
||||
$interface = str_replace("/", "-", $interface);
|
||||
list($interface, $sub) = explode(".", $interface);
|
||||
if($sub) {
|
||||
$sub = str_replace(" ", "", $sub);
|
||||
$sub = str_replace("aal5", "", $sub);
|
||||
$interface = "$sub.$interface";
|
||||
}
|
||||
$hostip = trim(gethostbyname($real_hostname));
|
||||
if(strstr($hostname, ".vostron.net")) {
|
||||
list($first, $second, $third, $fourth) = explode(".", $address);
|
||||
$revzone = "$third.$second.$first.in-addr.arpa";
|
||||
$reverse = "$fourth.$revzone";
|
||||
$dnsname = "$interface.$hostname";
|
||||
$rev_sql = "SELECT `domain_id` FROM `domains` WHERE domain = '" . $revzone . "'";
|
||||
$rev_domain_id = @mysql_result(mysql_query($rev_sql, $dnsdblink),0);
|
||||
$interface = $ip['ifDescr'];
|
||||
$address = $ip['addr'];
|
||||
$cidr = $ip['cidr'];
|
||||
$interface = strtolower(makeshortif(fixifname($interface)));
|
||||
$interface = str_replace("/", "-", $interface);
|
||||
list($interface, $sub) = explode(".", $interface);
|
||||
if($sub) {
|
||||
$sub = str_replace(" ", "", $sub);
|
||||
$sub = str_replace("aal5", "", $sub);
|
||||
$interface = "$sub.$interface";
|
||||
}
|
||||
$hostip = trim(gethostbyname($real_hostname));
|
||||
if(strstr($hostname, ".vostron.net")) {
|
||||
list($first, $second, $third, $fourth) = explode(".", $address);
|
||||
$revzone = "$third.$second.$first.in-addr.arpa";
|
||||
$reverse = "$fourth.$revzone";
|
||||
$dnsname = "$interface.$hostname";
|
||||
$rev_sql = "SELECT `domain_id` FROM `domains` WHERE domain = '" . $revzone . "'";
|
||||
$rev_domain_id = @mysql_result(mysql_query($rev_sql, $dnsdblink),0);
|
||||
|
||||
|
||||
$rows_exist = mysql_result(mysql_query("SELECT COUNT(record_id) FROM `records` WHERE `host` = '$reverse'", $dnsdblink),0);
|
||||
$rows_exist = mysql_result(mysql_query("SELECT COUNT(record_id) FROM `records` WHERE `host` = '$reverse'", $dnsdblink),0);
|
||||
|
||||
if($rows_exist > '1') { $rows_exist = 1; echo("DELETE FROM `records` WHERE `host` = '$reverse' LIMIT $rows_exist;\n"); }
|
||||
if($rows_exist > '1') { $rows_exist = 1; echo("DELETE FROM `records` WHERE `host` = '$reverse' LIMIT $rows_exist;\n"); }
|
||||
|
||||
if($address == $hostip) {
|
||||
if($rows_exist < '1') {
|
||||
$reverse_query = "INSERT INTO `records` (`host`, `ttl`, `type`, `val`, `domain_id`) ";
|
||||
$reverse_query .= "VALUES ('$reverse','38400','P','$real_hostname','$rev_domain_id')";
|
||||
} else {
|
||||
$reverse_query = "UPDATE `records` SET `val` = '$real_hostname' WHERE `host` = '".$reverse.".'";
|
||||
}
|
||||
} else {
|
||||
if($rows_exist < '1') {
|
||||
$reverse_query = "INSERT INTO `records` (`host`, `ttl`, `type`, `val`, `domain_id`) ";
|
||||
$reverse_query .= "VALUES ('$reverse','38400','P','$dnsname','$rev_domain_id')";
|
||||
} else {
|
||||
$reverse_query = "UPDATE `records` SET `val` = '".$dnsname.".' WHERE `host` = '".$reverse."'";
|
||||
}
|
||||
if($address == $hostip) {
|
||||
if($rows_exist < '1') {
|
||||
$reverse_query = "INSERT INTO `records` (`host`, `ttl`, `type`, `val`, `domain_id`) ";
|
||||
$reverse_query .= "VALUES ('$reverse','38400','P','$real_hostname','$rev_domain_id')";
|
||||
} else {
|
||||
$reverse_query = "UPDATE `records` SET `val` = '$real_hostname' WHERE `host` = '".$reverse.".'";
|
||||
}
|
||||
} else {
|
||||
if($rows_exist < '1') {
|
||||
$reverse_query = "INSERT INTO `records` (`host`, `ttl`, `type`, `val`, `domain_id`) ";
|
||||
$reverse_query .= "VALUES ('$reverse','38400','P','$dnsname','$rev_domain_id')";
|
||||
} else {
|
||||
$reverse_query = "UPDATE `records` SET `val` = '".$dnsname.".' WHERE `host` = '".$reverse."'";
|
||||
}
|
||||
}
|
||||
|
||||
if($rev_domain_id) {
|
||||
echo("$reverse_query; \n");
|
||||
#mysql_query($reverse_query, $dnsdblink);
|
||||
} else {
|
||||
#echo("$hostname - $interface - $reverse FAILED\n");
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
unset($exist);
|
||||
while ($i <= count($zoneupdated)) {
|
||||
$thiszone = "$revzone";
|
||||
if ($zoneupdated[$i] == $thiszone) { $exist = "yes"; }
|
||||
$i++;
|
||||
}
|
||||
if(!$exist) { $zoneupdated[] = "$revzone"; }
|
||||
|
||||
unset ($forward_query);
|
||||
|
||||
if($address != $hostip) {
|
||||
|
||||
$rows_exist = mysql_result(mysql_query("SELECT COUNT(record_id) FROM `records` WHERE `host` = '$dnsname'", $dnsdblink),0);
|
||||
if($rows_exist > '1') { $rows_exist--; echo("DELETE FROM `records` WHERE `host` = '$hostname' LIMIT $rows_exist;\n"); }
|
||||
|
||||
if($rows_exist < '1') {
|
||||
$forward_query = "INSERT INTO `records` (`host`, `ttl`, `type`, `val`, `domain_id`) ";
|
||||
$forward_query .= "VALUES ('$dnsname','38400','A','$address','381')";
|
||||
} elseif ($address != $hostip) {
|
||||
$forward_query = "UPDATE `records` SET `val` = '$address' WHERE `host` = '$dnsname'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($rev_domain_id) {
|
||||
echo("$reverse_query; \n");
|
||||
#mysql_query($reverse_query, $dnsdblink);
|
||||
} else {
|
||||
#echo("$hostname - $interface - $reverse FAILED\n");
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
unset($exist);
|
||||
while ($i <= count($zoneupdated)) {
|
||||
$thiszone = "$revzone";
|
||||
if ($zoneupdated[$i] == $thiszone) { $exist = "yes"; }
|
||||
$i++;
|
||||
}
|
||||
if(!$exist) { $zoneupdated[] = "$revzone"; }
|
||||
|
||||
unset ($forward_query);
|
||||
|
||||
if($address != $hostip) {
|
||||
|
||||
$rows_exist = mysql_result(mysql_query("SELECT COUNT(record_id) FROM `records` WHERE `host` = '$dnsname'", $dnsdblink),0);
|
||||
if($rows_exist > '1') { $rows_exist--; echo("DELETE FROM `records` WHERE `host` = '$hostname' LIMIT $rows_exist;\n"); }
|
||||
|
||||
if($rows_exist < '1') {
|
||||
$forward_query = "INSERT INTO `records` (`host`, `ttl`, `type`, `val`, `domain_id`) ";
|
||||
$forward_query .= "VALUES ('$dnsname','38400','A','$address','381')";
|
||||
} elseif ($address != $hostip) {
|
||||
$forward_query = "UPDATE `records` SET `val` = '$address' WHERE `host` = '$dnsname'";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($forward_query && $rev_domain_id) {
|
||||
echo("$forward_query; \n");
|
||||
}
|
||||
if($forward_query && $rev_domain_id) {
|
||||
echo("$forward_query; \n");
|
||||
}
|
||||
|
||||
|
||||
mysql_query($forward_query, $dnsdblink);
|
||||
# $i = 1;
|
||||
# unset($exist)
|
||||
# while ($i <= count($linkdone)) {
|
||||
# $thiszone = "$";
|
||||
# if ($zoneupdated[$i] == $thiszone) { $exist = "yes"; }
|
||||
# $i++;
|
||||
# }
|
||||
mysql_query($forward_query, $dnsdblink);
|
||||
# $i = 1;
|
||||
# unset($exist)
|
||||
# while ($i <= count($linkdone)) {
|
||||
# $thiszone = "$";
|
||||
# if ($zoneupdated[$i] == $thiszone) { $exist = "yes"; }
|
||||
# $i++;
|
||||
# }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($zoneupdated)) {
|
||||
|
||||
# $sSQL = "update zones set name = '" . $name . "', ttl = " . $ttl . ", rdtype =
|
||||
# '" . $rdtype1 . "', rdata = '" . $rdata . "' where zoneid = " . $id;
|
||||
# $result = mysql_query($sSQL, $dnsdblink);
|
||||
# $sSQL = "update zones set name = '" . $name . "', ttl = " . $ttl . ", rdtype =
|
||||
# '" . $rdtype1 . "', rdata = '" . $rdata . "' where zoneid = " . $id;
|
||||
# $result = mysql_query($sSQL, $dnsdblink);
|
||||
|
||||
$domain = $zoneupdated[$i];
|
||||
$domain = $zoneupdated[$i];
|
||||
|
||||
$sSQL = "select rdata, zoneid from zones where domain_name = '" . $domain . "' and rdtype = 'SOA'";
|
||||
# $result = mysql_query($sSQL, $dnsdblink);
|
||||
# $row = mysql_fetch_array($result);
|
||||
$soa = explode(" ", $row[0]);
|
||||
$year = substr($soa[2],0,4);
|
||||
$month = substr($soa[2],4,2);
|
||||
$day = substr($soa[2],6,2);
|
||||
$serial = substr($soa[2],8,2);
|
||||
$thisday = date("d",time());
|
||||
$thismonth = date("m",time());
|
||||
$thisyear = date("Y", time());
|
||||
if($day == $thisday && $month == $thismonth && $year = $thisyear) {
|
||||
$serial++;
|
||||
}
|
||||
else {
|
||||
$serial = "01";
|
||||
}
|
||||
$date = $thisyear . $thismonth . $thisday . sprintf("%02s",$serial);
|
||||
$rdata = $soa[0] . " " . $soa[1] . " " . $date . " " . $soa[3] . " " . $soa[4] . " " . $soa[5] . " " . $soa[6];
|
||||
$sSQL = "update zones set rdata = '" . $rdata . "' where zoneid = " . $row[1];
|
||||
# echo("$sSQL\n");
|
||||
# $result = mysql_query($sSQL, $dnsdblink);
|
||||
$sSQL = "select rdata, zoneid from zones where domain_name = '" . $domain . "' and rdtype = 'SOA'";
|
||||
# $result = mysql_query($sSQL, $dnsdblink);
|
||||
# $row = mysql_fetch_array($result);
|
||||
$soa = explode(" ", $row[0]);
|
||||
$year = substr($soa[2],0,4);
|
||||
$month = substr($soa[2],4,2);
|
||||
$day = substr($soa[2],6,2);
|
||||
$serial = substr($soa[2],8,2);
|
||||
$thisday = date("d",time());
|
||||
$thismonth = date("m",time());
|
||||
$thisyear = date("Y", time());
|
||||
if($day == $thisday && $month == $thismonth && $year = $thisyear) {
|
||||
$serial++;
|
||||
}
|
||||
else {
|
||||
$serial = "01";
|
||||
}
|
||||
$date = $thisyear . $thismonth . $thisday . sprintf("%02s",$serial);
|
||||
$rdata = $soa[0] . " " . $soa[1] . " " . $date . " " . $soa[3] . " " . $soa[4] . " " . $soa[5] . " " . $soa[6];
|
||||
$sSQL = "update zones set rdata = '" . $rdata . "' where zoneid = " . $row[1];
|
||||
# echo("$sSQL\n");
|
||||
# $result = mysql_query($sSQL, $dnsdblink);
|
||||
|
||||
$i++;
|
||||
$i++;
|
||||
}
|
||||
|
||||
?>
|
||||
|
22
delhost.php
22
delhost.php
@@ -9,17 +9,17 @@ include("includes/functions.php");
|
||||
|
||||
if ($argv[1])
|
||||
{
|
||||
$host = strtolower($argv[1]);
|
||||
$id = getidbyname($host);
|
||||
if ($id)
|
||||
{
|
||||
echo(delete_device($id));
|
||||
echo("Removed $host\n");
|
||||
} else {
|
||||
echo("Host doesn't exist!\n");
|
||||
}
|
||||
$host = strtolower($argv[1]);
|
||||
$id = getidbyname($host);
|
||||
if ($id)
|
||||
{
|
||||
echo(delete_device($id));
|
||||
echo("Removed $host\n");
|
||||
} else {
|
||||
echo("Host doesn't exist!\n");
|
||||
}
|
||||
} else {
|
||||
echo("Host Removal Tool\nUsage: ./delhost.php <hostname>\n");
|
||||
echo("Host Removal Tool\nUsage: ./delhost.php <hostname>\n");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
281
discovery.php
281
discovery.php
@@ -28,116 +28,116 @@ $options = getopt("h:t:i:n:d::a::");
|
||||
|
||||
if (isset($options['h']))
|
||||
{
|
||||
if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; }
|
||||
elseif ($options['h'] == "even") { $options['n'] = "0"; $options['i'] = "2"; }
|
||||
elseif ($options['h'] == "all") { $where = " "; $doing = "all"; }
|
||||
elseif ($options['h'] == "new") { $where = "AND `last_discovered` IS NULL"; $doing = "new"; }
|
||||
elseif ($options['h'])
|
||||
if ($options['h'] == "odd") { $options['n'] = "1"; $options['i'] = "2"; }
|
||||
elseif ($options['h'] == "even") { $options['n'] = "0"; $options['i'] = "2"; }
|
||||
elseif ($options['h'] == "all") { $where = " "; $doing = "all"; }
|
||||
elseif ($options['h'] == "new") { $where = "AND `last_discovered` IS NULL"; $doing = "new"; }
|
||||
elseif ($options['h'])
|
||||
{
|
||||
if (is_numeric($options['h']))
|
||||
{
|
||||
if (is_numeric($options['h']))
|
||||
{
|
||||
$where = "AND `device_id` = '".$options['h']."'";
|
||||
$doing = $options['h'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'";
|
||||
$doing = $options['h'];
|
||||
}
|
||||
$where = "AND `device_id` = '".$options['h']."'";
|
||||
$doing = $options['h'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = "AND `hostname` LIKE '".str_replace('*','%',mres($options['h']))."'";
|
||||
$doing = $options['h'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['i']) && $options['i'] && isset($options['n']))
|
||||
{
|
||||
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'";
|
||||
$doing = $options['n'] ."/".$options['i'];
|
||||
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'";
|
||||
$doing = $options['n'] ."/".$options['i'];
|
||||
}
|
||||
|
||||
if (isset($options['d']))
|
||||
{
|
||||
echo("DEBUG!\n");
|
||||
$debug = TRUE;
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', 1);
|
||||
echo("DEBUG!\n");
|
||||
$debug = TRUE;
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', 1);
|
||||
} else {
|
||||
$debug = FALSE;
|
||||
# ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
# ini_set('error_reporting', 0);
|
||||
$debug = FALSE;
|
||||
# ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
# ini_set('error_reporting', 0);
|
||||
}
|
||||
|
||||
|
||||
if (!$where)
|
||||
{
|
||||
echo("-h <device id> | <device hostname wildcard> Poll single device\n");
|
||||
echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n");
|
||||
echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n");
|
||||
echo("-h all Poll all devices\n");
|
||||
echo("-h new Poll all devices that have not had a discovery run before\n\n");
|
||||
echo("-i <instances> -n <number> Poll as instance <number> of <instances>\n");
|
||||
echo(" Instances start at 0. 0-3 for -n 4\n\n");
|
||||
echo("-d Enable debugging output\n");
|
||||
echo("\n");
|
||||
echo("No polling type specified!\n");
|
||||
exit;
|
||||
echo("-h <device id> | <device hostname wildcard> Poll single device\n");
|
||||
echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n");
|
||||
echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n");
|
||||
echo("-h all Poll all devices\n");
|
||||
echo("-h new Poll all devices that have not had a discovery run before\n\n");
|
||||
echo("-i <instances> -n <number> Poll as instance <number> of <instances>\n");
|
||||
echo(" Instances start at 0. 0-3 for -n 4\n\n");
|
||||
echo("-d Enable debugging output\n");
|
||||
echo("\n");
|
||||
echo("No polling type specified!\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (file_exists('.svn'))
|
||||
{
|
||||
list(,$dbu_rev) = preg_split('/: /',@shell_exec('svn info database-update.sql|grep ^Revision'));
|
||||
list(,$dbu_rev) = preg_split('/: /',@shell_exec('svn info database-update.sql|grep ^Revision'));
|
||||
|
||||
$device_query = mysql_query("SELECT revision FROM `dbSchema`");
|
||||
if ($rev = @mysql_fetch_array($device_query))
|
||||
$device_query = mysql_query("SELECT revision FROM `dbSchema`");
|
||||
if ($rev = @mysql_fetch_array($device_query))
|
||||
{
|
||||
$db_rev = $rev['revision'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$db_rev = 0;
|
||||
}
|
||||
|
||||
if ($db_rev+0 < 1223)
|
||||
{
|
||||
include('upgrade-scripts/fix-events.php'); ## Fix events table (needs to copy some data around, so needs script)
|
||||
}
|
||||
|
||||
if ($db_rev+0 < 1656)
|
||||
{
|
||||
include('upgrade-scripts/fix-port-rrd.php'); ## Rewrites all port RRDs. Nothing will work without this after 1656
|
||||
}
|
||||
|
||||
if ($db_rev+0 < 1757)
|
||||
{
|
||||
include('upgrade-scripts/fix-sensor-rrd.php'); ## Rewrites all sensor RRDs. Nothing will work without this after 1757
|
||||
}
|
||||
|
||||
if ($dbu_rev+0 > $db_rev)
|
||||
{
|
||||
echo("SVN revision changed.\n");
|
||||
if ($db_rev+0 < "1000")
|
||||
{
|
||||
$db_rev = $rev['revision'];
|
||||
echo("Running pre-revision 1000 SQL update script...\n");
|
||||
shell_exec("scripts/update-sql.php database-update-pre1000.sql");
|
||||
}
|
||||
if ($db_rev+0 < "1435")
|
||||
{
|
||||
echo("Running pre-revision 1435 SQL update script...\n");
|
||||
shell_exec("scripts/update-sql.php database-update-pre1435.sql");
|
||||
}
|
||||
echo("Running development SQL update script to update from r$db_rev to r" . trim($dbu_rev) . "...\n");
|
||||
shell_exec("scripts/update-sql.php database-update.sql");
|
||||
if ($db_rev == 0)
|
||||
{
|
||||
mysql_query("INSERT INTO dbSchema VALUES ($dbu_rev)");
|
||||
}
|
||||
else
|
||||
{
|
||||
$db_rev = 0;
|
||||
}
|
||||
|
||||
if ($db_rev+0 < 1223)
|
||||
{
|
||||
include('upgrade-scripts/fix-events.php'); ## Fix events table (needs to copy some data around, so needs script)
|
||||
}
|
||||
|
||||
if ($db_rev+0 < 1656)
|
||||
{
|
||||
include('upgrade-scripts/fix-port-rrd.php'); ## Rewrites all port RRDs. Nothing will work without this after 1656
|
||||
}
|
||||
|
||||
if ($db_rev+0 < 1757)
|
||||
{
|
||||
include('upgrade-scripts/fix-sensor-rrd.php'); ## Rewrites all sensor RRDs. Nothing will work without this after 1757
|
||||
}
|
||||
|
||||
if ($dbu_rev+0 > $db_rev)
|
||||
{
|
||||
echo("SVN revision changed.\n");
|
||||
if ($db_rev+0 < "1000")
|
||||
{
|
||||
echo("Running pre-revision 1000 SQL update script...\n");
|
||||
shell_exec("scripts/update-sql.php database-update-pre1000.sql");
|
||||
}
|
||||
if ($db_rev+0 < "1435")
|
||||
{
|
||||
echo("Running pre-revision 1435 SQL update script...\n");
|
||||
shell_exec("scripts/update-sql.php database-update-pre1435.sql");
|
||||
}
|
||||
echo("Running development SQL update script to update from r$db_rev to r" . trim($dbu_rev) . "...\n");
|
||||
shell_exec("scripts/update-sql.php database-update.sql");
|
||||
if ($db_rev == 0)
|
||||
{
|
||||
mysql_query("INSERT INTO dbSchema VALUES ($dbu_rev)");
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("UPDATE dbSchema set revision=$dbu_rev");
|
||||
}
|
||||
mysql_query("UPDATE dbSchema set revision=$dbu_rev");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$discovered_devices = 0;
|
||||
@@ -145,67 +145,66 @@ $discovered_devices = 0;
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC");
|
||||
while ($device = mysql_fetch_array($device_query))
|
||||
{
|
||||
$device_start = utime(); // Start counting device poll time
|
||||
|
||||
$device_start = utime(); // Start counting device poll time
|
||||
echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." ");
|
||||
if ($device['os'] != strtolower($device['os']))
|
||||
{
|
||||
mysql_query("UPDATE `devices` SET `os` = '".strtolower($device['os'])."' WHERE device_id = '".$device['device_id']."'");
|
||||
$device['os'] = strtolower($device['os']);
|
||||
echo("OS lowercased.");
|
||||
}
|
||||
if ($config['os'][$device['os']]['group'])
|
||||
{
|
||||
$device['os_group'] = $config['os'][$device['os']]['group'];
|
||||
echo("(".$device['os_group'].")");
|
||||
}
|
||||
|
||||
echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." ");
|
||||
if ($device['os'] != strtolower($device['os']))
|
||||
echo("\n");
|
||||
|
||||
#include("includes/discovery/os.inc.php");
|
||||
|
||||
include("includes/discovery/ports.inc.php");
|
||||
include("includes/discovery/entity-physical.inc.php");
|
||||
include("includes/discovery/processors.inc.php");
|
||||
include("includes/discovery/mempools.inc.php");
|
||||
include("includes/discovery/ipv4-addresses.inc.php");
|
||||
include("includes/discovery/ipv6-addresses.inc.php");
|
||||
include("includes/discovery/sensors.inc.php");
|
||||
include("includes/discovery/storage.inc.php");
|
||||
include("includes/discovery/hr-device.inc.php");
|
||||
include("includes/discovery/discovery-protocols.inc.php");
|
||||
include("includes/discovery/arp-table.inc.php");
|
||||
include("includes/discovery/junose-atm-vp.inc.php");
|
||||
include("includes/discovery/bgp-peers.inc.php");
|
||||
include("includes/discovery/q-bridge-mib.inc.php");
|
||||
include("includes/discovery/cisco-vlans.inc.php");
|
||||
include("includes/discovery/cisco-mac-accounting.inc.php");
|
||||
include("includes/discovery/cisco-pw.inc.php");
|
||||
include("includes/discovery/cisco-vrf.inc.php");
|
||||
include("includes/discovery/toner.inc.php");
|
||||
include("includes/discovery/ucd-diskio.inc.php");
|
||||
include("includes/discovery/services.inc.php");
|
||||
|
||||
if ($device['type'] == "unknown" || $device['type'] == "")
|
||||
{
|
||||
if ($config['os'][$device['os']]['type'])
|
||||
{
|
||||
mysql_query("UPDATE `devices` SET `os` = '".strtolower($device['os'])."' WHERE device_id = '".$device['device_id']."'");
|
||||
$device['os'] = strtolower($device['os']);
|
||||
echo("OS lowercased.");
|
||||
}
|
||||
if ($config['os'][$device['os']]['group'])
|
||||
{
|
||||
$device['os_group'] = $config['os'][$device['os']]['group'];
|
||||
echo("(".$device['os_group'].")");
|
||||
$device['type'] = $config['os'][$device['os']]['type'];
|
||||
}
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
$device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5);
|
||||
|
||||
#include("includes/discovery/os.inc.php");
|
||||
$update_query = "UPDATE `devices` SET ";
|
||||
$update_query .= " `last_discovered` = NOW(), `type` = '" . $device['type'] . "'";
|
||||
$update_query .= ", `last_discovered_timetaken` = '$device_time'";
|
||||
$update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";
|
||||
$update_result = mysql_query($update_query);
|
||||
|
||||
include("includes/discovery/ports.inc.php");
|
||||
include("includes/discovery/entity-physical.inc.php");
|
||||
include("includes/discovery/processors.inc.php");
|
||||
include("includes/discovery/mempools.inc.php");
|
||||
include("includes/discovery/ipv4-addresses.inc.php");
|
||||
include("includes/discovery/ipv6-addresses.inc.php");
|
||||
include("includes/discovery/sensors.inc.php");
|
||||
include("includes/discovery/storage.inc.php");
|
||||
include("includes/discovery/hr-device.inc.php");
|
||||
include("includes/discovery/discovery-protocols.inc.php");
|
||||
include("includes/discovery/arp-table.inc.php");
|
||||
include("includes/discovery/junose-atm-vp.inc.php");
|
||||
include("includes/discovery/bgp-peers.inc.php");
|
||||
include("includes/discovery/q-bridge-mib.inc.php");
|
||||
include("includes/discovery/cisco-vlans.inc.php");
|
||||
include("includes/discovery/cisco-mac-accounting.inc.php");
|
||||
include("includes/discovery/cisco-pw.inc.php");
|
||||
include("includes/discovery/cisco-vrf.inc.php");
|
||||
include("includes/discovery/toner.inc.php");
|
||||
include("includes/discovery/ucd-diskio.inc.php");
|
||||
include("includes/discovery/services.inc.php");
|
||||
|
||||
if ($device['type'] == "unknown" || $device['type'] == "")
|
||||
{
|
||||
if ($config['os'][$device['os']]['type'])
|
||||
{
|
||||
$device['type'] = $config['os'][$device['os']]['type'];
|
||||
}
|
||||
}
|
||||
|
||||
$device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5);
|
||||
|
||||
$update_query = "UPDATE `devices` SET ";
|
||||
$update_query .= " `last_discovered` = NOW(), `type` = '" . $device['type'] . "'";
|
||||
$update_query .= ", `last_discovered_timetaken` = '$device_time'";
|
||||
$update_query .= " WHERE `device_id` = '" . $device['device_id'] . "'";
|
||||
$update_result = mysql_query($update_query);
|
||||
|
||||
echo("Discovered in $device_time seconds\n");
|
||||
unset($cache); // Clear cache (unify all things here?)
|
||||
echo("\n"); $discovered_devices++;
|
||||
echo("Discovered in $device_time seconds\n");
|
||||
unset($cache); // Clear cache (unify all things here?)
|
||||
echo("\n"); $discovered_devices++;
|
||||
}
|
||||
|
||||
$end = utime(); $run = $end - $start;
|
||||
@@ -213,8 +212,8 @@ $proctime = substr($run, 0, 5);
|
||||
|
||||
if ($discovered_devices)
|
||||
{
|
||||
mysql_query("INSERT INTO `perf_times` (`type`, `doing`, `start`, `duration`, `devices`)
|
||||
VALUES ('discover', '$doing', '$start', '$proctime', '$discovered_devices')");
|
||||
mysql_query("INSERT INTO `perf_times` (`type`, `doing`, `start`, `duration`, `devices`)
|
||||
VALUES ('discover', '$doing', '$start', '$proctime', '$discovered_devices')");
|
||||
}
|
||||
|
||||
$string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $discovered_devices devices discovered in $proctime secs";
|
||||
@@ -222,4 +221,4 @@ if ($debug) echo("$string\n");
|
||||
|
||||
logfile($string);
|
||||
|
||||
?>
|
||||
?>
|
@@ -10,24 +10,24 @@ $handle = fopen("ips.txt", "w");
|
||||
$query = mysql_query("SELECT * FROM `ipv4_networks`");
|
||||
while ($data = mysql_fetch_array($query))
|
||||
{
|
||||
$cidr = $data['ipv4_network'];
|
||||
list ($network, $bits) = explode("/", $cidr);
|
||||
if ($bits != '32' && $bits != '32' && $bits > '22')
|
||||
$cidr = $data['ipv4_network'];
|
||||
list ($network, $bits) = explode("/", $cidr);
|
||||
if ($bits != '32' && $bits != '32' && $bits > '22')
|
||||
{
|
||||
$addr = Net_IPv4::parseAddress($cidr);
|
||||
$broadcast = $addr->broadcast;
|
||||
$ip = ip2long($network) + '1';
|
||||
$end = ip2long($broadcast);
|
||||
while ($ip < $end)
|
||||
{
|
||||
$addr = Net_IPv4::parseAddress($cidr);
|
||||
$broadcast = $addr->broadcast;
|
||||
$ip = ip2long($network) + '1';
|
||||
$end = ip2long($broadcast);
|
||||
while ($ip < $end)
|
||||
{
|
||||
$ipdotted = long2ip($ip);
|
||||
if (mysql_result(mysql_query("SELECT count(ipv4_address_id) FROM ipv4_addresses WHERE ipv4_address = '$ipdotted'"),0) == '0' && match_network($config['nets'], $ipdotted))
|
||||
{
|
||||
fputs($handle, $ipdotted . "\n");
|
||||
}
|
||||
$ip++;
|
||||
}
|
||||
$ipdotted = long2ip($ip);
|
||||
if (mysql_result(mysql_query("SELECT count(ipv4_address_id) FROM ipv4_addresses WHERE ipv4_address = '$ipdotted'"),0) == '0' && match_network($config['nets'], $ipdotted))
|
||||
{
|
||||
fputs($handle, $ipdotted . "\n");
|
||||
}
|
||||
$ip++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
if ($_GET['debug'])
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
@@ -20,11 +20,11 @@ if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
|
||||
if (is_numeric($_GET['device_id']))
|
||||
{
|
||||
$ports = mysql_query("SELECT * FROM ports WHERE device_id = '".$_GET['device_id']."'");
|
||||
while ($interface = mysql_fetch_array($ports))
|
||||
{
|
||||
echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['interface_id']."');\n");
|
||||
}
|
||||
$ports = mysql_query("SELECT * FROM ports WHERE device_id = '".$_GET['device_id']."'");
|
||||
while ($interface = mysql_fetch_array($ports))
|
||||
{
|
||||
echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['interface_id']."');\n");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
if ($_GET['debug'])
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
} else { ini_set('display_errors', 0); }
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
@@ -21,16 +21,16 @@ include("includes/jpgraph/src/jpgraph_utils.inc.php");
|
||||
|
||||
if (is_numeric($_GET['bill_id']))
|
||||
{
|
||||
if (bill_permitted($_GET['bill_id']))
|
||||
{
|
||||
$bill_id = $_GET['bill_id'];
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
if (bill_permitted($_GET['bill_id']))
|
||||
{
|
||||
$bill_id = $_GET['bill_id'];
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start = $_GET[from];
|
||||
@@ -86,68 +86,68 @@ $data = mysql_query($sql);
|
||||
|
||||
while ($row = mysql_fetch_array($data))
|
||||
{
|
||||
@$timestamp = $row['formatted_date'];
|
||||
if (!$first) { $first = $timestamp; }
|
||||
@$delta = $row['delta'];
|
||||
@$period = $row['period'];
|
||||
@$in_delta = $row['in_delta'];
|
||||
@$out_delta = $row['out_delta'];
|
||||
@$in_value = round($in_delta * 8 / $period / $div, 2);
|
||||
@$out_value = round($out_delta * 8 / $period / $div, 2);
|
||||
@$timestamp = $row['formatted_date'];
|
||||
if (!$first) { $first = $timestamp; }
|
||||
@$delta = $row['delta'];
|
||||
@$period = $row['period'];
|
||||
@$in_delta = $row['in_delta'];
|
||||
@$out_delta = $row['out_delta'];
|
||||
@$in_value = round($in_delta * 8 / $period / $div, 2);
|
||||
@$out_value = round($out_delta * 8 / $period / $div, 2);
|
||||
|
||||
#@$data[] = $in_value + $out_value;
|
||||
#@$in_data[] = $in_value;
|
||||
#@$out_data[] = $out_value;
|
||||
# @$ticks[] = $timestamp;
|
||||
#@$per_data[] = $rate_95th / 1000;
|
||||
#@$ave_data[] = $rate_average / 1000;
|
||||
#@$data[] = $in_value + $out_value;
|
||||
#@$in_data[] = $in_value;
|
||||
#@$out_data[] = $out_value;
|
||||
# @$ticks[] = $timestamp;
|
||||
#@$per_data[] = $rate_95th / 1000;
|
||||
#@$ave_data[] = $rate_average / 1000;
|
||||
|
||||
@$last = $timestamp;
|
||||
@$last = $timestamp;
|
||||
|
||||
$iter_in = $iter_in + $in_delta;
|
||||
$iter_out = $iter_out + $out_delta;
|
||||
$iter_period = $iter_period + $period;
|
||||
$iter_in = $iter_in + $in_delta;
|
||||
$iter_out = $iter_out + $out_delta;
|
||||
$iter_period = $iter_period + $period;
|
||||
|
||||
if ($iter == $count)
|
||||
if ($iter == $count)
|
||||
{
|
||||
$out_data[$i] = round($iter_out * 8 / $iter_period / $div, 2);
|
||||
$in_data[$i] = round($iter_in * 8 / $iter_period / $div, 2);
|
||||
$tot_data[$i] = $out_data[$i] + $in_data[$i];
|
||||
$ticks[$i] = date('M j g:ia', $timestamp);
|
||||
$ticks[$i] = $timestamp;
|
||||
|
||||
if ($dur < 172800)
|
||||
{
|
||||
$out_data[$i] = round($iter_out * 8 / $iter_period / $div, 2);
|
||||
$in_data[$i] = round($iter_in * 8 / $iter_period / $div, 2);
|
||||
$tot_data[$i] = $out_data[$i] + $in_data[$i];
|
||||
$ticks[$i] = date('M j g:ia', $timestamp);
|
||||
$ticks[$i] = $timestamp;
|
||||
$hour = date('h', $timestamp);
|
||||
if ($hour != $lasthour) { $tickPositions[] = $i; $tickLabels[] = date('ga', $timestamp); }
|
||||
$lasthour = $hour;
|
||||
} elseif ($dur < 604800) {
|
||||
$day = date('d', $timestamp);
|
||||
if ($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('D', $timestamp); $h = 0; }
|
||||
$lastday = $day;
|
||||
|
||||
if ($dur < 172800)
|
||||
{
|
||||
$hour = date('h', $timestamp);
|
||||
if ($hour != $lasthour) { $tickPositions[] = $i; $tickLabels[] = date('ga', $timestamp); }
|
||||
$lasthour = $hour;
|
||||
} elseif ($dur < 604800) {
|
||||
$day = date('d', $timestamp);
|
||||
if ($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('D', $timestamp); $h = 0; }
|
||||
$lastday = $day;
|
||||
$hour = trim(date('g', $timestamp));
|
||||
if ($hour != $lasthour)
|
||||
{
|
||||
if ($hour == '12') { $tickMinPositions[] = $i; $h = 0; } $h++;
|
||||
}
|
||||
|
||||
$hour = trim(date('g', $timestamp));
|
||||
if ($hour != $lasthour)
|
||||
{
|
||||
if ($hour == '12') { $tickMinPositions[] = $i; $h = 0; } $h++;
|
||||
}
|
||||
|
||||
$lasthour = $hour;
|
||||
} else {
|
||||
$day = date('d', $timestamp);
|
||||
if ($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('dS', $timestamp); }
|
||||
$lastday = $day;
|
||||
}
|
||||
|
||||
$per_data[$i] = $rate_95th / $div;
|
||||
$ave_data[$i] = $rate_average / $div;
|
||||
$timestamps[$i] = $timestamp;
|
||||
$iter = "1";
|
||||
$i++;
|
||||
unset($iter_out, $iter_in, $iter_period);
|
||||
$lasthour = $hour;
|
||||
} else {
|
||||
$day = date('d', $timestamp);
|
||||
if ($day != $lastday) { $tickPositions[] = $i; $tickLabels[] = date('dS', $timestamp); }
|
||||
$lastday = $day;
|
||||
}
|
||||
|
||||
$iter++;
|
||||
$per_data[$i] = $rate_95th / $div;
|
||||
$ave_data[$i] = $rate_average / $div;
|
||||
$timestamps[$i] = $timestamp;
|
||||
$iter = "1";
|
||||
$i++;
|
||||
unset($iter_out, $iter_in, $iter_period);
|
||||
}
|
||||
|
||||
$iter++;
|
||||
}
|
||||
|
||||
#print_r($ticks);
|
||||
@@ -175,9 +175,9 @@ $graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
|
||||
|
||||
if (count($tickPositions) > 24)
|
||||
{
|
||||
$graph->xaxis->SetTextLabelInterval(6);
|
||||
$graph->xaxis->SetTextLabelInterval(6);
|
||||
} elseif (count($tickPositions) > 12) {
|
||||
$graph->xaxis->SetTextLabelInterval(2);
|
||||
$graph->xaxis->SetTextLabelInterval(2);
|
||||
}
|
||||
|
||||
$graph->xaxis->SetPos('min');
|
||||
@@ -219,14 +219,14 @@ $lineplot_out->SetColor("blue");
|
||||
|
||||
if ($_GET['95th'])
|
||||
{
|
||||
$lineplot_95th = new LinePlot($per_data);
|
||||
$lineplot_95th ->SetColor("red");
|
||||
$lineplot_95th = new LinePlot($per_data);
|
||||
$lineplot_95th ->SetColor("red");
|
||||
}
|
||||
|
||||
if ($_GET['ave'])
|
||||
{
|
||||
$lineplot_ave = new LinePlot($ave_data);
|
||||
$lineplot_ave ->SetColor("red");
|
||||
$lineplot_ave = new LinePlot($ave_data);
|
||||
$lineplot_ave ->SetColor("red");
|
||||
}
|
||||
|
||||
#$graph->legend->SetLayout(LEGEND_HOR);
|
||||
@@ -238,12 +238,12 @@ $graph->Add($lineplot_out);
|
||||
|
||||
if ($_GET['95th'])
|
||||
{
|
||||
$graph->Add($lineplot_95th);
|
||||
$graph->Add($lineplot_95th);
|
||||
}
|
||||
|
||||
if ($_GET['ave'])
|
||||
{
|
||||
$graph->Add($lineplot_ave);
|
||||
$graph->Add($lineplot_ave);
|
||||
}
|
||||
|
||||
$graph->stroke();
|
||||
|
@@ -17,11 +17,11 @@
|
||||
*/
|
||||
|
||||
if($_GET['debug']) {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
@@ -36,21 +36,21 @@ include("includes/authenticate.inc.php");
|
||||
if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; }
|
||||
|
||||
function makeTextBlock($text, $fontfile, $fontsize, $width) {
|
||||
// TODO: handle explicit line-break!
|
||||
$words = explode(' ', $text);
|
||||
$lines = array($words[0]);
|
||||
$currentLine = 0;
|
||||
foreach ($words as $word) {
|
||||
$lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine] . ' ' . $word);
|
||||
if($lineSize[2] - $lineSize[0] < $width) {
|
||||
$lines[$currentLine] .= ' ' . $word;
|
||||
} else {
|
||||
$currentLine++;
|
||||
$lines[$currentLine] = $word;
|
||||
}
|
||||
// TODO: handle explicit line-break!
|
||||
$words = explode(' ', $text);
|
||||
$lines = array($words[0]);
|
||||
$currentLine = 0;
|
||||
foreach ($words as $word) {
|
||||
$lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine] . ' ' . $word);
|
||||
if($lineSize[2] - $lineSize[0] < $width) {
|
||||
$lines[$currentLine] .= ' ' . $word;
|
||||
} else {
|
||||
$currentLine++;
|
||||
$lines[$currentLine] = $word;
|
||||
}
|
||||
error_log(sprintf('Handles message "%s", %d words => %d/%d lines', $text, count($words), $currentLine, count($lines)));
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
error_log(sprintf('Handles message "%s", %d words => %d/%d lines', $text, count($words), $currentLine, count($lines)));
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,65 +61,65 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) {
|
||||
* @msg Complete error message to display in place of graph content
|
||||
*/
|
||||
function error($code, $code_msg, $title, $msg) {
|
||||
global $config;
|
||||
header(sprintf("HTTP/1.0 %d %s", $code, $code_msg));
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: Mon, 01 Jan 2008 00:00:00 CET");
|
||||
header("Content-Type: image/png");
|
||||
$w = $config['rrd_width']+81;
|
||||
$h = $config['rrd_height']+79;
|
||||
global $config;
|
||||
header(sprintf("HTTP/1.0 %d %s", $code, $code_msg));
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: Mon, 01 Jan 2008 00:00:00 CET");
|
||||
header("Content-Type: image/png");
|
||||
$w = $config['rrd_width']+81;
|
||||
$h = $config['rrd_height']+79;
|
||||
|
||||
$png = imagecreate($w, $h);
|
||||
$c_bkgnd = imagecolorallocate($png, 240, 240, 240);
|
||||
$c_fgnd = imagecolorallocate($png, 255, 255, 255);
|
||||
$c_blt = imagecolorallocate($png, 208, 208, 208);
|
||||
$c_brb = imagecolorallocate($png, 160, 160, 160);
|
||||
$c_grln = imagecolorallocate($png, 114, 114, 114);
|
||||
$c_grarr = imagecolorallocate($png, 128, 32, 32);
|
||||
$c_txt = imagecolorallocate($png, 0, 0, 0);
|
||||
$c_etxt = imagecolorallocate($png, 64, 0, 0);
|
||||
$png = imagecreate($w, $h);
|
||||
$c_bkgnd = imagecolorallocate($png, 240, 240, 240);
|
||||
$c_fgnd = imagecolorallocate($png, 255, 255, 255);
|
||||
$c_blt = imagecolorallocate($png, 208, 208, 208);
|
||||
$c_brb = imagecolorallocate($png, 160, 160, 160);
|
||||
$c_grln = imagecolorallocate($png, 114, 114, 114);
|
||||
$c_grarr = imagecolorallocate($png, 128, 32, 32);
|
||||
$c_txt = imagecolorallocate($png, 0, 0, 0);
|
||||
$c_etxt = imagecolorallocate($png, 64, 0, 0);
|
||||
|
||||
if (function_exists('imageantialias'))
|
||||
imageantialias($png, true);
|
||||
imagefilledrectangle($png, 0, 0, $w, $h, $c_bkgnd);
|
||||
imagefilledrectangle($png, 51, 33, $w-31, $h-47, $c_fgnd);
|
||||
imageline($png, 51, 30, 51, $h-43, $c_grln);
|
||||
imageline($png, 48, $h-46, $w-28, $h-46, $c_grln);
|
||||
imagefilledpolygon($png, array(49, 30, 51, 26, 53, 30), 3, $c_grarr);
|
||||
imagefilledpolygon($png, array($w-28, $h-48, $w-24, $h-46, $w-28, $h-44), 3, $c_grarr);
|
||||
imageline($png, 0, 0, $w, 0, $c_blt);
|
||||
imageline($png, 0, 1, $w, 1, $c_blt);
|
||||
imageline($png, 0, 0, 0, $h, $c_blt);
|
||||
imageline($png, 1, 0, 1, $h, $c_blt);
|
||||
imageline($png, $w-1, 0, $w-1, $h, $c_brb);
|
||||
imageline($png, $w-2, 1, $w-2, $h, $c_brb);
|
||||
imageline($png, 1, $h-2, $w, $h-2, $c_brb);
|
||||
imageline($png, 0, $h-1, $w, $h-1, $c_brb);
|
||||
if (function_exists('imageantialias'))
|
||||
imageantialias($png, true);
|
||||
imagefilledrectangle($png, 0, 0, $w, $h, $c_bkgnd);
|
||||
imagefilledrectangle($png, 51, 33, $w-31, $h-47, $c_fgnd);
|
||||
imageline($png, 51, 30, 51, $h-43, $c_grln);
|
||||
imageline($png, 48, $h-46, $w-28, $h-46, $c_grln);
|
||||
imagefilledpolygon($png, array(49, 30, 51, 26, 53, 30), 3, $c_grarr);
|
||||
imagefilledpolygon($png, array($w-28, $h-48, $w-24, $h-46, $w-28, $h-44), 3, $c_grarr);
|
||||
imageline($png, 0, 0, $w, 0, $c_blt);
|
||||
imageline($png, 0, 1, $w, 1, $c_blt);
|
||||
imageline($png, 0, 0, 0, $h, $c_blt);
|
||||
imageline($png, 1, 0, 1, $h, $c_blt);
|
||||
imageline($png, $w-1, 0, $w-1, $h, $c_brb);
|
||||
imageline($png, $w-2, 1, $w-2, $h, $c_brb);
|
||||
imageline($png, 1, $h-2, $w, $h-2, $c_brb);
|
||||
imageline($png, 0, $h-1, $w, $h-1, $c_brb);
|
||||
|
||||
imagestring($png, 4, ceil(($w-strlen($title)*imagefontwidth(4)) / 2), 10, $title, $c_txt);
|
||||
imagestring($png, 5, 60, 35, sprintf('%s [%d]', $code_msg, $code), $c_etxt);
|
||||
if (function_exists('imagettfbbox') && is_file($config['error_font'])) {
|
||||
// Detailled error message
|
||||
$fmt_msg = makeTextBlock($msg, $errorfont, 10, $w-86);
|
||||
$fmtbox = imagettfbbox(12, 0, $errorfont, $fmt_msg);
|
||||
imagettftext($png, 10, 0, 55, 35+3+imagefontwidth(5)-$fmtbox[7]+$fmtbox[1], $c_txt, $errorfont, $fmt_msg);
|
||||
} else {
|
||||
imagestring($png, 4, 53, 35+6+imagefontwidth(5), $msg, $c_txt);
|
||||
}
|
||||
imagestring($png, 4, ceil(($w-strlen($title)*imagefontwidth(4)) / 2), 10, $title, $c_txt);
|
||||
imagestring($png, 5, 60, 35, sprintf('%s [%d]', $code_msg, $code), $c_etxt);
|
||||
if (function_exists('imagettfbbox') && is_file($config['error_font'])) {
|
||||
// Detailled error message
|
||||
$fmt_msg = makeTextBlock($msg, $errorfont, 10, $w-86);
|
||||
$fmtbox = imagettfbbox(12, 0, $errorfont, $fmt_msg);
|
||||
imagettftext($png, 10, 0, 55, 35+3+imagefontwidth(5)-$fmtbox[7]+$fmtbox[1], $c_txt, $errorfont, $fmt_msg);
|
||||
} else {
|
||||
imagestring($png, 4, 53, 35+6+imagefontwidth(5), $msg, $c_txt);
|
||||
}
|
||||
|
||||
imagepng($png);
|
||||
imagedestroy($png);
|
||||
imagepng($png);
|
||||
imagedestroy($png);
|
||||
}
|
||||
|
||||
/**
|
||||
* No RRD files found that could match request
|
||||
*/
|
||||
function error404($title, $msg) {
|
||||
return error(404, "Not found", $title, $msg);
|
||||
return error(404, "Not found", $title, $msg);
|
||||
}
|
||||
|
||||
function error500($title, $msg) {
|
||||
return error(500, "Not found", $title, $msg);
|
||||
return error(500, "Not found", $title, $msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,49 +127,49 @@ function error500($title, $msg) {
|
||||
* Incomplete / invalid request
|
||||
*/
|
||||
function error400($title, $msg) {
|
||||
return error(400, "Bad request", $title, $msg);
|
||||
return error(400, "Bad request", $title, $msg);
|
||||
}
|
||||
|
||||
// Process input arguments
|
||||
$host = read_var('host', $_GET, null);
|
||||
$host = read_var('host', $_GET, null);
|
||||
if (is_null($host))
|
||||
return error400("?/?-?/?", "Missing host name");
|
||||
return error400("?/?-?/?", "Missing host name");
|
||||
else if (!is_string($host))
|
||||
return error400("?/?-?/?", "Expecting exactly 1 host name");
|
||||
return error400("?/?-?/?", "Expecting exactly 1 host name");
|
||||
else if (strlen($host) == 0)
|
||||
return error400("?/?-?/?", "Host name may not be blank");
|
||||
return error400("?/?-?/?", "Host name may not be blank");
|
||||
|
||||
$plugin = read_var('plugin', $_GET, null);
|
||||
if (is_null($plugin))
|
||||
return error400($host.'/?-?/?', "Missing plugin name");
|
||||
return error400($host.'/?-?/?', "Missing plugin name");
|
||||
else if (!is_string($plugin))
|
||||
return error400($host.'/?-?/?', "Plugin name must be a string");
|
||||
return error400($host.'/?-?/?', "Plugin name must be a string");
|
||||
else if (strlen($plugin) == 0)
|
||||
return error400($host.'/?-?/?', "Plugin name may not be blank");
|
||||
return error400($host.'/?-?/?', "Plugin name may not be blank");
|
||||
|
||||
$pinst = read_var('plugin_instance', $_GET, '');
|
||||
$pinst = read_var('plugin_instance', $_GET, '');
|
||||
if (!is_string($pinst))
|
||||
return error400($host.'/'.$plugin.'-?/?', "Plugin instance name must be a string");
|
||||
return error400($host.'/'.$plugin.'-?/?', "Plugin instance name must be a string");
|
||||
|
||||
$type = read_var('type', $_GET, '');
|
||||
$type = read_var('type', $_GET, '');
|
||||
if (is_null($type))
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Missing type name");
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Missing type name");
|
||||
else if (!is_string($type))
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name must be a string");
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name must be a string");
|
||||
else if (strlen($type) == 0)
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name may not be blank");
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name may not be blank");
|
||||
|
||||
$tinst = read_var('type_instance', $_GET, '');
|
||||
$tinst = read_var('type_instance', $_GET, '');
|
||||
|
||||
$graph_identifier = $host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/'.$type.(strlen($tinst) ? '-'.$tinst : '-*');
|
||||
|
||||
$timespan = read_var('timespan', $_GET, $config['timespan'][0]['name']);
|
||||
$timespan_ok = false;
|
||||
foreach ($config['timespan'] as &$ts)
|
||||
if ($ts['name'] == $timespan)
|
||||
$timespan_ok = true;
|
||||
if ($ts['name'] == $timespan)
|
||||
$timespan_ok = true;
|
||||
if (!$timespan_ok)
|
||||
return error400($graph_identifier, "Unknown timespan requested");
|
||||
return error400($graph_identifier, "Unknown timespan requested");
|
||||
|
||||
$logscale = (boolean)read_var('logarithmic', $_GET, false);
|
||||
$tinylegend = (boolean)read_var('tinylegend', $_GET, false);
|
||||
@@ -177,7 +177,7 @@ $tinylegend = (boolean)read_var('tinylegend', $_GET, false);
|
||||
// Check that at least 1 RRD exists for the specified request
|
||||
$all_tinst = collectd_list_tinsts($host, $plugin, $pinst, $type);
|
||||
if (count($all_tinst) == 0)
|
||||
return error404($graph_identifier, "No rrd file found for graphing");
|
||||
return error404($graph_identifier, "No rrd file found for graphing");
|
||||
|
||||
// Now that we are read, do the bulk work
|
||||
load_graph_definitions($logscale, $tinylegend);
|
||||
@@ -188,49 +188,49 @@ $tinst = strlen($tinst) == 0 ? null : $tinst;
|
||||
$opts = array();
|
||||
$opts['timespan'] = $timespan;
|
||||
if ($logscale)
|
||||
$opts['logarithmic'] = 1;
|
||||
$opts['logarithmic'] = 1;
|
||||
if ($tinylegend)
|
||||
$opts['tinylegend'] = 1;
|
||||
$opts['tinylegend'] = 1;
|
||||
|
||||
$rrd_cmd = false;
|
||||
if (isset($MetaGraphDefs[$type])) {
|
||||
$identifiers = array();
|
||||
foreach ($all_tinst as &$atinst)
|
||||
$identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst);
|
||||
collectd_flush($identifiers);
|
||||
$rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts);
|
||||
$identifiers = array();
|
||||
foreach ($all_tinst as &$atinst)
|
||||
$identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst);
|
||||
collectd_flush($identifiers);
|
||||
$rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts);
|
||||
} else {
|
||||
if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst))
|
||||
return error404($host.'/'.$plugin.(!is_null($pinst) ? '-'.$pinst : '').'/'.$type.(!is_null($tinst) ? '-'.$tinst : ''), "No rrd file found for graphing");
|
||||
collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst));
|
||||
if (isset($GraphDefs[$type]))
|
||||
$rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst);
|
||||
else
|
||||
$rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst);
|
||||
if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst))
|
||||
return error404($host.'/'.$plugin.(!is_null($pinst) ? '-'.$pinst : '').'/'.$type.(!is_null($tinst) ? '-'.$tinst : ''), "No rrd file found for graphing");
|
||||
collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst));
|
||||
if (isset($GraphDefs[$type]))
|
||||
$rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst);
|
||||
else
|
||||
$rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst);
|
||||
}
|
||||
|
||||
if(isset($rrd_cmd))
|
||||
{
|
||||
if($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
|
||||
if($_GET['from']) { $from = mres($_GET['from']); }
|
||||
if($_GET['to']) { $to = mres($_GET['to']); }
|
||||
$rrd_cmd .= " -s " . $from . " -e " . $to;
|
||||
if($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
|
||||
if($_GET['from']) { $from = mres($_GET['from']); }
|
||||
if($_GET['to']) { $to = mres($_GET['to']); }
|
||||
$rrd_cmd .= " -s " . $from . " -e " . $to;
|
||||
}
|
||||
|
||||
if (isset($_GET['debug'])) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
printf("Would have executed:\n%s\n", $rrd_cmd);
|
||||
return 0;
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
printf("Would have executed:\n%s\n", $rrd_cmd);
|
||||
return 0;
|
||||
} else if ($rrd_cmd) {
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: max-age=60');
|
||||
$rt = 0;
|
||||
passthru($rrd_cmd, $rt);
|
||||
if ($rt != 0)
|
||||
return error500($graph_identifier, "RRD failed to generate the graph: ".$rt);
|
||||
return $rt;
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: max-age=60');
|
||||
$rt = 0;
|
||||
passthru($rrd_cmd, $rt);
|
||||
if ($rt != 0)
|
||||
return error500($graph_identifier, "RRD failed to generate the graph: ".$rt);
|
||||
return $rt;
|
||||
} else {
|
||||
return error500($graph_identifier, "Failed to tell RRD how to generate the graph");
|
||||
return error500($graph_identifier, "Failed to tell RRD how to generate the graph");
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -2,4 +2,4 @@
|
||||
|
||||
include("includes/graphs/graph.inc.php");
|
||||
|
||||
?>
|
||||
?>
|
@@ -6,17 +6,17 @@ ini_set('display_errors', 0);
|
||||
|
||||
if (strpos($_SERVER['REQUEST_URI'], "debug"))
|
||||
{
|
||||
$debug = "1";
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
$debug = "1";
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
} else {
|
||||
$debug = FALSE;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
$debug = FALSE;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
@@ -35,18 +35,18 @@ $year = time() - (365 * 24 * 60 * 60);
|
||||
|
||||
# Load the settings for Multi-Tenancy.
|
||||
if (is_array($config['branding'])) {
|
||||
if ($config['branding'][$_SERVER['SERVER_NAME']])
|
||||
if ($config['branding'][$_SERVER['SERVER_NAME']])
|
||||
{
|
||||
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
|
||||
{
|
||||
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
} else {
|
||||
foreach ($config['branding']['default'] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
} else {
|
||||
foreach ($config['branding']['default'] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
@@ -67,16 +67,16 @@ if ($config['page_refresh']) { echo("<meta http-equiv='refresh' content='".$conf
|
||||
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
|
||||
<script type="text/javascript" src="js/mktree.js"></script>
|
||||
<script type="text/javascript" src="js/sorttable.js"></script>
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
<!-- Begin
|
||||
function popUp(URL)
|
||||
{
|
||||
day = new Date();
|
||||
id = day.getTime();
|
||||
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
|
||||
day = new Date();
|
||||
id = day.getTime();
|
||||
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');");
|
||||
}
|
||||
// End -->
|
||||
</script>
|
||||
</script>
|
||||
<script type="text/javascript" src="js/overlib.js"></script>
|
||||
<div id="center">
|
||||
|
||||
@@ -93,23 +93,23 @@ function popUp(URL)
|
||||
<?php
|
||||
if ($_SESSION['authenticated'])
|
||||
{
|
||||
## Authenticated. Print a page.
|
||||
if (isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".inc.php"))
|
||||
## Authenticated. Print a page.
|
||||
if (isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".inc.php"))
|
||||
{
|
||||
include("pages/" . $_GET['page'] . ".inc.php");
|
||||
} else {
|
||||
if (isset($config['front_page']) && is_file($config['front_page']))
|
||||
{
|
||||
include("pages/" . $_GET['page'] . ".inc.php");
|
||||
include($config['front_page']);
|
||||
} else {
|
||||
if (isset($config['front_page']) && is_file($config['front_page']))
|
||||
{
|
||||
include($config['front_page']);
|
||||
} else {
|
||||
include("pages/front/default.php");
|
||||
}
|
||||
include("pages/front/default.php");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
## Not Authenticated. Print login.
|
||||
include("pages/logon.inc.php");
|
||||
exit;
|
||||
## Not Authenticated. Print login.
|
||||
include("pages/logon.inc.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
@@ -125,9 +125,9 @@ echo('<br />Powered by <a href="http://www.observium.org" target="_blank">Observ
|
||||
|
||||
if (file_exists('.svn/entries'))
|
||||
{
|
||||
$svn = File('.svn/entries');
|
||||
echo('-SVN r' . trim($svn[3]));
|
||||
unset($svn);
|
||||
$svn = File('.svn/entries');
|
||||
echo('-SVN r' . trim($svn[3]));
|
||||
unset($svn);
|
||||
}
|
||||
|
||||
echo('</a>. Copyright © 2006-'. date("Y"). ' by Adam Armstrong. All rights reserved.');
|
||||
|
264
html/map.php
264
html/map.php
@@ -12,18 +12,18 @@ include("includes/authenticate.inc.php");
|
||||
|
||||
if (is_array($config['branding']))
|
||||
{
|
||||
if ($config['branding'][$_SERVER['SERVER_NAME']])
|
||||
if ($config['branding'][$_SERVER['SERVER_NAME']])
|
||||
{
|
||||
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
|
||||
{
|
||||
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
} else {
|
||||
foreach ($config['branding']['default'] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
} else {
|
||||
foreach ($config['branding']['default'] as $confitem => $confval)
|
||||
{
|
||||
eval("\$config['" . $confitem . "'] = \$confval;");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['device'])) { $where = "WHERE device_id = ".$_GET['device']; } else { $where = ""; }
|
||||
@@ -31,148 +31,148 @@ $deviceresult = mysql_query("SELECT * from devices $where");
|
||||
|
||||
if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
|
||||
{
|
||||
$map = "digraph G { sep=0.01; size=\"12,5.5\"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0;
|
||||
node [ fontname=\"helvetica\", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false;];
|
||||
edge [ bgcolor=white; fontname=\"helvetica\"; fontstyle=bold; arrowhead=dot; arrowtail=dot];
|
||||
graph [bgcolor=transparent;];\n\n";
|
||||
$map = "digraph G { sep=0.01; size=\"12,5.5\"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0;
|
||||
node [ fontname=\"helvetica\", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false;];
|
||||
edge [ bgcolor=white; fontname=\"helvetica\"; fontstyle=bold; arrowhead=dot; arrowtail=dot];
|
||||
graph [bgcolor=transparent;];\n\n";
|
||||
|
||||
if (!$_SESSION['authenticated'])
|
||||
if (!$_SESSION['authenticated'])
|
||||
{
|
||||
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\" URL=\"/\" shape=box3d]\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
while ($device = mysql_fetch_array($deviceresult))
|
||||
{
|
||||
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\" URL=\"/\" shape=box3d]\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
while ($device = mysql_fetch_array($deviceresult))
|
||||
if ($device)
|
||||
{
|
||||
$sql = "SELECT * from ports AS I, links AS L WHERE I.device_id = ".$device['device_id']." AND L.local_interface_id = I.interface_id ORDER BY L.remote_hostname";
|
||||
$links = mysql_query($sql);
|
||||
|
||||
if (mysql_num_rows($links))
|
||||
{
|
||||
if ($device)
|
||||
{
|
||||
$sql = "SELECT * from ports AS I, links AS L WHERE I.device_id = ".$device['device_id']." AND L.local_interface_id = I.interface_id ORDER BY L.remote_hostname";
|
||||
$links = mysql_query($sql);
|
||||
|
||||
if (mysql_num_rows($links))
|
||||
{
|
||||
$map .= "\"".$device['hostname']."\" [fontsize=20 fillcolor=\"lightblue\" URL=\"{$config['base_url']}/device/".$device['device_id']."/map/\" shape=box3d]\n";
|
||||
}
|
||||
|
||||
while ($link = mysql_fetch_array($links))
|
||||
{
|
||||
$local_interface_id = $link['local_interface_id'];
|
||||
$remote_interface_id = $link['remote_interface_id'];
|
||||
|
||||
$i = 0; $done = 0;
|
||||
while (isset($linkdone) && $i < count($linkdone))
|
||||
{
|
||||
if ($linkdone[$i] == "$remote_interface_id $local_interface_id") { $done = 1; }
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$done)
|
||||
{
|
||||
$linkdone[] = "$local_interface_id $remote_interface_id";
|
||||
|
||||
$links++;
|
||||
|
||||
if ($link['ifSpeed'] >= "10000000000")
|
||||
{
|
||||
$info = "color=red3 style=\"setlinewidth(6)\"";
|
||||
} elseif ($link['ifSpeed'] >= "1000000000") {
|
||||
$info = "color=lightblue style=\"setlinewidth(4)\"";
|
||||
} elseif ($link['ifSpeed'] >= "100000000") {
|
||||
$info = "color=lightgrey style=\"setlinewidth(2)\"";
|
||||
} elseif ($link['ifSpeed'] >= "10000000") {
|
||||
$info = "style=\"setlinewidth(1)\"";
|
||||
} else {
|
||||
$info = "style=\"setlinewidth(1)\"";
|
||||
}
|
||||
|
||||
$src = $device['hostname'];
|
||||
if ($remote_interface_id)
|
||||
{
|
||||
$dst = mysql_result(mysql_query("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = '$remote_interface_id' AND D.device_id = I.device_id"),0);
|
||||
$dst_host = mysql_result(mysql_query("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.interface_id = '$remote_interface_id' AND D.device_id = I.device_id"),0);
|
||||
} else {
|
||||
$dst_host = $link['remote_hostname'];
|
||||
$dst = $link['remote_hostname'];
|
||||
}
|
||||
|
||||
$sif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['local_interface_id'])),$device);
|
||||
if ($remote_interface_id)
|
||||
{
|
||||
$dif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['remote_interface_id'])));
|
||||
} else {
|
||||
$dif['label'] = $link['remote_port'];
|
||||
$dif['interface_id'] = $link['remote_hostname'] . $link['remote_port'];
|
||||
}
|
||||
|
||||
$map .= "\"" . $sif['interface_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue URL=\"{$config['base_url']}/device/".$device['device_id']."/interface/$local_interface_id/\"]\n";
|
||||
if (!$ifdone[$src][$sif['interface_id']])
|
||||
{
|
||||
$map .= "\"$src\" -> \"" . $sif['interface_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$src][$sif['interface_id']] = 1;
|
||||
}
|
||||
|
||||
$map .= "\"$dst\" [URL=\"{$config['base_url']}/device/$dst_host/map/\" fontsize=20 shape=box3d]\n";
|
||||
|
||||
if ($dst_host == $device['device_id'] || $where == '') {
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n";
|
||||
} else {
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n";
|
||||
}
|
||||
|
||||
if (!$ifdone[$dst][$dif['interface_id']])
|
||||
{
|
||||
$map .= "\"" . $dif['interface_id'] . "\" -> \"$dst\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$dst][$dif['interface_id']] = 1;
|
||||
}
|
||||
$map .= "\"" . $sif['interface_id'] . "\" -> \"" . $dif['interface_id'] . "\" [weight=1, arrowhead=normal, arrowtail=normal, len=2, $info] \n";
|
||||
}
|
||||
}
|
||||
$done = 0;
|
||||
}
|
||||
$map .= "\"".$device['hostname']."\" [fontsize=20 fillcolor=\"lightblue\" URL=\"{$config['base_url']}/device/".$device['device_id']."/map/\" shape=box3d]\n";
|
||||
}
|
||||
}
|
||||
|
||||
$map .= "
|
||||
while ($link = mysql_fetch_array($links))
|
||||
{
|
||||
$local_interface_id = $link['local_interface_id'];
|
||||
$remote_interface_id = $link['remote_interface_id'];
|
||||
|
||||
$i = 0; $done = 0;
|
||||
while (isset($linkdone) && $i < count($linkdone))
|
||||
{
|
||||
if ($linkdone[$i] == "$remote_interface_id $local_interface_id") { $done = 1; }
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!$done)
|
||||
{
|
||||
$linkdone[] = "$local_interface_id $remote_interface_id";
|
||||
|
||||
$links++;
|
||||
|
||||
if ($link['ifSpeed'] >= "10000000000")
|
||||
{
|
||||
$info = "color=red3 style=\"setlinewidth(6)\"";
|
||||
} elseif ($link['ifSpeed'] >= "1000000000") {
|
||||
$info = "color=lightblue style=\"setlinewidth(4)\"";
|
||||
} elseif ($link['ifSpeed'] >= "100000000") {
|
||||
$info = "color=lightgrey style=\"setlinewidth(2)\"";
|
||||
} elseif ($link['ifSpeed'] >= "10000000") {
|
||||
$info = "style=\"setlinewidth(1)\"";
|
||||
} else {
|
||||
$info = "style=\"setlinewidth(1)\"";
|
||||
}
|
||||
|
||||
$src = $device['hostname'];
|
||||
if ($remote_interface_id)
|
||||
{
|
||||
$dst = mysql_result(mysql_query("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = '$remote_interface_id' AND D.device_id = I.device_id"),0);
|
||||
$dst_host = mysql_result(mysql_query("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.interface_id = '$remote_interface_id' AND D.device_id = I.device_id"),0);
|
||||
} else {
|
||||
$dst_host = $link['remote_hostname'];
|
||||
$dst = $link['remote_hostname'];
|
||||
}
|
||||
|
||||
$sif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['local_interface_id'])),$device);
|
||||
if ($remote_interface_id)
|
||||
{
|
||||
$dif = ifNameDescr(mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE `interface_id`=" . $link['remote_interface_id'])));
|
||||
} else {
|
||||
$dif['label'] = $link['remote_port'];
|
||||
$dif['interface_id'] = $link['remote_hostname'] . $link['remote_port'];
|
||||
}
|
||||
|
||||
$map .= "\"" . $sif['interface_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue URL=\"{$config['base_url']}/device/".$device['device_id']."/interface/$local_interface_id/\"]\n";
|
||||
if (!$ifdone[$src][$sif['interface_id']])
|
||||
{
|
||||
$map .= "\"$src\" -> \"" . $sif['interface_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$src][$sif['interface_id']] = 1;
|
||||
}
|
||||
|
||||
$map .= "\"$dst\" [URL=\"{$config['base_url']}/device/$dst_host/map/\" fontsize=20 shape=box3d]\n";
|
||||
|
||||
if ($dst_host == $device['device_id'] || $where == '') {
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n";
|
||||
} else {
|
||||
$map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n";
|
||||
}
|
||||
|
||||
if (!$ifdone[$dst][$dif['interface_id']])
|
||||
{
|
||||
$map .= "\"" . $dif['interface_id'] . "\" -> \"$dst\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$dst][$dif['interface_id']] = 1;
|
||||
}
|
||||
$map .= "\"" . $sif['interface_id'] . "\" -> \"" . $dif['interface_id'] . "\" [weight=1, arrowhead=normal, arrowtail=normal, len=2, $info] \n";
|
||||
}
|
||||
}
|
||||
$done = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$map .= "
|
||||
};";
|
||||
|
||||
if ($_GET['debug'] == 1) { echo("<pre>$map</pre>");exit(); }
|
||||
if ($_GET['debug'] == 1) { echo("<pre>$map</pre>");exit(); }
|
||||
|
||||
switch ($_GET['format'])
|
||||
{
|
||||
case 'svg':
|
||||
switch ($_GET['format'])
|
||||
{
|
||||
case 'svg':
|
||||
case 'png':
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
$_GET['format'] = 'png';
|
||||
}
|
||||
$_GET['format'] = 'png';
|
||||
}
|
||||
|
||||
if ($links > 10) ### Unflatten if there are more than 10 links. beyond that it gets messy
|
||||
{
|
||||
if ($links > 10) ### Unflatten if there are more than 10 links. beyond that it gets messy
|
||||
{
|
||||
$maptool = 'unflatten -f -l 5 |dot';
|
||||
} else {
|
||||
} else {
|
||||
$maptool = 'dot';
|
||||
}
|
||||
}
|
||||
|
||||
if ($where == '') { $maptool = 'neato -Gpack'; }
|
||||
if ($where == '') { $maptool = 'neato -Gpack'; }
|
||||
|
||||
$img = shell_exec("echo \"".addslashes($map)."\" | $maptool -T".$_GET['format']."");
|
||||
if ($_GET['format'] == "png") {
|
||||
$img = shell_exec("echo \"".addslashes($map)."\" | $maptool -T".$_GET['format']."");
|
||||
if ($_GET['format'] == "png") {
|
||||
header("Content-type: image/".$_GET['format']);
|
||||
} elseif ($_GET['format'] == "svg") {
|
||||
} elseif ($_GET['format'] == "svg") {
|
||||
header("Content-type: image/svg+xml");
|
||||
$img = str_replace("<a ", '<a target="_parent" ', $img);
|
||||
}
|
||||
echo("$img");
|
||||
}
|
||||
echo("$img");
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($_SESSION['authenticated']) ## FIXME level 10 only?
|
||||
{
|
||||
echo('<center>
|
||||
<object data="'. $config['base_url'] . '/map.php?format=svg" type="image/svg+xml">
|
||||
</object>
|
||||
</center>');
|
||||
}
|
||||
if ($_SESSION['authenticated']) ## FIXME level 10 only?
|
||||
{
|
||||
echo('<center>
|
||||
<object data="'. $config['base_url'] . '/map.php?format=svg" type="image/svg+xml">
|
||||
</object>
|
||||
</center>');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -5,10 +5,10 @@ ini_set('display_errors', 0);
|
||||
|
||||
if ($_GET[debug])
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
@@ -19,37 +19,40 @@ include("includes/authenticate.inc.php");
|
||||
|
||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
|
||||
if ($_GET['query'] && $_GET['cmd']) {
|
||||
$host = $_GET['query'];
|
||||
if (Net_IPv6::checkIPv6($host)||Net_IPv4::validateip($host)||preg_match("/^[a-zA-Z0-9.-]*$/", $host)) {
|
||||
switch ($_GET['cmd']) {
|
||||
case 'whois':
|
||||
$cmd = $config['whois'] . " $host | grep -v \%";
|
||||
break;
|
||||
case 'ping':
|
||||
$cmd = $config['ping'] . " -c 5 $host";
|
||||
break;
|
||||
case 'tracert':
|
||||
$cmd = $config['mtr'] . " -r -c 5 $host";
|
||||
break;
|
||||
case 'nmap':
|
||||
if ($_SESSION['userlevel'] != '10')
|
||||
{
|
||||
echo("insufficient privileges");
|
||||
} else {
|
||||
$cmd = $config['nmap'] . " $host";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($cmd))
|
||||
if ($_GET['query'] && $_GET['cmd'])
|
||||
{
|
||||
$host = $_GET['query'];
|
||||
if (Net_IPv6::checkIPv6($host)||Net_IPv4::validateip($host)||preg_match("/^[a-zA-Z0-9.-]*$/", $host))
|
||||
{
|
||||
switch ($_GET['cmd'])
|
||||
{
|
||||
case 'whois':
|
||||
$cmd = $config['whois'] . " $host | grep -v \%";
|
||||
break;
|
||||
case 'ping':
|
||||
$cmd = $config['ping'] . " -c 5 $host";
|
||||
break;
|
||||
case 'tracert':
|
||||
$cmd = $config['mtr'] . " -r -c 5 $host";
|
||||
break;
|
||||
case 'nmap':
|
||||
if ($_SESSION['userlevel'] != '10')
|
||||
{
|
||||
$output = `$cmd`;
|
||||
echo("insufficient privileges");
|
||||
} else {
|
||||
$cmd = $config['nmap'] . " $host";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($cmd))
|
||||
{
|
||||
$output = `$cmd`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = trim($output);
|
||||
echo("<pre>$output</pre>");
|
||||
|
||||
?>
|
||||
?>
|
@@ -92,7 +92,9 @@ include("overview/sensors/frequencies.inc.php");
|
||||
include("overview/sensors/current.inc.php");
|
||||
|
||||
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
|
||||
echo("<p style='padding: 0px 5px 5px;' class=sectionhead><img align='absmiddle' src='".$config['base_url']."/images/16/report.png'> Recent Events</p>");
|
||||
echo("<p style='padding: 0px 5px 5px;' class=sectionhead>");
|
||||
echo('<a class="sectionhead" href="device/'.$device['device_id'].'/events/">');
|
||||
echo("<img align='absmiddle' src='".$config['base_url']."/images/16/report.png'> Recent Events</a></p>");
|
||||
|
||||
$query = "SELECT *,DATE_FORMAT(datetime, '%d/%b/%y %T') as humandate FROM `eventlog` WHERE `host` = '$_GET[id]' ORDER BY `datetime` DESC LIMIT 0,10";
|
||||
$data = mysql_query($query);
|
||||
|
@@ -2,4 +2,4 @@
|
||||
|
||||
phpinfo();
|
||||
|
||||
?>
|
||||
?>
|
@@ -2,190 +2,190 @@
|
||||
|
||||
function getDates($dayofmonth)
|
||||
{
|
||||
$dayofmonth = zeropad($dayofmonth);
|
||||
list($year, $month) = split('-', date('Y-m'));
|
||||
$dayofmonth = zeropad($dayofmonth);
|
||||
list($year, $month) = split('-', date('Y-m'));
|
||||
|
||||
if (date('d') > $dayofmonth)
|
||||
if (date('d') > $dayofmonth)
|
||||
{
|
||||
$newmonth = $month + 1;
|
||||
if ($newmonth == 13)
|
||||
{
|
||||
$newmonth = $month + 1;
|
||||
if ($newmonth == 13)
|
||||
{
|
||||
$newmonth = 1;
|
||||
$newyear = year + 1;
|
||||
} else {
|
||||
$newyear = $year;
|
||||
}
|
||||
|
||||
$date_from = $year . $month . $dayofmonth;
|
||||
$date_to = $newyear . $newmonth . $dayofmonth;
|
||||
$dt_q = mysql_query("SELECT DATE_SUB(DATE_ADD('$date_from', INTERVAL 1 MONTH), INTERVAL 1 DAY);");
|
||||
$date_to = mysql_result($dt_q,0);
|
||||
$date_to = str_replace("-","",$date_to);
|
||||
}
|
||||
else
|
||||
{
|
||||
$newmonth = $month - 1;
|
||||
if ($newmonth == 0)
|
||||
{
|
||||
$newmonth = 12;
|
||||
$newyear = $year - 1;
|
||||
} else {
|
||||
$newyear = $year;
|
||||
}
|
||||
|
||||
$date_from = $newyear . $newmonth . $dayofmonth;
|
||||
$date_to = $year . $month . $dayofmonth;
|
||||
$dt_q = mysql_query("SELECT DATE_SUB(DATE_ADD('$date_to', INTERVAL 1 MONTH, INTERVAL 1 DAY);");
|
||||
$date_from = mysql_result($dt_q,0);
|
||||
$date_from = str_replace("-","",$date_from);
|
||||
$newmonth = 1;
|
||||
$newyear = year + 1;
|
||||
} else {
|
||||
$newyear = $year;
|
||||
}
|
||||
|
||||
$lq_from = mysql_query("SELECT DATE_SUB('$date_from', INTERVAL 1 MONTH);");
|
||||
$last_from = mysql_result($lq_from,0);
|
||||
$last_from = str_replace("-","",$last_from);
|
||||
$date_from = $year . $month . $dayofmonth;
|
||||
$date_to = $newyear . $newmonth . $dayofmonth;
|
||||
$dt_q = mysql_query("SELECT DATE_SUB(DATE_ADD('$date_from', INTERVAL 1 MONTH), INTERVAL 1 DAY);");
|
||||
$date_to = mysql_result($dt_q,0);
|
||||
$date_to = str_replace("-","",$date_to);
|
||||
}
|
||||
else
|
||||
{
|
||||
$newmonth = $month - 1;
|
||||
if ($newmonth == 0)
|
||||
{
|
||||
$newmonth = 12;
|
||||
$newyear = $year - 1;
|
||||
} else {
|
||||
$newyear = $year;
|
||||
}
|
||||
|
||||
$lq_to = mysql_query("SELECT DATE_SUB('$date_to', INTERVAL 1 MONTH);");
|
||||
$last_to = mysql_result($lq_to,0);
|
||||
$last_to = str_replace("-","",$last_to);
|
||||
$date_from = $newyear . $newmonth . $dayofmonth;
|
||||
$date_to = $year . $month . $dayofmonth;
|
||||
$dt_q = mysql_query("SELECT DATE_SUB(DATE_ADD('$date_to', INTERVAL 1 MONTH, INTERVAL 1 DAY);");
|
||||
$date_from = mysql_result($dt_q,0);
|
||||
$date_from = str_replace("-","",$date_from);
|
||||
}
|
||||
|
||||
$return['0'] = $date_from . "000000";
|
||||
$return['1'] = $date_to . "235959";
|
||||
$return['2'] = $last_from . "000000";
|
||||
$return['3'] = $last_to . "235959";
|
||||
$lq_from = mysql_query("SELECT DATE_SUB('$date_from', INTERVAL 1 MONTH);");
|
||||
$last_from = mysql_result($lq_from,0);
|
||||
$last_from = str_replace("-","",$last_from);
|
||||
|
||||
return($return);
|
||||
$lq_to = mysql_query("SELECT DATE_SUB('$date_to', INTERVAL 1 MONTH);");
|
||||
$last_to = mysql_result($lq_to,0);
|
||||
$last_to = str_replace("-","",$last_to);
|
||||
|
||||
$return['0'] = $date_from . "000000";
|
||||
$return['1'] = $date_to . "235959";
|
||||
$return['2'] = $last_from . "000000";
|
||||
$return['3'] = $last_to . "235959";
|
||||
|
||||
return($return);
|
||||
}
|
||||
|
||||
|
||||
function getValue($host, $port, $id, $inout)
|
||||
{
|
||||
global $config;
|
||||
global $config;
|
||||
|
||||
$oid = "IF-MIB::ifHC" . $inout . "Octets." . $id;
|
||||
$device = mysql_fetch_assoc(mysql_query("SELECT * from `devices` WHERE `hostname` = '" . $host . "' LIMIT 1"));
|
||||
$value = snmp_get($device, $oid, "-O qv");
|
||||
$oid = "IF-MIB::ifHC" . $inout . "Octets." . $id;
|
||||
$device = mysql_fetch_assoc(mysql_query("SELECT * from `devices` WHERE `hostname` = '" . $host . "' LIMIT 1"));
|
||||
$value = snmp_get($device, $oid, "-O qv");
|
||||
|
||||
if (!is_numeric($value))
|
||||
{
|
||||
$oid = "IF-MIB::if" . $inout . "Octets." . $id;
|
||||
$value = snmp_get($device, $oid, "-Oqv");
|
||||
}
|
||||
if (!is_numeric($value))
|
||||
{
|
||||
$oid = "IF-MIB::if" . $inout . "Octets." . $id;
|
||||
$value = snmp_get($device, $oid, "-Oqv");
|
||||
}
|
||||
|
||||
return $value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
function getLastPortCounter($port_id,$inout)
|
||||
{
|
||||
$query = mysql_query("SELECT count(counter) from port_" . $inout . "_measurements WHERE port_id=" . $port_id);
|
||||
$rows = mysql_result($query, 0);
|
||||
$query = mysql_query("SELECT count(counter) from port_" . $inout . "_measurements WHERE port_id=" . $port_id);
|
||||
$rows = mysql_result($query, 0);
|
||||
|
||||
if ($rows > 0)
|
||||
{
|
||||
$query = mysql_query("SELECT counter,delta FROM port_" . $inout . "_measurements WHERE port_id=$port_id ORDER BY timestamp DESC");
|
||||
$row = mysql_fetch_row($query);
|
||||
$return[counter] = $row[0];
|
||||
$return[delta] = $row[1];
|
||||
$return[state] = "ok";
|
||||
} else {
|
||||
$return[state] = "failed";
|
||||
}
|
||||
if ($rows > 0)
|
||||
{
|
||||
$query = mysql_query("SELECT counter,delta FROM port_" . $inout . "_measurements WHERE port_id=$port_id ORDER BY timestamp DESC");
|
||||
$row = mysql_fetch_row($query);
|
||||
$return[counter] = $row[0];
|
||||
$return[delta] = $row[1];
|
||||
$return[state] = "ok";
|
||||
} else {
|
||||
$return[state] = "failed";
|
||||
}
|
||||
|
||||
return($return);
|
||||
return($return);
|
||||
}
|
||||
|
||||
function getLastMeasurement($bill_id)
|
||||
{
|
||||
$query = mysql_query("SELECT count(delta) from bill_data WHERE bill_id=" . $bill_id);
|
||||
$rows = mysql_result($query, 0);
|
||||
$query = mysql_query("SELECT count(delta) from bill_data WHERE bill_id=" . $bill_id);
|
||||
$rows = mysql_result($query, 0);
|
||||
|
||||
if ($rows > 0)
|
||||
{
|
||||
$query = mysql_query("SELECT timestamp,delta,in_delta,out_delta FROM bill_data WHERE bill_id=$bill_id ORDER BY timestamp DESC");
|
||||
$row = mysql_fetch_row($query);
|
||||
$return[delta] = $row[1];
|
||||
$return[delta] = $row[2];
|
||||
$return[delta] = $row[3];
|
||||
$return[timestamp] = $row[0];
|
||||
$return[state] = "ok";
|
||||
} else {
|
||||
$return[state] = "failed";
|
||||
}
|
||||
if ($rows > 0)
|
||||
{
|
||||
$query = mysql_query("SELECT timestamp,delta,in_delta,out_delta FROM bill_data WHERE bill_id=$bill_id ORDER BY timestamp DESC");
|
||||
$row = mysql_fetch_row($query);
|
||||
$return[delta] = $row[1];
|
||||
$return[delta] = $row[2];
|
||||
$return[delta] = $row[3];
|
||||
$return[timestamp] = $row[0];
|
||||
$return[state] = "ok";
|
||||
} else {
|
||||
$return[state] = "failed";
|
||||
}
|
||||
|
||||
return($return);
|
||||
return($return);
|
||||
}
|
||||
|
||||
function get95thin($bill_id,$datefrom,$dateto)
|
||||
{
|
||||
$mq_text = "SELECT count(delta) FROM bill_data WHERE bill_id = $bill_id";
|
||||
$mq_text .= " AND timestamp > $datefrom AND timestamp <= $dateto";
|
||||
$m_query = mysql_query($mq_text);
|
||||
$measurements = mysql_result($m_query,0);
|
||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||
$mq_text = "SELECT count(delta) FROM bill_data WHERE bill_id = $bill_id";
|
||||
$mq_text .= " AND timestamp > $datefrom AND timestamp <= $dateto";
|
||||
$m_query = mysql_query($mq_text);
|
||||
$measurements = mysql_result($m_query,0);
|
||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||
|
||||
$q_95_text = "SELECT (in_delta / period / 1000 * 8) AS rate FROM bill_data WHERE bill_id = $bill_id";
|
||||
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY in_delta ASC";
|
||||
$q_95th = mysql_query($q_95_text);
|
||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||
$q_95_text = "SELECT (in_delta / period / 1000 * 8) AS rate FROM bill_data WHERE bill_id = $bill_id";
|
||||
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY in_delta ASC";
|
||||
$q_95th = mysql_query($q_95_text);
|
||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||
|
||||
return(round($m_95th, 2));
|
||||
return(round($m_95th, 2));
|
||||
}
|
||||
|
||||
function get95thout($bill_id,$datefrom,$dateto)
|
||||
{
|
||||
$mq_text = "SELECT count(delta) FROM bill_data WHERE bill_id = $bill_id";
|
||||
$mq_text .= " AND timestamp > $datefrom AND timestamp <= $dateto";
|
||||
$m_query = mysql_query($mq_text);
|
||||
$measurements = mysql_result($m_query,0);
|
||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||
$mq_text = "SELECT count(delta) FROM bill_data WHERE bill_id = $bill_id";
|
||||
$mq_text .= " AND timestamp > $datefrom AND timestamp <= $dateto";
|
||||
$m_query = mysql_query($mq_text);
|
||||
$measurements = mysql_result($m_query,0);
|
||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||
|
||||
$q_95_text = "SELECT (out_delta / period / 1000 * 8) AS rate FROM bill_data WHERE bill_id = $bill_id";
|
||||
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY out_delta ASC";
|
||||
$q_95th = mysql_query($q_95_text);
|
||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||
$q_95_text = "SELECT (out_delta / period / 1000 * 8) AS rate FROM bill_data WHERE bill_id = $bill_id";
|
||||
$q_95_text .= " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY out_delta ASC";
|
||||
$q_95th = mysql_query($q_95_text);
|
||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||
|
||||
return(round($m_95th, 2));
|
||||
return(round($m_95th, 2));
|
||||
}
|
||||
|
||||
function getRates($bill_id,$datefrom,$dateto)
|
||||
{
|
||||
$mq_text = "SELECT count(delta) FROM bill_data ";
|
||||
$mq_text = $mq_text . " WHERE bill_id = $bill_id";
|
||||
$mq_text = $mq_text . " AND timestamp > $datefrom AND timestamp <= $dateto";
|
||||
$m_query = mysql_query($mq_text);
|
||||
$measurements = mysql_result($m_query,0);
|
||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||
$mq_text = "SELECT count(delta) FROM bill_data ";
|
||||
$mq_text = $mq_text . " WHERE bill_id = $bill_id";
|
||||
$mq_text = $mq_text . " AND timestamp > $datefrom AND timestamp <= $dateto";
|
||||
$m_query = mysql_query($mq_text);
|
||||
$measurements = mysql_result($m_query,0);
|
||||
$measurement_95th = round($measurements /100 * 95) - 1;
|
||||
|
||||
$q_95_text = "SELECT delta FROM bill_data WHERE bill_id = $bill_id";
|
||||
$q_95_text = $q_95_text . " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY delta ASC";
|
||||
$q_95th = mysql_query($q_95_text);
|
||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||
$q_95_text = "SELECT delta FROM bill_data WHERE bill_id = $bill_id";
|
||||
$q_95_text = $q_95_text . " AND timestamp > $datefrom AND timestamp <= $dateto ORDER BY delta ASC";
|
||||
$q_95th = mysql_query($q_95_text);
|
||||
$m_95th = mysql_result($q_95th,$measurement_95th);
|
||||
|
||||
$mt_q = mysql_query("SELECT SUM(delta) FROM bill_data WHERE bill_id = '$bill_id' AND timestamp > '$datefrom' AND timestamp <= '$dateto'");
|
||||
$mtot = mysql_result($mt_q,0);
|
||||
$data['rate_95th_in'] = get95thIn($bill_id,$datefrom,$dateto);
|
||||
$data['rate_95th_out'] = get95thOut($bill_id,$datefrom,$dateto);
|
||||
$mt_q = mysql_query("SELECT SUM(delta) FROM bill_data WHERE bill_id = '$bill_id' AND timestamp > '$datefrom' AND timestamp <= '$dateto'");
|
||||
$mtot = mysql_result($mt_q,0);
|
||||
$data['rate_95th_in'] = get95thIn($bill_id,$datefrom,$dateto);
|
||||
$data['rate_95th_out'] = get95thOut($bill_id,$datefrom,$dateto);
|
||||
|
||||
if ($data['rate_95th_out'] > $data['rate_95th_in'])
|
||||
{
|
||||
$data['rate_95th'] = $data['rate_95th_out'];
|
||||
$data['dir_95th'] = 'out';
|
||||
} else {
|
||||
$data['rate_95th'] = $data['rate_95th_in'];
|
||||
$data['dir_95th'] = 'in';
|
||||
}
|
||||
if ($data['rate_95th_out'] > $data['rate_95th_in'])
|
||||
{
|
||||
$data['rate_95th'] = $data['rate_95th_out'];
|
||||
$data['dir_95th'] = 'out';
|
||||
} else {
|
||||
$data['rate_95th'] = $data['rate_95th_in'];
|
||||
$data['dir_95th'] = 'in';
|
||||
}
|
||||
|
||||
$data['total_data'] = round($mtot / 1000 / 1000, 2);
|
||||
$data['rate_average'] = round($mtot / $measurements / 1000 / 300 * 8, 2);
|
||||
$data['total_data'] = round($mtot / 1000 / 1000, 2);
|
||||
$data['rate_average'] = round($mtot / $measurements / 1000 / 300 * 8, 2);
|
||||
|
||||
return($data);
|
||||
return($data);
|
||||
}
|
||||
|
||||
function getTotal($bill_id,$datefrom,$dateto)
|
||||
{
|
||||
$mt_q = mysql_query("SELECT sum(delta) FROM bill_data WHERE bill_id = $bill_id AND timestamp > $datefrom AND timestamp <= $dateto");
|
||||
$mtot = mysql_result($mt_q,0);
|
||||
$mt_q = mysql_query("SELECT sum(delta) FROM bill_data WHERE bill_id = $bill_id AND timestamp > $datefrom AND timestamp <= $dateto");
|
||||
$mtot = mysql_result($mt_q,0);
|
||||
|
||||
return($mtot);
|
||||
return($mtot);
|
||||
}
|
||||
|
||||
$dayofmonth = date("j"); //FIXME is this used anywhere?
|
||||
|
@@ -3,23 +3,23 @@
|
||||
## List of real names for cisco entities
|
||||
|
||||
$entPhysicalVendorTypes = array (
|
||||
'cevC7xxxIo1feTxIsl' => 'C7200-IO-FE-MII',
|
||||
'cevChassis7140Dualfe' => 'C7140-2FE',
|
||||
'cevChassis7204' => "C7204",
|
||||
'cevChassis7204Vxr' => 'C7204VXR',
|
||||
'cevChassis7206' => 'C7206',
|
||||
'cevChassis7206Vxr' => 'C7206VXR',
|
||||
'cevCpu7200Npe200' => 'NPE-200',
|
||||
'cevCpu7200Npe225' => 'NPE-225',
|
||||
'cevCpu7200Npe300' => 'NPE-300',
|
||||
'cevCpu7200Npe400' => 'NPE-400',
|
||||
'cevCpu7200Npeg1' => 'NPE-G1',
|
||||
'cevCpu7200Npeg2' => 'NPE-G2',
|
||||
'cevPa1feTxIsl' => 'PA-FE-TX-ISL',
|
||||
'cevPa2feTxI82543' => 'PA-2FE-TX',
|
||||
'cevPa8e' => 'PA-8E',
|
||||
'cevPaA8tX21' => 'PA-8T-X21',
|
||||
'cevMGBIC1000BaseLX' => '1000BaseLX GBIC',
|
||||
'cevPort10GigBaseLR' => '10GigBaseLR');
|
||||
'cevC7xxxIo1feTxIsl' => 'C7200-IO-FE-MII',
|
||||
'cevChassis7140Dualfe' => 'C7140-2FE',
|
||||
'cevChassis7204' => "C7204",
|
||||
'cevChassis7204Vxr' => 'C7204VXR',
|
||||
'cevChassis7206' => 'C7206',
|
||||
'cevChassis7206Vxr' => 'C7206VXR',
|
||||
'cevCpu7200Npe200' => 'NPE-200',
|
||||
'cevCpu7200Npe225' => 'NPE-225',
|
||||
'cevCpu7200Npe300' => 'NPE-300',
|
||||
'cevCpu7200Npe400' => 'NPE-400',
|
||||
'cevCpu7200Npeg1' => 'NPE-G1',
|
||||
'cevCpu7200Npeg2' => 'NPE-G2',
|
||||
'cevPa1feTxIsl' => 'PA-FE-TX-ISL',
|
||||
'cevPa2feTxI82543' => 'PA-2FE-TX',
|
||||
'cevPa8e' => 'PA-8E',
|
||||
'cevPaA8tX21' => 'PA-8T-X21',
|
||||
'cevMGBIC1000BaseLX' => '1000BaseLX GBIC',
|
||||
'cevPort10GigBaseLR' => '10GigBaseLR');
|
||||
|
||||
?>
|
||||
|
@@ -1,186 +1,185 @@
|
||||
<?php
|
||||
|
||||
|
||||
## Common Functions
|
||||
|
||||
function get_port_by_id($port_id)
|
||||
{
|
||||
if (is_numeric($port_id))
|
||||
{
|
||||
$port = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '".$port_id."'"));
|
||||
}
|
||||
if (is_array($port))
|
||||
{
|
||||
return $port;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
if (is_numeric($port_id))
|
||||
{
|
||||
$port = mysql_fetch_assoc(mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '".$port_id."'"));
|
||||
}
|
||||
if (is_array($port))
|
||||
{
|
||||
return $port;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function get_application_by_id($application_id)
|
||||
{
|
||||
if (is_numeric($application_id))
|
||||
{
|
||||
$application = mysql_fetch_assoc(mysql_query("SELECT * FROM `applications` WHERE `app_id` = '".$application_id."'"));
|
||||
}
|
||||
if (is_array($application))
|
||||
{
|
||||
return $application;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
if (is_numeric($application_id))
|
||||
{
|
||||
$application = mysql_fetch_assoc(mysql_query("SELECT * FROM `applications` WHERE `app_id` = '".$application_id."'"));
|
||||
}
|
||||
if (is_array($application))
|
||||
{
|
||||
return $application;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function get_sensor_by_id($sensor_id)
|
||||
{
|
||||
if (is_numeric($sensor_id))
|
||||
{
|
||||
$sensor = mysql_fetch_assoc(mysql_query("SELECT * FROM `sensors` WHERE `sensor_id` = '".$sensor_id."'"));
|
||||
}
|
||||
if (is_array($sensor))
|
||||
{
|
||||
return $sensor;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
if (is_numeric($sensor_id))
|
||||
{
|
||||
$sensor = mysql_fetch_assoc(mysql_query("SELECT * FROM `sensors` WHERE `sensor_id` = '".$sensor_id."'"));
|
||||
}
|
||||
if (is_array($sensor))
|
||||
{
|
||||
return $sensor;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function get_device_id_by_interface_id($interface_id)
|
||||
{
|
||||
if (is_numeric($interface_id))
|
||||
{
|
||||
$device_id = mysql_result(mysql_query("SELECT `device_id` FROM `ports` WHERE `interface_id` = '".$interface_id."'"),0);
|
||||
}
|
||||
if (is_numeric($device_id))
|
||||
{
|
||||
return $device_id;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
if (is_numeric($interface_id))
|
||||
{
|
||||
$device_id = mysql_result(mysql_query("SELECT `device_id` FROM `ports` WHERE `interface_id` = '".$interface_id."'"),0);
|
||||
}
|
||||
if (is_numeric($device_id))
|
||||
{
|
||||
return $device_id;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function ifclass($ifOperStatus, $ifAdminStatus)
|
||||
{
|
||||
$ifclass = "interface-upup";
|
||||
$ifclass = "interface-upup";
|
||||
|
||||
if ($ifAdminStatus == "down") { $ifclass = "interface-admindown"; }
|
||||
if ($ifAdminStatus == "up" && $ifOperStatus== "down") { $ifclass = "interface-updown"; }
|
||||
if ($ifAdminStatus == "up" && $ifOperStatus== "up") { $ifclass = "interface-upup"; }
|
||||
if ($ifAdminStatus == "down") { $ifclass = "interface-admindown"; }
|
||||
if ($ifAdminStatus == "up" && $ifOperStatus== "down") { $ifclass = "interface-updown"; }
|
||||
if ($ifAdminStatus == "up" && $ifOperStatus== "up") { $ifclass = "interface-upup"; }
|
||||
|
||||
return $ifclass;
|
||||
return $ifclass;
|
||||
}
|
||||
|
||||
function device_by_id_cache($device_id)
|
||||
{
|
||||
global $device_cache;
|
||||
global $device_cache;
|
||||
|
||||
if (is_array($device_cache[$device_id]))
|
||||
{
|
||||
$device = $device_cache[$device_id];
|
||||
} else {
|
||||
$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device_id."'"));
|
||||
$device_cache[$device_id] = $device;
|
||||
}
|
||||
if (is_array($device_cache[$device_id]))
|
||||
{
|
||||
$device = $device_cache[$device_id];
|
||||
} else {
|
||||
$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device_id."'"));
|
||||
$device_cache[$device_id] = $device;
|
||||
}
|
||||
|
||||
return $device;
|
||||
return $device;
|
||||
}
|
||||
|
||||
function truncate($substring, $max = 50, $rep = '...')
|
||||
{
|
||||
if (strlen($substring) < 1){ $string = $rep; } else { $string = $substring; }
|
||||
$leave = $max - strlen ($rep);
|
||||
if (strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; }
|
||||
if (strlen($substring) < 1){ $string = $rep; } else { $string = $substring; }
|
||||
$leave = $max - strlen ($rep);
|
||||
if (strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; }
|
||||
}
|
||||
|
||||
function mres($string)
|
||||
{ // short function wrapper because the real one is stupidly long and ugly. aestetics.
|
||||
return mysql_real_escape_string($string);
|
||||
return mysql_real_escape_string($string);
|
||||
}
|
||||
|
||||
function getifhost($id)
|
||||
{
|
||||
$sql = mysql_query("SELECT `device_id` from `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
$sql = mysql_query("SELECT `device_id` from `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function gethostbyid($id)
|
||||
{
|
||||
$sql = mysql_query("SELECT `hostname` FROM `devices` WHERE `device_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
$sql = mysql_query("SELECT `hostname` FROM `devices` WHERE `device_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function strgen ($length = 16)
|
||||
{
|
||||
$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 = "";
|
||||
$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];
|
||||
}
|
||||
for ($i=0; $i<$length; $i++)
|
||||
{
|
||||
$key = mt_rand(0,61);
|
||||
$string .= $entropy[$key];
|
||||
}
|
||||
|
||||
return $string;
|
||||
return $string;
|
||||
}
|
||||
|
||||
function getpeerhost($id)
|
||||
{
|
||||
$sql = mysql_query("SELECT `device_id` from `bgpPeers` WHERE `bgpPeer_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
$sql = mysql_query("SELECT `device_id` from `bgpPeers` WHERE `bgpPeer_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getifindexbyid($id)
|
||||
{
|
||||
$sql = mysql_query("SELECT `ifIndex` FROM `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
$sql = mysql_query("SELECT `ifIndex` FROM `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getifbyid($id)
|
||||
{
|
||||
$sql = mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_fetch_array($sql);
|
||||
$sql = mysql_query("SELECT * FROM `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_fetch_array($sql);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getifdescrbyid($id)
|
||||
{
|
||||
$sql = mysql_query("SELECT `ifDescr` FROM `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
$sql = mysql_query("SELECT `ifDescr` FROM `ports` WHERE `interface_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getidbyname($domain)
|
||||
{
|
||||
$sql = mysql_query("SELECT `device_id` FROM `devices` WHERE `hostname` = '$domain'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
$sql = mysql_query("SELECT `device_id` FROM `devices` WHERE `hostname` = '$domain'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function gethostosbyid($id)
|
||||
{
|
||||
$sql = mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
$sql = mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '$id'");
|
||||
$result = @mysql_result($sql, 0);
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function safename($name)
|
||||
{
|
||||
return preg_replace('/[^a-zA-Z0-9,._\-]/', '_', $name);
|
||||
return preg_replace('/[^a-zA-Z0-9,._\-]/', '_', $name);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -31,7 +31,7 @@ $config['ipmitool'] = "/usr/bin/ipmitool";
|
||||
|
||||
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["SERVER_PORT"]))
|
||||
{
|
||||
$config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] .":".$_SERVER["SERVER_PORT"];
|
||||
$config['base_url'] = "http://" . $_SERVER["SERVER_NAME"] .":".$_SERVER["SERVER_PORT"];
|
||||
}
|
||||
$config['title_image'] = "images/observium-logo.png";
|
||||
$config['stylesheet'] = "css/styles.css";
|
||||
@@ -155,10 +155,10 @@ $config['rancid_ignorecomments'] = 0; # Ignore lines starting with #
|
||||
### Ignores & Allows
|
||||
|
||||
$config['bad_if'] = array("voip-null", "virtual-", "unrouted", "eobc", "mpls", "sl0", "lp0", "faith0",
|
||||
"-atm layer", "-atm subif", "-shdsl", "-aal5", "-atm", "container",
|
||||
"async", "plip", "-physical", "-signalling", "container", "unrouted",
|
||||
"bri", "-bearer", "bluetooth", "isatap", "ras", "qos", "miniport", "sonet/sdh",
|
||||
"span rp", "span sp", "sslvpn");
|
||||
"-atm layer", "-atm subif", "-shdsl", "-aal5", "-atm", "container",
|
||||
"async", "plip", "-physical", "-signalling", "container", "unrouted",
|
||||
"bri", "-bearer", "bluetooth", "isatap", "ras", "qos", "miniport", "sonet/sdh",
|
||||
"span rp", "span sp", "sslvpn");
|
||||
|
||||
$config['bad_if_regexp'] = array("/serial[0-9]:/");
|
||||
|
||||
@@ -195,9 +195,9 @@ $config['ignore_mount'] = array("/kern", "/mnt/cdrom", "/proc", "/dev");
|
||||
$config['ignore_mount_string'] = array("packages", "devfs", "procfs", "UMA", "MALLOC");
|
||||
|
||||
$config['ignore_mount_regexp'] = array("/on: \/packages/", "/on: \/dev/", "/on: \/proc/", "/on: \/junos^/", ## JunOS Drives
|
||||
"/on: \/junos\/dev/", "/on: \/jail\/dev/", "/^(dev|proc)fs/", "/^\/dev\/md0/", ## JunOS Drives
|
||||
"/^\/var\/dhcpd\/dev,/", "/UMA/" ## BSD Drives
|
||||
);
|
||||
"/on: \/junos\/dev/", "/on: \/jail\/dev/", "/^(dev|proc)fs/", "/^\/dev\/md0/", ## JunOS Drives
|
||||
"/^\/var\/dhcpd\/dev,/", "/UMA/" ## BSD Drives
|
||||
);
|
||||
|
||||
$config['ignore_mount_removable'] = 1; # Ignore removable disk storage
|
||||
$config['ignore_mount_network'] = 1; # Ignore network mounted storage
|
||||
@@ -206,8 +206,8 @@ $config['ignore_mount_network'] = 1; # Ignore network mounted storage
|
||||
|
||||
$config['syslog_age'] = "1 month"; ## Entries older than this will be removed
|
||||
$config['syslog_filter'] = array("last message repeated", "Connection from UDP: [",
|
||||
"ipSystemStatsTable node ipSystemStatsOutFragOKs not implemented",
|
||||
"diskio.c: don't know how to handle"); ## Ignore some crappy stuff from SNMP daemon
|
||||
"ipSystemStatsTable node ipSystemStatsOutFragOKs not implemented",
|
||||
"diskio.c: don't know how to handle"); ## Ignore some crappy stuff from SNMP daemon
|
||||
|
||||
### LDAP Authentication
|
||||
|
||||
@@ -224,4 +224,4 @@ $config['astext'][65333] = "Cymru Bogon Feed";
|
||||
### What should we warn about?
|
||||
$config['warn']['ifdown'] = false;
|
||||
|
||||
?>
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@@ -6,20 +6,20 @@ $app_data = mysql_query($sql);
|
||||
|
||||
if (mysql_affected_rows())
|
||||
{
|
||||
echo('Applications: ');
|
||||
while ($app = mysql_fetch_array($app_data))
|
||||
echo('Applications: ');
|
||||
while ($app = mysql_fetch_array($app_data))
|
||||
{
|
||||
$app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php';
|
||||
if (is_file($app_include))
|
||||
{
|
||||
$app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php';
|
||||
if (is_file($app_include))
|
||||
{
|
||||
include($app_include);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo($app['app_type'].' include missing! ');
|
||||
}
|
||||
include($app_include);
|
||||
}
|
||||
echo("\n");
|
||||
else
|
||||
{
|
||||
echo($app['app_type'].' include missing! ');
|
||||
}
|
||||
}
|
||||
echo("\n");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -4,240 +4,240 @@ echo("Polling BGP peers\n");
|
||||
|
||||
if (!$config['enable_bgp'])
|
||||
{
|
||||
echo("BGP Support Disabled\n");
|
||||
echo("BGP Support Disabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'");
|
||||
while ($peer = mysql_fetch_array($peers))
|
||||
$peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'");
|
||||
while ($peer = mysql_fetch_array($peers))
|
||||
{
|
||||
### Poll BGP Peer
|
||||
|
||||
echo("Checking ".$peer['bgpPeerIdentifier']." ");
|
||||
|
||||
if (!strstr($peer['bgpPeerIdentifier'],':'))
|
||||
{
|
||||
### Poll BGP Peer
|
||||
# v4 BGP4 MIB
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m BGP4-MIB -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
||||
$peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " ";
|
||||
$peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
|
||||
$peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . "";
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
}
|
||||
else
|
||||
if ($device['os'] == "junos")
|
||||
{
|
||||
# v6 for JunOS via Juniper MIB
|
||||
$peer_ip = ipv62snmp($peer['bgpPeerIdentifier']);
|
||||
|
||||
echo("Checking ".$peer['bgpPeerIdentifier']." ");
|
||||
|
||||
if (!strstr($peer['bgpPeerIdentifier'],':'))
|
||||
if (!isset($junos_v6))
|
||||
{
|
||||
echo("\nCaching Oids...");
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpwalk'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUnq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6";
|
||||
foreach (explode("\n",trim(`$peer_cmd`)) as $oid)
|
||||
{
|
||||
# v4 BGP4 MIB
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m BGP4-MIB -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
||||
$peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " ";
|
||||
$peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
|
||||
$peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . "";
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
list($peer_oid) = split(' ',$oid);
|
||||
$peer_id = explode('.',$peer_oid);
|
||||
$junos_v6[implode('.',array_slice($peer_id,35))] = implode('.',array_slice($peer_id,18));
|
||||
}
|
||||
else
|
||||
if ($device['os'] == "junos")
|
||||
}
|
||||
|
||||
## FIXME - move to function (and clean up, wtf?)
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6." . $junos_v6[$peer_ip]; # Should be jnxBgpM2CfgPeerAdminStatus but doesn't seem to be implemented?
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerFsmEstablishedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdatesElapsedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerLocalAddr.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= ' -M"' . $config['install_dir'] . '/mibs/junos"|grep -v "No Such Instance"';
|
||||
if ($debug) echo("\n$peer_cmd\n");
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
|
||||
if ($debug) { echo("State = $bgpPeerState - AdminStatus: $bgpPeerAdminStatus\n"); }
|
||||
|
||||
$bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
|
||||
if ($bgpLocalAddr == "00000000000000000000000000000000")
|
||||
{
|
||||
$bgpLocalAddr = ''; # Unknown?
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgpLocalAddr = strtolower($bgpLocalAddr);
|
||||
for ($i = 0;$i < 32;$i+=4)
|
||||
{
|
||||
$bgpLocalAddr6[] = substr($bgpLocalAddr,$i,4);
|
||||
}
|
||||
$bgpLocalAddr = Net_IPv6::compress(implode(':',$bgpLocalAddr6)); unset($bgpLocalAddr6);
|
||||
}
|
||||
}
|
||||
|
||||
if ($bgpPeerFsmEstablishedTime)
|
||||
{
|
||||
if ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])
|
||||
{
|
||||
if ($peer['bgpPeerState'] == $bgpPeerState)
|
||||
{
|
||||
notify($device, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($bgpPeerState == "established")
|
||||
{
|
||||
notify($device, "BGP Session up: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session up since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($peer['bgpPeerState'] == "established")
|
||||
{
|
||||
notify($device, "BGP Session down: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session down since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("bgp-" . $peer['bgpPeerIdentifier'] . ".rrd");
|
||||
if (!is_file($peerrrd))
|
||||
{
|
||||
$create_rrd = "DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerEstablished:GAUGE:600:0:U \
|
||||
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";
|
||||
|
||||
rrdtool_create($peerrrd, $create_rrd);
|
||||
}
|
||||
|
||||
rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
|
||||
|
||||
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
|
||||
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', bgpPeerInUpdates = '$bgpPeerInUpdates' , bgpLocalAddr = '$bgpLocalAddr' , bgpPeerOutUpdates = '$bgpPeerOutUpdates'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'";
|
||||
mysql_query($update);
|
||||
|
||||
if ($device['os_group'] == "ios" || $device['os'] == "junos")
|
||||
{
|
||||
## Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
|
||||
$afi_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'");
|
||||
while ($peer_afi = mysql_fetch_assoc($afi_query))
|
||||
{
|
||||
$afi = $peer_afi['afi'];
|
||||
$safi = $peer_afi['safi'];
|
||||
if ($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); }
|
||||
|
||||
if ($device['os_group'] == "ios")
|
||||
{
|
||||
## FIXME - move to function
|
||||
$cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixClearThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
|
||||
if ($debug) { echo("$cbgp_cmd\n"); }
|
||||
$cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`));
|
||||
if ($debug) { echo("$cbgp_data\n"); }
|
||||
list($cbgpPeerAcceptedPrefixes,$cbgpPeerDeniedPrefixes,$cbgpPeerPrefixAdminLimit,$cbgpPeerPrefixThreshold,$cbgpPeerPrefixClearThreshold,$cbgpPeerAdvertisedPrefixes,$cbgpPeerSuppressedPrefixes,$cbgpPeerWithdrawnPrefixes) = explode("\n", $cbgp_data);
|
||||
}
|
||||
|
||||
if ($device['os'] == "junos")
|
||||
{
|
||||
# Missing: cbgpPeerAdminLimit cbgpPeerPrefixThreshold cbgpPeerPrefixClearThreshold cbgpPeerSuppressedPrefixes cbgpPeerWithdrawnPrefixes
|
||||
|
||||
$safis['unicast'] = 1;
|
||||
$safis['multicast'] = 2;
|
||||
|
||||
if (!isset($peerIndexes))
|
||||
{
|
||||
$j_bgp = snmpwalk_cache_multi_oid($device, "jnxBgpM2PeerTable", $jbgp, "BGP4-V2-MIB-JUNIPER", $config['install_dir']."/mibs/junos");
|
||||
foreach ($j_bgp as $index => $entry)
|
||||
{
|
||||
# v6 for JunOS via Juniper MIB
|
||||
$peer_ip = ipv62snmp($peer['bgpPeerIdentifier']);
|
||||
|
||||
if (!isset($junos_v6))
|
||||
{
|
||||
echo("\nCaching Oids...");
|
||||
## FIXME - needs moved to function
|
||||
$peer_cmd = $config['snmpwalk'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUnq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6";
|
||||
foreach (explode("\n",trim(`$peer_cmd`)) as $oid)
|
||||
{
|
||||
list($peer_oid) = split(' ',$oid);
|
||||
$peer_id = explode('.',$peer_oid);
|
||||
$junos_v6[implode('.',array_slice($peer_id,35))] = implode('.',array_slice($peer_id,18));
|
||||
}
|
||||
}
|
||||
|
||||
## FIXME - move to function (and clean up, wtf?)
|
||||
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6." . $junos_v6[$peer_ip]; # Should be jnxBgpM2CfgPeerAdminStatus but doesn't seem to be implemented?
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerOutTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerFsmEstablishedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerInUpdatesElapsedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= " jnxBgpM2PeerLocalAddr.0.ipv6." . $junos_v6[$peer_ip];
|
||||
$peer_cmd .= ' -M"' . $config['install_dir'] . '/mibs/junos"|grep -v "No Such Instance"';
|
||||
if ($debug) echo("\n$peer_cmd\n");
|
||||
$peer_data = trim(`$peer_cmd`);
|
||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||
|
||||
if ($debug) { echo("State = $bgpPeerState - AdminStatus: $bgpPeerAdminStatus\n"); }
|
||||
|
||||
$bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
|
||||
if ($bgpLocalAddr == "00000000000000000000000000000000")
|
||||
{
|
||||
$bgpLocalAddr = ''; # Unknown?
|
||||
}
|
||||
else
|
||||
{
|
||||
$bgpLocalAddr = strtolower($bgpLocalAddr);
|
||||
for ($i = 0;$i < 32;$i+=4)
|
||||
{
|
||||
$bgpLocalAddr6[] = substr($bgpLocalAddr,$i,4);
|
||||
}
|
||||
$bgpLocalAddr = Net_IPv6::compress(implode(':',$bgpLocalAddr6)); unset($bgpLocalAddr6);
|
||||
}
|
||||
switch ($entry['jnxBgpM2PeerRemoteAddrType'])
|
||||
{
|
||||
case 'ipv4':
|
||||
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
|
||||
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
case 'ipv6':
|
||||
$ip6 = trim(str_replace(' ','',$entry['jnxBgpM2PeerRemoteAddr']),'"');
|
||||
$ip6 = substr($ip6,0,4) . ':' . substr($ip6,4,4) . ':' . substr($ip6,8,4) . ':' . substr($ip6,12,4) . ':' . substr($ip6,16,4) . ':' . substr($ip6,20,4) . ':' . substr($ip6,24,4) . ':' . substr($ip6,28,4);
|
||||
$ip6 = Net_IPv6::compress($ip6);
|
||||
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
default:
|
||||
echo("PANIC: Don't know RemoteAddrType " . $entry['jnxBgpM2PeerRemoteAddrType'] . "!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($bgpPeerFsmEstablishedTime)
|
||||
{
|
||||
if ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])
|
||||
{
|
||||
if ($peer['bgpPeerState'] == $bgpPeerState)
|
||||
{
|
||||
notify($device, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($bgpPeerState == "established")
|
||||
{
|
||||
notify($device, "BGP Session up: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session up since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($peer['bgpPeerState'] == "established")
|
||||
{
|
||||
notify($device, "BGP Session down: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session down since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
}
|
||||
$j_prefixes = snmpwalk_cache_multi_oid($device, "jnxBgpM2PrefixCountersTable", $jbgp, "BGP4-V2-MIB-JUNIPER", $config['install_dir']."/mibs/junos");
|
||||
|
||||
$cbgpPeerAcceptedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi." . $safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted'];
|
||||
$cbgpPeerDeniedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi." . $safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected'];
|
||||
$cbgpPeerAdvertisedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi." . $safis[$safi]]['jnxBgpM2PrefixOutPrefixes'];
|
||||
|
||||
unset($j_prefixes);
|
||||
unset($j_bgp);
|
||||
unset($j_peerIndexes);
|
||||
}
|
||||
|
||||
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("bgp-" . $peer['bgpPeerIdentifier'] . ".rrd");
|
||||
if (!is_file($peerrrd))
|
||||
{
|
||||
$create_rrd = "DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerInTotal:COUNTER:600:U:100000000000 \
|
||||
DS:bgpPeerEstablished:GAUGE:600:0:U \
|
||||
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";
|
||||
|
||||
rrdtool_create($peerrrd, $create_rrd);
|
||||
}
|
||||
|
||||
rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
|
||||
|
||||
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
|
||||
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', bgpPeerInUpdates = '$bgpPeerInUpdates' , bgpLocalAddr = '$bgpLocalAddr' , bgpPeerOutUpdates = '$bgpPeerOutUpdates'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'";
|
||||
# FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
|
||||
$update = "UPDATE bgpPeers_cbgp SET";
|
||||
$update .= " `cbgpPeerAcceptedPrefixes` = '$cbgpPeerAcceptedPrefixes'";
|
||||
$update .= ", `cbgpPeerDeniedPrefixes` = '$cbgpPeerDeniedPrefixes'";
|
||||
$update .= ", `cbgpPeerPrefixAdminLimit` = '$cbgpPeerAdminLimit'";
|
||||
$update .= ", `cbgpPeerPrefixThreshold` = '$cbgpPeerPrefixThreshold'";
|
||||
$update .= ", `cbgpPeerPrefixClearThreshold` = '$cbgpPeerPrefixClearThreshold'";
|
||||
$update .= ", `cbgpPeerAdvertisedPrefixes` = '$cbgpPeerAdvertisedPrefixes'";
|
||||
$update .= ", `cbgpPeerSuppressedPrefixes` = '$cbgpPeerSuppressedPrefixes'";
|
||||
$update .= ", `cbgpPeerWithdrawnPrefixes` = '$cbgpPeerWithdrawnPrefixes'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "' AND afi = '$afi' AND safi = '$safi'";
|
||||
if ($debug) { echo("MYSQL: $update\n"); }
|
||||
mysql_query($update);
|
||||
|
||||
if ($device['os_group'] == "ios" || $device['os'] == "junos")
|
||||
$cbgp_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cbgp-" . $peer['bgpPeerIdentifier'] . ".$afi.$safi.rrd");
|
||||
if (!is_file($cbgp_rrd))
|
||||
{
|
||||
## Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB)
|
||||
$afi_query = mysql_query("SELECT * FROM bgpPeers_cbgp WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'");
|
||||
while ($peer_afi = mysql_fetch_assoc($afi_query))
|
||||
{
|
||||
$afi = $peer_afi['afi'];
|
||||
$safi = $peer_afi['safi'];
|
||||
if ($debug) { echo("$afi $safi". $config['afi'][$afi][$safi]. "\n"); }
|
||||
$rrd_create = "DS:AcceptedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:DeniedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:SuppressedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 \
|
||||
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";
|
||||
rrdtool_create($cbgp_rrd, $rrd_create);
|
||||
}
|
||||
rrdtool_update("$cbgp_rrd", "N:$cbgpPeerAcceptedPrefixes:$cbgpPeerDeniedPrefixes:$cbgpPeerAdvertisedPrefixes:$cbgpPeerSuppressedPrefixes:$cbgpPeerWithdrawnPrefixes");
|
||||
} # while
|
||||
} # os=ios | junos
|
||||
echo("\n");
|
||||
|
||||
if ($device['os_group'] == "ios")
|
||||
{
|
||||
## FIXME - move to function
|
||||
$cbgp_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||
$cbgp_cmd .= " cbgpPeerAcceptedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerDeniedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixAdminLimit." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerPrefixClearThreshold." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerAdvertisedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerSuppressedPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
$cbgp_cmd .= " cbgpPeerWithdrawnPrefixes." . $peer['bgpPeerIdentifier'] . ".$afi.$safi";
|
||||
|
||||
if ($debug) { echo("$cbgp_cmd\n"); }
|
||||
$cbgp_data = preg_replace("/^OID.*$/", "", trim(`$cbgp_cmd`));
|
||||
if ($debug) { echo("$cbgp_data\n"); }
|
||||
list($cbgpPeerAcceptedPrefixes,$cbgpPeerDeniedPrefixes,$cbgpPeerPrefixAdminLimit,$cbgpPeerPrefixThreshold,$cbgpPeerPrefixClearThreshold,$cbgpPeerAdvertisedPrefixes,$cbgpPeerSuppressedPrefixes,$cbgpPeerWithdrawnPrefixes) = explode("\n", $cbgp_data);
|
||||
}
|
||||
|
||||
if ($device['os'] == "junos")
|
||||
{
|
||||
# Missing: cbgpPeerAdminLimit cbgpPeerPrefixThreshold cbgpPeerPrefixClearThreshold cbgpPeerSuppressedPrefixes cbgpPeerWithdrawnPrefixes
|
||||
|
||||
$safis['unicast'] = 1;
|
||||
$safis['multicast'] = 2;
|
||||
|
||||
if (!isset($peerIndexes))
|
||||
{
|
||||
$j_bgp = snmpwalk_cache_multi_oid($device, "jnxBgpM2PeerTable", $jbgp, "BGP4-V2-MIB-JUNIPER", $config['install_dir']."/mibs/junos");
|
||||
foreach ($j_bgp as $index => $entry)
|
||||
{
|
||||
switch ($entry['jnxBgpM2PeerRemoteAddrType'])
|
||||
{
|
||||
case 'ipv4':
|
||||
$ip = long2ip(hexdec($entry['jnxBgpM2PeerRemoteAddr']));
|
||||
$j_peerIndexes[$ip] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
case 'ipv6':
|
||||
$ip6 = trim(str_replace(' ','',$entry['jnxBgpM2PeerRemoteAddr']),'"');
|
||||
$ip6 = substr($ip6,0,4) . ':' . substr($ip6,4,4) . ':' . substr($ip6,8,4) . ':' . substr($ip6,12,4) . ':' . substr($ip6,16,4) . ':' . substr($ip6,20,4) . ':' . substr($ip6,24,4) . ':' . substr($ip6,28,4);
|
||||
$ip6 = Net_IPv6::compress($ip6);
|
||||
$j_peerIndexes[$ip6] = $entry['jnxBgpM2PeerIndex'];
|
||||
break;
|
||||
default:
|
||||
echo("PANIC: Don't know RemoteAddrType " . $entry['jnxBgpM2PeerRemoteAddrType'] . "!\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$j_prefixes = snmpwalk_cache_multi_oid($device, "jnxBgpM2PrefixCountersTable", $jbgp, "BGP4-V2-MIB-JUNIPER", $config['install_dir']."/mibs/junos");
|
||||
|
||||
$cbgpPeerAcceptedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi." . $safis[$safi]]['jnxBgpM2PrefixInPrefixesAccepted'];
|
||||
$cbgpPeerDeniedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi." . $safis[$safi]]['jnxBgpM2PrefixInPrefixesRejected'];
|
||||
$cbgpPeerAdvertisedPrefixes = $j_prefixes[$j_peerIndexes[$peer['bgpPeerIdentifier']].".$afi." . $safis[$safi]]['jnxBgpM2PrefixOutPrefixes'];
|
||||
|
||||
unset($j_prefixes);
|
||||
unset($j_bgp);
|
||||
unset($j_peerIndexes);
|
||||
}
|
||||
|
||||
# FIXME THESE FIELDS DO NOT EXIST IN THE DATABASE!
|
||||
$update = "UPDATE bgpPeers_cbgp SET";
|
||||
$update .= " `cbgpPeerAcceptedPrefixes` = '$cbgpPeerAcceptedPrefixes'";
|
||||
$update .= ", `cbgpPeerDeniedPrefixes` = '$cbgpPeerDeniedPrefixes'";
|
||||
$update .= ", `cbgpPeerPrefixAdminLimit` = '$cbgpPeerAdminLimit'";
|
||||
$update .= ", `cbgpPeerPrefixThreshold` = '$cbgpPeerPrefixThreshold'";
|
||||
$update .= ", `cbgpPeerPrefixClearThreshold` = '$cbgpPeerPrefixClearThreshold'";
|
||||
$update .= ", `cbgpPeerAdvertisedPrefixes` = '$cbgpPeerAdvertisedPrefixes'";
|
||||
$update .= ", `cbgpPeerSuppressedPrefixes` = '$cbgpPeerSuppressedPrefixes'";
|
||||
$update .= ", `cbgpPeerWithdrawnPrefixes` = '$cbgpPeerWithdrawnPrefixes'";
|
||||
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "' AND afi = '$afi' AND safi = '$safi'";
|
||||
if ($debug) { echo("MYSQL: $update\n"); }
|
||||
mysql_query($update);
|
||||
|
||||
$cbgp_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cbgp-" . $peer['bgpPeerIdentifier'] . ".$afi.$safi.rrd");
|
||||
if (!is_file($cbgp_rrd))
|
||||
{
|
||||
$rrd_create = "DS:AcceptedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:DeniedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:AdvertisedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:SuppressedPrefixes:GAUGE:600:U:100000000000 \
|
||||
DS:WithdrawnPrefixes:GAUGE:600:U:100000000000 \
|
||||
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";
|
||||
rrdtool_create($cbgp_rrd, $rrd_create);
|
||||
}
|
||||
rrdtool_update("$cbgp_rrd", "N:$cbgpPeerAcceptedPrefixes:$cbgpPeerDeniedPrefixes:$cbgpPeerAdvertisedPrefixes:$cbgpPeerSuppressedPrefixes:$cbgpPeerWithdrawnPrefixes");
|
||||
} # while
|
||||
} # os=ios | junos
|
||||
echo("\n");
|
||||
|
||||
} ## End While loop on peers
|
||||
} ## End While loop on peers
|
||||
} ## End check for BGP support
|
||||
|
||||
?>
|
||||
?>
|
@@ -2,55 +2,55 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" ICMP");
|
||||
echo(" ICMP");
|
||||
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
|
||||
$oids = array('icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
|
||||
'icmpOutEchoReps','icmpInDestUnreachs','icmpOutDestUnreachs','icmpInParmProbs','icmpInTimeExcds',
|
||||
'icmpInSrcQuenchs','icmpInRedirects','icmpInTimestamps','icmpInTimestampReps','icmpInAddrMasks',
|
||||
'icmpInAddrMaskReps','icmpOutTimeExcds','icmpOutParmProbs','icmpOutSrcQuenchs','icmpOutRedirects',
|
||||
'icmpOutTimestamps','icmpOutTimestampReps','icmpOutAddrMasks','icmpOutAddrMaskReps');
|
||||
$oids = array('icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
|
||||
'icmpOutEchoReps','icmpInDestUnreachs','icmpOutDestUnreachs','icmpInParmProbs','icmpInTimeExcds',
|
||||
'icmpInSrcQuenchs','icmpInRedirects','icmpInTimestamps','icmpInTimestampReps','icmpInAddrMasks',
|
||||
'icmpInAddrMaskReps','icmpOutTimeExcds','icmpOutParmProbs','icmpOutSrcQuenchs','icmpOutRedirects',
|
||||
'icmpOutTimestamps','icmpOutTimestampReps','icmpOutAddrMasks','icmpOutAddrMaskReps');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-icmp.rrd";
|
||||
|
||||
$rrd_create = "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";
|
||||
$rrd_create = "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";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$data_array = snmpwalk_cache_oid($device, "icmp", array());
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
$data_array = snmpwalk_cache_oid($device, "icmp", array());
|
||||
unset($snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
if (isset($data_array[0]['icmpInMsgs']) && isset($data_array[0]['icmpOutMsgs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_icmp'] = TRUE;
|
||||
$graphs['netstat_icmp_info'] = TRUE;
|
||||
}
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
{
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
unset($snmpstring);
|
||||
|
||||
if (isset($data_array[0]['icmpInMsgs']) && isset($data_array[0]['icmpOutMsgs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_icmp'] = TRUE;
|
||||
$graphs['netstat_icmp_info'] = TRUE;
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -2,52 +2,52 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" IP");
|
||||
echo(" IP");
|
||||
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
|
||||
|
||||
$oids = array ('ipForwDatagrams','ipInDelivers','ipInReceives','ipOutRequests','ipInDiscards','ipOutDiscards','ipOutNoRoutes',
|
||||
'ipReasmReqds','ipReasmOKs','ipReasmFails','ipFragOKs','ipFragFails','ipFragCreates', 'ipInUnknownProtos',
|
||||
'ipInHdrErrors', 'ipInAddrErrors');
|
||||
$oids = array ('ipForwDatagrams','ipInDelivers','ipInReceives','ipOutRequests','ipInDiscards','ipOutDiscards','ipOutNoRoutes',
|
||||
'ipReasmReqds','ipReasmOKs','ipReasmFails','ipFragOKs','ipFragFails','ipFragCreates', 'ipInUnknownProtos',
|
||||
'ipInHdrErrors', 'ipInAddrErrors');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip.rrd";
|
||||
|
||||
$rrd_create = "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";
|
||||
$rrd_create = "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";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$snmpstring .= " $oid.0";
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_ip'] = TRUE;
|
||||
$graphs['netstat_ip_frag'] = TRUE;
|
||||
}
|
||||
if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_ip'] = TRUE;
|
||||
$graphs['netstat_ip_frag'] = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid);
|
||||
|
||||
?>
|
||||
?>
|
@@ -2,51 +2,51 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" SNMP");
|
||||
echo(" SNMP");
|
||||
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
|
||||
|
||||
$oids = array ('snmpInPkts','snmpOutPkts','snmpInBadVersions','snmpInBadCommunityNames','snmpInBadCommunityUses','snmpInASNParseErrs',
|
||||
'snmpInTooBigs','snmpInNoSuchNames','snmpInBadValues','snmpInReadOnlys','snmpInGenErrs','snmpInTotalReqVars','snmpInTotalSetVars',
|
||||
'snmpInGetRequests','snmpInGetNexts','snmpInSetRequests','snmpInGetResponses','snmpInTraps','snmpOutTooBigs','snmpOutNoSuchNames',
|
||||
'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps','snmpSilentDrops','snmpProxyDrops');
|
||||
$oids = array ('snmpInPkts','snmpOutPkts','snmpInBadVersions','snmpInBadCommunityNames','snmpInBadCommunityUses','snmpInASNParseErrs',
|
||||
'snmpInTooBigs','snmpInNoSuchNames','snmpInBadValues','snmpInReadOnlys','snmpInGenErrs','snmpInTotalReqVars','snmpInTotalSetVars',
|
||||
'snmpInGetRequests','snmpInGetNexts','snmpInSetRequests','snmpInGetResponses','snmpInTraps','snmpOutTooBigs','snmpOutNoSuchNames',
|
||||
'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps','snmpSilentDrops','snmpProxyDrops');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("netstats-snmp.rrd");
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("netstats-snmp.rrd");
|
||||
|
||||
$rrd_create = "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";
|
||||
$rrd_create = "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";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
}
|
||||
|
||||
$data_array = snmpwalk_cache_oid($device, "snmp", array());
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
$data_array = snmpwalk_cache_oid($device, "snmp", array());
|
||||
if (isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_snmp'] = TRUE;
|
||||
$graphs['netstat_snmp_pkt'] = TRUE;
|
||||
}
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data_array[0][$oid]))
|
||||
{
|
||||
$value = $data_array[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_snmp'] = TRUE;
|
||||
$graphs['netstat_snmp_pkt'] = TRUE;
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -2,56 +2,56 @@
|
||||
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
echo(" TCP");
|
||||
echo(" TCP");
|
||||
|
||||
$oids = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
|
||||
'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts');
|
||||
$oids = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
|
||||
'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts');
|
||||
|
||||
# $oids['tcp_collect'] = $oids['tcp'];
|
||||
# $oids['tcp_collect'][] = 'tcpHCInSegs';
|
||||
# $oids['tcp_collect'][] = 'tcpHCOutSegs';
|
||||
# $oids['tcp_collect'] = $oids['tcp'];
|
||||
# $oids['tcp_collect'][] = 'tcpHCInSegs';
|
||||
# $oids['tcp_collect'][] = 'tcpHCOutSegs';
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-tcp.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-tcp.rrd";
|
||||
|
||||
$rrd_create = "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";
|
||||
$rrd_create = "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";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:10000000"; ## Limit to 10MPPS
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$snmpstring .= " tcpHCInSegs.0";
|
||||
$snmpstring .= " tcpHCOutSegs.0";
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:10000000"; ## Limit to 10MPPS
|
||||
$snmpstring .= " $oid.0";
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
$snmpstring .= " tcpHCInSegs.0";
|
||||
$snmpstring .= " tcpHCOutSegs.0";
|
||||
unset($snmpstring);
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_tcp'] = TRUE;
|
||||
}
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
unset($snmpstring);
|
||||
|
||||
if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_tcp'] = TRUE;
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
unset($oids, $data, $data_array, $oid, $protos);
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -3,48 +3,48 @@
|
||||
if ($device['os'] != "Snom")
|
||||
{
|
||||
|
||||
echo(" UDP");
|
||||
echo(" UDP");
|
||||
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmpget_multi them
|
||||
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmpget_multi them
|
||||
|
||||
$oids = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts');
|
||||
$oids = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts');
|
||||
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-udp.rrd";
|
||||
unset($snmpstring, $rrdupdate, $snmpdata, $snmpdata_cmd, $rrd_create);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-udp.rrd";
|
||||
|
||||
$rrd_create = "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";
|
||||
$rrd_create = "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";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000"; ## Limit to 1MPPS?
|
||||
$snmpstring .= " $oid.0";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$oid_ds = truncate($oid, 19, '');
|
||||
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000"; ## Limit to 1MPPS?
|
||||
$snmpstring .= " $oid.0";
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring);
|
||||
|
||||
$rrdupdate = "N";
|
||||
|
||||
foreach ($oids as $oid)
|
||||
{
|
||||
if (is_numeric($data[0][$oid]))
|
||||
{
|
||||
$value = $data[0][$oid];
|
||||
} else {
|
||||
$value = "0";
|
||||
}
|
||||
$rrdupdate .= ":$value";
|
||||
}
|
||||
|
||||
if (isset($data[0]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_udp'] = TRUE;
|
||||
}
|
||||
if (isset($data[0]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams']))
|
||||
{
|
||||
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
|
||||
rrdtool_update($rrd_file, $rrdupdate);
|
||||
$graphs['netstat_udp'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
unset($oids, $data, $data_array, $oid, $protos, $snmpstring);
|
||||
|
||||
?>
|
||||
?>
|
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
echo("Polling Netstats:");
|
||||
echo("Polling Netstats:");
|
||||
|
||||
include("netstats-ip.inc.php");
|
||||
include("netstats-tcp.inc.php");
|
||||
include("netstats-udp.inc.php");
|
||||
include("netstats-icmp.inc.php");
|
||||
include("netstats-snmp.inc.php");
|
||||
include("netstats-ip.inc.php");
|
||||
include("netstats-tcp.inc.php");
|
||||
include("netstats-udp.inc.php");
|
||||
include("netstats-icmp.inc.php");
|
||||
include("netstats-snmp.inc.php");
|
||||
|
||||
echo("\n");
|
||||
echo("\n");
|
||||
|
||||
?>
|
||||
|
@@ -7,25 +7,25 @@ $ports = snmp_cache_ifIndex($device); // Cache Port List
|
||||
|
||||
// Build SNMP Cache Array
|
||||
$data_oids = array('ifName','ifDescr','ifAlias', 'ifAdminStatus', 'ifOperStatus', 'ifMtu', 'ifSpeed', 'ifHighSpeed', 'ifType', 'ifPhysAddress',
|
||||
'ifPromiscuousMode','ifConnectorPresent','ifDuplex');
|
||||
'ifPromiscuousMode','ifConnectorPresent','ifDuplex');
|
||||
|
||||
$stat_oids = array('ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts', 'ifInNUcastPkts', 'ifOutNUcastPkts',
|
||||
'ifHCInMulticastPkts', 'ifHCInBroadcastPkts', 'ifHCOutMulticastPkts', 'ifHCOutBroadcastPkts',
|
||||
'ifInOctets', 'ifOutOctets', 'ifHCInOctets', 'ifHCOutOctets', 'ifInDiscards', 'ifOutDiscards', 'ifInUnknownProtos',
|
||||
'ifInBroadcastPkts', 'ifOutBroadcastPkts', 'ifInMulticastPkts', 'ifOutMulticastPkts');
|
||||
'ifHCInMulticastPkts', 'ifHCInBroadcastPkts', 'ifHCOutMulticastPkts', 'ifHCOutBroadcastPkts',
|
||||
'ifInOctets', 'ifOutOctets', 'ifHCInOctets', 'ifHCOutOctets', 'ifInDiscards', 'ifOutDiscards', 'ifInUnknownProtos',
|
||||
'ifInBroadcastPkts', 'ifOutBroadcastPkts', 'ifInMulticastPkts', 'ifOutMulticastPkts');
|
||||
|
||||
$stat_oids_db = array('ifInOctets', 'ifOutOctets', 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts'); // From above for DB
|
||||
|
||||
$etherlike_oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames',
|
||||
'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions',
|
||||
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
|
||||
'dot3StatsSymbolErrors');
|
||||
'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions',
|
||||
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
|
||||
'dot3StatsSymbolErrors');
|
||||
|
||||
$cisco_oids = array('locIfHardType', 'locIfInRunts', 'locIfInGiants', 'locIfInCRC', 'locIfInFrame', 'locIfInOverrun', 'locIfInIgnored', 'locIfInAbort',
|
||||
'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops');
|
||||
'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops');
|
||||
|
||||
$pagp_oids = array('pagpOperationMode', 'pagpPortState', 'pagpPartnerDeviceId', 'pagpPartnerLearnMethod', 'pagpPartnerIfIndex', 'pagpPartnerGroupIfIndex',
|
||||
'pagpPartnerDeviceName', 'pagpEthcOperationMode', 'pagpDeviceId', 'pagpGroupIfIndex');
|
||||
'pagpPartnerDeviceName', 'pagpEthcOperationMode', 'pagpDeviceId', 'pagpGroupIfIndex');
|
||||
|
||||
$ifmib_oids = array_merge($data_oids, $stat_oids);
|
||||
|
||||
@@ -36,39 +36,39 @@ foreach ($ifmib_oids as $oid) { echo("$oid "); $port_stats = snmpwalk_cache_oid(
|
||||
|
||||
if ($config['enable_ports_etherlike'])
|
||||
{
|
||||
echo("dot3Stats "); $port_stats = snmpwalk_cache_oid($device, "dot3StatsEntry", $port_stats, "EtherLike-MIB");
|
||||
echo("dot3Stats "); $port_stats = snmpwalk_cache_oid($device, "dot3StatsEntry", $port_stats, "EtherLike-MIB");
|
||||
} else {
|
||||
echo("dot3StatsDuplexStatus"); $port_stats = snmpwalk_cache_oid($device, "dot3StatsDuplexStatus", $port_stats, "EtherLike-MIB");
|
||||
echo("dot3StatsDuplexStatus"); $port_stats = snmpwalk_cache_oid($device, "dot3StatsDuplexStatus", $port_stats, "EtherLike-MIB");
|
||||
}
|
||||
|
||||
if ($config['enable_ports_adsl'])
|
||||
{
|
||||
$device['adsl_count'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifType` = 'adsl'"),0);
|
||||
$device['adsl_count'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifType` = 'adsl'"),0);
|
||||
}
|
||||
|
||||
if ($device['adsl_count'] > "0")
|
||||
{
|
||||
echo("ADSL ");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.2.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.3.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.4.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.5.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.8", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
echo("ADSL ");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.2.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.3.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.4.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.5.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.6.1.8", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.1", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.2", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.3", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.4", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.5", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.6", $port_stats, "ADSL-LINE-MIB");
|
||||
$port_stats = snmpwalk_cache_oid($device, ".1.3.6.1.2.1.10.94.1.1.7.1.7", $port_stats, "ADSL-LINE-MIB");
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
@@ -79,12 +79,12 @@ echo("\n");
|
||||
|
||||
if ($device['os_group'] == "ios")
|
||||
{
|
||||
$port_stats = snmp_cache_portIfIndex ($device, $port_stats);
|
||||
$port_stats = snmp_cache_portName ($device, $port_stats);
|
||||
$data_oids[] = "portName";
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vmVlan", $port_stats, "CISCO-VLAN-MEMBERSHIP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortEncapsulationOperType", $port_stats, "CISCO-VTP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortNativeVlan", $port_stats, "CISCO-VTP-MIB");
|
||||
$port_stats = snmp_cache_portIfIndex ($device, $port_stats);
|
||||
$port_stats = snmp_cache_portName ($device, $port_stats);
|
||||
$data_oids[] = "portName";
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vmVlan", $port_stats, "CISCO-VLAN-MEMBERSHIP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortEncapsulationOperType", $port_stats, "CISCO-VTP-MIB");
|
||||
#$port_stats = snmpwalk_cache_oid($device, "vlanTrunkPortNativeVlan", $port_stats, "CISCO-VTP-MIB");
|
||||
}
|
||||
|
||||
$polled = time();
|
||||
@@ -101,218 +101,218 @@ if ($debug) { print_r($port_stats); }
|
||||
$port_query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = 0");
|
||||
while ($port = mysql_fetch_array($port_query))
|
||||
{
|
||||
echo("Port " . $port['ifDescr'] . " ");
|
||||
if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1")
|
||||
{ // Check to make sure Port data is cached.
|
||||
$this_port = &$port_stats[$port['ifIndex']];
|
||||
echo("Port " . $port['ifDescr'] . " ");
|
||||
if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1")
|
||||
{ // Check to make sure Port data is cached.
|
||||
$this_port = &$port_stats[$port['ifIndex']];
|
||||
|
||||
$polled_period = $polled - $port['poll_time'];
|
||||
$polled_period = $polled - $port['poll_time'];
|
||||
|
||||
$update .= "`poll_time` = '".$polled."'";
|
||||
$update .= ", `poll_prev` = '".$port['poll_time']."'";
|
||||
$update .= ", `poll_period` = '".$polled_period."'";
|
||||
$update .= "`poll_time` = '".$polled."'";
|
||||
$update .= ", `poll_prev` = '".$port['poll_time']."'";
|
||||
$update .= ", `poll_period` = '".$polled_period."'";
|
||||
|
||||
#echo("\n32bit - In: ".$this_port['ifInOctets']." Out: ".$this_port['ifOutOctets']);
|
||||
#echo("\n64bit - In: ".$this_port['ifHCInOctets']." Out: ".$this_port['ifHCOutOctets']."\n");
|
||||
#echo("\n32bit - In: ".$this_port['ifInOctets']." Out: ".$this_port['ifOutOctets']);
|
||||
#echo("\n64bit - In: ".$this_port['ifHCInOctets']." Out: ".$this_port['ifHCOutOctets']."\n");
|
||||
|
||||
### Copy ifHC[In|Out]Octets values to non-HC if they exist
|
||||
if ($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets']))
|
||||
{
|
||||
echo("HC ");
|
||||
$this_port['ifInOctets'] = $this_port['ifHCInOctets'];
|
||||
$this_port['ifOutOctets'] = $this_port['ifHCOutOctets'];
|
||||
}
|
||||
|
||||
if (is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts']))
|
||||
{
|
||||
echo("HC ");
|
||||
$this_port['ifInBroadcastPkts'] = $this_port['ifHCInBroadcastPkts'];
|
||||
$this_port['ifOutBroadcastPkts'] = $this_port['ifHCOutBroadcastPkts'];
|
||||
$this_port['ifInMulticastPkts'] = $this_port['ifHCInMulticastPkts'];
|
||||
$this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts'];
|
||||
}
|
||||
|
||||
### Overwrite ifSpeed with ifHighSpeed if it's over 10G
|
||||
if (is_numeric($this_port['ifHighSpeed']) && $this_port['ifSpeed'] > "1000000000")
|
||||
{
|
||||
echo("HighSpeed ");
|
||||
$this_port['ifSpeed'] = $this_port['ifHighSpeed'] * 1000000;
|
||||
}
|
||||
|
||||
### Overwrite ifDuplex with dot3StatsDuplexStatus if it exists
|
||||
if (isset($this_port['dot3StatsDuplexStatus']))
|
||||
{
|
||||
echo("dot3Duplex ");
|
||||
$this_port['ifDuplex'] = $this_port['dot3StatsDuplexStatus'];
|
||||
}
|
||||
|
||||
### Update IF-MIB data
|
||||
foreach ($data_oids as $oid)
|
||||
{
|
||||
if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid]))
|
||||
{
|
||||
$update .= ", `$oid` = NULL";
|
||||
log_event($oid . ": ".$port[$oid]." -> NULL", $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); }
|
||||
} elseif ($port[$oid] != $this_port[$oid] ) {
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse description (usually ifAlias) if config option set
|
||||
|
||||
if (isset($config['port_descr_parser']) && is_file($config['install_dir'] . "/" . $config['port_descr_parser']))
|
||||
{
|
||||
$port_attribs = array('type','descr','circuit','speed','notes');
|
||||
include($config['install_dir'] . "/" . $config['port_descr_parser']);
|
||||
|
||||
foreach ($port_attribs as $attrib)
|
||||
{
|
||||
$attrib_key = "port_descr_".$attrib;
|
||||
if ($port_ifAlias[$attrib] != $port[$attrib_key])
|
||||
{
|
||||
$update .= ", `".$attrib_key."` = '".$port_ifAlias[$attrib]."'";
|
||||
log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device['device_id'], 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ende parse ifAlias
|
||||
|
||||
/// Update IF-MIB metrics
|
||||
foreach ($stat_oids_db as $oid)
|
||||
{
|
||||
$update .= ", `$oid` = '".$this_port[$oid]."'";
|
||||
$update .= ", `".$oid."_prev` = '".$port[$oid]."'";
|
||||
$oid_prev = $oid . "_prev";
|
||||
if ($port[$oid])
|
||||
{
|
||||
$oid_diff = $this_port[$oid] - $port[$oid];
|
||||
$oid_rate = $oid_diff / $polled_period;
|
||||
if ($oid_rate < 0) { $oid_rate = "0"; }
|
||||
$update .= ", `".$oid."_rate` = '".$oid_rate."'";
|
||||
$update .= ", `".$oid."_delta` = '".$oid_diff."'";
|
||||
if ($debug) {echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Update RRDs
|
||||
$rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
if (!is_file($rrdfile))
|
||||
{
|
||||
rrdtool_create($rrdfile," --step 300 \
|
||||
DS:INOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:INERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:INUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000 \
|
||||
DS:INBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INMULTICASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTMULTICASTPKTS:DERIVE: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");
|
||||
}
|
||||
|
||||
foreach ($stat_oids as $oid)
|
||||
{ /// Copy values from array to global variables and force numeric.
|
||||
$$oid = $this_port[$oid];
|
||||
if (!is_numeric($$oid)) { $$oid = "0"; }
|
||||
}
|
||||
|
||||
$if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts:$ifInDiscards:$ifOutDiscards:$ifInUnknownProtos";
|
||||
$if_rrd_update .= ":$ifInBroadcastPkts:$ifOutBroadcastPkts:$ifInMulticastPkts:$ifOutMulticastPkts";
|
||||
$ret = rrdtool_update("$rrdfile", $if_rrd_update);
|
||||
|
||||
# if ($config['enable_ports_Xbcmc'] && $config['os'][$device['os']]['ifXmcbc']) {
|
||||
# if (!is_file($ifx_rrd)) { shell_exec($ifx_rrd_cmd); }
|
||||
# $ifx_rrd_update = "$polled:$ifHCInBroadcastPkts:$ifHCOutBroadcastPkts:$ifHCInMulticastPkts:$ifHCOutMulticastPkts";
|
||||
# $ret = rrdtool_update($ifx_rrd, $ifx_rrd_update);
|
||||
# }
|
||||
|
||||
/// End Update IF-MIB
|
||||
|
||||
/// Update PAgP
|
||||
if ($this_port['pagpOperationMode'])
|
||||
{
|
||||
foreach ($pagp_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($this_port[$oid] != $port[$oid] )
|
||||
{ // If data has changed, build a query
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
echo("PAgP ");
|
||||
log_event("$oid -> ".$this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// End Update PAgP
|
||||
|
||||
/// Do EtherLike-MIB
|
||||
if ($config['enable_ports_etherlike']) { include("port-etherlike.inc.php"); }
|
||||
|
||||
/// Do ADSL MIB
|
||||
if ($config['enable_ports_adsl']) { include("port-adsl.inc.php"); }
|
||||
|
||||
/// Do PoE MIBs
|
||||
if ($config['enable_ports_poe']) { include("port-poe.inc.php"); }
|
||||
|
||||
// Update MySQL
|
||||
if ($update)
|
||||
{
|
||||
$update_query = "UPDATE `ports` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'";
|
||||
@mysql_query($update_query);
|
||||
if ($debug) {echo("\nMYSQL : [ $update_query ]"); }
|
||||
}
|
||||
// End Update MySQL
|
||||
|
||||
unset($update_query); unset($update);
|
||||
|
||||
// Send alerts for interface flaps.
|
||||
if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0)
|
||||
{
|
||||
if ($this_port['ifAlias'])
|
||||
{
|
||||
$falias = preg_replace('/^"/', '', $this_port['ifAlias']); $falias = preg_replace('/"$/', '', $falias); $full = $this_port['ifDescr'] . " (" . $falias . ")";
|
||||
} else {
|
||||
$full = $this_port['ifDescr'];
|
||||
}
|
||||
switch ($this_port['ifOperStatus'])
|
||||
{
|
||||
case "up":
|
||||
notify($device, "Interface UP - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
case "down":
|
||||
notify($device, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($port['disabled'] != "1")
|
||||
### Copy ifHC[In|Out]Octets values to non-HC if they exist
|
||||
if ($this_port['ifHCInOctets'] > 0 && is_numeric($this_port['ifHCInOctets']) && $this_port['ifHCOutOctets'] > 0 && is_numeric($this_port['ifHCOutOctets']))
|
||||
{
|
||||
echo("Port Deleted"); // Port missing from SNMP cache.
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$this_port['ifIndex']."'");
|
||||
} else {
|
||||
echo("Port Disabled.");
|
||||
echo("HC ");
|
||||
$this_port['ifInOctets'] = $this_port['ifHCInOctets'];
|
||||
$this_port['ifOutOctets'] = $this_port['ifHCOutOctets'];
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
if (is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts']))
|
||||
{
|
||||
echo("HC ");
|
||||
$this_port['ifInBroadcastPkts'] = $this_port['ifHCInBroadcastPkts'];
|
||||
$this_port['ifOutBroadcastPkts'] = $this_port['ifHCOutBroadcastPkts'];
|
||||
$this_port['ifInMulticastPkts'] = $this_port['ifHCInMulticastPkts'];
|
||||
$this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts'];
|
||||
}
|
||||
|
||||
#### Clear Per-Port Variables Here
|
||||
unset($this_port);
|
||||
### Overwrite ifSpeed with ifHighSpeed if it's over 10G
|
||||
if (is_numeric($this_port['ifHighSpeed']) && $this_port['ifSpeed'] > "1000000000")
|
||||
{
|
||||
echo("HighSpeed ");
|
||||
$this_port['ifSpeed'] = $this_port['ifHighSpeed'] * 1000000;
|
||||
}
|
||||
|
||||
### Overwrite ifDuplex with dot3StatsDuplexStatus if it exists
|
||||
if (isset($this_port['dot3StatsDuplexStatus']))
|
||||
{
|
||||
echo("dot3Duplex ");
|
||||
$this_port['ifDuplex'] = $this_port['dot3StatsDuplexStatus'];
|
||||
}
|
||||
|
||||
### Update IF-MIB data
|
||||
foreach ($data_oids as $oid)
|
||||
{
|
||||
if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid]))
|
||||
{
|
||||
$update .= ", `$oid` = NULL";
|
||||
log_event($oid . ": ".$port[$oid]." -> NULL", $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); }
|
||||
} elseif ($port[$oid] != $this_port[$oid] ) {
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse description (usually ifAlias) if config option set
|
||||
|
||||
if (isset($config['port_descr_parser']) && is_file($config['install_dir'] . "/" . $config['port_descr_parser']))
|
||||
{
|
||||
$port_attribs = array('type','descr','circuit','speed','notes');
|
||||
include($config['install_dir'] . "/" . $config['port_descr_parser']);
|
||||
|
||||
foreach ($port_attribs as $attrib)
|
||||
{
|
||||
$attrib_key = "port_descr_".$attrib;
|
||||
if ($port_ifAlias[$attrib] != $port[$attrib_key])
|
||||
{
|
||||
$update .= ", `".$attrib_key."` = '".$port_ifAlias[$attrib]."'";
|
||||
log_event($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device['device_id'], 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Ende parse ifAlias
|
||||
|
||||
/// Update IF-MIB metrics
|
||||
foreach ($stat_oids_db as $oid)
|
||||
{
|
||||
$update .= ", `$oid` = '".$this_port[$oid]."'";
|
||||
$update .= ", `".$oid."_prev` = '".$port[$oid]."'";
|
||||
$oid_prev = $oid . "_prev";
|
||||
if ($port[$oid])
|
||||
{
|
||||
$oid_diff = $this_port[$oid] - $port[$oid];
|
||||
$oid_rate = $oid_diff / $polled_period;
|
||||
if ($oid_rate < 0) { $oid_rate = "0"; }
|
||||
$update .= ", `".$oid."_rate` = '".$oid_rate."'";
|
||||
$update .= ", `".$oid."_delta` = '".$oid_diff."'";
|
||||
if ($debug) {echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Update RRDs
|
||||
$rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
if (!is_file($rrdfile))
|
||||
{
|
||||
rrdtool_create($rrdfile," --step 300 \
|
||||
DS:INOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTOCTETS:DERIVE:600:0:12500000000 \
|
||||
DS:INERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTERRORS:DERIVE:600:0:12500000000 \
|
||||
DS:INUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTDISCARDS:DERIVE:600:0:12500000000 \
|
||||
DS:INUNKNOWNPROTOS:DERIVE:600:0:12500000000 \
|
||||
DS:INBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTBROADCASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:INMULTICASTPKTS:DERIVE:600:0:12500000000 \
|
||||
DS:OUTMULTICASTPKTS:DERIVE: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");
|
||||
}
|
||||
|
||||
foreach ($stat_oids as $oid)
|
||||
{ /// Copy values from array to global variables and force numeric.
|
||||
$$oid = $this_port[$oid];
|
||||
if (!is_numeric($$oid)) { $$oid = "0"; }
|
||||
}
|
||||
|
||||
$if_rrd_update = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts:$ifInDiscards:$ifOutDiscards:$ifInUnknownProtos";
|
||||
$if_rrd_update .= ":$ifInBroadcastPkts:$ifOutBroadcastPkts:$ifInMulticastPkts:$ifOutMulticastPkts";
|
||||
$ret = rrdtool_update("$rrdfile", $if_rrd_update);
|
||||
|
||||
# if ($config['enable_ports_Xbcmc'] && $config['os'][$device['os']]['ifXmcbc']) {
|
||||
# if (!is_file($ifx_rrd)) { shell_exec($ifx_rrd_cmd); }
|
||||
# $ifx_rrd_update = "$polled:$ifHCInBroadcastPkts:$ifHCOutBroadcastPkts:$ifHCInMulticastPkts:$ifHCOutMulticastPkts";
|
||||
# $ret = rrdtool_update($ifx_rrd, $ifx_rrd_update);
|
||||
# }
|
||||
|
||||
/// End Update IF-MIB
|
||||
|
||||
/// Update PAgP
|
||||
if ($this_port['pagpOperationMode'])
|
||||
{
|
||||
foreach ($pagp_oids as $oid)
|
||||
{ // Loop the OIDs
|
||||
if ($this_port[$oid] != $port[$oid] )
|
||||
{ // If data has changed, build a query
|
||||
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
|
||||
echo("PAgP ");
|
||||
log_event("$oid -> ".$this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
// End Update PAgP
|
||||
|
||||
/// Do EtherLike-MIB
|
||||
if ($config['enable_ports_etherlike']) { include("port-etherlike.inc.php"); }
|
||||
|
||||
/// Do ADSL MIB
|
||||
if ($config['enable_ports_adsl']) { include("port-adsl.inc.php"); }
|
||||
|
||||
/// Do PoE MIBs
|
||||
if ($config['enable_ports_poe']) { include("port-poe.inc.php"); }
|
||||
|
||||
// Update MySQL
|
||||
if ($update)
|
||||
{
|
||||
$update_query = "UPDATE `ports` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'";
|
||||
@mysql_query($update_query);
|
||||
if ($debug) {echo("\nMYSQL : [ $update_query ]"); }
|
||||
}
|
||||
// End Update MySQL
|
||||
|
||||
unset($update_query); unset($update);
|
||||
|
||||
// Send alerts for interface flaps.
|
||||
if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0)
|
||||
{
|
||||
if ($this_port['ifAlias'])
|
||||
{
|
||||
$falias = preg_replace('/^"/', '', $this_port['ifAlias']); $falias = preg_replace('/"$/', '', $falias); $full = $this_port['ifDescr'] . " (" . $falias . ")";
|
||||
} else {
|
||||
$full = $this_port['ifDescr'];
|
||||
}
|
||||
switch ($this_port['ifOperStatus'])
|
||||
{
|
||||
case "up":
|
||||
notify($device, "Interface UP - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
case "down":
|
||||
notify($device, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device: " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($port['disabled'] != "1")
|
||||
{
|
||||
echo("Port Deleted"); // Port missing from SNMP cache.
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '".$this_port['ifIndex']."'");
|
||||
} else {
|
||||
echo("Port Disabled.");
|
||||
}
|
||||
|
||||
echo("\n");
|
||||
|
||||
#### Clear Per-Port Variables Here
|
||||
unset($this_port);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -15,19 +15,19 @@ $descr = trim($descr);
|
||||
|
||||
if ($type && $descr)
|
||||
{
|
||||
$type = strtolower($type);
|
||||
$port_ifAlias['type'] = $type;
|
||||
$port_ifAlias['descr'] = $descr;
|
||||
$port_ifAlias['circuit'] = $circuit;
|
||||
$port_ifAlias['speed'] = $speed;
|
||||
$port_ifAlias['notes'] = $notes;
|
||||
$type = strtolower($type);
|
||||
$port_ifAlias['type'] = $type;
|
||||
$port_ifAlias['descr'] = $descr;
|
||||
$port_ifAlias['circuit'] = $circuit;
|
||||
$port_ifAlias['speed'] = $speed;
|
||||
$port_ifAlias['notes'] = $notes;
|
||||
|
||||
if ($debug)
|
||||
{
|
||||
print_r($port_ifAlias);
|
||||
}
|
||||
if ($debug)
|
||||
{
|
||||
print_r($port_ifAlias);
|
||||
}
|
||||
}
|
||||
|
||||
unset ($port_type, $port_descr, $port_circuit, $port_notes, $port_speed);
|
||||
|
||||
?>
|
||||
?>
|
@@ -2,297 +2,297 @@
|
||||
|
||||
function formatMac($mac)
|
||||
{
|
||||
$mac = preg_replace("/(..)(..)(..)(..)(..)(..)/", "\\1:\\2:\\3:\\4:\\5:\\6", $mac);
|
||||
return $mac;
|
||||
$mac = preg_replace("/(..)(..)(..)(..)(..)(..)/", "\\1:\\2:\\3:\\4:\\5:\\6", $mac);
|
||||
return $mac;
|
||||
}
|
||||
|
||||
function rewrite_entity_descr ($descr)
|
||||
{
|
||||
$descr = str_replace("Distributed Forwarding Card", "DFC", $descr);
|
||||
$descr = preg_replace("/7600 Series SPA Interface Processor-/", "7600 SIP-", $descr);
|
||||
$descr = preg_replace("/Rev\.\ [0-9\.]+\ /", "", $descr);
|
||||
$descr = preg_replace("/12000 Series Performance Route Processor/", "12000 PRP", $descr);
|
||||
$descr = preg_replace("/^12000/", "", $descr);
|
||||
$descr = preg_replace("/Gigabit Ethernet/", "GigE", $descr);
|
||||
$descr = preg_replace("/^ASR1000\ /", "", $descr);
|
||||
$descr = str_replace("Routing Processor", "RP", $descr);
|
||||
$descr = str_replace("Route Processor", "RP", $descr);
|
||||
$descr = str_replace("Switching Processor", "SP", $descr);
|
||||
$descr = str_replace("Sub-Module", "Module ", $descr);
|
||||
$descr = str_replace("DFC Card", "DFC", $descr);
|
||||
$descr = str_replace("Centralized Forwarding Card", "CFC", $descr);
|
||||
$descr = str_replace("Power Supply Module", "PSU ", $descr);
|
||||
$descr = str_replace("/Voltage Sensor/", "Voltage", $descr);
|
||||
$descr = preg_replace("/^temperatures /", "", $descr);
|
||||
$descr = preg_replace("/^voltages /", "", $descr);
|
||||
$descr = str_replace("Distributed Forwarding Card", "DFC", $descr);
|
||||
$descr = preg_replace("/7600 Series SPA Interface Processor-/", "7600 SIP-", $descr);
|
||||
$descr = preg_replace("/Rev\.\ [0-9\.]+\ /", "", $descr);
|
||||
$descr = preg_replace("/12000 Series Performance Route Processor/", "12000 PRP", $descr);
|
||||
$descr = preg_replace("/^12000/", "", $descr);
|
||||
$descr = preg_replace("/Gigabit Ethernet/", "GigE", $descr);
|
||||
$descr = preg_replace("/^ASR1000\ /", "", $descr);
|
||||
$descr = str_replace("Routing Processor", "RP", $descr);
|
||||
$descr = str_replace("Route Processor", "RP", $descr);
|
||||
$descr = str_replace("Switching Processor", "SP", $descr);
|
||||
$descr = str_replace("Sub-Module", "Module ", $descr);
|
||||
$descr = str_replace("DFC Card", "DFC", $descr);
|
||||
$descr = str_replace("Centralized Forwarding Card", "CFC", $descr);
|
||||
$descr = str_replace("Power Supply Module", "PSU ", $descr);
|
||||
$descr = str_replace("/Voltage Sensor/", "Voltage", $descr);
|
||||
$descr = preg_replace("/^temperatures /", "", $descr);
|
||||
$descr = preg_replace("/^voltages /", "", $descr);
|
||||
|
||||
return $descr;
|
||||
return $descr;
|
||||
}
|
||||
|
||||
function ifNameDescr($interface, $device = NULL)
|
||||
{
|
||||
return ifLabel($interface, $device);
|
||||
return ifLabel($interface, $device);
|
||||
}
|
||||
|
||||
function ifLabel ($interface, $device = NULL)
|
||||
{
|
||||
global $config;
|
||||
global $config;
|
||||
|
||||
if (!$device) { $device = device_by_id_cache($interface['device_id']); }
|
||||
$os = strtolower($device['os']);
|
||||
if (!$device) { $device = device_by_id_cache($interface['device_id']); }
|
||||
$os = strtolower($device['os']);
|
||||
|
||||
if (isset($config['os'][$os]['ifname']))
|
||||
if (isset($config['os'][$os]['ifname']))
|
||||
{
|
||||
$interface['label'] = $interface['ifName'];
|
||||
} elseif (isset($config['os'][$os]['ifalias']))
|
||||
{
|
||||
$interface['label'] = $interface['ifAlias'];
|
||||
} else {
|
||||
$interface['label'] = $interface['ifDescr'];
|
||||
if (isset($config['os'][$os]['ifindex']))
|
||||
{
|
||||
$interface['label'] = $interface['ifName'];
|
||||
} elseif (isset($config['os'][$os]['ifalias']))
|
||||
{
|
||||
$interface['label'] = $interface['ifAlias'];
|
||||
} else {
|
||||
$interface['label'] = $interface['ifDescr'];
|
||||
if (isset($config['os'][$os]['ifindex']))
|
||||
{
|
||||
$interface['label'] = $interface['label'] . " " . $interface['ifIndex'];
|
||||
}
|
||||
$interface['label'] = $interface['label'] . " " . $interface['ifIndex'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($device['os'] == "speedtouch")
|
||||
{
|
||||
list($interface['label']) = explode("thomson", $interface['label']);
|
||||
}
|
||||
if ($device['os'] == "speedtouch")
|
||||
{
|
||||
list($interface['label']) = explode("thomson", $interface['label']);
|
||||
}
|
||||
|
||||
return $interface;
|
||||
return $interface;
|
||||
}
|
||||
|
||||
$rewrite_entSensorType = array (
|
||||
'celsius' => 'C',
|
||||
'unknown' => '',
|
||||
'specialEnum' => 'C',
|
||||
'watts' => 'W',
|
||||
'truthvalue' => '',
|
||||
'celsius' => 'C',
|
||||
'unknown' => '',
|
||||
'specialEnum' => 'C',
|
||||
'watts' => 'W',
|
||||
'truthvalue' => '',
|
||||
);
|
||||
|
||||
$translate_ifOperStatus = array(
|
||||
"1" => "up",
|
||||
"2" => "down",
|
||||
"3" => "testing",
|
||||
"4" => "unknown",
|
||||
"5" => "dormant",
|
||||
"6" => "notPresent",
|
||||
"7" => "lowerLayerDown",
|
||||
"1" => "up",
|
||||
"2" => "down",
|
||||
"3" => "testing",
|
||||
"4" => "unknown",
|
||||
"5" => "dormant",
|
||||
"6" => "notPresent",
|
||||
"7" => "lowerLayerDown",
|
||||
);
|
||||
|
||||
function translate_ifOperStatus ($ifOperStatus)
|
||||
{
|
||||
global $translate_ifOperStatus;
|
||||
global $translate_ifOperStatus;
|
||||
|
||||
if ($translate_ifOperStatus['$ifOperStatus'])
|
||||
{
|
||||
$ifOperStatus = $translate_ifOperStatus['$ifOperStatus'];
|
||||
}
|
||||
if ($translate_ifOperStatus['$ifOperStatus'])
|
||||
{
|
||||
$ifOperStatus = $translate_ifOperStatus['$ifOperStatus'];
|
||||
}
|
||||
|
||||
return $ifOperStatus;
|
||||
return $ifOperStatus;
|
||||
}
|
||||
|
||||
$translate_ifAdminStatus = array(
|
||||
"1" => "up",
|
||||
"2" => "down",
|
||||
"3" => "testing",
|
||||
"1" => "up",
|
||||
"2" => "down",
|
||||
"3" => "testing",
|
||||
);
|
||||
|
||||
function translate_ifAdminStatus ($ifAdminStatus)
|
||||
{
|
||||
global $translate_ifAdminStatus;
|
||||
global $translate_ifAdminStatus;
|
||||
|
||||
if ($translate_ifAdminStatus[$ifAdminStatus])
|
||||
{
|
||||
$ifAdminStatus = $translate_ifAdminStatus[$ifAdminStatus];
|
||||
}
|
||||
if ($translate_ifAdminStatus[$ifAdminStatus])
|
||||
{
|
||||
$ifAdminStatus = $translate_ifAdminStatus[$ifAdminStatus];
|
||||
}
|
||||
|
||||
return $ifAdminStatus;
|
||||
return $ifAdminStatus;
|
||||
}
|
||||
|
||||
$rewrite_junose_hardware = array(
|
||||
'juniErx1400' => 'ERX-1400',
|
||||
'juniErx700' => 'ERX-700',
|
||||
'juniErx1440' => 'ERX-1440',
|
||||
'juniErx705' => 'ERX-705',
|
||||
'juniErx310' => 'ERX-310',
|
||||
'juniE320' => 'E320',
|
||||
'juniE120' => 'E120',
|
||||
'juniSsx1400' => 'SSX-1400',
|
||||
'juniSsx700' => 'SSX-700',
|
||||
'juniSsx1440' => 'SSX-1440',
|
||||
'juniErx1400' => 'ERX-1400',
|
||||
'juniErx700' => 'ERX-700',
|
||||
'juniErx1440' => 'ERX-1440',
|
||||
'juniErx705' => 'ERX-705',
|
||||
'juniErx310' => 'ERX-310',
|
||||
'juniE320' => 'E320',
|
||||
'juniE120' => 'E120',
|
||||
'juniSsx1400' => 'SSX-1400',
|
||||
'juniSsx700' => 'SSX-700',
|
||||
'juniSsx1440' => 'SSX-1440',
|
||||
);
|
||||
|
||||
$rewrite_ftos_hardware = array (
|
||||
'.1.3.6.1.4.1.6027.1.1.1'=> 'E1200',
|
||||
'.1.3.6.1.4.1.6027.1.1.2'=> 'E600',
|
||||
'.1.3.6.1.4.1.6027.1.1.3'=> 'E300',
|
||||
'.1.3.6.1.4.1.6027.1.1.4'=> 'E610',
|
||||
'.1.3.6.1.4.1.6027.1.1.5'=> 'E1200i',
|
||||
'.1.3.6.1.4.1.6027.1.2.1'=> 'C300',
|
||||
'.1.3.6.1.4.1.6027.1.2.2'=> 'C150',
|
||||
'.1.3.6.1.4.1.6027.1.3.1'=> 'S50',
|
||||
'.1.3.6.1.4.1.6027.1.3.2'=> 'S50E',
|
||||
'.1.3.6.1.4.1.6027.1.3.3'=> 'S50V',
|
||||
'.1.3.6.1.4.1.6027.1.3.4'=> 'S25P-AC',
|
||||
'.1.3.6.1.4.1.6027.1.3.5'=> 'S2410CP',
|
||||
'.1.3.6.1.4.1.6027.1.3.6'=> 'S2410P',
|
||||
'.1.3.6.1.4.1.6027.1.3.7'=> 'S50N-AC',
|
||||
'.1.3.6.1.4.1.6027.1.3.8'=> 'S50N-DC',
|
||||
'.1.3.6.1.4.1.6027.1.3.9'=> 'S25P-DC',
|
||||
'.1.3.6.1.4.1.6027.1.3.10'=> 'S25V',
|
||||
'.1.3.6.1.4.1.6027.1.3.11'=> 'S25N'
|
||||
'.1.3.6.1.4.1.6027.1.1.1'=> 'E1200',
|
||||
'.1.3.6.1.4.1.6027.1.1.2'=> 'E600',
|
||||
'.1.3.6.1.4.1.6027.1.1.3'=> 'E300',
|
||||
'.1.3.6.1.4.1.6027.1.1.4'=> 'E610',
|
||||
'.1.3.6.1.4.1.6027.1.1.5'=> 'E1200i',
|
||||
'.1.3.6.1.4.1.6027.1.2.1'=> 'C300',
|
||||
'.1.3.6.1.4.1.6027.1.2.2'=> 'C150',
|
||||
'.1.3.6.1.4.1.6027.1.3.1'=> 'S50',
|
||||
'.1.3.6.1.4.1.6027.1.3.2'=> 'S50E',
|
||||
'.1.3.6.1.4.1.6027.1.3.3'=> 'S50V',
|
||||
'.1.3.6.1.4.1.6027.1.3.4'=> 'S25P-AC',
|
||||
'.1.3.6.1.4.1.6027.1.3.5'=> 'S2410CP',
|
||||
'.1.3.6.1.4.1.6027.1.3.6'=> 'S2410P',
|
||||
'.1.3.6.1.4.1.6027.1.3.7'=> 'S50N-AC',
|
||||
'.1.3.6.1.4.1.6027.1.3.8'=> 'S50N-DC',
|
||||
'.1.3.6.1.4.1.6027.1.3.9'=> 'S25P-DC',
|
||||
'.1.3.6.1.4.1.6027.1.3.10'=> 'S25V',
|
||||
'.1.3.6.1.4.1.6027.1.3.11'=> 'S25N'
|
||||
);
|
||||
|
||||
$rewrite_fortinet_hardware = array(
|
||||
'.1.3.6.1.4.1.12356.102.1.1000' => 'FortiAnalyzer 100',
|
||||
'.1.3.6.1.4.1.12356.102.1.10002' => 'FortiAnalyzer 1000B',
|
||||
'.1.3.6.1.4.1.12356.102.1.1001' => 'FortiAnalyzer 100A',
|
||||
'.1.3.6.1.4.1.12356.102.1.1002' => 'FortiAnalyzer 100B',
|
||||
'.1.3.6.1.4.1.12356.102.1.20000' => 'FortiAnalyzer 2000',
|
||||
'.1.3.6.1.4.1.12356.102.1.20001' => 'FortiAnalyzer 2000A',
|
||||
'.1.3.6.1.4.1.12356.102.1.4000' => 'FortiAnalyzer 400',
|
||||
'.1.3.6.1.4.1.12356.102.1.40000' => 'FortiAnalyzer 4000',
|
||||
'.1.3.6.1.4.1.12356.102.1.40001' => 'FortiAnalyzer 4000A',
|
||||
'.1.3.6.1.4.1.12356.102.1.4002' => 'FortiAnalyzer 400B',
|
||||
'.1.3.6.1.4.1.12356.102.1.8000' => 'FortiAnalyzer 800',
|
||||
'.1.3.6.1.4.1.12356.102.1.8002' => 'FortiAnalyzer 800B',
|
||||
'.1.3.6.1.4.1.12356.101.1.1000' => 'FortiGate 100',
|
||||
'.1.3.6.1.4.1.12356.101.1.10000' => 'FortiGate 1000',
|
||||
'.1.3.6.1.4.1.12356.101.1.10001' => 'FortiGate 1000A',
|
||||
'.1.3.6.1.4.1.12356.101.1.10002' => 'FortiGate 1000AFA2',
|
||||
'.1.3.6.1.4.1.12356.101.1.10003' => 'FortiGate 1000ALENC',
|
||||
'.1.3.6.1.4.1.12356.101.1.1001' => 'FortiGate 100A',
|
||||
'.1.3.6.1.4.1.12356.101.1.1002' => 'FortiGate 110C',
|
||||
'.1.3.6.1.4.1.12356.101.1.1003' => 'FortiGate 111C',
|
||||
'.1.3.6.1.4.1.12356.101.1.2000' => 'FortiGate 200',
|
||||
'.1.3.6.1.4.1.12356.101.1.20000' => 'FortiGate 2000',
|
||||
'.1.3.6.1.4.1.12356.101.1.2001' => 'FortiGate 200A',
|
||||
'.1.3.6.1.4.1.12356.101.1.2002' => 'FortiGate 224B',
|
||||
'.1.3.6.1.4.1.12356.101.1.2003' => 'FortiGate 200A',
|
||||
'.1.3.6.1.4.1.12356.101.1.3000' => 'FortiGate 300',
|
||||
'.1.3.6.1.4.1.12356.101.1.30000' => 'FortiGate 3000',
|
||||
'.1.3.6.1.4.1.12356.101.1.3001' => 'FortiGate 300A',
|
||||
'.1.3.6.1.4.1.12356.101.1.30160' => 'FortiGate 3016B',
|
||||
'.1.3.6.1.4.1.12356.101.1.302' => 'FortiGate 30B',
|
||||
'.1.3.6.1.4.1.12356.101.1.3002' => 'FortiGate 310B',
|
||||
'.1.3.6.1.4.1.12356.101.1.36000' => 'FortiGate 3600',
|
||||
'.1.3.6.1.4.1.12356.101.1.36003' => 'FortiGate 3600A',
|
||||
'.1.3.6.1.4.1.12356.101.1.38100' => 'FortiGate 3810A',
|
||||
'.1.3.6.1.4.1.12356.101.1.4000' => 'FortiGate 400',
|
||||
'.1.3.6.1.4.1.12356.101.1.40000' => 'FortiGate 4000',
|
||||
'.1.3.6.1.4.1.12356.101.1.4001' => 'FortiGate 400A',
|
||||
'.1.3.6.1.4.1.12356.101.1.5000' => 'FortiGate 500',
|
||||
'.1.3.6.1.4.1.12356.101.1.50000' => 'FortiGate 5000',
|
||||
'.1.3.6.1.4.1.12356.101.1.50010' => 'FortiGate 5001',
|
||||
'.1.3.6.1.4.1.12356.101.1.50011' => 'FortiGate 5001A',
|
||||
'.1.3.6.1.4.1.12356.101.1.50012' => 'FortiGate 5001FA2',
|
||||
'.1.3.6.1.4.1.12356.101.1.50021' => 'FortiGate 5002A',
|
||||
'.1.3.6.1.4.1.12356.101.1.50001' => 'FortiGate 5002FB2',
|
||||
'.1.3.6.1.4.1.12356.101.1.50040' => 'FortiGate 5004',
|
||||
'.1.3.6.1.4.1.12356.101.1.50050' => 'FortiGate 5005',
|
||||
'.1.3.6.1.4.1.12356.101.1.50051' => 'FortiGate 5005FA2',
|
||||
'.1.3.6.1.4.1.12356.101.1.5001' => 'FortiGate 500A',
|
||||
'.1.3.6.1.4.1.12356.101.1.500' => 'FortiGate 50A',
|
||||
'.1.3.6.1.4.1.12356.101.1.501' => 'FortiGate 50AM',
|
||||
'.1.3.6.1.4.1.12356.101.1.502' => 'FortiGate 50B',
|
||||
'.1.3.6.1.4.1.12356.101.1.504' => 'FortiGate 51B',
|
||||
'.1.3.6.1.4.1.12356.101.1.600' => 'FortiGate 60',
|
||||
'.1.3.6.1.4.1.12356.101.1.6201' => 'FortiGate 600D',
|
||||
'.1.3.6.1.4.1.12356.101.1.602' => 'FortiGate 60ADSL',
|
||||
'.1.3.6.1.4.1.12356.101.1.603' => 'FortiGate 60B',
|
||||
'.1.3.6.1.4.1.12356.101.1.601' => 'FortiGate 60M',
|
||||
'.1.3.6.1.4.1.12356.101.1.6200' => 'FortiGate 620B',
|
||||
'.1.3.6.1.4.1.12356.101.1.8000' => 'FortiGate 800',
|
||||
'.1.3.6.1.4.1.12356.101.1.8001' => 'FortiGate 800F',
|
||||
'.1.3.6.1.4.1.12356.101.1.800' => 'FortiGate 80C',
|
||||
'.1.3.6.1.4.1.12356.1688' => 'FortiMail 2000A',
|
||||
'.1.3.6.1.4.1.12356.103.1.1000' => 'FortiManager 100',
|
||||
'.1.3.6.1.4.1.12356.103.1.20000' => 'FortiManager 2000XL',
|
||||
'.1.3.6.1.4.1.12356.103.1.30000' => 'FortiManager 3000',
|
||||
'.1.3.6.1.4.1.12356.103.1.30002' => 'FortiManager 3000B',
|
||||
'.1.3.6.1.4.1.12356.103.1.4000' => 'FortiManager 400',
|
||||
'.1.3.6.1.4.1.12356.103.1.4001' => 'FortiManager 400A',
|
||||
'.1.3.6.1.4.1.12356.106.1.50030' => 'FortiSwitch 5003A',
|
||||
'.1.3.6.1.4.1.12356.101.1.510' => 'FortiWiFi 50B',
|
||||
'.1.3.6.1.4.1.12356.101.1.610' => 'FortiWiFi 60',
|
||||
'.1.3.6.1.4.1.12356.101.1.611' => 'FortiWiFi 60A',
|
||||
'.1.3.6.1.4.1.12356.101.1.612' => 'FortiWiFi 60AM',
|
||||
'.1.3.6.1.4.1.12356.101.1.613' => 'FortiWiFi 60B');
|
||||
'.1.3.6.1.4.1.12356.102.1.1000' => 'FortiAnalyzer 100',
|
||||
'.1.3.6.1.4.1.12356.102.1.10002' => 'FortiAnalyzer 1000B',
|
||||
'.1.3.6.1.4.1.12356.102.1.1001' => 'FortiAnalyzer 100A',
|
||||
'.1.3.6.1.4.1.12356.102.1.1002' => 'FortiAnalyzer 100B',
|
||||
'.1.3.6.1.4.1.12356.102.1.20000' => 'FortiAnalyzer 2000',
|
||||
'.1.3.6.1.4.1.12356.102.1.20001' => 'FortiAnalyzer 2000A',
|
||||
'.1.3.6.1.4.1.12356.102.1.4000' => 'FortiAnalyzer 400',
|
||||
'.1.3.6.1.4.1.12356.102.1.40000' => 'FortiAnalyzer 4000',
|
||||
'.1.3.6.1.4.1.12356.102.1.40001' => 'FortiAnalyzer 4000A',
|
||||
'.1.3.6.1.4.1.12356.102.1.4002' => 'FortiAnalyzer 400B',
|
||||
'.1.3.6.1.4.1.12356.102.1.8000' => 'FortiAnalyzer 800',
|
||||
'.1.3.6.1.4.1.12356.102.1.8002' => 'FortiAnalyzer 800B',
|
||||
'.1.3.6.1.4.1.12356.101.1.1000' => 'FortiGate 100',
|
||||
'.1.3.6.1.4.1.12356.101.1.10000' => 'FortiGate 1000',
|
||||
'.1.3.6.1.4.1.12356.101.1.10001' => 'FortiGate 1000A',
|
||||
'.1.3.6.1.4.1.12356.101.1.10002' => 'FortiGate 1000AFA2',
|
||||
'.1.3.6.1.4.1.12356.101.1.10003' => 'FortiGate 1000ALENC',
|
||||
'.1.3.6.1.4.1.12356.101.1.1001' => 'FortiGate 100A',
|
||||
'.1.3.6.1.4.1.12356.101.1.1002' => 'FortiGate 110C',
|
||||
'.1.3.6.1.4.1.12356.101.1.1003' => 'FortiGate 111C',
|
||||
'.1.3.6.1.4.1.12356.101.1.2000' => 'FortiGate 200',
|
||||
'.1.3.6.1.4.1.12356.101.1.20000' => 'FortiGate 2000',
|
||||
'.1.3.6.1.4.1.12356.101.1.2001' => 'FortiGate 200A',
|
||||
'.1.3.6.1.4.1.12356.101.1.2002' => 'FortiGate 224B',
|
||||
'.1.3.6.1.4.1.12356.101.1.2003' => 'FortiGate 200A',
|
||||
'.1.3.6.1.4.1.12356.101.1.3000' => 'FortiGate 300',
|
||||
'.1.3.6.1.4.1.12356.101.1.30000' => 'FortiGate 3000',
|
||||
'.1.3.6.1.4.1.12356.101.1.3001' => 'FortiGate 300A',
|
||||
'.1.3.6.1.4.1.12356.101.1.30160' => 'FortiGate 3016B',
|
||||
'.1.3.6.1.4.1.12356.101.1.302' => 'FortiGate 30B',
|
||||
'.1.3.6.1.4.1.12356.101.1.3002' => 'FortiGate 310B',
|
||||
'.1.3.6.1.4.1.12356.101.1.36000' => 'FortiGate 3600',
|
||||
'.1.3.6.1.4.1.12356.101.1.36003' => 'FortiGate 3600A',
|
||||
'.1.3.6.1.4.1.12356.101.1.38100' => 'FortiGate 3810A',
|
||||
'.1.3.6.1.4.1.12356.101.1.4000' => 'FortiGate 400',
|
||||
'.1.3.6.1.4.1.12356.101.1.40000' => 'FortiGate 4000',
|
||||
'.1.3.6.1.4.1.12356.101.1.4001' => 'FortiGate 400A',
|
||||
'.1.3.6.1.4.1.12356.101.1.5000' => 'FortiGate 500',
|
||||
'.1.3.6.1.4.1.12356.101.1.50000' => 'FortiGate 5000',
|
||||
'.1.3.6.1.4.1.12356.101.1.50010' => 'FortiGate 5001',
|
||||
'.1.3.6.1.4.1.12356.101.1.50011' => 'FortiGate 5001A',
|
||||
'.1.3.6.1.4.1.12356.101.1.50012' => 'FortiGate 5001FA2',
|
||||
'.1.3.6.1.4.1.12356.101.1.50021' => 'FortiGate 5002A',
|
||||
'.1.3.6.1.4.1.12356.101.1.50001' => 'FortiGate 5002FB2',
|
||||
'.1.3.6.1.4.1.12356.101.1.50040' => 'FortiGate 5004',
|
||||
'.1.3.6.1.4.1.12356.101.1.50050' => 'FortiGate 5005',
|
||||
'.1.3.6.1.4.1.12356.101.1.50051' => 'FortiGate 5005FA2',
|
||||
'.1.3.6.1.4.1.12356.101.1.5001' => 'FortiGate 500A',
|
||||
'.1.3.6.1.4.1.12356.101.1.500' => 'FortiGate 50A',
|
||||
'.1.3.6.1.4.1.12356.101.1.501' => 'FortiGate 50AM',
|
||||
'.1.3.6.1.4.1.12356.101.1.502' => 'FortiGate 50B',
|
||||
'.1.3.6.1.4.1.12356.101.1.504' => 'FortiGate 51B',
|
||||
'.1.3.6.1.4.1.12356.101.1.600' => 'FortiGate 60',
|
||||
'.1.3.6.1.4.1.12356.101.1.6201' => 'FortiGate 600D',
|
||||
'.1.3.6.1.4.1.12356.101.1.602' => 'FortiGate 60ADSL',
|
||||
'.1.3.6.1.4.1.12356.101.1.603' => 'FortiGate 60B',
|
||||
'.1.3.6.1.4.1.12356.101.1.601' => 'FortiGate 60M',
|
||||
'.1.3.6.1.4.1.12356.101.1.6200' => 'FortiGate 620B',
|
||||
'.1.3.6.1.4.1.12356.101.1.8000' => 'FortiGate 800',
|
||||
'.1.3.6.1.4.1.12356.101.1.8001' => 'FortiGate 800F',
|
||||
'.1.3.6.1.4.1.12356.101.1.800' => 'FortiGate 80C',
|
||||
'.1.3.6.1.4.1.12356.1688' => 'FortiMail 2000A',
|
||||
'.1.3.6.1.4.1.12356.103.1.1000' => 'FortiManager 100',
|
||||
'.1.3.6.1.4.1.12356.103.1.20000' => 'FortiManager 2000XL',
|
||||
'.1.3.6.1.4.1.12356.103.1.30000' => 'FortiManager 3000',
|
||||
'.1.3.6.1.4.1.12356.103.1.30002' => 'FortiManager 3000B',
|
||||
'.1.3.6.1.4.1.12356.103.1.4000' => 'FortiManager 400',
|
||||
'.1.3.6.1.4.1.12356.103.1.4001' => 'FortiManager 400A',
|
||||
'.1.3.6.1.4.1.12356.106.1.50030' => 'FortiSwitch 5003A',
|
||||
'.1.3.6.1.4.1.12356.101.1.510' => 'FortiWiFi 50B',
|
||||
'.1.3.6.1.4.1.12356.101.1.610' => 'FortiWiFi 60',
|
||||
'.1.3.6.1.4.1.12356.101.1.611' => 'FortiWiFi 60A',
|
||||
'.1.3.6.1.4.1.12356.101.1.612' => 'FortiWiFi 60AM',
|
||||
'.1.3.6.1.4.1.12356.101.1.613' => 'FortiWiFi 60B');
|
||||
|
||||
$rewrite_extreme_hardware = array (
|
||||
'.1.3.6.1.4.1.1916.2.26' => 'Alpine 3802',
|
||||
'.1.3.6.1.4.1.1916.2.20' => 'Alpine 3804',
|
||||
'.1.3.6.1.4.1.1916.2.17' => 'Alpine 3808',
|
||||
'.1.3.6.1.4.1.1916.2.86' => 'Altitude 300',
|
||||
'.1.3.6.1.4.1.1916.2.75' => 'Altitude 350',
|
||||
'.1.3.6.1.4.1.1916.2.56' => 'BlackDiamond 10808',
|
||||
'.1.3.6.1.4.1.1916.2.85' => 'BlackDiamond 12802',
|
||||
'.1.3.6.1.4.1.1916.2.77' => 'BlackDiamond 12804',
|
||||
'.1.3.6.1.4.1.1916.2.8' => 'BlackDiamond 6800',
|
||||
'.1.3.6.1.4.1.1916.2.27' => 'BlackDiamond 6804',
|
||||
'.1.3.6.1.4.1.1916.2.11' => 'BlackDiamond 6808',
|
||||
'.1.3.6.1.4.1.1916.2.24' => 'BlackDiamond 6816',
|
||||
'.1.3.6.1.4.1.1916.2.74' => 'BlackDiamond 8806',
|
||||
'.1.3.6.1.4.1.1916.2.62' => 'BlackDiamond 8810',
|
||||
'.1.3.6.1.4.1.1916.2.23' => 'EnetSwitch 24Port',
|
||||
'.1.3.6.1.4.1.1916.2.83' => 'Sentriant CE150',
|
||||
'.1.3.6.1.4.1.1916.2.58' => 'Summit 400-48t',
|
||||
'.1.3.6.1.4.1.1916.2.59' => 'Summit 400-48t',
|
||||
'.1.3.6.1.4.1.1916.2.71' => 'Summit X450a-24t',
|
||||
'.1.3.6.1.4.1.1916.2.81' => 'Summit X450a-24t',
|
||||
'.1.3.6.1.4.1.1916.2.1' => 'Summit 1',
|
||||
'.1.3.6.1.4.1.1916.2.19' => 'Summit 1iSX',
|
||||
'.1.3.6.1.4.1.1916.2.14' => 'Summit 1iTX',
|
||||
'.1.3.6.1.4.1.1916.2.2' => 'Summit 2',
|
||||
'.1.3.6.1.4.1.1916.2.53' => 'Summit 200-24',
|
||||
'.1.3.6.1.4.1.1916.2.70' => 'Summit 200-24fx',
|
||||
'.1.3.6.1.4.1.1916.2.54' => 'Summit 200-48',
|
||||
'.1.3.6.1.4.1.1916.2.7' => 'Summit 24',
|
||||
'.1.3.6.1.4.1.1916.2.41' => 'Summit 24e2SX',
|
||||
'.1.3.6.1.4.1.1916.2.40' => 'Summit 24e2TX',
|
||||
'.1.3.6.1.4.1.1916.2.25' => 'Summit 24e3',
|
||||
'.1.3.6.1.4.1.1916.2.3' => 'Summit 3',
|
||||
'.1.3.6.1.4.1.1916.2.61' => 'Summit 300-24',
|
||||
'.1.3.6.1.4.1.1916.2.55' => 'Summit 300-48',
|
||||
'.1.3.6.1.4.1.1916.2.4' => 'Summit 4',
|
||||
'.1.3.6.1.4.1.1916.2.58' => 'Summit 400-24',
|
||||
'.1.3.6.1.4.1.1916.2.64' => 'Summit 400-24p',
|
||||
'.1.3.6.1.4.1.1916.2.63' => 'Summit 400-24t',
|
||||
'.1.3.6.1.4.1.1916.2.59' => 'Summit 400-24x',
|
||||
'.1.3.6.1.4.1.1916.2.6' => 'Summit 48',
|
||||
'.1.3.6.1.4.1.1916.2.16' => 'Summit 48i',
|
||||
'.1.3.6.1.4.1.1916.2.28' => 'Summit 48i1u',
|
||||
'.1.3.6.1.4.1.1916.2.5' => 'Summit 4FX',
|
||||
'.1.3.6.1.4.1.1916.2.15' => 'Summit 5i',
|
||||
'.1.3.6.1.4.1.1916.2.21' => 'Summit 5iLX',
|
||||
'.1.3.6.1.4.1.1916.2.22' => 'Summit 5iTX',
|
||||
'.1.3.6.1.4.1.1916.2.12' => 'Summit 7iSX',
|
||||
'.1.3.6.1.4.1.1916.2.13' => 'Summit 7iTX',
|
||||
'.1.3.6.1.4.1.1916.2.30' => 'Summit Px1',
|
||||
'.1.3.6.1.4.1.1916.2.67' => 'SummitStack',
|
||||
'.1.3.6.1.4.1.1916.2.93' => 'Summit Ver2Stack',
|
||||
'.1.3.6.1.4.1.1916.2.68' => 'SummitWM 100',
|
||||
'.1.3.6.1.4.1.1916.2.69' => 'SummitWM 1000',
|
||||
'.1.3.6.1.4.1.1916.2.94' => 'SummitWM 200',
|
||||
'.1.3.6.1.4.1.1916.2.95' => 'SummitWM 2000',
|
||||
'.1.3.6.1.4.1.1916.2.89' => 'Summit X250-24p',
|
||||
'.1.3.6.1.4.1.1916.2.88' => 'Summit X250-24t',
|
||||
'.1.3.6.1.4.1.1916.2.90' => 'Summit X250-24x',
|
||||
'.1.3.6.1.4.1.1916.2.92' => 'Summit X250-48p',
|
||||
'.1.3.6.1.4.1.1916.2.91' => 'Summit X250-48t',
|
||||
'.1.3.6.1.4.1.1916.2.93' => 'Summit X250e-24t (3-Stack)',
|
||||
'.1.3.6.1.4.1.1916.2.88' => 'Summit X250e-24t (Single)',
|
||||
'.1.3.6.1.4.1.1916.2.66' => 'Summit X450-24t',
|
||||
'.1.3.6.1.4.1.1916.2.65' => 'Summit X450-24x',
|
||||
'.1.3.6.1.4.1.1916.2.80' => 'Summit X450a-24tDC',
|
||||
'.1.3.6.1.4.1.1916.2.84' => 'Summit X450a-24x',
|
||||
'.1.3.6.1.4.1.1916.2.82' => 'Summit X450a-24xDC',
|
||||
'.1.3.6.1.4.1.1916.2.76' => 'Summit X450a-48t',
|
||||
'.1.3.6.1.4.1.1916.2.87' => 'Summit X450a-48tDC',
|
||||
'.1.3.6.1.4.1.1916.2.72' => 'Summit X450e-24p',
|
||||
'.1.3.6.1.4.1.1916.2.79' => 'Summit X450e-48p'
|
||||
'.1.3.6.1.4.1.1916.2.26' => 'Alpine 3802',
|
||||
'.1.3.6.1.4.1.1916.2.20' => 'Alpine 3804',
|
||||
'.1.3.6.1.4.1.1916.2.17' => 'Alpine 3808',
|
||||
'.1.3.6.1.4.1.1916.2.86' => 'Altitude 300',
|
||||
'.1.3.6.1.4.1.1916.2.75' => 'Altitude 350',
|
||||
'.1.3.6.1.4.1.1916.2.56' => 'BlackDiamond 10808',
|
||||
'.1.3.6.1.4.1.1916.2.85' => 'BlackDiamond 12802',
|
||||
'.1.3.6.1.4.1.1916.2.77' => 'BlackDiamond 12804',
|
||||
'.1.3.6.1.4.1.1916.2.8' => 'BlackDiamond 6800',
|
||||
'.1.3.6.1.4.1.1916.2.27' => 'BlackDiamond 6804',
|
||||
'.1.3.6.1.4.1.1916.2.11' => 'BlackDiamond 6808',
|
||||
'.1.3.6.1.4.1.1916.2.24' => 'BlackDiamond 6816',
|
||||
'.1.3.6.1.4.1.1916.2.74' => 'BlackDiamond 8806',
|
||||
'.1.3.6.1.4.1.1916.2.62' => 'BlackDiamond 8810',
|
||||
'.1.3.6.1.4.1.1916.2.23' => 'EnetSwitch 24Port',
|
||||
'.1.3.6.1.4.1.1916.2.83' => 'Sentriant CE150',
|
||||
'.1.3.6.1.4.1.1916.2.58' => 'Summit 400-48t',
|
||||
'.1.3.6.1.4.1.1916.2.59' => 'Summit 400-48t',
|
||||
'.1.3.6.1.4.1.1916.2.71' => 'Summit X450a-24t',
|
||||
'.1.3.6.1.4.1.1916.2.81' => 'Summit X450a-24t',
|
||||
'.1.3.6.1.4.1.1916.2.1' => 'Summit 1',
|
||||
'.1.3.6.1.4.1.1916.2.19' => 'Summit 1iSX',
|
||||
'.1.3.6.1.4.1.1916.2.14' => 'Summit 1iTX',
|
||||
'.1.3.6.1.4.1.1916.2.2' => 'Summit 2',
|
||||
'.1.3.6.1.4.1.1916.2.53' => 'Summit 200-24',
|
||||
'.1.3.6.1.4.1.1916.2.70' => 'Summit 200-24fx',
|
||||
'.1.3.6.1.4.1.1916.2.54' => 'Summit 200-48',
|
||||
'.1.3.6.1.4.1.1916.2.7' => 'Summit 24',
|
||||
'.1.3.6.1.4.1.1916.2.41' => 'Summit 24e2SX',
|
||||
'.1.3.6.1.4.1.1916.2.40' => 'Summit 24e2TX',
|
||||
'.1.3.6.1.4.1.1916.2.25' => 'Summit 24e3',
|
||||
'.1.3.6.1.4.1.1916.2.3' => 'Summit 3',
|
||||
'.1.3.6.1.4.1.1916.2.61' => 'Summit 300-24',
|
||||
'.1.3.6.1.4.1.1916.2.55' => 'Summit 300-48',
|
||||
'.1.3.6.1.4.1.1916.2.4' => 'Summit 4',
|
||||
'.1.3.6.1.4.1.1916.2.58' => 'Summit 400-24',
|
||||
'.1.3.6.1.4.1.1916.2.64' => 'Summit 400-24p',
|
||||
'.1.3.6.1.4.1.1916.2.63' => 'Summit 400-24t',
|
||||
'.1.3.6.1.4.1.1916.2.59' => 'Summit 400-24x',
|
||||
'.1.3.6.1.4.1.1916.2.6' => 'Summit 48',
|
||||
'.1.3.6.1.4.1.1916.2.16' => 'Summit 48i',
|
||||
'.1.3.6.1.4.1.1916.2.28' => 'Summit 48i1u',
|
||||
'.1.3.6.1.4.1.1916.2.5' => 'Summit 4FX',
|
||||
'.1.3.6.1.4.1.1916.2.15' => 'Summit 5i',
|
||||
'.1.3.6.1.4.1.1916.2.21' => 'Summit 5iLX',
|
||||
'.1.3.6.1.4.1.1916.2.22' => 'Summit 5iTX',
|
||||
'.1.3.6.1.4.1.1916.2.12' => 'Summit 7iSX',
|
||||
'.1.3.6.1.4.1.1916.2.13' => 'Summit 7iTX',
|
||||
'.1.3.6.1.4.1.1916.2.30' => 'Summit Px1',
|
||||
'.1.3.6.1.4.1.1916.2.67' => 'SummitStack',
|
||||
'.1.3.6.1.4.1.1916.2.93' => 'Summit Ver2Stack',
|
||||
'.1.3.6.1.4.1.1916.2.68' => 'SummitWM 100',
|
||||
'.1.3.6.1.4.1.1916.2.69' => 'SummitWM 1000',
|
||||
'.1.3.6.1.4.1.1916.2.94' => 'SummitWM 200',
|
||||
'.1.3.6.1.4.1.1916.2.95' => 'SummitWM 2000',
|
||||
'.1.3.6.1.4.1.1916.2.89' => 'Summit X250-24p',
|
||||
'.1.3.6.1.4.1.1916.2.88' => 'Summit X250-24t',
|
||||
'.1.3.6.1.4.1.1916.2.90' => 'Summit X250-24x',
|
||||
'.1.3.6.1.4.1.1916.2.92' => 'Summit X250-48p',
|
||||
'.1.3.6.1.4.1.1916.2.91' => 'Summit X250-48t',
|
||||
'.1.3.6.1.4.1.1916.2.93' => 'Summit X250e-24t (3-Stack)',
|
||||
'.1.3.6.1.4.1.1916.2.88' => 'Summit X250e-24t (Single)',
|
||||
'.1.3.6.1.4.1.1916.2.66' => 'Summit X450-24t',
|
||||
'.1.3.6.1.4.1.1916.2.65' => 'Summit X450-24x',
|
||||
'.1.3.6.1.4.1.1916.2.80' => 'Summit X450a-24tDC',
|
||||
'.1.3.6.1.4.1.1916.2.84' => 'Summit X450a-24x',
|
||||
'.1.3.6.1.4.1.1916.2.82' => 'Summit X450a-24xDC',
|
||||
'.1.3.6.1.4.1.1916.2.76' => 'Summit X450a-48t',
|
||||
'.1.3.6.1.4.1.1916.2.87' => 'Summit X450a-48tDC',
|
||||
'.1.3.6.1.4.1.1916.2.72' => 'Summit X450e-24p',
|
||||
'.1.3.6.1.4.1.1916.2.79' => 'Summit X450e-48p'
|
||||
);
|
||||
|
||||
$rewrite_ironware_hardware = array(
|
||||
@@ -718,38 +718,38 @@ $rewrite_ironware_hardware = array(
|
||||
);
|
||||
|
||||
$rewrite_ios_features = array(
|
||||
'PK9S' => 'IP w/SSH LAN Only',
|
||||
'LANBASEK9' => 'Lan Base Crypto',
|
||||
'LANBASE' => 'Lan Base',
|
||||
'ADVENTERPRISEK9_IVS' => 'Advanced Enterprise Crypto Voice',
|
||||
'ADVENTERPRISEK9' => 'Advanced Enterprise Crypto',
|
||||
'ADVSECURITYK9' => 'Advanced Security Crypto',
|
||||
'K91P' => 'Provider Crypto',
|
||||
'K4P' => 'Provider Crypto',
|
||||
'ADVIPSERVICESK9' => 'Adv IP Services Crypto',
|
||||
'ADVIPSERVICES' => 'Adv IP Services',
|
||||
'IK9P' => 'IP Plus Crypto',
|
||||
'K9O3SY7' => 'IP ADSL FW IDS Plus IPSEC 3DES',
|
||||
'SPSERVICESK9' => 'SP Services Crypto',
|
||||
'PK9SV' => 'IP MPLS/IPV6 W/SSH + BGP',
|
||||
'IS' => 'IP Plus',
|
||||
'IPSERVICESK9' => 'IP Services Crypto',
|
||||
'BROADBAND' => 'Broadband',
|
||||
'IPBASE' => 'IP Base',
|
||||
'IPSERVICE' => 'IP Services',
|
||||
'P' => 'Service Provider',
|
||||
'P11' => 'Broadband Router',
|
||||
'G4P5' => 'NRP',
|
||||
'JK9S' => 'Enterprise Plus Crypto',
|
||||
'IK9S' => 'IP Plus Crypto',
|
||||
'JK' => 'Enterprise Plus',
|
||||
'I6Q4L2' => 'Layer 2',
|
||||
'I6K2L2Q4' => 'Layer 2 Crypto',
|
||||
'C3H2S' => 'Layer 2 SI/EI',
|
||||
'_WAN' => ' + WAN',
|
||||
);
|
||||
'PK9S' => 'IP w/SSH LAN Only',
|
||||
'LANBASEK9' => 'Lan Base Crypto',
|
||||
'LANBASE' => 'Lan Base',
|
||||
'ADVENTERPRISEK9_IVS' => 'Advanced Enterprise Crypto Voice',
|
||||
'ADVENTERPRISEK9' => 'Advanced Enterprise Crypto',
|
||||
'ADVSECURITYK9' => 'Advanced Security Crypto',
|
||||
'K91P' => 'Provider Crypto',
|
||||
'K4P' => 'Provider Crypto',
|
||||
'ADVIPSERVICESK9' => 'Adv IP Services Crypto',
|
||||
'ADVIPSERVICES' => 'Adv IP Services',
|
||||
'IK9P' => 'IP Plus Crypto',
|
||||
'K9O3SY7' => 'IP ADSL FW IDS Plus IPSEC 3DES',
|
||||
'SPSERVICESK9' => 'SP Services Crypto',
|
||||
'PK9SV' => 'IP MPLS/IPV6 W/SSH + BGP',
|
||||
'IS' => 'IP Plus',
|
||||
'IPSERVICESK9' => 'IP Services Crypto',
|
||||
'BROADBAND' => 'Broadband',
|
||||
'IPBASE' => 'IP Base',
|
||||
'IPSERVICE' => 'IP Services',
|
||||
'P' => 'Service Provider',
|
||||
'P11' => 'Broadband Router',
|
||||
'G4P5' => 'NRP',
|
||||
'JK9S' => 'Enterprise Plus Crypto',
|
||||
'IK9S' => 'IP Plus Crypto',
|
||||
'JK' => 'Enterprise Plus',
|
||||
'I6Q4L2' => 'Layer 2',
|
||||
'I6K2L2Q4' => 'Layer 2 Crypto',
|
||||
'C3H2S' => 'Layer 2 SI/EI',
|
||||
'_WAN' => ' + WAN',
|
||||
);
|
||||
|
||||
$rewrite_shortif = array (
|
||||
$rewrite_shortif = array (
|
||||
'tengigabitethernet' => 'Te',
|
||||
'gigabitethernet' => 'Gi',
|
||||
'fastethernet' => 'Fa',
|
||||
@@ -764,9 +764,9 @@ $rewrite_shortif = array (
|
||||
'vlan' => 'Vlan',
|
||||
'tunnel' => 'Tunnel',
|
||||
'serviceinstance' => 'SI',
|
||||
);
|
||||
);
|
||||
|
||||
$rewrite_iftype = array (
|
||||
$rewrite_iftype = array (
|
||||
'/^frameRelay$/' => 'Frame Relay',
|
||||
'/^ethernetCsmacd$/' => 'Ethernet',
|
||||
'/^softwareLoopback$/' => 'Loopback',
|
||||
@@ -783,9 +783,9 @@ $rewrite_iftype = array (
|
||||
'/^aal5$/' => 'ATM AAL5',
|
||||
'/^atmSubInterface$/' => 'ATM Subif',
|
||||
'/^propPointToPointSerial$/' => 'PtP Serial',
|
||||
);
|
||||
);
|
||||
|
||||
$rewrite_ifname = array (
|
||||
$rewrite_ifname = array (
|
||||
'ether' => 'Ether',
|
||||
'gig' => 'Gig',
|
||||
'fast' => 'Fast',
|
||||
@@ -805,149 +805,149 @@ $rewrite_ifname = array (
|
||||
'hp procurve switch software loopback interface' => 'Loopback Interface',
|
||||
'control plane interface' => 'Control Plane',
|
||||
'loop' => 'Loop',
|
||||
);
|
||||
);
|
||||
|
||||
$rewrite_hrDevice = array (
|
||||
$rewrite_hrDevice = array (
|
||||
'GenuineIntel:' => '',
|
||||
'AuthenticAMD:' => '',
|
||||
'Intel(R)' => '',
|
||||
'CPU' => '',
|
||||
'(R)' => '',
|
||||
' ' => ' ',
|
||||
);
|
||||
);
|
||||
|
||||
|
||||
// Specific rewrite functions
|
||||
|
||||
function makeshortif($if)
|
||||
{
|
||||
global $rewrite_shortif;
|
||||
global $rewrite_shortif;
|
||||
|
||||
$if = fixifName ($if);
|
||||
$if = strtolower($if);
|
||||
$if = array_str_replace($rewrite_shortif, $if);
|
||||
$if = fixifName ($if);
|
||||
$if = strtolower($if);
|
||||
$if = array_str_replace($rewrite_shortif, $if);
|
||||
|
||||
return $if;
|
||||
return $if;
|
||||
}
|
||||
|
||||
function rewrite_ios_features ($features)
|
||||
{
|
||||
global $rewrite_ios_features;
|
||||
global $rewrite_ios_features;
|
||||
|
||||
$type = array_preg_replace($rewrite_ios_features, $features);
|
||||
$type = array_preg_replace($rewrite_ios_features, $features);
|
||||
|
||||
return ($features);
|
||||
return ($features);
|
||||
}
|
||||
|
||||
function rewrite_fortinet_hardware ($hardware)
|
||||
{
|
||||
global $rewrite_fortinet_hardware;
|
||||
global $rewrite_fortinet_hardware;
|
||||
|
||||
$hardware = $rewrite_fortinet_hardware[$hardware];
|
||||
$hardware = $rewrite_fortinet_hardware[$hardware];
|
||||
|
||||
return ($hardware);
|
||||
return ($hardware);
|
||||
}
|
||||
|
||||
|
||||
function rewrite_extreme_hardware ($hardware)
|
||||
{
|
||||
global $rewrite_extreme_hardware;
|
||||
global $rewrite_extreme_hardware;
|
||||
|
||||
#$hardware = array_str_replace($rewrite_extreme_hardware, $hardware);
|
||||
$hardware = $rewrite_extreme_hardware[$hardware];
|
||||
#$hardware = array_str_replace($rewrite_extreme_hardware, $hardware);
|
||||
$hardware = $rewrite_extreme_hardware[$hardware];
|
||||
|
||||
return ($hardware);
|
||||
return ($hardware);
|
||||
}
|
||||
|
||||
function rewrite_ftos_hardware ($hardware)
|
||||
{
|
||||
global $rewrite_ftos_hardware;
|
||||
global $rewrite_ftos_hardware;
|
||||
|
||||
$hardware = $rewrite_ftos_hardware[$hardware];
|
||||
$hardware = $rewrite_ftos_hardware[$hardware];
|
||||
|
||||
return ($hardware);
|
||||
return ($hardware);
|
||||
}
|
||||
|
||||
|
||||
function rewrite_ironware_hardware ($hardware)
|
||||
{
|
||||
global $rewrite_ironware_hardware;
|
||||
global $rewrite_ironware_hardware;
|
||||
|
||||
$hardware = array_str_replace($rewrite_ironware_hardware, $hardware);
|
||||
$hardware = array_str_replace($rewrite_ironware_hardware, $hardware);
|
||||
|
||||
return ($hardware);
|
||||
return ($hardware);
|
||||
}
|
||||
|
||||
function rewrite_junose_hardware ($hardware)
|
||||
{
|
||||
global $rewrite_junose_hardware;
|
||||
global $rewrite_junose_hardware;
|
||||
|
||||
$hardware = array_str_replace($rewrite_junose_hardware, $hardware);
|
||||
$hardware = array_str_replace($rewrite_junose_hardware, $hardware);
|
||||
|
||||
return ($hardware);
|
||||
return ($hardware);
|
||||
}
|
||||
|
||||
function fixiftype ($type)
|
||||
{
|
||||
global $rewrite_iftype;
|
||||
global $rewrite_iftype;
|
||||
|
||||
$type = array_preg_replace($rewrite_iftype, $type);
|
||||
$type = array_preg_replace($rewrite_iftype, $type);
|
||||
|
||||
return ($type);
|
||||
return ($type);
|
||||
}
|
||||
|
||||
function fixifName ($inf)
|
||||
{
|
||||
global $rewrite_ifname;
|
||||
global $rewrite_ifname;
|
||||
|
||||
$inf = strtolower($inf);
|
||||
$inf = array_str_replace($rewrite_ifname, $inf);
|
||||
$inf = strtolower($inf);
|
||||
$inf = array_str_replace($rewrite_ifname, $inf);
|
||||
|
||||
return $inf;
|
||||
return $inf;
|
||||
}
|
||||
|
||||
function short_hrDeviceDescr($dev)
|
||||
{
|
||||
global $rewrite_hrDevice;
|
||||
global $rewrite_hrDevice;
|
||||
|
||||
$dev = array_str_replace($rewrite_hrDevice, $dev);
|
||||
$dev = preg_replace("/\ +/"," ", $dev);
|
||||
$dev = trim($dev);
|
||||
$dev = array_str_replace($rewrite_hrDevice, $dev);
|
||||
$dev = preg_replace("/\ +/"," ", $dev);
|
||||
$dev = trim($dev);
|
||||
|
||||
return $dev;
|
||||
return $dev;
|
||||
}
|
||||
|
||||
function short_port_descr ($desc)
|
||||
{
|
||||
list($desc) = explode("(", $desc);
|
||||
list($desc) = explode("[", $desc);
|
||||
list($desc) = explode("{", $desc);
|
||||
list($desc) = explode("|", $desc);
|
||||
list($desc) = explode("<", $desc);
|
||||
$desc = trim($desc);
|
||||
list($desc) = explode("(", $desc);
|
||||
list($desc) = explode("[", $desc);
|
||||
list($desc) = explode("{", $desc);
|
||||
list($desc) = explode("|", $desc);
|
||||
list($desc) = explode("<", $desc);
|
||||
$desc = trim($desc);
|
||||
|
||||
return $desc;
|
||||
return $desc;
|
||||
}
|
||||
|
||||
// Underlying rewrite functions
|
||||
function array_str_replace($array, $string)
|
||||
{
|
||||
foreach ($array as $search => $replace)
|
||||
{
|
||||
$string = str_replace($search, $replace, $string);
|
||||
}
|
||||
foreach ($array as $search => $replace)
|
||||
{
|
||||
$string = str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
return $string;
|
||||
}
|
||||
|
||||
function array_preg_replace($array, $string)
|
||||
{
|
||||
foreach ($array as $search => $replace)
|
||||
{
|
||||
$string = preg_replace($search, $replace, $string);
|
||||
}
|
||||
foreach ($array as $search => $replace)
|
||||
{
|
||||
$string = preg_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
return $string;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -2,53 +2,53 @@
|
||||
|
||||
function rrdtool_update($rrdfile, $rrdupdate)
|
||||
{
|
||||
return rrdtool("update", $rrdfile, $rrdupdate);
|
||||
return rrdtool("update", $rrdfile, $rrdupdate);
|
||||
}
|
||||
|
||||
function rrdtool_create($rrdfile, $rrdupdate)
|
||||
{
|
||||
global $config; global $debug;
|
||||
global $config; global $debug;
|
||||
|
||||
$command = $config['rrdtool'] . " create $rrdfile $rrdupdate";
|
||||
$command = $config['rrdtool'] . " create $rrdfile $rrdupdate";
|
||||
|
||||
if ($debug) { echo($command."\n"); }
|
||||
if ($debug) { echo($command."\n"); }
|
||||
|
||||
return shell_exec($command);
|
||||
return shell_exec($command);
|
||||
|
||||
}
|
||||
|
||||
function rrdtool_fetch($rrdfile, $rrdupdate)
|
||||
{
|
||||
return rrdtool("fetch", $rrdfile, $rrdupdate);
|
||||
return rrdtool("fetch", $rrdfile, $rrdupdate);
|
||||
}
|
||||
|
||||
function rrdtool_graph($rrdfile, $rrdupdate)
|
||||
{
|
||||
return rrdtool("graph", $rrdfile, $rrdupdate);
|
||||
return rrdtool("graph", $rrdfile, $rrdupdate);
|
||||
}
|
||||
|
||||
function rrdtool_last($rrdfile, $rrdupdate)
|
||||
{
|
||||
return rrdtool("last", $rrdfile, $rrdupdate);
|
||||
return rrdtool("last", $rrdfile, $rrdupdate);
|
||||
}
|
||||
|
||||
function rrdtool_lastupdate($rrdfile, $rrdupdate)
|
||||
{
|
||||
return rrdtool("lastupdate", $rrdfile, $rrdupdate);
|
||||
return rrdtool("lastupdate", $rrdfile, $rrdupdate);
|
||||
}
|
||||
|
||||
function rrdtool($command, $file, $options)
|
||||
{
|
||||
global $config; global $debug;
|
||||
global $config; global $debug;
|
||||
|
||||
$command = $config['rrdtool'] . " $command $file $options";
|
||||
if ($config['rrdcached'])
|
||||
{
|
||||
$command .= " --daemon " . $config['rrdcached'];
|
||||
}
|
||||
$command = $config['rrdtool'] . " $command $file $options";
|
||||
if ($config['rrdcached'])
|
||||
{
|
||||
$command .= " --daemon " . $config['rrdcached'];
|
||||
}
|
||||
|
||||
if ($debug) { echo($command."\n"); }
|
||||
return shell_exec($command);
|
||||
if ($debug) { echo($command."\n"); }
|
||||
return shell_exec($command);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
function add_service($service) {
|
||||
function add_service($service) {
|
||||
global $id;
|
||||
global $hostname;
|
||||
echo("$service ");
|
||||
$sql = "INSERT INTO `services` (`device_id`,`service_ip`,`service_type`,`service_desc`,`service_param`,`service_ignore`)
|
||||
VALUES ('" . mres($id). "','" . mres($hostname) . "','" . mres($service) . "',
|
||||
'" . mres("auto discovered: $service") . "','" . mres("") . "','0')";
|
||||
VALUES ('" . mres($id). "','" . mres($hostname) . "','" . mres($service) . "',
|
||||
'" . mres("auto discovered: $service") . "','" . mres("") . "','0')";
|
||||
|
||||
$query = mysql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,8 @@ log_event("SNMP Trap: linkDown " . $interface['ifDescr'], $device, "interface",
|
||||
#}
|
||||
if ($ifOperStatus != $interface['ifOperStatus'])
|
||||
{
|
||||
log_event("Interface went Down : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']);
|
||||
mysql_query("UPDATE `ports` SET ifOperStatus = 'down' WHERE `interface_id` = '".$interface['interface_id']."'");
|
||||
log_event("Interface went Down : " . $interface['ifDescr'] . " (TRAP)", $device, "interface", $interface['interface_id']);
|
||||
mysql_query("UPDATE `ports` SET ifOperStatus = 'down' WHERE `interface_id` = '".$interface['interface_id']."'");
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -3,34 +3,34 @@
|
||||
# FIXME not used, do we still need this?
|
||||
|
||||
function callsgraphSNOM ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) {
|
||||
global $config;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical ,"--alt-autoscale-max",
|
||||
"-l 0",
|
||||
"-E",
|
||||
"--title", $title,
|
||||
"DEF:call=$database:CALLS:AVERAGE",
|
||||
"CDEF:calls=call,360,*",
|
||||
"LINE1.25:calls#FF9900:Calls",
|
||||
"GPRINT:calls:LAST:Cu\: %2.0lf/min",
|
||||
"GPRINT:calls:AVERAGE:Av\: %2.0lf/min",
|
||||
"GPRINT:calls:MAX:Mx\: %2.0lf/min\\n");
|
||||
if($width <= "300") {$optsb = array("--font", "LEGEND:7:".$config['mono_font']."",
|
||||
"--font", "AXIS:6:".$config['mono_font']."",
|
||||
"--font-render-mode", "normal");}
|
||||
global $config;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$optsa = array( "--start", $from, "--end", $to, "--width", $width, "--height", $height, "--vertical-label", $vertical ,"--alt-autoscale-max",
|
||||
"-l 0",
|
||||
"-E",
|
||||
"--title", $title,
|
||||
"DEF:call=$database:CALLS:AVERAGE",
|
||||
"CDEF:calls=call,360,*",
|
||||
"LINE1.25:calls#FF9900:Calls",
|
||||
"GPRINT:calls:LAST:Cu\: %2.0lf/min",
|
||||
"GPRINT:calls:AVERAGE:Av\: %2.0lf/min",
|
||||
"GPRINT:calls:MAX:Mx\: %2.0lf/min\\n");
|
||||
if($width <= "300") {$optsb = array("--font", "LEGEND:7:".$config['mono_font']."",
|
||||
"--font", "AXIS:6:".$config['mono_font']."",
|
||||
"--font-render-mode", "normal");}
|
||||
|
||||
$opts = array_merge($config['rrdgraph_defaults'], $optsa, $optsb);
|
||||
$opts = array_merge($config['rrdgraph_defaults'], $optsa, $optsb);
|
||||
|
||||
$ret = rrd_graph("$imgfile", $opts, count($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;
|
||||
}
|
||||
if( !is_array($ret) ) {
|
||||
$err = rrd_error();
|
||||
echo("rrd_graph() ERROR: $err\n");
|
||||
return FALSE;
|
||||
} else {
|
||||
return $imgfile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
166
poll-billing.php
166
poll-billing.php
@@ -14,106 +14,106 @@ echo("Starting Polling Session ... \n\n");
|
||||
$bill_query = mysql_query("select * from bills");
|
||||
while ($bill_data = mysql_fetch_array($bill_query))
|
||||
{
|
||||
echo("Bill : ".$bill_data['bill_name']."\n");
|
||||
CollectData($bill_data['bill_id']);
|
||||
$iter++;
|
||||
echo("Bill : ".$bill_data['bill_name']."\n");
|
||||
CollectData($bill_data['bill_id']);
|
||||
$iter++;
|
||||
}
|
||||
|
||||
function CollectData($bill_id)
|
||||
{
|
||||
$port_query = mysql_query("select * from bill_ports as P, ports as I, devices as D where P.bill_id='$bill_id' AND I.interface_id = P.port_id AND D.device_id = I.device_id");
|
||||
$port_query = mysql_query("select * from bill_ports as P, ports as I, devices as D where P.bill_id='$bill_id' AND I.interface_id = P.port_id AND D.device_id = I.device_id");
|
||||
|
||||
while ($port_data = mysql_fetch_array($port_query))
|
||||
{
|
||||
unset($port_in_measurement);
|
||||
unset($port_in_delta);
|
||||
unset($last_port_in_measurement);
|
||||
unset($last_port_in_delta);
|
||||
unset($port_out_measurement);
|
||||
unset($port_out_delta);
|
||||
unset($last_port_out_measurement);
|
||||
unset($last_port_out_delta);
|
||||
while ($port_data = mysql_fetch_array($port_query))
|
||||
{
|
||||
unset($port_in_measurement);
|
||||
unset($port_in_delta);
|
||||
unset($last_port_in_measurement);
|
||||
unset($last_port_in_delta);
|
||||
unset($port_out_measurement);
|
||||
unset($port_out_delta);
|
||||
unset($last_port_out_measurement);
|
||||
unset($last_port_out_delta);
|
||||
|
||||
$port_id = $port_data['port_id'];
|
||||
$host = $port_data['hostname'];
|
||||
$port = $port_data['port'];
|
||||
$port_id = $port_data['port_id'];
|
||||
$host = $port_data['hostname'];
|
||||
$port = $port_data['port'];
|
||||
|
||||
echo("\nPolling ".$port_data['ifDescr']." on ".$port_data['hostname']."\n");
|
||||
echo("\nPolling ".$port_data['ifDescr']." on ".$port_data['hostname']."\n");
|
||||
|
||||
$port_in_measurement = getValue($host, $port, $port_data['ifIndex'], "In");
|
||||
$port_out_measurement = getValue($host, $port, $port_data['ifIndex'], "Out");
|
||||
$port_in_measurement = getValue($host, $port, $port_data['ifIndex'], "In");
|
||||
$port_out_measurement = getValue($host, $port, $port_data['ifIndex'], "Out");
|
||||
|
||||
$now = mysql_result(mysql_query("SELECT NOW()"), 0);
|
||||
|
||||
$last_data = getLastPortCounter($port_id,in);
|
||||
if ($last_data[state] == "ok")
|
||||
{
|
||||
$last_port_in_measurement = $last_data[counter];
|
||||
$last_port_in_delta = $last_data[delta];
|
||||
if ($port_in_measurement > $last_port_in_measurement)
|
||||
{
|
||||
$port_in_delta = $port_in_measurement - $last_port_in_measurement;
|
||||
} else {
|
||||
$port_in_delta = $last_port_in_delta;
|
||||
}
|
||||
} else {
|
||||
$port_in_delta = '0';
|
||||
}
|
||||
$pim = "INSERT INTO port_in_measurements (port_id,timestamp,counter,delta) VALUES ($port_id, '$now', $port_in_measurement, $port_in_delta) ";
|
||||
#echo("$pim \n");
|
||||
$pim_query = mysql_query($pim);
|
||||
unset($last_data, $last_port_in_measurement, $last_port_in_delta);
|
||||
|
||||
$last_data = getLastPortCounter($port_id,out);
|
||||
if ($last_data[state] == "ok")
|
||||
{
|
||||
$last_port_out_measurement = $last_data[counter];
|
||||
$last_port_out_delta = $last_data[delta];
|
||||
if ($port_out_measurement > $last_port_out_measurement)
|
||||
{
|
||||
$port_out_delta = $port_out_measurement - $last_port_out_measurement;
|
||||
} else {
|
||||
$port_out_delta = $last_port_out_delta;
|
||||
}
|
||||
} else {
|
||||
$port_out_delta = '0';
|
||||
}
|
||||
$pom = "INSERT INTO port_out_measurements (port_id,timestamp,counter,delta) VALUES ($port_id, '$now', $port_out_measurement, $port_out_delta) ";
|
||||
#echo("$pom \n");
|
||||
$pom_query = mysql_query($pom);
|
||||
unset($last_data, $last_port_in_measurement, $last_port_in_delta);
|
||||
|
||||
$delta = $delta + $port_in_delta + $port_out_delta;
|
||||
$in_delta = $in_delta + $port_in_delta;
|
||||
$out_delta = $out_delta + $port_out_delta;
|
||||
unset($port_in_delta,$port_out_delta,$prev_delta,$prev_timestamp,$period);
|
||||
|
||||
}
|
||||
$last_data = getLastMeasurement($bill_id);
|
||||
$now = mysql_result(mysql_query("SELECT NOW()"), 0);
|
||||
|
||||
$last_data = getLastPortCounter($port_id,in);
|
||||
if ($last_data[state] == "ok")
|
||||
{
|
||||
$prev_delta = $last_data[delta];
|
||||
$prev_in_delta = $last_data[in_delta];
|
||||
$prev_out_delta = $last_data[out_delta];
|
||||
$prev_timestamp = $last_data[timestamp];
|
||||
$period = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - UNIX_TIMESTAMP('$prev_timestamp')"),0);
|
||||
$last_port_in_measurement = $last_data[counter];
|
||||
$last_port_in_delta = $last_data[delta];
|
||||
if ($port_in_measurement > $last_port_in_measurement)
|
||||
{
|
||||
$port_in_delta = $port_in_measurement - $last_port_in_measurement;
|
||||
} else {
|
||||
$port_in_delta = $last_port_in_delta;
|
||||
}
|
||||
} else {
|
||||
$prev_delta = '0';
|
||||
$period = '0';
|
||||
$prev_in_delta = '0';
|
||||
$prev_out_delta = '0';
|
||||
$port_in_delta = '0';
|
||||
}
|
||||
$pim = "INSERT INTO port_in_measurements (port_id,timestamp,counter,delta) VALUES ($port_id, '$now', $port_in_measurement, $port_in_delta) ";
|
||||
#echo("$pim \n");
|
||||
$pim_query = mysql_query($pim);
|
||||
unset($last_data, $last_port_in_measurement, $last_port_in_delta);
|
||||
|
||||
if ($delta < '0' )
|
||||
$last_data = getLastPortCounter($port_id,out);
|
||||
if ($last_data[state] == "ok")
|
||||
{
|
||||
$delta = $prev_delta;
|
||||
$in_delta = $prev_in_delta;
|
||||
$out_delta = $prev_out_delta;
|
||||
|
||||
$last_port_out_measurement = $last_data[counter];
|
||||
$last_port_out_delta = $last_data[delta];
|
||||
if ($port_out_measurement > $last_port_out_measurement)
|
||||
{
|
||||
$port_out_delta = $port_out_measurement - $last_port_out_measurement;
|
||||
} else {
|
||||
$port_out_delta = $last_port_out_delta;
|
||||
}
|
||||
} else {
|
||||
$port_out_delta = '0';
|
||||
}
|
||||
$insert_string = "INSERT INTO bill_data (bill_id,timestamp,period,delta,in_delta,out_delta) VALUES ('$bill_id','$now','$period','$delta','$in_delta','$out_delta')";
|
||||
$insert_measurement = mysql_query($insert_string);
|
||||
$pom = "INSERT INTO port_out_measurements (port_id,timestamp,counter,delta) VALUES ($port_id, '$now', $port_out_measurement, $port_out_delta) ";
|
||||
#echo("$pom \n");
|
||||
$pom_query = mysql_query($pom);
|
||||
unset($last_data, $last_port_in_measurement, $last_port_in_delta);
|
||||
|
||||
$delta = $delta + $port_in_delta + $port_out_delta;
|
||||
$in_delta = $in_delta + $port_in_delta;
|
||||
$out_delta = $out_delta + $port_out_delta;
|
||||
unset($port_in_delta,$port_out_delta,$prev_delta,$prev_timestamp,$period);
|
||||
|
||||
}
|
||||
$last_data = getLastMeasurement($bill_id);
|
||||
|
||||
if ($last_data[state] == "ok")
|
||||
{
|
||||
$prev_delta = $last_data[delta];
|
||||
$prev_in_delta = $last_data[in_delta];
|
||||
$prev_out_delta = $last_data[out_delta];
|
||||
$prev_timestamp = $last_data[timestamp];
|
||||
$period = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - UNIX_TIMESTAMP('$prev_timestamp')"),0);
|
||||
} else {
|
||||
$prev_delta = '0';
|
||||
$period = '0';
|
||||
$prev_in_delta = '0';
|
||||
$prev_out_delta = '0';
|
||||
}
|
||||
|
||||
if ($delta < '0' )
|
||||
{
|
||||
$delta = $prev_delta;
|
||||
$in_delta = $prev_in_delta;
|
||||
$out_delta = $prev_out_delta;
|
||||
|
||||
}
|
||||
$insert_string = "INSERT INTO bill_data (bill_id,timestamp,period,delta,in_delta,out_delta) VALUES ('$bill_id','$now','$period','$delta','$in_delta','$out_delta')";
|
||||
$insert_measurement = mysql_query($insert_string);
|
||||
}
|
||||
|
||||
if ($argv[1]) { CollectData($argv[1]); }
|
||||
|
Reference in New Issue
Block a user