diff --git a/config.php.default b/config.php.default index 068c0a4c7..b2a7fec57 100755 --- a/config.php.default +++ b/config.php.default @@ -123,10 +123,7 @@ $list_colour_a_b = "#f0f0f0"; $list_colour_b_a = "#e9e9e9"; $list_colour_b_b = "#e0e0e0"; - -$warn_colour_a = "#ffeeee"; -$warn_colour_b = "#ffcccc"; - +$list_highlight = "#ffcccc"; $warn_colour_a = "#ffeeee"; $warn_colour_b = "#ffcccc"; diff --git a/html/.htaccess b/html/.htaccess index 6e27e098e..15a61d8da 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -8,6 +8,9 @@ RewriteCond %{REQUEST_URI} !^(.*)\.jpg$ RewriteCond %{REQUEST_URI} !^(.*)\.gif$ RewriteCond %{REQUEST_URI} !^(.*)\.png$ +RewriteRule ^bare/(.+)/ index-bare.php?page=$1 + + ## Rewrites for Devices RewriteRule ^devices/location/(.+)/ ?page=devices&location=$1 @@ -24,12 +27,13 @@ RewriteRule ^vrf/(.+)/ ?page=vrf&id=$1 RewriteRule ^bill/([0-9]+) ?page=bills&bill=$1 +RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/ ?page=device&id=$1§ion=$2&opta=$3&optb=$4&optc=$5 RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/ ?page=device&id=$1§ion=$2&opta=$3&optb=$4 RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/ ?page=device&id=$1§ion=$2&opta=$3 RewriteRule ^device/([0-9]+)/([a-z]+)/ ?page=device&id=$1§ion=$2 RewriteRule ^device/([0-9]+) ?page=device&id=$1 -RewriteRule ^([a-z]+)/$ ?page=$1 +RewriteRule ^([a-z|0-9]+)/$ ?page=$1 -RewriteRule ^([a-z]+)/(.+)/$ ?page=$1&opta=$2 +RewriteRule ^([a-z|0-9]+)/(.+)/$ ?page=$1&opta=$2 diff --git a/html/css/styles.css b/html/css/styles.css index a81a29c02..cc77dc5f3 100644 --- a/html/css/styles.css +++ b/html/css/styles.css @@ -765,5 +765,6 @@ color: #cc0000; width: 1175px; margin-bottom: 1em; padding: 10px; + float: left; } diff --git a/html/graph.php b/html/graph.php index a55f68560..09a8c4c10 100644 --- a/html/graph.php +++ b/html/graph.php @@ -72,6 +72,15 @@ if($_GET['debug']) { if($_GET['if']) { $_GET['interfaces'] = $_GET['if']; } $graph = graph_multi_bits ($_GET['interfaces'], $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend); break; + case 'multi_bits_duo': + $groups = array($_GET['interfaces'], $_GET['interfaces_b']); + $graph = graph_multi_bits_duo ($groups, $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend); + break; + case 'multi_bits_trio': + $groups = array($_GET['interfaces'], $_GET['interfaces_b'], $_GET['interfaces_c']); + $graph = graph_multi_bits_trio ($groups, $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend); + break; + case 'adsl_rate': $graph = graph_adsl_rate ($hostname. "/adsl-4.rrd", $graphfile, $from, $to, $width, $height); break; diff --git a/html/includes/print-interface.inc b/html/includes/print-interface.inc index 45f3befd1..c23297188 100644 --- a/html/includes/print-interface.inc +++ b/html/includes/print-interface.inc @@ -7,19 +7,13 @@ $if_id = $interface['interface_id']; - -# $ifType = fixiftype($interface['ifType']); -# $ifHardType = $interface['ifHardType']; - - if($bg == "#e5e5e5") { $bg = "#ffffff"; } else { $bg="#e5e5e5"; } - if($int_colour) { $bg = $int_colour; } + if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { $error_img = generateiflink($interface,"Interface Errors",errors); } else { $error_img = ""; } - - echo(" + echo(" "); echo(" @@ -210,9 +204,4 @@ echo(""); } - - - $i++; - - -?> + ?> diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index e1d059ca4..8e4d2da52 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -130,6 +130,10 @@ if($config['enable_pseudowires']) { echo("
  • VRFs
  • "); $ifbreak = 1;} +?> +
  • IP Search
  • + += '5') { echo("

  • "); @@ -152,6 +156,8 @@ echo("
  • Down
  • Disabled
  • + + @@ -195,7 +201,7 @@ echo("

  • ?> -
  • Configuration +
  • System "); - echo(""); + echo(""); echo(""); - echo(""); +# echo(""); echo("
      @@ -203,7 +209,7 @@ echo("

    • = '10') { echo("

    • -
    • System Settings
    • +
    • Statistics

    • Add User
    • Remove User
    • diff --git a/html/pages/device/collectd.inc.php b/html/pages/device/collectd.inc.php index 54577e13d..14501765d 100644 --- a/html/pages/device/collectd.inc.php +++ b/html/pages/device/collectd.inc.php @@ -67,7 +67,11 @@ function dhtml_response_list(&$items, $method) { if($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); } foreach ($typeinstances as &$tinst) { + if($tinst) { echo("

      ".$_GET['opta']." $instance - $type - $tinst

      "); + } else { + echo("

      ".$_GET['opta']." $instance - $type

      "); + } $daily_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."×pan=day&to=$now&width=215&height=100"; $daily_traffic .= $args; diff --git a/html/pages/device/macaccounting.php b/html/pages/device/macaccounting.php index fe401cfb4..7064c3d69 100644 --- a/html/pages/device/macaccounting.php +++ b/html/pages/device/macaccounting.php @@ -1,4 +1,10 @@ - +Full | +Compact +
      "); + $hostname = $device['hostname']; $hostid = $device['interface_id']; @@ -22,6 +28,8 @@ $query = mysql_query("SELECT *, (M.bps_in + M.bps_out) as bps FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '".$interface['interface_id']."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id ORDER BY bps DESC"); + echo("
      "); + while($acc = mysql_fetch_array($query)) { $addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."'")); @@ -35,14 +43,32 @@ $peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"); $peer_info = mysql_fetch_array($peer_query); - } else { unset ($peer_info); } + } else { unset ($peer_info); } - echo("
      "); if($peer_info) { $asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext']; } else { - unset ($as); unset ($astext); + unset ($as); unset ($astext); unset($asn); } + if($_GET['optc'] == "thumbs") { + + if(!$asn) { $asn = "No Session"; } + + echo("
      + ".$addy['ipv4_address']." - ".$asn." + ".$name." - ".$addy['ipv4_address']." - ".$asn."
      \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" > + + + ".$name." +
      "); + + } else { + + echo("
      "); + echo(" @@ -86,4 +112,6 @@ } +} + ?> diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index 5a8f99059..682bf2400 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,14 +1,44 @@ +
      Basic | Details | Graphs: -Bits | +Bits +(Compact) | Packets | NU Packets | Errors
      "); +if($_GET['optc'] == thumbs) { + + $timeperiods = array('-1day','-1week','-1month','-1year'); + + $from = '-1day'; + + echo("
      "); + + $sql = "select * from interfaces WHERE device_id = '".$device['device_id']."' ORDER BY ifIndex"; + $query = mysql_query($sql); + unset ($seperator); + while($interface = mysql_fetch_array($query)) { + echo("
      +
      ".makeshortif($interface['ifDescr'])."
      + ".$device['hostname']." - ".$interface['ifDescr']."
      \ + ".$interface['ifAlias']." \ + \ + ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". + " + +
      ".truncate(short_port_descr($interface['ifAlias']), 32, '')."
      +
      "); + + } + echo(""); + +} else { + if($_GET['opta'] == graphs ) { if($_GET['optb']) { $graph_type = $_GET['optb']; @@ -30,7 +60,12 @@ $i = "1"; $interface_query = mysql_query("select * from interfaces WHERE device_id = '$_GET[id]' AND deleted = '0' ORDER BY `ifIndex` ASC"); while($interface = mysql_fetch_array($interface_query)) { include("includes/print-interface.inc"); + $i++; } echo("
      "); +echo("
      "); + +} + ?> diff --git a/html/pages/vrfs.php b/html/pages/vrfs.php index 15320c2d3..d2d8f9873 100644 --- a/html/pages/vrfs.php +++ b/html/pages/vrfs.php @@ -9,10 +9,10 @@ echo("
    " . $vrf['vrf_name'] . "" . $vrf['vrf_name'] . "
    " . $vrf['mplsVpnVrfDescription'] . "
    " . $vrf['mplsVpnVrfRouteDistinguisher'] . "" . $vrf['mplsVpnVrfDescription'] . "" . $vrf['mplsVpnVrfDescription'] . ""); @@ -24,10 +24,13 @@ } else { if(!is_integer($x/2)) { $dev_colour = $list_colour_b_b; } else { $dev_colour = $list_colour_b_a; } } - echo("
    ".generatedevicelink($device) . ""); + echo("
    ".generatedevicelink($device)); + if($device['vrf_name'] != $vrf['vrf_name']) { echo("Configured : ".$device['vrf_name']."', CAPTION, 'VRF Inconsistency' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> "); } + echo(""); $interfaces = mysql_query("SELECT * FROM `interfaces` WHERE `ifVrf` = '".$device['vrf_id']."' and device_id = '".$device['device_id']."'"); unset($seperator); while($interface = mysql_fetch_array($interfaces)) { + $interface = array_merge ($device, $interface); echo($seperator.generateiflink($interface,makeshortif($interface['ifDescr']))); $seperator = ", "; } diff --git a/includes/collectd/definitions.php b/includes/collectd/definitions.php index 8923607ad..f93798537 100644 --- a/includes/collectd/definitions.php +++ b/includes/collectd/definitions.php @@ -690,21 +690,21 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'DEF:l_max={file}:longterm:MAX', "AREA:s_max#$HalfGreen", "AREA:s_min#$Canvas", - "LINE1:s_avg#$FullGreen: 1m average", - 'GPRINT:s_min:MIN:%4.2lf', - 'GPRINT:s_avg:AVERAGE:%4.2lf', - 'GPRINT:s_max:MAX:%4.2lf', - 'GPRINT:s_avg:LAST:%4.2lf Last\n', - "LINE1:m_avg#$FullBlue: 5m average", - 'GPRINT:m_min:MIN:%4.2lf', - 'GPRINT:m_avg:AVERAGE:%4.2lf', - 'GPRINT:m_max:MAX:%4.2lf', - 'GPRINT:m_avg:LAST:%4.2lf Last\n', + "LINE1:s_avg#$FullGreen: 1m average ", + 'GPRINT:s_min:MIN:%5.2lf', + 'GPRINT:s_avg:AVERAGE:%5.2lf', + 'GPRINT:s_max:MAX:%5.2lf', + 'GPRINT:s_avg:LAST:%5.2lf\\j', + "LINE1:m_avg#$FullBlue: 5m average ", + 'GPRINT:m_min:MIN:%5.2lf', + 'GPRINT:m_avg:AVERAGE:%5.2lf', + 'GPRINT:m_max:MAX:%5.2lf', + 'GPRINT:m_avg:LAST:%5.2lf\\j', "LINE1:l_avg#$FullRed:15m average", - 'GPRINT:l_min:MIN:%4.2lf', - 'GPRINT:l_avg:AVERAGE:%4.2lf', - 'GPRINT:l_max:MAX:%4.2lf', - 'GPRINT:l_avg:LAST:%4.2lf'); + 'GPRINT:l_min:MIN:%5.2lf', + 'GPRINT:l_avg:AVERAGE:%5.2lf', + 'GPRINT:l_max:MAX:%5.2lf', + 'GPRINT:l_avg:LAST:%5.2lf\\j'); $GraphDefs['load_percent'] = array( 'DEF:avg={file}:percent:AVERAGE', 'DEF:min={file}:percent:MIN', @@ -1396,7 +1396,8 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false) { 'GPRINT:s_max:MAX:%5.2lf%s', 'GPRINT:s_avg:LAST:%5.2lf%s'); $GraphDefs['if_octets'] = array( - '-v', 'Bits/s', '--units=si', + #'-v', 'Bits/s', + '--units=si', 'DEF:out_min_raw={file}:tx:MIN', 'DEF:out_avg_raw={file}:tx:AVERAGE', 'DEF:out_max_raw={file}:tx:MAX', diff --git a/includes/discovery/bgp-peers.php b/includes/discovery/bgp-peers.php index bf6bc2ab4..c75d16f4d 100755 --- a/includes/discovery/bgp-peers.php +++ b/includes/discovery/bgp-peers.php @@ -8,7 +8,7 @@ $as_cmd .= ".1.3.6.1.2.1.15.2"; $bgpLocalAs = trim(shell_exec($as_cmd)); - if($bgpLocalAs) { + if($bgpLocalAs && !strstr($bgpLocalAs, "No")) { echo("AS$bgpLocalAs \n"); diff --git a/includes/graphing.php b/includes/graphing.php index ede909279..792f3ea4c 100644 --- a/includes/graphing.php +++ b/includes/graphing.php @@ -5,11 +5,291 @@ include("graphing/fortigate.php"); include("graphing/windows.php"); include("graphing/unix.php"); +function graph_multi_bits_trio ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '1') { + global $config, $installdir; + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height"; + if($height < "99") { $options .= " --only-graph"; } + $i = 1; + foreach(explode(",", $interfaces[0]) as $ifid) { + $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); + $int = mysql_fetch_row($query); + if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) { + if(strstr($inverse, "a")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; } + $options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE"; + $options .= " DEF:outoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE"; + $in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF"; + $out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF"; + $pluses .= $plus; + $seperator = ","; + $plus = ",+"; + $i++; + } + } + unset($seperator); unset($plus); + foreach(explode(",", $interfaces[1]) as $ifid) { + $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); + $int = mysql_fetch_row($query); + if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) { + if(strstr($inverse, "b")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; } + $options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE"; + $options .= " DEF:outoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE"; + $in_thingb .= $seperator . "inoctetsb" . $i . ",UN,0," . "inoctetsb" . $i . ",IF"; + $out_thingb .= $seperator . "outoctetsb" . $i . ",UN,0," . "outoctetsb" . $i . ",IF"; + $plusesb .= $plus; + $seperator = ","; + $plus = ",+"; + $i++; + } + } + unset($seperator); unset($plus); + foreach(explode(",", $interfaces[2]) as $ifid) { + $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); + $int = mysql_fetch_row($query); + if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) { + if(strstr($inverse, "c")) { $in = "OUT"; $out = "IN"; } else { $in = "IN"; $out = "OUT"; } + $options .= " DEF:inoctetsc" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$in."OCTETS:AVERAGE"; + $options .= " DEF:outoctetsc" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:".$out."OCTETS:AVERAGE"; + $in_thingc .= $seperator . "inoctetsc" . $i . ",UN,0," . "inoctetsc" . $i . ",IF"; + $out_thingc .= $seperator . "outoctetsc" . $i . ",UN,0," . "outoctetsc" . $i . ",IF"; + $plusesc .= $plus; + $seperator = ","; + $plus = ",+"; + $i++; + } + } + $options .= " CDEF:inoctets=" . $in_thing . $pluses; + $options .= " CDEF:outoctets=" . $out_thing . $pluses; + $options .= " CDEF:inoctetsb=" . $in_thingb . $plusesb; + $options .= " CDEF:outoctetsb=" . $out_thingb . $plusesb; + $options .= " CDEF:inoctetsc=" . $in_thingc . $plusesc; + $options .= " CDEF:outoctetsc=" . $out_thingc . $plusesc; + $options .= " CDEF:doutoctets=outoctets,-1,*"; + $options .= " CDEF:inbits=inoctets,8,*"; + $options .= " CDEF:outbits=outoctets,8,*"; + $options .= " CDEF:doutbits=doutoctets,8,*"; + $options .= " CDEF:doutoctetsb=outoctetsb,-1,*"; + $options .= " CDEF:inbitsb=inoctetsb,8,*"; + $options .= " CDEF:outbitsb=outoctetsb,8,*"; + $options .= " CDEF:doutbitsb=doutoctetsb,8,*"; + $options .= " CDEF:doutoctetsc=outoctetsc,-1,*"; + $options .= " CDEF:inbitsc=inoctetsc,8,*"; + $options .= " CDEF:outbitsc=outoctetsc,8,*"; + $options .= " CDEF:doutbitsc=doutoctetsc,8,*"; + $options .= " CDEF:inbits_tot=inbits,inbitsb,inbitsc,+,+"; + $options .= " CDEF:outbits_tot=outbits,outbitsb,outbitsc,+,+"; + $options .= " CDEF:inbits_stot=inbitsc,inbitsb,+"; + $options .= " CDEF:outbits_stot=outbitsc,outbitsb,+"; + $options .= " CDEF:doutbits_stot=outbits_stot,-1,*"; + $options .= " CDEF:doutbits_tot=outbits_tot,-1,*"; + $options .= " CDEF:nothing=outbits_tot,outbits_tot,-"; + + if($legend == "no") { + $options .= " AREA:inbits_tot#cdeb8b:"; + $options .= " AREA:doutbits_tot#cdeb8b:"; + $options .= " LINE1.25:inbits_tot#aacc77:"; + $options .= " LINE1.25:doutbits_tot#aacc88:"; + $options .= " AREA:inbits_stot#c3d9ff:"; + $options .= " AREA:doutbits_stot#c3d9ff:"; + $options .= " LINE1:inbits_stot#b3a9cf:"; + $options .= " LINE1:doutbits_stot#b3a9cf:"; + $options .= " AREA:inbitsc#ffcc99:"; + $options .= " AREA:doutbitsc#ffcc99:"; + $options .= " LINE1.25:inbitsc#ddaa88"; + $options .= " LINE1.25:doutbitsc#ddaa88"; + $options .= " LINE1:inbits#006600:"; + $options .= " LINE1:doutbits#006600:"; + $options .= " LINE1:inbitsb#000099:"; + $options .= " LINE1:doutbitsb#000099:"; + $options .= " LINE0.5:nothing#555555:"; + } else { + $options .= " COMMENT:BPS\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Min\ \ \ \ \ \ Max\\\\n"; + $options .= " AREA:inbits_tot#cdeb8b:ATM\ \ In\ "; + $options .= " GPRINT:inbits:LAST:%6.2lf%s"; + $options .= " GPRINT:inbits:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:inbits:MIN:%6.2lf%s"; + $options .= " GPRINT:inbits:MAX:%6.2lf%s\\\\l"; + $options .= " AREA:doutbits_tot#cdeb8b:"; + $options .= " COMMENT:\ \ \ \ \ \ \ Out"; + $options .= " GPRINT:outbits:LAST:%6.2lf%s"; + $options .= " GPRINT:outbits:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:outbits:MIN:%6.2lf%s"; + $options .= " GPRINT:outbits:MAX:%6.2lf%s\\\\l"; + $options .= " LINE1.25:inbits_tot#aacc77:"; + $options .= " LINE1.25:doutbits_tot#aacc88:"; + $options .= " AREA:inbits_stot#c3d9ff:NGN\ \ In\ "; + $options .= " GPRINT:inbitsb:LAST:%6.2lf%s"; + $options .= " GPRINT:inbitsb:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:inbitsb:MIN:%6.2lf%s"; + $options .= " GPRINT:inbitsb:MAX:%6.2lf%s\\\\l"; + $options .= " AREA:doutbits_stot#c3d9ff:"; + $options .= " COMMENT:\ \ \ \ \ \ \ Out"; + $options .= " GPRINT:outbitsb:LAST:%6.2lf%s"; + $options .= " GPRINT:outbitsb:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:outbitsb:MIN:%6.2lf%s"; + $options .= " GPRINT:outbitsb:MAX:%6.2lf%s\\\\l"; + $options .= " LINE1:inbits_stot#b3a9cf:"; + $options .= " LINE1:doutbits_stot#b3a9cf:"; + $options .= " AREA:inbitsc#ffcc99:Wave\ In\ "; + $options .= " GPRINT:inbitsc:LAST:%6.2lf%s"; + $options .= " GPRINT:inbitsc:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:inbitsc:MIN:%6.2lf%s"; + $options .= " GPRINT:inbitsc:MAX:%6.2lf%s\\\\l"; + $options .= " AREA:doutbitsc#ffcc99:"; + $options .= " COMMENT:\ \ \ \ \ \ \ Out"; + $options .= " GPRINT:outbitsc:LAST:%6.2lf%s"; + $options .= " GPRINT:outbitsc:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:outbitsc:MIN:%6.2lf%s"; + $options .= " GPRINT:outbitsc:MAX:%6.2lf%s\\\\l"; + $options .= " LINE1.25:inbitsc#ddaa88"; + $options .= " LINE1.25:doutbitsc#ddaa88"; + $options .= " LINE1:inbits#006600:"; + $options .= " LINE1:doutbits#006600:"; + $options .= " LINE1:inbitsb#000099:"; + $options .= " LINE1:doutbitsb#000099:"; + $options .= " LINE0.5:nothing#555555:"; + + $options .= " COMMENT:Total\ \ In\ "; + $options .= " GPRINT:inbits_tot:LAST:%6.2lf%s"; + $options .= " GPRINT:inbits_tot:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:inbits_tot:MIN:%6.2lf%s"; + $options .= " GPRINT:inbits_tot:MAX:%6.2lf%s\\\\l"; + $options .= " COMMENT:\ \ \ \ \ \ \ Out"; + $options .= " GPRINT:outbits_tot:LAST:%6.2lf%s"; + $options .= " GPRINT:outbits_tot:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:outbits_tot:MIN:%6.2lf%s"; + $options .= " GPRINT:outbits_tot:MAX:%6.2lf%s\\\\l"; + + + } + if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; } +# echo($config['rrdtool'] . " graph $imgfile $options"); + $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); + return $imgfile; +} + + +function graph_multi_bits_duo ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '1') { + global $config, $installdir; + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height"; + if($height < "99") { $options .= " --only-graph"; } + $i = 1; + foreach(explode(",", $interfaces[1]) as $ifid) { + $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); + $int = mysql_fetch_row($query); + if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) { + $options .= " DEF:inoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE"; + $options .= " DEF:outoctets" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE"; + $in_thing .= $seperator . "inoctets" . $i . ",UN,0," . "inoctets" . $i . ",IF"; + $out_thing .= $seperator . "outoctets" . $i . ",UN,0," . "outoctets" . $i . ",IF"; + $pluses .= $plus; + $seperator = ","; + $plus = ",+"; + $i++; + } + } + unset($seperator); unset($plus); + foreach(explode(",", $interfaces[0]) as $ifid) { + $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); + $int = mysql_fetch_row($query); + if(is_file($config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd")) { + $options .= " DEF:inoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:INOCTETS:AVERAGE"; + $options .= " DEF:outoctetsb" . $i . "=" . $config['rrd_dir'] . "/" . $int[1] . "/" . $int[0] . ".rrd:OUTOCTETS:AVERAGE"; + $in_thingb .= $seperator . "inoctetsb" . $i . ",UN,0," . "inoctetsb" . $i . ",IF"; + $out_thingb .= $seperator . "outoctetsb" . $i . ",UN,0," . "outoctetsb" . $i . ",IF"; + $plusesb .= $plus; + $seperator = ","; + $plus = ",+"; + $i++; + } + } + if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } + $options .= " CDEF:".$in."octets=" . $in_thing . $pluses; + $options .= " CDEF:".$out."octets=" . $out_thing . $pluses; + $options .= " CDEF:".$in."octetsb=" . $in_thingb . $plusesb; + $options .= " CDEF:".$out."octetsb=" . $out_thingb . $plusesb; + $options .= " CDEF:doutoctets=outoctets,-1,*"; + $options .= " CDEF:inbits=inoctets,8,*"; + $options .= " CDEF:outbits=outoctets,8,*"; + $options .= " CDEF:doutbits=doutoctets,8,*"; + $options .= " CDEF:doutoctetsb=outoctetsb,-1,*"; + $options .= " CDEF:inbitsb=inoctetsb,8,*"; + $options .= " CDEF:outbitsb=outoctetsb,8,*"; + $options .= " CDEF:doutbitsb=doutoctetsb,8,*"; + $options .= " CDEF:inbits_tot=inbits,inbitsb,+"; + $options .= " CDEF:outbits_tot=outbits,outbitsb,+"; + $options .= " CDEF:doutbits_tot=outbits_tot,-1,*"; + $options .= " CDEF:nothing=outbits_tot,outbits_tot,-"; + if($legend == "no") { + $options .= " AREA:inbits_tot#cdeb8b:"; + $options .= " AREA:inbits#ffcc99:"; + $options .= " AREA:doutbits_tot#cdeb8b:"; + $options .= " AREA:doutbits#ffcc99:"; + $options .= " LINE1:inbits#aa9966:"; + $options .= " LINE1:doutbits#aa9966:"; + $options .= " LINE1:inbitsb#006600:"; + $options .= " LINE1:doutbitsb#006600:"; + $options .= " LINE1.25:inbits_tot#006600:"; + $options .= " LINE1.25:doutbits_tot#006600:"; + $options .= " LINE0.5:nothing#555555:"; + } else { + $options .= " COMMENT:BPS\ \ \ \ \ \ \ \ \ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Min\ \ \ \ \ \ Max\\\\n"; + $options .= " AREA:inbits_tot#cdeb8b:Peering\ In\ "; + $options .= " GPRINT:inbitsb:LAST:%6.2lf%s"; + $options .= " GPRINT:inbitsb:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:inbitsb:MIN:%6.2lf%s"; + $options .= " GPRINT:inbitsb:MAX:%6.2lf%s\\\\l"; + $options .= " AREA:doutbits_tot#cdeb8b:"; + $options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Out"; + $options .= " GPRINT:outbitsb:LAST:%6.2lf%s"; + $options .= " GPRINT:outbitsb:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:outbitsb:MIN:%6.2lf%s"; + $options .= " GPRINT:outbitsb:MAX:%6.2lf%s\\\\l"; + + $options .= " AREA:inbits#ffcc99:Transit\ In\ "; + $options .= " GPRINT:inbits:LAST:%6.2lf%s"; + $options .= " GPRINT:inbits:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:inbits:MIN:%6.2lf%s"; + $options .= " GPRINT:inbits:MAX:%6.2lf%s\\\\l"; + $options .= " AREA:doutbits#ffcc99:"; + $options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Out"; + $options .= " GPRINT:outbits:LAST:%6.2lf%s"; + $options .= " GPRINT:outbits:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:outbits:MIN:%6.2lf%s"; + $options .= " GPRINT:outbits:MAX:%6.2lf%s\\\\l"; + + $options .= " COMMENT:Total\ \ \ \ \ In\ "; + $options .= " GPRINT:inbits_tot:LAST:%6.2lf%s"; + $options .= " GPRINT:inbits_tot:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:inbits_tot:MIN:%6.2lf%s"; + $options .= " GPRINT:inbits_tot:MAX:%6.2lf%s\\\\l"; + $options .= " COMMENT:\ \ \ \ \ \ \ \ \ \ Out"; + $options .= " GPRINT:outbits_tot:LAST:%6.2lf%s"; + $options .= " GPRINT:outbits_tot:AVERAGE:%6.2lf%s"; + $options .= " GPRINT:outbits_tot:MIN:%6.2lf%s"; + $options .= " GPRINT:outbits_tot:MAX:%6.2lf%s\\\\l"; + + $options .= " LINE1:inbits#aa9966:"; + $options .= " LINE1:doutbits#aa9966:"; + $options .= " LINE1.25:inbitsb#006600:"; + $options .= " LINE1.25:doutbitsb#006600:"; + $options .= " LINE1.25:inbits_tot#006600:"; + $options .= " LINE1.25:doutbits_tot#006600:"; + $options .= " LINE0.5:nothing#555555:"; + + } + if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; } + $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); + return $imgfile; +} + + function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '1') { global $config, $installdir; $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height"; - if($height < "33") { $options .= " --only-graph"; } + if($height < "99") { $options .= " --only-graph"; } $i = 1; foreach(explode(",", $interfaces) as $ifid) { $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `interfaces` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); @@ -95,6 +375,7 @@ function graph_cpmCPU ($id, $graph, $from, $to, $width, $height, $title, $vertic global $config, $installdir; $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; $options .= " -l 0 -E -b 1024 --title '$title' "; + if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $hostname = gethostbyid($device); $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; @@ -124,6 +405,7 @@ function graph_device_cpmCPU ($device, $graph, $from, $to, $width, $height, $tit global $config, $installdir; $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; $options .= " -l 0 -E -b 1024 --title '$title' "; + if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $hostname = gethostbyid($device); $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; @@ -151,6 +433,7 @@ function graph_device_cempMemPool ($device, $graph, $from, $to, $width, $height, global $config, $installdir; $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; $options .= " -l 0 -E -b 1024 --title '$title' "; + if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $hostname = gethostbyid($device); $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; @@ -227,6 +510,7 @@ function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $ global $config, $installdir; $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; $options .= " -l 0 -E -b 1024 --title '$title' "; + if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $hostname = gethostbyid($device); $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; @@ -269,16 +553,27 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height, $title } function graph_mac_acc ($id, $graph, $from, $to, $width, $height) { + global $config; + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id"); + $acc = mysql_fetch_array($query); + $database = $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; + return graph_bits ($database, $graph, $from, $to, $width, $height, $title, $vertical); + +} + + +function graph_mac_acc_old ($id, $graph, $from, $to, $width, $height) { global $config; $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id"); $acc = mysql_fetch_array($query); $database = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height "; - if($height < "33") { $options .= " --only-graph"; } + if($height < "99") { $options .= " --only-graph"; } $period = $to - $from; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - if($height < "33") { $options .= " --only-graph"; } + if($height < "99") { $options .= " --only-graph"; } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= " DEF:inoctets=$database:IN:AVERAGE"; @@ -320,7 +615,7 @@ function graph_mac_acc_interface ($interface, $graph, $from, $to, $width, $heigh global $config, $installdir; $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height "; - if($height < "33") { $options .= " --only-graph"; } + if($height < "99") { $options .= " --only-graph"; } $hostname = gethostbyid($device); $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '$interface' AND I.interface_id = M.interface_id AND I.device_id = D.device_id"); if($width <= "300") { $options .= "--font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -362,7 +657,7 @@ function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertica $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $period = $to - $from; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - if($height < "33") { $options .= " --only-graph"; unset ($legend); } + if($height < "99") { $options .= " --only-graph"; unset ($legend); } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } if($inverse) { $in = 'out'; @@ -371,10 +666,17 @@ function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertica $in = 'in'; $out = 'out'; } - $options .= " DEF:".$out."octets=$database:OUTOCTETS:AVERAGE"; - $options .= " DEF:".$in."octets=$database:INOCTETS:AVERAGE"; - $options .= " DEF:".$out."octets_max=$database:OUTOCTETS:MAX"; - $options .= " DEF:".$in."octets_max=$database:INOCTETS:MAX"; + if(strstr($database, "mac-accounting")) { + $options .= " DEF:".$out."octets=$database:OUT:AVERAGE"; + $options .= " DEF:".$in."octets=$database:IN:AVERAGE"; + $options .= " DEF:".$out."octets_max=$database:OUT:MAX"; + $options .= " DEF:".$in."octets_max=$database:IN:MAX"; + } else { + $options .= " DEF:".$out."octets=$database:OUTOCTETS:AVERAGE"; + $options .= " DEF:".$in."octets=$database:INOCTETS:AVERAGE"; + $options .= " DEF:".$out."octets_max=$database:OUTOCTETS:MAX"; + $options .= " DEF:".$in."octets_max=$database:INOCTETS:MAX"; + } $options .= " CDEF:octets=inoctets,outoctets,+"; $options .= " CDEF:doutoctets=outoctets,-1,*"; @@ -555,12 +857,11 @@ function graph_entity_sensor ($sensor, $graph , $from, $to, $width, $height, $ti $sensor = mysql_fetch_array(mysql_query("SELECT * FROM entPhysical as E, devices as D WHERE entPhysical_id = '$sensor' and D.device_id = E.device_id")); $database = $config['rrd_dir'] . "/" . $sensor['hostname'] . "/ces-" . $sensor['entPhysicalIndex'] . ".rrd"; $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height "; + if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - $type = str_pad($sensor['entSensorType'], 8); $type = substr($type,0,8); - $options .= " DEF:avg=$database:value:AVERAGE"; $options .= " DEF:min=$database:value:MIN"; $options .= " DEF:max=$database:value:MAX"; @@ -692,7 +993,6 @@ function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $verti return $imgfile; } - function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; diff --git a/includes/rewrites.php b/includes/rewrites.php index 25c13bfd1..6e74b2546 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -1,5 +1,6 @@ 'C', 'unknown' => '', @@ -196,6 +197,19 @@ function fixifName ($inf) return $inf; } +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); + + return $desc; + +} + // Underlying rewrite functions diff --git a/poll-reachability.php b/poll-reachability.php index c2f2ac76b..086a33052 100755 --- a/poll-reachability.php +++ b/poll-reachability.php @@ -17,7 +17,7 @@ while ($device = mysql_fetch_array($device_query)) { $snmpver = $device['snmpver']; $port = $device['port']; - echo("$hostname\n"); + echo("$hostname "); $status = shell_exec($config['fping'] . " $hostname | cut -d ' ' -f 3"); $status = trim($status); @@ -34,6 +34,12 @@ while ($device = mysql_fetch_array($device_query)) { } + if($status == '1') { + echo("Up\n"); + } else { + echo("Down\n"); + } + if($status != $device['status']) { if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; } @@ -44,7 +50,7 @@ while ($device = mysql_fetch_array($device_query)) { mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')"); mail($email, "DeviceUp: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date('l dS F Y h:i:s A'), $config['email_headers']); } else { - $stat = "Down"; + $stat = "Down"; mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')"); mail($email, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date('l dS F Y h:i:s A'), $config['email_headers']); } diff --git a/process-syslog.php b/process-syslog.php index b3488d41e..d5836702c 100755 --- a/process-syslog.php +++ b/process-syslog.php @@ -3,6 +3,11 @@ include("config.php"); +if(!$config['enable_syslog']) { + echo("Syslog support disabled.\n"); + exit(); +} + include("includes/syslog.php"); mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%last message repeated%'"); @@ -12,10 +17,11 @@ mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%PM-3- mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%RHWatchdog%'"); mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Hardware Monitoring%'"); -if(!$config['enable_syslog']) { - echo("Syslog support disabled.\n"); - exit(); -} +#mysql_query("DELETE FROM `syslog` WHERE `program` LIKE 'SNMP-3-AUTHFAIL'"); +#mysql_query("DELETE FROM `syslog` WHERE `program` LIKE 'SW_MATM-4-MACFLAP_NOTIF'"); + +mysql_query("DELETE FROM `syslog` WHERE `priority` = 'debug'"); + ## Delete all the old old old syslogs (as per config.php variable) diff --git a/cron-hourly.sh b/scripts/cron-hourly.sh similarity index 100% rename from cron-hourly.sh rename to scripts/cron-hourly.sh diff --git a/cron-minute.sh b/scripts/cron-minute.sh similarity index 100% rename from cron-minute.sh rename to scripts/cron-minute.sh diff --git a/cron.sh b/scripts/cron.sh similarity index 100% rename from cron.sh rename to scripts/cron.sh