mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
cleanups
git-svn-id: http://www.observium.org/svn/observer/trunk@327 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -18,6 +18,8 @@ RewriteRule ^devices/(.+)/ ?page=devices&type=$1
|
|||||||
RewriteRule ^interfaces/(.+)/ ?page=interfaces&type=$1
|
RewriteRule ^interfaces/(.+)/ ?page=interfaces&type=$1
|
||||||
|
|
||||||
RewriteRule ^bill/([0-9]+) ?page=bills&bill=$1
|
RewriteRule ^bill/([0-9]+) ?page=bills&bill=$1
|
||||||
|
|
||||||
|
RewriteRule ^device/([0-9]+)/([a-z]+)/ ?page=device&id=$1§ion=$2
|
||||||
RewriteRule ^device/([0-9]+) ?page=device&id=$1
|
RewriteRule ^device/([0-9]+) ?page=device&id=$1
|
||||||
|
|
||||||
RewriteRule ^([a-z]+)/$ ?page=$1
|
RewriteRule ^([a-z]+)/$ ?page=$1
|
||||||
|
|||||||
@@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
|
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
|
||||||
|
|
||||||
$hostname = gethostbyid($entry['host']);
|
|
||||||
$interface = fixifname(getifbyid($entry['interface']));
|
|
||||||
|
|
||||||
unset($icon);
|
unset($icon);
|
||||||
|
|
||||||
$icon = geteventicon($entry['message']);
|
$icon = geteventicon($entry['message']);
|
||||||
@@ -17,10 +14,11 @@ if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
|
|||||||
<td class=syslog width=140>
|
<td class=syslog width=140>
|
||||||
".$entry['humandate']."
|
".$entry['humandate']."
|
||||||
</td>");
|
</td>");
|
||||||
$if['interface_id'] = $entry['interface'];
|
|
||||||
$if['ifDescr'] = makeshortif($interface);
|
$if = mysql_fetch_array(mysql_query("SELECT * from interfaces AS I, devices as D where I.device_id = D.device_id AND I.interface_id = '".$entry['interface']."'"));
|
||||||
|
|
||||||
echo("<td class=list-bold width=75>
|
echo("<td class=list-bold width=75>
|
||||||
" . generateiflink($if) . "
|
" . generateiflink($if, makeshortif($if['ifDescr'])) . "
|
||||||
</td>
|
</td>
|
||||||
<td class=syslog>" .
|
<td class=syslog>" .
|
||||||
htmlspecialchars(truncate($entry['message'], 45))
|
htmlspecialchars(truncate($entry['message'], 45))
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ if(devicepermitted($_GET['id'])) {
|
|||||||
$selected['iface'] = "selected";
|
$selected['iface'] = "selected";
|
||||||
|
|
||||||
if(!$_GET['section']) {
|
if(!$_GET['section']) {
|
||||||
$_GET['section'] = "dev-overview";
|
$_GET['section'] = "overview";
|
||||||
}
|
}
|
||||||
$section = mres($_GET['section']);
|
$section = mres($_GET['section']);
|
||||||
$section = str_replace(".", "", $section);
|
$section = str_replace(".", "", $section);
|
||||||
@@ -24,16 +24,16 @@ echo("<div class=mainpane>");
|
|||||||
|
|
||||||
echo("
|
echo("
|
||||||
<ul id='maintab' class='shadetabs'>
|
<ul id='maintab' class='shadetabs'>
|
||||||
<li class=" . $select['dev-overview'] . ">
|
<li class=" . $select['overview'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-overview' >
|
<a href='/device/" . $device['device_id'] . "/overview/'>
|
||||||
<img src='images/16/server_lightning.png' align=absmiddle border=0> Overview
|
<img src='images/16/server_lightning.png' align=absmiddle border=0> Overview
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
|
|
||||||
if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-vlans'] . ">
|
<li class=" . $select['vlans'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-vlans' >
|
<a href='/device/" . $device['device_id'] . "/vlans/'>
|
||||||
<img src='images/16/vlans.png' align=absmiddle border=0> VLANs
|
<img src='images/16/vlans.png' align=absmiddle border=0> VLANs
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
@@ -41,8 +41,8 @@ if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id =
|
|||||||
|
|
||||||
if(@mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(@mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-vrfs'] . ">
|
<li class=" . $select['vrfs'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-vrfs' >
|
<a href='/device/" . $device['device_id'] . "/vrfs/'>
|
||||||
<img src='images/16/layers.png' align=absmiddle border=0> VRFs
|
<img src='images/16/layers.png' align=absmiddle border=0> VRFs
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
@@ -51,8 +51,8 @@ if(@mysql_result(mysql_query("select count(*) from vrfs WHERE device_id = '" . $
|
|||||||
|
|
||||||
if($config['enable_bgp'] && $device['bgpLocalAs']) {
|
if($config['enable_bgp'] && $device['bgpLocalAs']) {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-bgp'] . ">
|
<li class=" . $select['bgp'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-bgp' >
|
<a href='/device/" . $device['device_id'] . "/bgp/'>
|
||||||
<img src='images/16/link.png' align=absmiddle border=0> BGP
|
<img src='images/16/link.png' align=absmiddle border=0> BGP
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
@@ -60,20 +60,20 @@ if($config['enable_bgp'] && $device['bgpLocalAs']) {
|
|||||||
|
|
||||||
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-ifs'] . ">
|
<li class=" . $select['ifs'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-ifs' >
|
<a href='/device/" . $device['device_id'] . "/ifs/'>
|
||||||
<img src='images/16/server_link.png' align=absmiddle border=0> Ports
|
<img src='images/16/server_link.png' align=absmiddle border=0> Ports
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class=" . $select['dev-ifgraphs'] . ">
|
<li class=" . $select['ifgraphs'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-ifgraphs'>
|
<a href='/device/" . $device['device_id'] . "/ifgraphs/'>
|
||||||
<img src='images/16/chart_curve_link.png' align=absmiddle border=0> Port Graphs
|
<img src='images/16/chart_curve_link.png' align=absmiddle border=0> Port Graphs
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo("<li class=" . $select['dev-graphs'] . ">
|
echo("<li class=" . $select['graphs'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-graphs'>
|
<a href='/device/" . $device['device_id'] . "/graphs/'>
|
||||||
<img src='images/16/server_chart.png' align=absmiddle border=0> Host Graphs
|
<img src='images/16/server_chart.png' align=absmiddle border=0> Host Graphs
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -81,8 +81,8 @@ echo("<li class=" . $select['dev-graphs'] . ">
|
|||||||
|
|
||||||
if(@mysql_result(mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$_GET['id']."'"), 0) > '0') {
|
if(@mysql_result(mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$_GET['id']."'"), 0) > '0') {
|
||||||
|
|
||||||
echo("<li class=" . $select['dev-entphysical'] . ">
|
echo("<li class=" . $select['entphysical'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-entphysical'>
|
<a href='/device/" . $device['device_id'] . "/entphysical/'>
|
||||||
<img src='images/16/bricks.png' align=absmiddle border=0> Inventory
|
<img src='images/16/bricks.png' align=absmiddle border=0> Inventory
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -93,8 +93,8 @@ if(@mysql_result(mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$
|
|||||||
|
|
||||||
if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-temp'] . ">
|
<li class=" . $select['temp'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-temp'>
|
<a href='/device/" . $device['device_id'] . "/temp/'>
|
||||||
<img src='images/16/weather_sun.png' align=absmiddle border=0> Temps
|
<img src='images/16/weather_sun.png' align=absmiddle border=0> Temps
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -103,8 +103,8 @@ if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_h
|
|||||||
|
|
||||||
if(mysql_result(mysql_query("select count(storage_id) from storage WHERE host_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(mysql_result(mysql_query("select count(storage_id) from storage WHERE host_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-storage'] . ">
|
<li class=" . $select['storage'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-storage'>
|
<a href='/device/" . $device['device_id'] . "/storage/'>
|
||||||
<img src='images/16/database.png' align=absmiddle border=0> Storage
|
<img src='images/16/database.png' align=absmiddle border=0> Storage
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -114,8 +114,8 @@ if(mysql_result(mysql_query("select count(storage_id) from storage WHERE host_id
|
|||||||
|
|
||||||
if(mysql_result(mysql_query("select count(service_id) from services WHERE service_host = '" . $device['device_id'] . "'"), 0) > '0') {
|
if(mysql_result(mysql_query("select count(service_id) from services WHERE service_host = '" . $device['device_id'] . "'"), 0) > '0') {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-srv'] . ">
|
<li class=" . $select['srv'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-srv'>
|
<a href='/device/" . $device['device_id'] . "/srv/'>
|
||||||
<img src='images/16/server_cog.png' align=absmiddle border=0> Services
|
<img src='images/16/server_cog.png' align=absmiddle border=0> Services
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -123,15 +123,15 @@ if(mysql_result(mysql_query("select count(service_id) from services WHERE servic
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-events'] . ">
|
<li class=" . $select['events'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-events'>
|
<a href='/device/" . $device['device_id'] . "/events/'>
|
||||||
<img src='images/16/report_magnify.png' align=absmiddle border=0> Events
|
<img src='images/16/report_magnify.png' align=absmiddle border=0> Events
|
||||||
</a>
|
</a>
|
||||||
</li>");
|
</li>");
|
||||||
|
|
||||||
if($config['enable_syslog']) { echo("
|
if($config['enable_syslog']) { echo("
|
||||||
<li class=" . $select['dev-syslog'] . ">
|
<li class=" . $select['syslog'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-syslog'>
|
<a href='/device/" . $device['device_id'] . "/syslog/'>
|
||||||
<img src='images/16/printer.png' align=absmiddle border=0> Syslog
|
<img src='images/16/printer.png' align=absmiddle border=0> Syslog
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -139,8 +139,8 @@ if($config['enable_syslog']) { echo("
|
|||||||
|
|
||||||
if($_SESSION[userlevel] >= "5") {
|
if($_SESSION[userlevel] >= "5") {
|
||||||
echo("
|
echo("
|
||||||
<li class=" . $select['dev-edit'] . ">
|
<li class=" . $select['edit'] . ">
|
||||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-edit'>
|
<a href='/device/" . $device['device_id'] . "/edit/'>
|
||||||
<img src='images/16/server_edit.png' align=absmiddle border=0> Settings
|
<img src='images/16/server_edit.png' align=absmiddle border=0> Settings
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -152,7 +152,7 @@ echo("</ul>");
|
|||||||
echo("
|
echo("
|
||||||
<div class=contentstyle>");
|
<div class=contentstyle>");
|
||||||
|
|
||||||
include("pages/device/$section.inc");
|
include("pages/device/".mres($section).".inc.php");
|
||||||
|
|
||||||
echo("</div>
|
echo("</div>
|
||||||
");
|
");
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
$ifDescr = trim(str_replace("\"", "", $ifDescr));
|
$ifDescr = trim(str_replace("\"", "", $ifDescr));
|
||||||
} else { $ifDescr = trim(str_replace("\"", "", $ifName)); }
|
} else { $ifDescr = trim(str_replace("\"", "", $ifName)); }
|
||||||
|
|
||||||
|
|
||||||
if(!strstr($entry, "irtual")) {
|
if(!strstr($entry, "irtual")) {
|
||||||
$if = trim(strtolower($ifDescr));
|
$if = trim(strtolower($ifDescr));
|
||||||
$nullintf = 0;
|
$nullintf = 0;
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
$nullintf = 1;
|
$nullintf = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ifDescr = fixifName($ifDescr);
|
||||||
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = '1'; }
|
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = '1'; }
|
||||||
if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = '1'; }
|
if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = '1'; }
|
||||||
if ($nullintf == 0) {
|
if ($nullintf == 0) {
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ include_once($config['install_dir'] . "/includes/print-functions.php");
|
|||||||
include_once($config['install_dir'] . "/includes/billing.php");
|
include_once($config['install_dir'] . "/includes/billing.php");
|
||||||
include_once($config['install_dir'] . "/includes/cisco-entities.php");
|
include_once($config['install_dir'] . "/includes/cisco-entities.php");
|
||||||
include_once($config['install_dir'] . "/includes/syslog.php");
|
include_once($config['install_dir'] . "/includes/syslog.php");
|
||||||
|
include_once($config['install_dir'] . "/includes/rewrites.php");
|
||||||
|
|
||||||
function mres($string) {
|
|
||||||
// short function wrapper because the real one is stupidly long and ugly. aestetics.
|
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 validate_hostip($host) {
|
function validate_hostip($host) {
|
||||||
@@ -37,7 +38,6 @@ function write_dev_attrib($device_id, $attrib_type, $attrib_value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shorthost($hostname, $len=16) {
|
function shorthost($hostname, $len=16) {
|
||||||
|
|
||||||
list ($first, $second, $third, $fourth, $fifth) = explode(".", $hostname);
|
list ($first, $second, $third, $fourth, $fifth) = explode(".", $hostname);
|
||||||
$shorthost = $first;
|
$shorthost = $first;
|
||||||
if(strlen($first.".".$second) < $len && $second) {
|
if(strlen($first.".".$second) < $len && $second) {
|
||||||
@@ -52,9 +52,7 @@ function shorthost($hostname, $len=16) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($shorthost);
|
return ($shorthost);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function rrdtool_update($rrdfile, $rrdupdate) {
|
function rrdtool_update($rrdfile, $rrdupdate) {
|
||||||
@@ -86,14 +84,11 @@ function strgen ($length = 16)
|
|||||||
'E','f','F','g','G','h','H','i','I','j','J','k','K','l','L','m','M','n',
|
'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',
|
'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');
|
'W','x','X','y','Y','z','Z');
|
||||||
|
|
||||||
$string = "";
|
$string = "";
|
||||||
|
|
||||||
for ($i=0; $i<$length; $i++) {
|
for ($i=0; $i<$length; $i++) {
|
||||||
$key = mt_rand(0,61);
|
$key = mt_rand(0,61);
|
||||||
$string .= $entropy[$key];
|
$string .= $entropy[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,14 +152,16 @@ function format_si($rate)
|
|||||||
return round($rate, $round[$i]).$ext;
|
return round($rate, $round[$i]).$ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_bi($size) {
|
function format_bi($size)
|
||||||
|
{
|
||||||
$sizes = Array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei');
|
$sizes = Array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei');
|
||||||
$ext = $sizes[0];
|
$ext = $sizes[0];
|
||||||
for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; }
|
for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; }
|
||||||
return round($size, 2).$ext;
|
return round($size, 2).$ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
function arguments($argv) {
|
function arguments($argv)
|
||||||
|
{
|
||||||
$_ARG = array();
|
$_ARG = array();
|
||||||
foreach ($argv as $arg) {
|
foreach ($argv as $arg) {
|
||||||
if (ereg('--([^=]+)=(.*)',$arg,$reg)) {
|
if (ereg('--([^=]+)=(.*)',$arg,$reg)) {
|
||||||
@@ -185,7 +182,8 @@ function percent_colour($perc)
|
|||||||
return sprintf('#%02x%02x%02x', $r, $b, $b);
|
return sprintf('#%02x%02x%02x', $r, $b, $b);
|
||||||
}
|
}
|
||||||
|
|
||||||
function percent_colour_old($perc) {
|
function percent_colour_old($perc)
|
||||||
|
{
|
||||||
$red = round(5 * $perc);
|
$red = round(5 * $perc);
|
||||||
$blue = round(255 - (5 * $perc));
|
$blue = round(255 - (5 * $perc));
|
||||||
if($red > '255') { $red = "255"; }
|
if($red > '255') { $red = "255"; }
|
||||||
@@ -198,22 +196,26 @@ function percent_colour_old($perc) {
|
|||||||
return $colour;
|
return $colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_error($text){
|
function print_error($text)
|
||||||
|
{
|
||||||
echo("<table class=errorbox cellpadding=3><tr><td><img src='/images/15/exclamation.png' align=absmiddle> $text</td></tr></table>");
|
echo("<table class=errorbox cellpadding=3><tr><td><img src='/images/15/exclamation.png' align=absmiddle> $text</td></tr></table>");
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_message($text){
|
function print_message($text)
|
||||||
|
{
|
||||||
echo("<table class=messagebox cellpadding=3><tr><td><img src='/images/16/tick.png' align=absmiddle> $text</td></tr></table>");
|
echo("<table class=messagebox cellpadding=3><tr><td><img src='/images/16/tick.png' align=absmiddle> $text</td></tr></table>");
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate($substring, $max = 50, $rep = '...') {
|
function truncate($substring, $max = 50, $rep = '...')
|
||||||
|
{
|
||||||
if(strlen($substring) < 1){ $string = $rep; } else { $string = $substring; }
|
if(strlen($substring) < 1){ $string = $rep; } else { $string = $substring; }
|
||||||
$leave = $max - strlen ($rep);
|
$leave = $max - strlen ($rep);
|
||||||
if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; }
|
if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function interface_rates ($interface) {
|
function interface_rates ($interface)
|
||||||
|
{
|
||||||
global $config, $rrd_dir;
|
global $config, $rrd_dir;
|
||||||
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||||
$cmd = $config['rrdtool']." fetch -s -600s -e now ".$rrdfile." AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e";
|
$cmd = $config['rrdtool']." fetch -s -600s -e now ".$rrdfile." AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e";
|
||||||
@@ -227,7 +229,8 @@ function interface_rates ($interface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function interface_errors ($interface) {
|
function interface_errors ($interface)
|
||||||
|
{
|
||||||
global $config, $rrd_dir;
|
global $config, $rrd_dir;
|
||||||
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
$rrdfile = $rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd";
|
||||||
$cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d\" \" -f 4,5";
|
$cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d\" \" -f 4,5";
|
||||||
@@ -243,7 +246,8 @@ function interface_errors ($interface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function geteventicon ($message) {
|
function geteventicon ($message)
|
||||||
|
{
|
||||||
if($message == "Device status changed to Down") { $icon = "server_connect.png"; }
|
if($message == "Device status changed to Down") { $icon = "server_connect.png"; }
|
||||||
if($message == "Device status changed to Up") { $icon = "server_go.png"; }
|
if($message == "Device status changed to Up") { $icon = "server_go.png"; }
|
||||||
if($message == "Interface went down" || $message == "Interface changed state to Down" ) { $icon = "if-disconnect.png"; }
|
if($message == "Interface went down" || $message == "Interface changed state to Down" ) { $icon = "if-disconnect.png"; }
|
||||||
@@ -253,19 +257,21 @@ function geteventicon ($message) {
|
|||||||
if($icon) { return $icon; } else { return false; }
|
if($icon) { return $icon; } else { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateiflink($interface, $text=0,$type=bits) {
|
function generateiflink($interface, $text=0,$type=bits)
|
||||||
|
{
|
||||||
global $twoday; global $now; global $config; global $day;
|
global $twoday; global $now; global $config; global $day;
|
||||||
if(!$text) { $text = fixIfName($interface['ifDescr']); }
|
if(!$text) { $text = fixIfName($interface['ifDescr']); }
|
||||||
if(!$type) { $type = 'bits'; }
|
if(!$type) { $type = 'bits'; }
|
||||||
$class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
|
$class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
|
||||||
$graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=120&type=" . $type;
|
$graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=120&type=" . $type;
|
||||||
$link = "<a class=$class href='?page=interface&id=" . $interface['interface_id'] . "' ";
|
$link = "<a class=$class href='?page=interface&id=" . $interface['interface_id'] . "' ";
|
||||||
$link .= "onmouseover=\"return overlib('<div class=list-large>" . $interface['hostname'] . " - " . $interface['ifDescr'] . "</div><div>";
|
$link .= "onmouseover=\"return overlib('<div class=list-large>" . $interface['hostname'] . " - " . fixifName($interface['ifDescr']) . "</div><div>";
|
||||||
$link .= $interface['ifAlias'] . "</div><img src=\'$graph_url\'>'".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">$text</a>";
|
$link .= $interface['ifAlias'] . "</div><img src=\'$graph_url\'>'".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">$text</a>";
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generatedevicelink($device, $text=0, $start=0, $end=0) {
|
function generatedevicelink($device, $text=0, $start=0, $end=0)
|
||||||
|
{
|
||||||
global $twoday; global $day; global $now; global $config;
|
global $twoday; global $day; global $now; global $config;
|
||||||
if(!$start) { $start = $day; }
|
if(!$start) { $start = $day; }
|
||||||
if(!$end) { $end = $now; }
|
if(!$end) { $end = $now; }
|
||||||
@@ -279,7 +285,8 @@ function generatedevicelink($device, $text=0, $start=0, $end=0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function device_traffic_image($device, $width, $height, $from, $to) {
|
function device_traffic_image($device, $width, $height, $from, $to)
|
||||||
|
{
|
||||||
return "<img src='graph.php?device=" . $device . "&type=device_bits&from=" . $from . "&to=" . $to . "&width=" . $width . "&height=" . $height . "' />";
|
return "<img src='graph.php?device=" . $device . "&type=device_bits&from=" . $from . "&to=" . $to . "&width=" . $width . "&height=" . $height . "' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +300,8 @@ function devclass($device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getImage($host) {
|
function getImage($host)
|
||||||
|
{
|
||||||
$sql = "SELECT * FROM `devices` WHERE `device_id` = '$host'";
|
$sql = "SELECT * FROM `devices` WHERE `device_id` = '$host'";
|
||||||
$data = mysql_fetch_array(mysql_query($sql));
|
$data = mysql_fetch_array(mysql_query($sql));
|
||||||
$type = strtolower($data['os']);
|
$type = strtolower($data['os']);
|
||||||
@@ -310,7 +318,8 @@ $type = strtolower($data['os']);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function renamehost($id, $new) {
|
function renamehost($id, $new)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
|
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
|
||||||
shell_exec("mv ".$config['rrd_dir']."/$host ".$config['rrd_dir']."/$new");
|
shell_exec("mv ".$config['rrd_dir']."/$host ".$config['rrd_dir']."/$new");
|
||||||
@@ -318,7 +327,8 @@ function renamehost($id, $new) {
|
|||||||
mysql_query("INSERT INTO eventlog (host, datetime, message) VALUES ('" . $id . "', NULL, NOW(), 'Hostname changed -> $new (console)')");
|
mysql_query("INSERT INTO eventlog (host, datetime, message) VALUES ('" . $id . "', NULL, NOW(), 'Hostname changed -> $new (console)')");
|
||||||
}
|
}
|
||||||
|
|
||||||
function delHost($id) {
|
function delHost($id)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
|
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
|
||||||
mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'");
|
||||||
@@ -348,7 +358,8 @@ function delHost($id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function addHost($host, $community, $snmpver) {
|
function addHost($host, $community, $snmpver)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
list($hostshort) = explode(".", $host);
|
list($hostshort) = explode(".", $host);
|
||||||
if ( isDomainResolves($host)){
|
if ( isDomainResolves($host)){
|
||||||
@@ -367,7 +378,8 @@ function overlibprint($text) {
|
|||||||
return "onmouseover=\"return overlib('" . $text . "');\" onmouseout=\"return nd();\"";
|
return "onmouseover=\"return overlib('" . $text . "');\" onmouseout=\"return nd();\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
function scanUDP ($host, $port, $timeout) {
|
function scanUDP ($host, $port, $timeout)
|
||||||
|
{
|
||||||
$handle = fsockopen($host, $port, &$errno, &$errstr, 2);
|
$handle = fsockopen($host, $port, &$errno, &$errstr, 2);
|
||||||
if (!$handle) {
|
if (!$handle) {
|
||||||
}
|
}
|
||||||
@@ -389,23 +401,9 @@ function scanUDP ($host, $port, $timeout) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function humanmedia($media) {
|
function humanmedia($media)
|
||||||
$media = preg_replace("/^ethernetCsmacd$/", "Ethernet", $media);
|
{
|
||||||
$media = preg_replace("/^softwareLoopback$/", "Loopback", $media);
|
array_preg_replace($rewrite_iftype, $media);
|
||||||
$media = preg_replace("/^tunnel$/", "Tunnel", $media);
|
|
||||||
$media = preg_replace("/^propVirtual$/", "Virtual Int", $media);
|
|
||||||
$media = preg_replace("/^ppp$/", "PPP", $media);
|
|
||||||
$media = preg_replace("/^ds1$/", "DS1", $media);
|
|
||||||
$media = preg_replace("/^pos$/", "POS", $media);
|
|
||||||
$media = preg_replace("/^sonet$/", "SONET", $media);
|
|
||||||
$media = preg_replace("/^slip$/", "SLIP", $media);
|
|
||||||
$media = preg_replace("/^mpls$/", "MPLS Layer", $media);
|
|
||||||
$media = preg_replace("/^l2vlan$/", "VLAN Subif", $media);
|
|
||||||
$media = preg_replace("/^atm$/", "ATM", $media);
|
|
||||||
$media = preg_replace("/^aal5$/", "ATM AAL5", $media);
|
|
||||||
$media = preg_replace("/^atmSubInterface$/", "ATM Subif", $media);
|
|
||||||
$media = preg_replace("/^propPointToPointSerial$/", "PtP Serial", $media);
|
|
||||||
|
|
||||||
return $media;
|
return $media;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,17 +438,20 @@ function humanspeed($speed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function netmask2cidr($netmask) {
|
function netmask2cidr($netmask)
|
||||||
|
{
|
||||||
list ($network, $cidr) = explode("/", trim(`ipcalc $address/$mask | grep Network | cut -d" " -f 4`));
|
list ($network, $cidr) = explode("/", trim(`ipcalc $address/$mask | grep Network | cut -d" " -f 4`));
|
||||||
return $cidr;
|
return $cidr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cidr2netmask() {
|
function cidr2netmask()
|
||||||
|
{
|
||||||
return (long2ip(ip2long("255.255.255.255")
|
return (long2ip(ip2long("255.255.255.255")
|
||||||
<< (32-$netmask)));
|
<< (32-$netmask)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatUptime($diff, $format="long") {
|
function formatUptime($diff, $format="long")
|
||||||
|
{
|
||||||
$yearsDiff = floor($diff/31536000);
|
$yearsDiff = floor($diff/31536000);
|
||||||
$diff -= $yearsDiff*31536000;
|
$diff -= $yearsDiff*31536000;
|
||||||
$daysDiff = floor($diff/86400);
|
$daysDiff = floor($diff/86400);
|
||||||
@@ -476,7 +477,8 @@ function formatUptime($diff, $format="long") {
|
|||||||
return "$uptime";
|
return "$uptime";
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSNMPable($hostname, $community, $snmpver) {
|
function isSNMPable($hostname, $community, $snmpver)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$pos = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname sysDescr.0");
|
$pos = shell_exec($config['snmpget'] ." -$snmpver -c $community -t 1 $hostname sysDescr.0");
|
||||||
if($pos == '') {
|
if($pos == '') {
|
||||||
@@ -489,7 +491,8 @@ function isSNMPable($hostname, $community, $snmpver) {
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPingable($hostname) {
|
function isPingable($hostname)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$status = shell_exec($config['fping'] . " $hostname");
|
$status = shell_exec($config['fping'] . " $hostname");
|
||||||
if(strstr($status, "alive")) {
|
if(strstr($status, "alive")) {
|
||||||
@@ -500,11 +503,13 @@ function isPingable($hostname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function is_odd($number) {
|
function is_odd($number)
|
||||||
|
{
|
||||||
return $number & 1; // 0 = even, 1 = odd
|
return $number & 1; // 0 = even, 1 = odd
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidInterface($if) {
|
function isValidInterface($if)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$if = strtolower($if);
|
$if = strtolower($if);
|
||||||
$nullintf = 0;
|
$nullintf = 0;
|
||||||
@@ -521,7 +526,8 @@ function isValidInterface($if) {
|
|||||||
} else { return 0; }
|
} else { return 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function ifclass($ifOperStatus, $ifAdminStatus) {
|
function ifclass($ifOperStatus, $ifAdminStatus)
|
||||||
|
{
|
||||||
$ifclass = "interface-upup";
|
$ifclass = "interface-upup";
|
||||||
if ($ifAdminStatus == "down") { $ifclass = "interface-admindown"; }
|
if ($ifAdminStatus == "down") { $ifclass = "interface-admindown"; }
|
||||||
if ($ifAdminStatus == "up" && $ifOperStatus== "down") { $ifclass = "interface-updown"; }
|
if ($ifAdminStatus == "up" && $ifOperStatus== "down") { $ifclass = "interface-updown"; }
|
||||||
@@ -529,68 +535,16 @@ function ifclass($ifOperStatus, $ifAdminStatus) {
|
|||||||
return $ifclass;
|
return $ifclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeshortif($if) {
|
function utime()
|
||||||
$if = strtolower($if);
|
{
|
||||||
$if = str_replace("tengigabitethernet","Te", $if);
|
|
||||||
$if = str_replace("gigabitethernet","Gi", $if);
|
|
||||||
$if = str_replace("fastethernet","Fa", $if);
|
|
||||||
$if = str_replace("ethernet","Et", $if);
|
|
||||||
$if = str_replace("serial","Se", $if);
|
|
||||||
$if = str_replace("pos","Pos", $if);
|
|
||||||
$if = str_replace("port-channel","Po", $if);
|
|
||||||
$if = str_replace("atm","Atm", $if);
|
|
||||||
$if = str_replace("null", "Null", $if);
|
|
||||||
$if = str_replace("loopback","Lo", $if);
|
|
||||||
$if = str_replace("dialer","Di", $if);
|
|
||||||
$if = str_replace("vlan","Vlan", $if);
|
|
||||||
$if = str_replace("tunnel","Tunnel", $if);
|
|
||||||
return $if;
|
|
||||||
}
|
|
||||||
|
|
||||||
function utime() {
|
|
||||||
$time = explode( " ", microtime());
|
$time = explode( " ", microtime());
|
||||||
$usec = (double)$time[0];
|
$usec = (double)$time[0];
|
||||||
$sec = (double)$time[1];
|
$sec = (double)$time[1];
|
||||||
return $sec + $usec;
|
return $sec + $usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixiftype ($type) {
|
function fixIOSFeatures($features)
|
||||||
$type = str_replace("ethernetCsmacd", "Ethernet", $type);
|
{
|
||||||
$type = str_replace("tunnel", "Tunnel", $type);
|
|
||||||
$type = str_replace("softwareLoopback", "Software Loopback", $type);
|
|
||||||
$type = str_replace("propVirtual", "Ethernet VLAN", $type);
|
|
||||||
$type = str_replace("ethernetCsmacd", "Ethernet", $type);
|
|
||||||
$type = str_replace("l2vlan", "Ethernet VLAN", $type);
|
|
||||||
$type = str_replace("frameRelay", "Frame Relay", $type);
|
|
||||||
$type = str_replace("propPointToPointSerial", "PointToPoint Serial", $type);
|
|
||||||
return ($type);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fixifName ($inf) {
|
|
||||||
$inf = str_replace("ether", "Ether", $inf);
|
|
||||||
$inf = str_replace("gig", "Gig", $inf);
|
|
||||||
$inf = str_replace("fast", "Fast", $inf);
|
|
||||||
$inf = str_replace("ten", "Ten", $inf);
|
|
||||||
$inf = str_replace("bvi", "BVI", $inf);
|
|
||||||
$inf = str_replace("vlan", "Vlan", $inf);
|
|
||||||
$inf = str_replace("ether", "Ether", $inf);
|
|
||||||
$inf = str_replace("-802.1q Vlan subif", "", $inf);
|
|
||||||
$inf = str_replace("-802.1q", "", $inf);
|
|
||||||
$inf = str_replace("tunnel", "Tunnel", $inf);
|
|
||||||
$inf = str_replace("serial", "Serial", $inf);
|
|
||||||
$inf = str_replace("-aal5 layer", " aal5", $inf);
|
|
||||||
$inf = str_replace("null", "Null", $inf);
|
|
||||||
$inf = str_replace("atm", "ATM", $inf);
|
|
||||||
$inf = str_replace("port-channel", "Port-Channel", $inf);
|
|
||||||
$inf = str_replace("dial", "Dial", $inf);
|
|
||||||
$inf = str_replace("hp procurve switch software loopback interface", "Loopback Interface", $inf);
|
|
||||||
$inf = str_replace("control plane interface", "Control Plane", $inf);
|
|
||||||
$inf = str_replace("loop", "Loop", $inf);
|
|
||||||
$inf = preg_replace("/^([0-9]+)$/", "Interface \\0", $inf);
|
|
||||||
return $inf;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fixIOSFeatures($features){
|
|
||||||
$features = preg_replace("/^PK9S$/", "IP w/SSH LAN Only", $features);
|
$features = preg_replace("/^PK9S$/", "IP w/SSH LAN Only", $features);
|
||||||
$features = str_replace("LANBASEK9", "Lan Base Crypto", $features);
|
$features = str_replace("LANBASEK9", "Lan Base Crypto", $features);
|
||||||
$features = str_replace("LANBASE", "Lan Base", $features);
|
$features = str_replace("LANBASE", "Lan Base", $features);
|
||||||
|
|||||||
Reference in New Issue
Block a user