Lots of nice new things! Yum.

git-svn-id: http://www.observium.org/svn/observer/trunk@220 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-04-03 19:04:24 +00:00
parent 77c0647062
commit 4e10de77a7
13 changed files with 281 additions and 35 deletions

114
config.php Executable file
View File

@@ -0,0 +1,114 @@
<?php
### Database config
$config['db_host'] = "localhost";
$config['db_user'] = "observer";
$config['db_pass'] = "password";
$config['db_name'] = "observer";
### Installation Location
$config['install_dir'] = "/opt/observer/";
$config['html_dir'] = $config['install_dir'] . "html";
$config['rrd_dir'] = $config['install_dir'] . "rrd";
$rrd_dir = $config['rrd_dir'];
$config['mibs_dir'] = "/usr/share/snmp/mibs/";
### Default community
$config['community'] = "v05tr0n82";
$community = $config['community'];
$config['base_url'] = "http://dev.project-observer.org";
### Location of executables
$config['sipcalc'] = "/usr/bin/sipcalc";
$config['rrdtool'] = "/usr/bin/rrdtool";
$rrdtool = $config['rrdtool'];
$config['fping'] = "/usr/sbin/fping";
$fping = $config['fping'];
$config['ipcalc'] = "/usr/bin/ipcalc";
$ipcalc = $config['ipcalc'];
$config['snmpwalk'] = "/usr/bin/snmpwalk";
$snmpwalk = $config['snmpwalk'];
$config['snmpget'] = "/usr/bin/snmpget";
$snmpget = $config['snmpget'];
### RRDGraph Settings
# Set the general colours and other settings for rrdtool graphs
$config['rrdgraph_defaults'] = array("-c", "BACK#FFFFFF", "-c", "SHADEA#E5E5E5", "-c", "SHADEB#E5E5E5",
"-c", "FONT#000000", "-c", "CANVAS#FFFFFF", "-c", "GRID#aaaaaa",
"-c", "MGRID#FFAAAA", "-c", "FRAME#5e5e5e", "-c", "ARROW#5e5e5e",
"-R", "normal");
$config['overlib_defaults'] = ",FGCOLOR,'#e5e5e5', BGCOLOR, '#e5e5e5'";
### List of networks to allow scanning-based discovery
## This should probably be set to just the IP space you own!
$config['nets'] = array ("89.21.224.0/19", "10.0.0.0/8", "172.22.0.0/16", "213.253.1.0/24");
### Your domain name and specifics
$config['mydomain'] = "vostron.net";
$config['header_color'] = "#163275";
$config['page_title'] = "Observer Test Install";
$config['title_image'] = "images/observer-header.png";
$config['stylesheet'] = "css/styles.css";
$config['mono_font'] = $config['install_dir'] . "/fonts/DejaVuSansMono.ttf";
$mono_font = $config['mono_font'];
$config['favicon'] = "favicon.ico";
$config['page_refresh'] = "60"; ## Refresh the page every xx seconds
$config['email_default'] = "you@yourdomain";
$config['email_from'] = "Observer <observer@yourdomain>";
$config['email_headers'] = "From: " . $config['email_from'] . "\r\n";
### Which interface sections should we show?
$config['int_customers'] = 1; # Enable Customer Port Parsing
$config['int_transit'] = 1; # Enable Transit Types
$config['int_peering'] = 1; # Enable Peering Types
$config['int_core'] = 1; # Enable Core Port Types
$config['int_l2tp'] = 1; # Enable L2TP Port Types
$config['show_locations'] = 1; # Enable Locations on menu
### Which additional features should we enable?
$config['enable_bgp'] = 1; # Enable BGP session collection and display
$config['enable_syslog'] = 1; # Enable Syslog
## If a syslog entry contails these strings it is deleted from the database
$config['syslog_filter'] = array("last message repeated", "Connection from UDP: [127.0.0.1]:");
$config['syslog_age'] = "1 month"; ## Time to keep syslog for in
## MySQL DATE_SUB format (eg '1 day', '1 month')
### Interface name strings to ignore
$config['bad_if'] = array("null", "virtual-", "unrouted", "eobc", "mpls", "sl0", "lp0", "faith0",
"-atm layer", "-atm subif", "-shdsl", "-adsl", "-aal5", "-atm",
"async", "plip", "-physical", "-signalling", "control plane",
"bri", "-bearer", "ng", "bluetooth", "isatap", "ras", "qos", "miniport");
### Mountpoints to ignore
$config['ignore_mount'] = array("/kern", "/mnt/cdrom", "/dev", "/dev/pts", "/proc/bus/usb");
### Style Options
$list_colour_a = "#ffffff";
$list_colour_b = "#e5e5e5";
$warn_colour_a = "#ffeeee";
$warn_colour_b = "#ffcccc";
?>

50
discovery-test.php Executable file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/php
<?php
include("config.php");
include("includes/functions.php");
$start = utime();
### Observer Device Discovery
echo("Observer v".$config['version']." Discovery\n\n");
if($argv[1] == "--device" && $argv[2]) {
$where = "AND `device_id` = '".$argv[2]."'";
} elseif ($argv[1] == "--os") {
$where = "AND `os` = '".$argv[2]."'";
} elseif ($argv[1] == "--odd") {
$where = "AND MOD(device_id,2) = 1";
} elseif ($argv[1] == "--even") {
$where = "AND MOD(device_id,2) = 0";
} elseif ($argv[1] == "--all") {
$where = "";
} else {
echo("--device <device id> Poll single device\n");
echo("--os <os string> Poll all devices of a given OS\n");
echo("--all Poll all devices\n\n");
echo("No polling type specified!\n");
exit;
}
$devices_polled = 0;
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id DESC");
while ($device = mysql_fetch_array($device_query)) {
echo($device['hostname'] ."\n");
include("includes/discovery/unix-memory.php");
echo("\n"); $devices_polled++;
}
$end = utime(); $run = $end - $start;
$proctime = substr($run, 0, 5);
echo("$devices_polled devices polled in $proctime secs\n");
?>

View File

@@ -49,13 +49,16 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/discovery/storage.php");
}
if($device['os'] == "Netscreen") {
}
if($device['os'] == "IOS") {
include("includes/discovery/cisco-vlans.php");
include("includes/discovery/cisco-physical.php");
include("includes/discovery/bgp-peers.php");
}
echo("\n"); $devices_polled++;
}

View File

@@ -15,6 +15,8 @@ RewriteRule ^devices/alerted/ ?page=devices&status=alerted
RewriteRule ^devices/alerted/ ?page=devices&status=alerted
RewriteRule ^devices/(.+)/ ?page=devices&type=$1
RewriteRule ^interfaces/(.+)/ ?page=interfaces&type=$1
RewriteRule ^bill/([0-9]+) ?page=bills&bill=$1
RewriteRule ^device/([0-9]+) ?page=device&id=$1

View File

@@ -123,7 +123,7 @@ if($_SESSION['userlevel'] >= '5') {
if($config['int_core']) { echo("<li><a href='?page=iftype&type=core'><img src='images/16/brick_link.png' border=0 align=absmiddle> Core</a></li>"); $ifbreak = 1;}
}
if($ifbreak && $interface_alerts) { echo("<li><hr width=140 /></li>"); }
if($ifbreak) { echo("<li><hr width=140 /></li>"); }
if($interface_alerts) {
echo("<li><a href='?page=interfaces&status=0'><img src='images/16/link_error.png' border=0 align=absmiddle> Alerts ($interface_alerts)</a></li>");
@@ -131,6 +131,9 @@ echo("<li><a href='?page=interfaces&status=0'><img src='images/16/link_error.png
?>
<li><a href='interfaces/down/'><img src='images/16/if-disconnect.png' border=0 align=absmiddle> Down Ports</a></li>
<li><a href='interfaces/admindown/'><img src='images/16/if-disable.png' border=0 align=absmiddle> Disabled Ports</a></li>
</ul></td></tr></table>
<!--[if lte IE 6]></a><![endif]-->

View File

@@ -1,23 +1,28 @@
<?php
function generate_front_box ($type, $content) {
echo("<div style='float: left; padding: 5px; width: 135px; margin: 0px;'>
<b class='box-".$type."'>
<b class='box-".$type."1'><b></b></b>
<b class='box-".$type."2'><b></b></b>
<b class='box-".$type."3'></b>
<b class='box-".$type."4'></b>
<b class='box-".$type."5'></b></b>
<div class='box-".$type."fg' style='height: 90px;'>
".$content."
</div>
<b class='box-".$type."'>
<b class='box-".$type."5'></b>
<b class='box-".$type."4'></b>
<b class='box-".$type."3'></b>
<b class='box-".$type."2'><b></b></b>
<b class='box-".$type."1'><b></b></b></b>
</div>");
echo("<div style=' background: transparent url(/images/box-$type.png) no-repeat; display: block; height: 84px; width: 119px; padding: 8px; margin: 5px; float: left;'>
$content
</div>");
# echo("<div style='float: left; padding: 5px; width: 135px; margin: 0px;'>
# <b class='box-".$type."'>
# <b class='box-".$type."1'><b></b></b>
# <b class='box-".$type."2'><b></b></b>
# <b class='box-".$type."3'></b>
# <b class='box-".$type."4'></b>
# <b class='box-".$type."5'></b></b>
# <div class='box-".$type."fg' style='height: 90px;'>
# ".$content."
# </div>
# <b class='box-".$type."'>
# <b class='box-".$type."5'></b>
# <b class='box-".$type."4'></b>
# <b class='box-".$type."3'></b>
# <b class='box-".$type."2'><b></b></b>
# <b class='box-".$type."1'><b></b></b></b>
# </div>");
}
echo("<div style='width: 875px; float: left; padding: 3px 10px; background: #fff;'>");
@@ -25,12 +30,10 @@ echo("<div style='width: 875px; float: left; padding: 3px 10px; background: #fff
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while($device = mysql_fetch_array($sql)){
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>
<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
generate_front_box("alert", "<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span>
<span class=body-date-1>".truncate($device['location'], 20)."</span>
</center></div>");
</center>");
}
@@ -75,7 +78,7 @@ while($device = mysql_fetch_array($sql)){
generate_front_box("info", "<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />
<span class=body-date-1>".formatUptime($device['attrib_value'])."</span>
</center>");

View File

@@ -1,11 +1,20 @@
<?php
if ($_SESSION['userlevel'] >= '5') {
#if ($_SESSION['userlevel'] >= '5') {
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
} else {
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
#} else {
# $sql = "SELECT * FROM `interfaces` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
#}
if($_GET['type'] == "down") {
$where = "AND I.ifAdminStatus = 'up' AND I.ifOperStatus = 'down'";
} elseif ($_GET['type'] == "admindown") {
$where = "AND I.ifAdminStatus = 'down'";
}
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id $where ORDER BY D.hostname, I.ifDescr";
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
@@ -25,6 +34,7 @@ while($interface = mysql_fetch_array($query)) {
$error_img = generateiflink($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
if( interfacepermitted($interface['interface_id']) ) {
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generatedevicelink($interface) . "</td>
@@ -36,6 +46,8 @@ while($interface = mysql_fetch_array($query)) {
$row++;
}
}
echo("</table>");

View File

@@ -111,11 +111,11 @@ function interfacepermitted($interface_id) {
global $_SESSION;
if($_SESSION['userlevel'] >= "5") {
$allowed = true;
$allowed = TRUE;
} elseif ( devicepermitted(mysql_result(mysql_query("SELECT device_id FROM interface WHERE interface_id = '$interface_id'"),0))) {
$allowed = true;
$allowed = TRUE;
} elseif ( @mysql_result(mysql_query("SELECT count(*) FROM interface_perms WHERE `user_id` = '" . $_SESSION['user_id'] . "' AND `interface_id` = $interface_id"), 0) > '0') {
$allowed = true;
$allowed = TRUE;
} else { $allowed = FALSE; }
return $allowed;
}

View File

@@ -2,8 +2,8 @@
if(!$os) {
$sysObjectId = shell_exec($config['snmpget'] . " -Ovq -m ".$config['installdir']."/mibs/NS-PRODUCTS.mib -v2c -c ". $community ." ". $hostname ." .1.3.6.1.2.1.1.2.0");
if(strstr($sysObjectId, "netscreen")) { $os = "Netscreen"; }
$sysObjectId = shell_exec($config['snmpget'] . " -Ovq -m ".$config['mibs_dir']."/NS-PRODUCTS.mib -v2c -c ". $community ." ". $hostname ." .1.3.6.1.2.1.1.2.0");
if(strstr($sysObjectId, "netscreen")) { $os = "ScreenOS"; }
}

View File

@@ -1,6 +1,6 @@
<?
echo("doing SCREENOS");
echo("Doing Juniper Netscreen ScreenOS");
$cpurrd = $rrd_dir . "/" . $device['hostname'] . "/netscreen-cpu.rrd";
$memrrd = $rrd_dir . "/" . $device['hostname'] . "/netscreen-memory.rrd";

View File

@@ -241,7 +241,7 @@ function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $verti
$database = $rrd_dir . "/" . $rrd;
$imgfile = "graphs/" . "$graph";
$period = $to - $from;
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
$options = "-l 0 --alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") { $options .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal "; }
$options .= " DEF:user=$database:user:AVERAGE";
$options .= " DEF:nice=$database:nice:AVERAGE";

55
ipv6.php Executable file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/php
<?php
include("config.php");
include("includes/functions.php");
$sql = "SELECT * FROM devices WHERE device_id LIKE '%$argv[1]' AND status = '1' AND os != 'Snom' order by device_id DESC";
$q = mysql_query($sql);
while ($device = mysql_fetch_array($q)) {
echo("\n" . $device['hostname'] . " : ");
$oids = shell_exec("snmpwalk -v2c -c v05tr0n82 ".$device['hostname']." ipAddressIfIndex.ipv6 -Osq");
$oids = str_replace("ipAddressIfIndex.ipv6.", "", $oids); $oids = str_replace("\"", "", $oids); $oids = trim($oids);
foreach(explode("\n", $oids) as $data) {
$data = trim($data);
list($ipv6addr,$ifIndex) = explode(" ", $data);
$oid = "";
$sep = ''; $adsep = '';
unset($address);
$do = '0';
foreach(explode(":", $ipv6addr) as $part) {
$n = hexdec($part);
$oid = "$oid" . "$sep" . "$n";
$sep = ".";
$address = $address . "$adsep" . $part;
$do++;
if($do == 2) { $adsep = ":"; $do = '0'; } else { $adsep = "";}
}
$cidr = trim(shell_exec($config['snmpget']." -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." .1.3.6.1.2.1.4.34.1.5.2.16.$oid | sed 's/.*\.//'"));
$origin = trim(shell_exec($config['snmpget']." -Ovq -".$device['snmpver']." -c ".$device['community']." ".$device['hostname']." .1.3.6.1.2.1.4.34.1.6.2.16.$oid"));
$network = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Subnet | cut -f 2 -d '-'"));
$comp = trim(shell_exec($config['sipcalc']." $address/$cidr | grep Compressed | cut -f 2 -d '-'"));
if (mysql_result(mysql_query("SELECT count(*) FROM `interfaces` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $cidr > '0' && $cidr < '129' && $comp != '::1') {
$i_query = "SELECT interface_id FROM `interfaces` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'";
$interface_id = mysql_result(mysql_query($i_query), 0);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6addr` WHERE `addr` = '$address' AND `cidr` = '$cidr' AND `interface_id` = '$interface_id'"), 0) == '0') {
mysql_query("INSERT INTO `ip6addr` (`addr`, `comp_addr`, `cidr`, `origin`, `network`, `interface_id`) VALUES ('$address', '$comp', '$cidr', '$origin', '$network', '$interface_id')");
echo("+");
}
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6networks` WHERE `cidr` = '$network'"), 0) < '1') {
mysql_query("INSERT INTO `ip6networks` (`id`, `cidr`) VALUES ('', '$network')");
echo("N");
}
$network_id = @mysql_result(mysql_query("SELECT id from `ip6networks` WHERE `cidr` = '$network'"), 0);
if (match_network($nets, $address) && mysql_result(mysql_query("SELECT COUNT(*) FROM `ip6adjacencies` WHERE `network_id` = '$network_id' AND `interface_id` = '$interface_id'"), 0) < '1') {
mysql_query("INSERT INTO `ip6adjacencies` (`network_id`, `interface_id`) VALUES ('$network_id', '$interface_id')");
echo("A");
}
} else { echo("."); }
}
}
?>

View File

@@ -66,7 +66,10 @@ while ($device = mysql_fetch_array($device_query)) {
$ciscomodel = str_replace("\"", "", trim(`$snmp_cmdb`));
} else { unset($ciscomodel); }
echo("$snmp_cmd \n");
$snmpdata = shell_exec($snmp_cmd);
echo("completed");
$snmpdata = preg_replace("/^.*IOS/","", $snmpdata);
$snmpdata = trim($snmpdata);
$snmpdata = str_replace("\"", "", $snmpdata);
@@ -137,6 +140,7 @@ while ($device = mysql_fetch_array($device_query)) {
case "ScreenOS":
$version = preg_replace("/(.+)\ version\ (.+)\ \(SN:\ (.+)\,\ (.+)\)/", "Juniper Netscreen \\1||\\2||\\3||\\4", $sysDescr);
echo("$version\n");
list($hardware,$version,$serial,$features) = explode("||", $version);
include("includes/polling/device-screenos.inc.php");
break;