From 3207412c9eafb6e444c12f4ec09e8fb37a700442 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 2 Mar 2009 18:12:09 +0000 Subject: [PATCH] fixes git-svn-id: http://www.observium.org/svn/observer/trunk@349 61d68cd4-352d-0410-923a-c4978735b2b8 --- addhost.php | 4 +- discover-cdp.php | 43 ++++++----- generate-map.sh | 4 +- html/.htaccess | 4 +- html/includes/print-interface.inc | 13 ++-- html/pages/device/showconfig.inc.php | 8 +-- includes/discovery/temperatures.php | 2 +- includes/functions.php | 7 +- includes/polling/device-unix.inc.php | 2 +- map.php | 103 ++++++++------------------- poll-device.php | 12 +++- process-syslog.php | 5 +- test-discovery.php | 5 +- 13 files changed, 92 insertions(+), 120 deletions(-) diff --git a/addhost.php b/addhost.php index 7229160b6..90ab27855 100755 --- a/addhost.php +++ b/addhost.php @@ -18,10 +18,10 @@ if($argv[1] && $argv[2] && $argv[3]) { if ( isPingable($argv[1])) { if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) { $snmphost = trim(`snmpget -Oqv -$snmpver -c $community $host:$port sysName.0 | sed s/\"//g`); - var_dump($snmphost); +# var_dump($snmphost); if ($snmphost == $host || $hostshort = $host) { $return = createHost ($host, $community, $snmpver, $port); - var_dump($return); +# var_dump($return); if($return) { echo($return . "\n"); } else { echo("Adding $host failed\n"); } } else { echo("Given hostname does not match SNMP-read hostname!\n"); } } else { echo("Already got host $host\n"); } diff --git a/discover-cdp.php b/discover-cdp.php index 1322d473e..fc86c4802 100755 --- a/discover-cdp.php +++ b/discover-cdp.php @@ -4,24 +4,22 @@ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); ini_set('log_errors', 1); - ini_set('error_reporting', E_ALL); - + ini_set('error_reporting', E_WARNING); include("config.php"); include("includes/functions.php"); include("includes/cdp.inc.php"); -$device_query = mysql_query("SELECT * FROM `devices` WHERE `status` = '1' AND (`os` = 'IOS' OR `os` = 'IOS XE') ORDER BY `device_id` DESC"); +$device_query = mysql_query("SELECT * FROM `devices` WHERE `status` = '1' AND (`os` = 'IOS' OR `os` = 'IOS XE') AND hostname NOT LIKE '%bar%' ORDER BY `device_id` DESC"); while ($device = mysql_fetch_array($device_query)) { $hostname = $device['hostname']; $community = $device['community']; - echo("Discovering $hostname \n"); $id = $device['device_id']; $host = $id; - echo("Detecting CDP neighbours on $device[1]...\n"); + echo("\nDetecting CDP neighbours on $device[1]...\n"); $snmp = new snmpCDP($hostname, $community); $ports = $snmp->getports(); $cdp = $snmp->explore_cdp($ports); @@ -35,6 +33,9 @@ while ($device = mysql_fetch_array($device_query)) { } $cdp_links = trim($cdp_links); + + echo("\n$cdp_links\n\n"); + foreach ( explode("\n" ,$cdp_links) as $link ) { if ($link == "") { break; } list($src_host,$src_if, $dst_host, $dst_if) = explode(",", $link); @@ -42,33 +43,39 @@ while ($device = mysql_fetch_array($device_query)) { $dst_if = strtolower($dst_if); $src_host = strtolower($src_host); $src_if = strtolower($src_if); - if ( isDomainResolves($dst_host . "." . $config['mydomain']) ) { - $dst_host = $dst_host . "." . $config['mydomain']; - } +# if ( isDomainResolves($dst_host . "." . $config['mydomain']) ) { +# $dst_host = $dst_host . "." . $config['mydomain']; +# } $ip = gethostbyname($dst_host); if ( match_network($config['nets'], $ip) ) { - if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$dst_host'"), 0) == '0' ) { - createHost ($dst_host, $community, "v2c"); + if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `sysName` = '$dst_host'"), 0) == '0' ) { + echo("++ Creating: $dst_host \n"); + #createHost ($dst_host, $community, "v2c"); } else { - #echo("Already got host $dst_host\n"); + echo(".. Already got host $dst_host\n"); } - } else { echo("Bad DNS for $dst_host\n"); } - if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$dst_host'"), 0) == '1' && + } else { + #echo("!! Bad DNS for $dst_host\n"); + } + + if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `sysName` = '$dst_host'"), 0) == '1' && mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$src_host'"), 0) == '1' && - mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$dst_if' AND hostname = '$dst_host' AND D.device_id = I.device_id"), 0) == '1' && + mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$dst_if' AND sysName = '$dst_host' AND D.device_id = I.device_id"), 0) == '1' && mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$src_if' AND hostname = '$src_host' AND D.device_id = I.device_id"), 0) == '1') - { - $dst_if_id = mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$dst_if' AND hostname = '$dst_host' AND D.device_id = I.device_id"), 0); + { + $dst_if_id = mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$dst_if' AND sysName = '$dst_host' AND D.device_id = I.device_id"), 0); $src_if_id = mysql_result(mysql_query("SELECT I.interface_id FROM `interfaces` AS I, `devices` AS D WHERE `ifDescr` = '$src_if' AND hostname = '$src_host' AND D.device_id = I.device_id"), 0); $linkalive[] = $src_if_id . "," . $dst_if_id; if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `links` WHERE `dst_if` = '$dst_if_id' AND `src_if` = '$src_if_id'"),0) == '0') { $sql = "INSERT INTO `links` (`src_if`, `dst_if`, `cdp`) VALUES ('$src_if_id', '$dst_if_id', '1')"; mysql_query($sql); - echo("Creating Link : $src_host $src_if -> $dst_host $dst_if\n"); + echo("++ Creating Link : $src_host $src_if -> $dst_host $dst_if\n"); } else { - #echo("Link already exists : $src_host $src_if -> $dst_host $dst_if\n "); + echo(".. Existing Link : $src_host $src_if -> $dst_host $dst_if\n "); } + } else { + } } } diff --git a/generate-map.sh b/generate-map.sh index db72a0ac7..be7839f2b 100755 --- a/generate-map.sh +++ b/generate-map.sh @@ -1,4 +1,4 @@ #!/bin/bash -./map.php > map.dot && unflatten -l5 -f map.dot | fdp -Tpng -o html/network-big.png && convert -resize 400x500 html/network-big.png html/network.png -./map.php > map.dot && unflatten -l5 -f map.dot | circo -Tpng -o html/network-big.png && convert -resize 900x2000 html/network-big.png html/network-screen.png +./map.php > map.dot && unflatten -l5 -f map.dot | dot -Tpng -o html/network-big.png && convert -resize 400x500 html/network-big.png html/network.png +#./map.php > map.dot && unflatten -l5 -f map.dot | circo -Tpng -o html/network-screen-big.png && convert -resize 900x2000 html/network-screen-big.png html/network-screen.png diff --git a/html/.htaccess b/html/.htaccess index c54fee3bc..df5745186 100644 --- a/html/.htaccess +++ b/html/.htaccess @@ -19,8 +19,8 @@ RewriteRule ^interfaces/(.+)/ ?page=interfaces&type=$1 RewriteRule ^bill/([0-9]+) ?page=bills&bill=$1 -RewriteRule ^device/([0-9]+)/([a-z]+)/([a-z]+)/([a-z]+)/ ?page=device&id=$1§ion=$2&opta=$3&optb=$4 -RewriteRule ^device/([0-9]+)/([a-z]+)/([a-z]+)/ ?page=device&id=$1§ion=$2&opta=$3 +RewriteRule ^device/([0-9]+)/([a-z]+)/([a-z]+)/([a-z|0-9]+)/ ?page=device&id=$1§ion=$2&opta=$3&optb=$4 +RewriteRule ^device/([0-9]+)/([a-z]+)/([a-z|0-9]+)/ ?page=device&id=$1§ion=$2&idb=$3 RewriteRule ^device/([0-9]+)/([a-z]+)/ ?page=device&id=$1§ion=$2 RewriteRule ^device/([0-9]+) ?page=device&id=$1 diff --git a/html/includes/print-interface.inc b/html/includes/print-interface.inc index 597cf1b70..ca238ff25 100644 --- a/html/includes/print-interface.inc +++ b/html/includes/print-interface.inc @@ -71,20 +71,21 @@ formatRates($interface['out_rate']) . ""); } - echo(""); + echo(""); if($ifSpeed && $ifSpeed != "") { echo("$ifSpeed"); } echo("
"); # if($interface[ifDuplex] != unknown) { echo("Duplex " . $interface['ifDuplex'] . ""); } else { echo("-"); } - if($device['os'] == "IOS") { + if($device['os'] == "IOS" || $device['os'] == "IOS XE") { - if($interface['ifTrunk']) { echo("" . $interface['ifTrunk'] . ""); - } elseif ($interface['ifVlan']) { echo("VLAN " . $interface['ifVlan'] . ""); + if($interface['ifTrunk']) { + echo("" . $interface['ifTrunk'] . ""); + } elseif ($interface['ifVlan']) { + echo("VLAN " . $interface['ifVlan'] . ""); } elseif ($interface['ifVrf']) { $vrf = mysql_fetch_array(mysql_query("SELECT * FROM vrfs WHERE vrf_id = '".$interface['ifVrf']."'")); echo("" . $vrf['vrf_name'] . ""); - } - + } } diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index a7eb6dd62..019790973 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -1,16 +1,14 @@ = "5" && is_file($config['rancid_configs'] . $device['hostname'])) { - $file = $config['rancid_configs'] . $device['hostname']; $fh = fopen($file, 'r') or die("Can't open file"); - echo(highlight_string(fread($fh, filesize($file)))); + $text = fread($fh, filesize($file)); + echo(highlight_string($text)); fclose($fh); - } else { - print_error("Error : Insufficient access."); - } + ?> diff --git a/includes/discovery/temperatures.php b/includes/discovery/temperatures.php index b5fa431ca..ed4c4c60d 100755 --- a/includes/discovery/temperatures.php +++ b/includes/discovery/temperatures.php @@ -65,7 +65,7 @@ ## Dell Temperatures if(strstr($device['hardware'], "Dell")) { echo("Dell OMSA "); - $oids = `snmpwalk -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8`; + $oids = shell_exec($config['snmpwalk'] . " -v2c -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8"); $oids = trim($oids); foreach(explode("\n",$oids) as $oid) { $oid = substr(trim($oid), 36); diff --git a/includes/functions.php b/includes/functions.php index c60a008ca..29ab3b0c8 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -264,7 +264,8 @@ function generateiflink($interface, $text=0,$type=bits) if(!$type) { $type = 'bits'; } $class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']); $graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=120&type=" . $type; - $link = ""; if($interface['ifAlias']) { $link .= "
" . $interface['ifAlias']; } @@ -282,7 +283,7 @@ function generatedevicelink($device, $text=0, $start=0, $end=0) $class = devclass($device); if(!$text) { $text = $device['hostname']; } $graph_url = "graph.php?host=" . $device['device_id'] . "&from=$start&to=$end&width=400&height=120&type=cpu"; - $link = "
".$device['hostname']." - CPU Load"; $link .= "'".$config['overlib_defaults'].", LEFT);\" onmouseout=\"return nd();\">$text"; return $link; @@ -603,7 +604,7 @@ function createHost ($host, $community, $snmpver, $port = 161){ $host = trim(strtolower($host)); $host_os = getHostOS($host, $community, $snmpver, $port); if($host_os) { - $sql = mysql_query("INSERT INTO `devices` (`hostname`, `community`, `port`, `os`, `status`) VALUES ('$host', '$community', '$port', '$host_os', '1')"); + $sql = mysql_query("INSERT INTO `devices` (`hostname`, `sysName`, `community`, `port`, `os`, `status`) VALUES ('$host', '$host', '$community', '$port', '$host_os', '1')"); if(mysql_affected_rows()) { return("Created host : $host ($host_os)"); } else { return FALSE; } diff --git a/includes/polling/device-unix.inc.php b/includes/polling/device-unix.inc.php index 956f04bc8..97c2e606c 100755 --- a/includes/polling/device-unix.inc.php +++ b/includes/polling/device-unix.inc.php @@ -42,7 +42,7 @@ if(is_file($Osysrrd) && !is_file($sysrrd)) { rename($Osysrrd, $sysrrd); echo("Mo list(,,$version) = explode (" ", $sysDescr); if(strstr($sysDescr, "386")|| strstr($sysDescr, "486")||strstr($sysDescr, "586")||strstr($sysDescr, "686")) { $hardware = "Generic x86"; } if(strstr($sysDescr, "x86_64")) { $hardware = "Generic x86 64-bit"; } - $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']. " .1.3.6.1.4.1.2021.7890.1.101.1"; + $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']. " .1.3.6.1.4.1.2021.7890.1.3.1.1.6.100.105.115.116.114.111"; $features = trim(`$cmd`); $features = str_replace("No Such Object available on this agent at this OID", "", $features); $features = str_replace("\"", "", $features); diff --git a/map.php b/map.php index 31ce6a668..d23d71de4 100755 --- a/map.php +++ b/map.php @@ -4,9 +4,9 @@ include("config.php"); include("includes/functions.php"); -echo("digraph G { sep=0.5; size=\"40,30\"; pack=15; bgcolor=transparent;splines=true; - node [ fontname=\"times roman\", fontsize=24, fontstyle=bold, shape=box, style=bold]; - edge [ labelfontsize=14, labelfontname=\"times roman\", overlap=false]; +echo("digraph G { sep=0.1; size=\"40,20\"; pack=10; bgcolor=transparent;splines=true; + node [ fontname=\"helvetica\", fontsize=38, fontstyle=bold, shape=box, style=bold]; + edge [ labelfontsize=10, labelfontname=\"helvetica\", overlap=false, fontstyle= bold]; graph [bgcolor=transparent, remincross=true]; "); @@ -15,7 +15,7 @@ $linkdone = array(); $x = 1; -$loc_sql = "SELECT * FROM links AS L, interfaces AS I, interfaces AS X, devices as D WHERE I.device_id = D.device_id AND L.src_if = I.interface_id GROUP BY D.location ORDER BY D.device_id ASC"; +$loc_sql = "SELECT * FROM devices GROUP BY location"; $loc_result = mysql_query($loc_sql); while($loc_data = mysql_fetch_array($loc_result)) { @@ -24,90 +24,45 @@ while($loc_data = mysql_fetch_array($loc_result)) { style=filled; color=lightgrey;\n\n"); - $dev_sql = "SELECT * FROM links AS L, interfaces AS I, interfaces AS X, devices as D WHERE D.location = '" . $loc_data['location'] . "' AND I.device_id = D.device_id AND L.src_if = I.interface_id GROUP BY D.hostname"; + $dev_sql = "SELECT * FROM devices WHERE location = '" . $loc_data['location'] . "' and `os` LIKE '%IOS%' and disabled = 0"; $dev_result = mysql_query($dev_sql); while($dev_data = mysql_fetch_array($dev_result)) { + $device_id = $dev_data['device_id']; + +# if(mysql_result(mysql_query("SELECT count(*) from links WHERE src_if = '$device_id' OR dst_if = '$device_id'"),0)) { $host = $dev_data['hostname']; unset($hostinfo); if(strpos($host, "cust." . $config['mydomain'])) { $hostinfo = "shape=egg style=filled fillcolor=pink"; } - elseif(strpos($host, $config['mydomain'])) { - if(strpos($host, "-sw")||strpos($host, "-cs")) { $hostinfo = "shape=rectangle style=filled fillcolor=skyblue"; } - if(strpos($host, "-gw")||strpos($host, "-pe")||strpos($host, "-er")) { $hostinfo = "shape=ellipse style=filled fillcolor=darkolivegreen3"; } - if(strpos($host, "-lns")) { $hostinfo = "shape=egg style=filled fillcolor=darkolivegreen4"; } - } else { $hostinfo = "style=filled shape=circle fillcolor=lightgray"; } + if(strpos($host, "bas")) { $hostinfo = "shape=rectangle style=filled fillcolor=skyblue"; } + if(strpos($host, "crs")) { $hostinfo = "shape=box3d style=filled fillcolor=skyblue"; } + if(strpos($host, "ler")) { $hostinfo = "shape=tripleoctagon style=filled fillcolor=darkolivegreen3"; } + if(strpos($host, "pbr")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; } + if(strpos($host, "tbr")) { $hostinfo = "shape=ellipse style=filled fillcolor=red"; } + if(strstr($host, "gw")) { $hostinfo = "shape=rect style=filled fillcolor=orange"; } + if(strpos($host, "bar")) { $hostinfo = "shape=egg style=filled fillcolor=darkolivegreen4"; } + #} else { $hostinfo = "style=filled shape=circle fillcolor=lightgray"; } $host = $dev_data[hostname]; $host = str_replace("." . $config['mydomain'],"", $host); echo("\"$host\" [$hostinfo] - "); + "); + # } + } - $links_sql = "SELECT *, X.ifDescr AS sif, I.ifDescr AS dif FROM links AS L, interfaces AS I, interfaces AS X, devices as D, devices as Y WHERE I.device_id = D.device_id AND X.device_id = Y.device_id AND L.src_if = I.interface_id AND X.interface_id = L.dst_if AND D.location = '" . $loc_data['location'] . "' AND D.location = Y.location ORDER BY D.location DESC"; - $links_result = mysql_query($links_sql); - while($link_data = mysql_fetch_array($links_result)) { - - $src_if = $link_data['src_if']; - $dst_if = $link_data['dst_if']; - - $sq = mysql_fetch_row(mysql_query("SELECT `hostname`,`ifSpeed` FROM interfaces AS I, devices as D where I.device_id = D.device_id and I.interface_id = '$src_if'")); - $dq = mysql_fetch_row(mysql_query("SELECT `hostname`,`ifSpeed` FROM interfaces AS I, devices as D where I.device_id = D.device_id and I.interface_id = '$dst_if'")); - - $src = $sq[0]; - $dst = $dq[0]; - - $src_speed = $sq[1]; - $dst_speed = $dq[1]; - - $src = str_replace("." . $config['mydomain'], "", $src); - $dst = str_replace("." . $config['mydomain'], "", $dst); - - $info = ""; - - if($src_speed >= "10000000000") { - $info .= "color=darkred weight=10 style=\"setlinewidth(16)\""; - } elseif ($src_speed >= "1000000000") { - $info .= "color=navyblue weight=5 style=\"setlinewidth(8)\""; - } elseif ($src_speed >= "100000000") { - $info .= "color=darkgreen weight=1 style=\"setlinewidth(4)\""; - } elseif ($src_speed >= "10000000") { - $info .= "style=\"setlinewidth(2)\" weight=1"; - } - - unset($die); - - $i = 0; - while ($i < count($linkdone)) { - $thislink = "$dst $link_data[dif] $src $link_data[sif]"; - if ($linkdone[$i] == $thislink) { $die = "yes"; } - $i++; - } - - $sif = makeshortif($link_data[sif]); - $dif = makeshortif($link_data[dif]); - - if(!$die){ -# echo("\"$src\" -> \"$dst\" [taillabel=\"$dif\" headlabel=\"$sif\" arrowhead=none arrowtail=none $info];\n"); - echo("\"$src\" -> \"$dst\" [ arrowhead=none arrowtail=none $info];\n"); - $linkdone[] = "$src $link_data[sif] $dst $link_data[dif]"; - $x++; - } - } - echo("\n}\n"); } -#echo("\"thnlon-pe01\" -> \"thelon-cs01\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(8)\"];\n"); -#echo("\"thnlon-pe01\" -> \"thelon-cs02\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(8)\"];\n"); - -#echo("\"Internet\" -> \"thelon-pe01\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(8)\"];\n"); -#echo("\"Internet\" -> \"thelon-pe02\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(8)\"];\n"); -#echo("\"Internet\" -> \"thnlon-pe01\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(8)\"];\n"); +echo("\"Internet\" -> \"je.cen.pbr02\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(4)\"];\n"); +echo("\"Internet\" -> \"je.cen.pbr01\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(4)\"];\n"); +echo("\"Internet\" -> \"uk.thn.tbr01\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(4)\"];\n"); #echo("\"ADSL\" -> \"thnlon-pe01\" [ arrowhead=none arrowtail=none color=navyblue weight=5 style=\"setlinewidth(8)\"];\n"); -$links_sql = "SELECT *, X.ifDescr AS sif, I.ifDescr AS dif FROM links AS L, interfaces AS I, interfaces AS X, devices as D, devices as Y WHERE D.hostname LIKE '%vostron.net' AND I.device_id = D.device_id AND X.device_id = Y.device_id AND D.hostname NOT LIKE '%cust%' AND L.src_if = I.interface_id AND X.interface_id = L.dst_if AND D.location != Y.location AND D.hostname NOT LIKE '%cust.vostron.net' AND Y.hostname NOT LIKE '%cust.vostron.net' ORDER BY D.location DESC"; +$links_sql = "SELECT *, X.ifDescr AS sif, I.ifDescr AS dif FROM links AS L, interfaces AS I, interfaces AS X, devices as D, devices as Y WHERE I.device_id = D.device_id AND X.device_id = Y.device_id AND L.src_if = I.interface_id AND X.interface_id = L.dst_if"; + $links_result = mysql_query($links_sql); while($link_data = mysql_fetch_array($links_result)) { @@ -129,13 +84,13 @@ while($link_data = mysql_fetch_array($links_result)) { $info = ""; if($src_speed >= "10000000000") { - $info .= "color=darkred weight=10 style=\"setlinewidth(16)\""; + $info .= "color=lightred weight=10 style=\"setlinewidth(8)\""; } elseif ($src_speed >= "1000000000") { - $info .= "color=navyblue weight=5 style=\"setlinewidth(8)\""; + $info .= "color=lightblue weight=5 style=\"setlinewidth(4)\""; } elseif ($src_speed >= "100000000") { - $info .= "color=darkgreen weight=1 style=\"setlinewidth(4)\""; + $info .= "color=lightgrey weight=1 style=\"setlinewidth(2)\""; } elseif ($src_speed >= "10000000") { - $info .= "style=\"setlinewidth(2)\" weight=1"; + $info .= "style=\"setlinewidth(1)\" weight=1"; } unset($die); @@ -151,7 +106,7 @@ while($link_data = mysql_fetch_array($links_result)) { $dif = makeshortif($link_data[dif]); if(!$die){ - echo("\"$src\" -> \"$dst\" [taillabel=\"$dif\" headlabel=\"$sif\" arrowhead=none arrowtail=none $info];\n"); + echo("\"$src\" -> \"$dst\" [taillabel=\"$dif\" headlabel=\"$sif\" arrowhead=dot arrowtail=dot $info];\n"); # echo("\"$src\" -> \"$dst\" [ arrowhead=none arrowtail=none $info];\n"); $linkdone[] = "$src $link_data[sif] $dst $link_data[dif]"; $x++; diff --git a/poll-device.php b/poll-device.php index a35874c79..572039231 100755 --- a/poll-device.php +++ b/poll-device.php @@ -57,7 +57,7 @@ while ($device = mysql_fetch_array($device_query)) { $uptimeoid = "1.3.6.1.2.1.1.3.0"; } $snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; - $snmp_cmd .= " $uptimeoid sysLocation.0 sysContact.0"; + $snmp_cmd .= " $uptimeoid sysLocation.0 sysContact.0 sysName.0"; #$snmp_cmd .= " | grep -v 'Cisco Internetwork Operating System Software'"; if($device['os'] == "IOS" || $device['os'] == "IOS XE") { $snmp_cmdb = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; @@ -70,7 +70,7 @@ while ($device = mysql_fetch_array($device_query)) { # $snmpdata = preg_replace("/^.*IOS/","", $snmpdata); $snmpdata = trim($snmpdata); $snmpdata = str_replace("\"", "", $snmpdata); - list($sysUptime, $sysLocation, $sysContact) = explode("\n", $snmpdata); + list($sysUptime, $sysLocation, $sysContact, $sysName) = explode("\n", $snmpdata); $sysDescr = trim(shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " sysDescr.0")); $sysUptime = str_replace("(", "", $sysUptime); $sysUptime = str_replace(")", "", $sysUptime); @@ -167,6 +167,14 @@ while ($device = mysql_fetch_array($device_query)) { echo("$update\n"); + $sysName = strtolower($sysName); + + if ( $sysName && $sysName != $device['sysName'] ) { + $update .= $seperator . "`sysName` = '$sysName'"; + $seperator = ", "; + mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'sysName -> $sysName')"); + } + if ( $sysDescr && $sysDescr != $device['sysDescr'] ) { $update .= $seperator . "`sysDescr` = '$sysDescr'"; $seperator = ", "; diff --git a/process-syslog.php b/process-syslog.php index e439f2688..7c74057c2 100755 --- a/process-syslog.php +++ b/process-syslog.php @@ -4,9 +4,8 @@ include("config.php"); include("includes/functions.php"); -mysql_query("DELETE FROM `syslog` WHERE `msg` LIKE '%last message repeated%'"); -mysql_query("DELETE FROM `syslog` WHERE `msg` LIKE '%Connection from UDP: [89.21.224.44]:%'"); -mysql_query("DELETE FROM `syslog` WHERE `msg` LIKE '%Connection from UDP: [89.21.224.35]:%'"); +mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%last message repeated%'"); +mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Connection from UDP: [%]:%'"); if(!$config['enable_syslog']) { diff --git a/test-discovery.php b/test-discovery.php index df2c67089..438c07e19 100755 --- a/test-discovery.php +++ b/test-discovery.php @@ -38,7 +38,10 @@ while ($device = mysql_fetch_array($device_query)) { # include("includes/discovery/cisco-physical.php"); # include("includes/discovery/ipv6-addresses.php"); - include("includes/discovery/cisco-pw.php"); +# include("includes/discovery/cisco-pw.php"); + + include("includes/discovery/host-physical.php"); + echo("\n"); $devices_polled++; }