missing file!

git-svn-id: http://www.observium.org/svn/observer/trunk@199 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-03-23 21:32:54 +00:00
parent 7394b0c1db
commit 126fbc630d
11 changed files with 117 additions and 16 deletions

View File

@@ -59,6 +59,8 @@ $config['mono_font'] = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf"
$mono_font = $config['mono_font'];
$config['favicon'] = "favicon.ico";
$config['page_refresh'] = "30"; ## Refresh the page every xx seconds
$config['email_default'] = "adama@memetic.org";
$config['email_from'] = "Observer Dev <observer-dev@project-observer.org>";
$config['email_headers'] = "From: " . $config['email_from'] . "\r\n";
@@ -77,11 +79,16 @@ $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",
@@ -90,7 +97,7 @@ $config['bad_if'] = array("null", "virtual-", "unrouted", "eobc", "mpls", "sl0",
### Mountpoints to ignore
$config['ignore_mount'] = array("/kern", "/mnt/cdrom", "/dev", "/dev/pts");
$config['ignore_mount'] = array("/kern", "/mnt/cdrom", "/dev", "/dev/pts", "/proc/bus/usb");
### entPhysicalVendorType rewrites

View File

@@ -1,7 +1,8 @@
#!/bin/bash
./discovery.php
./discovery.php --even &
./discovery.php --odd &
./update-interface.php
./discover-cdp.php
./cleanup.php
./generate-map.sh
./update-interface.php
./check-errors.php

View File

@@ -10,9 +10,28 @@ $start = utime();
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'");
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where");
while ($device = mysql_fetch_array($device_query)) {
echo($device['hostname'] ."\n");

View File

@@ -136,7 +136,7 @@ echo("<li><a href='?page=interfaces&status=0'><img src='images/16/link_error.png
<!--[if lte IE 6]></a><![endif]-->
</li>
<li><a class="menu2four" href="?page=temperatures"><img src='images/16/flame.png' border=0 align=absmiddle> Temperatures</a></li>
<li><a class="menu2four" href="?page=temperatures"><img src='images/16/weather_sun.png' border=0 align=absmiddle> Temperatures</a></li>
<li><a class="menu2four" href="?page=storage"><img src='images/16/database.png' border=0 align=absmiddle> Storage</a></li>

View File

@@ -30,7 +30,9 @@ if($_GET[debug]) {
<title><?php echo("$page_title"); ?></title>
<base href="<?php echo($config['base_url']); ?>" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- <meta http-equiv="refresh" content="300"> -->
<?php
if($config['page_refresh']) { echo("<meta http-equiv='refresh' content='".$config['page_refresh']."'>"); }
?>
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="<?php echo($config['favicon']); ?>" />
<link rel="stylesheet" href="css/mktree.css" type="text/css">

View File

@@ -82,7 +82,7 @@ if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_h
echo("
<li class=" . $select['dev-temp'] . ">
<a href='?page=device&id=" . $device['device_id'] . "&section=dev-temp'>
<img src='images/16/flame.png' align=absmiddle border=0> Temps
<img src='images/16/weather_sun.png' align=absmiddle border=0> Temps
</a>
</li>
");

View File

@@ -9,7 +9,8 @@ if($_SESSION['userlevel'] >= '5') {
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2>");
echo("<div style='padding: 5px;'>
<table width=100% cellspacing=0 cellpadding=2>");
echo("<tr class=tablehead>
<th width=280>Device</th>
@@ -46,7 +47,7 @@ while($drive = mysql_fetch_array($query)) {
}
echo("</table>");
echo("</table></div>");
?>

View File

@@ -14,7 +14,16 @@
$temp = trim($temp);
list($descr, $units, $size, $type) = explode("\n", $temp);
list($units) = explode(" ", $units);
if(strstr($type, "FixedDisk") && $size > '0') {
$allow = 1;
foreach($config['ignore_mount'] as $bi) {
# echo("$descr == $bi\n");
if($descr == $bi) {
$allow = 0;
}
}
if(strstr($type, "FixedDisk") && $size > '0' && $allow) {
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'"),0) == '0') {
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) ";
$query .= "values ('".$device['device_id']."', '$hrStorageIndex', '$descr', '$size', '$units')";
@@ -30,7 +39,7 @@
} else { echo("."); }
}
$storage_exists[] = $device[device_id]." $hrStorageIndex";
}
} else { echo("X"); };
}

View File

@@ -15,8 +15,6 @@ if(is_file($Ocpurrd) && !is_file($cpurrd)) { rename($Ocpurrd, $cpurrd); echo("Mo
if(is_file($Omemrrd) && !is_file($memrrd)) { rename($Omemrrd, $memrrd); echo("Moving $Omemrrd to $memrrd"); }
if(is_file($Osysrrd) && !is_file($sysrrd)) { rename($Osysrrd, $sysrrd); echo("Moving $Osysrrd to $sysrrd"); }
## Check Disks
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '" . $device['device_id'] . "'");
while ($dr = mysql_fetch_array($dq)) {
@@ -90,11 +88,13 @@ $cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem .1.3.6.1.4.1
$cpu = `$cpu_cmd`;
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem, $cputemp) = explode("\n", $cpu);
$cpuUsage = $usageUser + $usageSystem;
$cpuUsage = $UsageUser + $UsageSystem;
$update_usage = mysql_query("UPDATE devices_attribs SET attrib_value = '$cpuUsage' WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'");
echo("\n CPU : $cpuUsage = $UsageUser + $UsageSystem; \n");
if(mysql_affected_rows() == '0') {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'"),0)) {
$update_usage = mysql_query("UPDATE devices_attribs SET attrib_value = '$cpuUsage' WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'");
} else {
$insert_usage = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . $device['device_id'] . "', 'cpuusage', '$cpuUsage')");
}

58
includes/syslog.php Executable file
View File

@@ -0,0 +1,58 @@
<?php
function process_syslog ($entry, $update) {
global $config;
foreach($config['syslog_filter'] as $bi) {
if (strstr($entry['msg'], $bi)) {
$delete = 1;
}
}
$device_id_host = @mysql_result(mysql_query("SELECT device_id FROM devices WHERE `hostname` = '".$entry['host']."'"),0);
if($device_id_host) {
$device_id = $device_id_host;
} else {
$device_id_ip = @mysql_result(mysql_query("SELECT D.device_id as device_id FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '" . $entry['host']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"),0);
if($device_id_ip) {
$device_id = $device_id_ip;
}
}
if($device_id && !$delete) {
$entry['device_id'] = $device_id;
if(mysql_result(mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '$device_id'"),0) == "IOS") {
list(,$entry[msg]) = split(": %", $entry['msg']);
$entry['msg'] = "%" . $entry['msg'];
$entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']);
list($entry['program'], $entry['msg']) = explode("||", $entry['msg']);
} else {
$program = preg_quote($entry['program'],'/');
$entry['msg'] = preg_replace("/^$program:\ /", "", $entry['msg']);
if(preg_match("/^[a-zA-Z\/]+\[[0-9]+\]:/", $entry['msg'])) {
$entry['msg'] = preg_replace("/^(.+?)\[[0-9]+\]:\ /", "\\1||", $entry['msg']);
list($entry['program'], $entry['msg']) = explode("||", $entry['msg']);
}
}
$x = "UPDATE `syslog` set `device_id` = '$device_id', `program` = '".$entry['program']."', `msg` = '" . mysql_real_escape_string($entry['msg']) . "', processed = '1' WHERE `seq` = '" . $entry['seq'] . "'";
$entry['processed'] = 1;
if($update) { mysql_query($x); }
unset ($fix);
} else {
$x = "DELETE FROM `syslog` where `seq` = '" . $entry['seq'] . "'";
if($update) { mysql_query($x);}
$entry['deleted'] = '1';
}
return $entry;
}
?>

View File

@@ -14,6 +14,10 @@ if(!$config['enable_syslog']) {
exit();
}
## Delete all the old old old syslogs (as per config.php variable)
mysql_query("DELETE FROM `syslog` WHERE `datetime` < DATE_SUB(NOW(), INTERVAL ".$config['syslog_age'].")");
$q = mysql_query("SELECT * FROM `syslog` where `processed` = '0'");
while($entry = mysql_fetch_array($q)){