diff --git a/html/includes/graphs/device_bits.inc.php b/html/includes/graphs/device_bits.inc.php index a6790d848..72540626e 100644 --- a/html/includes/graphs/device_bits.inc.php +++ b/html/includes/graphs/device_bits.inc.php @@ -2,14 +2,34 @@ ## Generate a list of ports and then call the multi_bits grapher to generate from the list -$device = mres($_GET['device']); -$hostname = gethostbyid($device); +if($_GET['device']) { + $device = device_by_id_cache(mres($_GET['device'])); +} elseif($_GET['id']) { + $device = device_by_id_cache(mres($_GET['id'])); +} -$query = mysql_query("SELECT `ifIndex`,`interface_id` FROM `ports` WHERE `device_id` = '$device' AND `ifType` NOT LIKE '%oopback%' AND `ifType` NOT LIKE '%SVI%' AND `ifType` != 'l2vlan'"); -while($int = mysql_fetch_row($query)) { - if(is_file($config['rrd_dir'] . "/" . $hostname . "/" . safename($int[0] . ".rrd"))) { - $rrd_filenames[] = $config['rrd_dir'] . "/" . $hostname . "/" . safename($int[0] . ".rrd"); +$query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."'"); +while($int = mysql_fetch_assoc($query)) { + $ignore = 0; + if(is_array($config['device_traffic_iftype'])) { + foreach($config['device_traffic_iftype'] as $iftype) { + if (preg_match($iftype ."i", $int['ifType'])) { + $ignore = 1; + } + } } + if(is_array($config['device_traffic_descr'])) { + foreach($config['device_traffic_descr'] as $ifdescr) { + if (preg_match($ifdescr."i", $int['ifDescr']) || preg_match($ifdescr."i", $int['ifName']) || preg_match($ifdescr."i", $int['portName'])) { + $ignore = 1; + } + } + } + + if(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($int['ifIndex'] . ".rrd")) && $ignore != 1) { + $rrd_filenames[] = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($int['ifIndex'] . ".rrd"); + } + unset($ignore); } $rra_in = "INOCTETS"; diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 8f1d220b1..c7f9b8dd0 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -162,8 +162,8 @@ echo('
  • Processorss
  • -
  • Memory
  • +
  • Processorss
  • +
  • Memory
  • Storage

  • Temperatures
  • diff --git a/html/includes/print-syslog.inc b/html/includes/print-syslog.inc index 394d8b3c7..4ab5d4335 100644 --- a/html/includes/print-syslog.inc +++ b/html/includes/print-syslog.inc @@ -13,7 +13,7 @@ if(!is_integer($syslog_iter/2)) { $bg_colour = $list_colour_a; } else { $bg_colo echo("" . $entry['date'] . ""); -# $entry['hostname'] = shorthost(gethostbyid($entry['host']), 20); + $entry['hostname'] = shorthost($entry['hostname'], 20); if($_GET['page'] != "device") { echo("".generatedevicelink($entry).""); diff --git a/html/index.php b/html/index.php index 8862d3bc3..b097ec7bf 100755 --- a/html/index.php +++ b/html/index.php @@ -137,7 +137,7 @@ function popUp(URL) { if(isset($_GET['page']) && !strstr("..", $_GET['page']) && is_file("pages/" . $_GET['page'] . ".php")) { include("pages/" . $_GET['page'] . ".php"); } else { - if($config['front_page']) { + if(isset($config['front_page'])) { include($config['front_page']); } else { include("pages/front/default.php"); diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 0e92f3f1a..4786f1d7e 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -3,77 +3,97 @@
    Devices with Alerts
    Host
    Int
    Srv
    -?> - '0' AND A.attrib_value < '86400'"); + +while($device = mysql_fetch_array($sql)){ + unset($already); + $i = 0; + while ($i <= count($nodes)) { + $thisnode = $device['device_id']; + if ($nodes[$i] == $thisnode) { + $already = "yes"; + } + $i++; + } + if(!$already) { $nodes[] = $device['device_id']; } +} + $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'"); while($device = mysql_fetch_array($sql)){ - - echo("
    -
    ".generatedevicelink($device, shorthost($device['hostname']))."
    - Device Down
    - ".truncate($device['location'], 20)." -
    "); - + if(devicepermitted($device['device_id'])) { + echo("
    + ".generatedevicelink($device, shorthost($device['hostname']))."
    + Device Down
    + ".truncate($device['location'], 35)." +
    "); + } } -$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND D.status = '1' AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); +if($config['warn']['ifdown']) { + +$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'"); while($interface = mysql_fetch_array($sql)){ - - echo("
    -
    ".generatedevicelink($interface, shorthost($interface['hostname']))."
    - Port Down - ".generateiflink($interface, makeshortif($interface['ifDescr']))."
    - ".truncate($interface['ifAlias'], 20)." -
    "); + if(interfacepermitted($interface['interface_id'])) { + echo("
    + ".generatedevicelink($interface, shorthost($interface['hostname']))."
    + Port Down
    + ".generateiflink($interface, makeshortif($interface['ifDescr']))."
    + ".truncate($interface['ifAlias'], 15)." +
    "); + } +} } -$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND D.status = '1' AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); +$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'"); while($service = mysql_fetch_array($sql)){ - - echo("
    -
    ".generatedevicelink($service, shorthost($service['hostname']))."
    - Service Down + if(devicepermitted($service['device_id'])) { + echo("
    + ".generatedevicelink($service, shorthost($service['hostname']))."
    + Service Down
    ".$service['service_type']."
    - ".truncate($interface['ifAlias'], 20)." + ".truncate($interface['ifAlias'], 15)."
    "); - + } } -$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE D.status = '1' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); +$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id"); while($peer = mysql_fetch_array($sql)){ - - echo("
    -
    ".generatedevicelink($peer, shorthost($peer['hostname']))."
    - BGP Down - ".$peer['bgpPeerIdentifier']."
    + if(devicepermitted($peer['device_id'])) { + echo("
    + ".generatedevicelink($peer, shorthost($peer['hostname']))."
    + BGP Down
    + ".$peer['bgpPeerIdentifier']."
    AS".$peer['bgpPeerRemoteAs']." ".truncate($peer['astext'], 10)." -
    "); - + "); + } } -$sql = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND `uptime` < '84600'"); +$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); while($device = mysql_fetch_array($sql)){ - echo("
    -
    ".generatedevicelink($device, shorthost($device['hostname']))."
    - Device
    Rebooted

    - ".formatUptime($device['uptime'])." -
    "); + if(devicepermitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) { + echo("
    + ".generatedevicelink($device, shorthost($device['hostname']))."
    + Device
    Rebooted

    + ".formatUptime($device['attrib_value'])." +
    "); + } } - echo(" -
    $errorboxes
    +
    $errorboxes

    Recent Syslog Messages

    "); -$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog AS S, devices AS D - WHERE S.device_id = D.device_id ORDER BY timestamp DESC LIMIT 20"; + +$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20"; $query = mysql_query($sql); echo(""); while($entry = mysql_fetch_array($query)) { include("includes/print-syslog.inc"); } @@ -83,28 +103,92 @@ echo("
    "); echo("
    - "); + "); /// this stuff can be customised to show whatever you want.... -#if($_SESSION['userlevel'] >= '5') { -echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    Alpha Traffic
    ". - "
    "); + $ports['fileserver'] = "78"; + $ports['broadband'] = "228,251,182"; + $ports['homeserver'] = "256,245,74"; -echo("
    "); + echo("
    "); + + if($ports['fileserver']) { + echo("
    + \ + \ + ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". + "
    Main Fileserver
    ". + "
    "); + } + + echo("
    "); + + echo("
    "); + + echo("
    + \ + \ + ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". " +
    NE61 Broadband
    ". + "
    "); + + echo("
    + \ + \ + ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". " +
    NE61 Server
    ". + "
    "); + + echo("
    "); + + echo("
    "); + + echo("
    + \ + \ + ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". " +
    DE56 Broadband
    ". + "
    "); + + echo("
    + \ + \ + ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". " +
    DE56 Server
    ". + "
    "); + + echo("
    "); + + echo("
    "); + + echo("
    + \ + \ + ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". " +
    DE24 Broadband
    ". + "
    "); + + echo("
    + \ + \ + ', LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". " +
    DE24 Server
    ". + "
    "); + + echo("
    "); -echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". - "
    Alpha Storage
    ". - "
    "); -#} ?> diff --git a/includes/common.php b/includes/common.php index 795b2eeb2..5e7b700d4 100644 --- a/includes/common.php +++ b/includes/common.php @@ -2,6 +2,19 @@ ## Common Functions +function device_by_id_cache($device_id) +{ + global $device_cache; + if (is_array($device_cache[$device_id])) + { + $device = $device_cache[$device_id]; + } else { + $device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device_id."'")); + $device_cache[$device_id] = $device; + } + return $device; +} + function truncate($substring, $max = 50, $rep = '...'){ if(strlen($substring) < 1){ $string = $rep; } else { $string = $substring; } $leave = $max - strlen ($rep); diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 344b4f33f..2546b0a0d 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -27,7 +27,7 @@ $config['mono_font'] = "DejaVuSansMono"; $config['favicon'] = "favicon.ico"; $config['header_color'] = "#1F334E"; $config['page_refresh'] = "30"; ## Refresh the page every xx seconds -$config['frong_page'] = "default.php"; +$config['frong_page'] = "pages/front/default.php"; $config['page_title'] = "ObserverNMS"; $config['syslog_age'] = "1 month"; $config['timestamp_format'] = 'd-m-Y H:i:s'; @@ -80,6 +80,9 @@ $config['ignore_mount_removable'] = 1; # Ignore removable disk storage $config['ignore_mount_network'] = 1; # Ignore network mounted storage $config['ignore_mount_optical'] = 1; # Ignore mounted optical discs +$config['device_traffic_iftype'] = array('/loopback/','/other/','/tunnel/','/virtual/','/mpls/'); +$config['device_traffic_descr'] = array('/loopback/','/vlan/','/tunnel/','/:/'); + # Sensors $config['allow_entity_sensor']['amperes'] = 1; diff --git a/includes/functions.php b/includes/functions.php index d900b06a9..e7d1098d2 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -25,19 +25,6 @@ require('collectd/config.php'); require('collectd/functions.php'); require('collectd/definitions.php'); -function device_by_id_cache($device_id) -{ - global $device_cache; - if (is_array($device_cache[$device_id])) - { - $device = $device_cache[$device_id]; - } else { - $device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device_id."'")); - $device_cache[$device_id] = $device; - } - return $device; -} - function mac_clean_to_readable($mac) { $r = substr($mac, 0, 2);