From 126fbc630dd3a5dbb9e0f5c820d2fb4b236e0e57 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 23 Mar 2008 21:32:54 +0000 Subject: [PATCH] missing file! git-svn-id: http://www.observium.org/svn/observer/trunk@199 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 9 ++++- cron-hourly.sh | 5 ++- discovery.php | 21 +++++++++- html/includes/print-menubar.php | 2 +- html/index.php | 4 +- html/pages/device.php | 2 +- html/pages/storage.php | 5 ++- includes/discovery/storage.php | 13 ++++++- includes/polling/device-unix.inc.php | 10 ++--- includes/syslog.php | 58 ++++++++++++++++++++++++++++ process-syslog.php | 4 ++ 11 files changed, 117 insertions(+), 16 deletions(-) create mode 100755 includes/syslog.php diff --git a/config.php.default b/config.php.default index ca11d0b70f..b0bd53b559 100755 --- a/config.php.default +++ b/config.php.default @@ -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 "; $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 diff --git a/cron-hourly.sh b/cron-hourly.sh index 42a61577b1..e73bc4e76f 100755 --- a/cron-hourly.sh +++ b/cron-hourly.sh @@ -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 diff --git a/discovery.php b/discovery.php index 4199a823ec..711cc2fb17 100755 --- a/discovery.php +++ b/discovery.php @@ -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 Poll single device\n"); + echo("--os 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"); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 919e4276b7..fa13ff2c37 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -136,7 +136,7 @@ echo("
  • Temperatures
  • +
  • Temperatures
  • Storage
  • diff --git a/html/index.php b/html/index.php index 428dedcc32..3e2cfe6f18 100755 --- a/html/index.php +++ b/html/index.php @@ -30,7 +30,9 @@ if($_GET[debug]) { <?php echo("$page_title"); ?> - +"); } +?> diff --git a/html/pages/device.php b/html/pages/device.php index ede1b0fcdc..b17b3e5fd9 100644 --- a/html/pages/device.php +++ b/html/pages/device.php @@ -82,7 +82,7 @@ if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_h echo("
  • - Temps + Temps
  • "); diff --git a/html/pages/storage.php b/html/pages/storage.php index 61c953a050..7486433a2f 100644 --- a/html/pages/storage.php +++ b/html/pages/storage.php @@ -9,7 +9,8 @@ if($_SESSION['userlevel'] >= '5') { $query = mysql_query($sql); -echo(""); +echo("
    +
    "); echo(" @@ -46,7 +47,7 @@ while($drive = mysql_fetch_array($query)) { } -echo("
    Device
    "); +echo(""); ?> diff --git a/includes/discovery/storage.php b/includes/discovery/storage.php index 7c97ab4663..1c754d2263 100755 --- a/includes/discovery/storage.php +++ b/includes/discovery/storage.php @@ -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"); }; } diff --git a/includes/polling/device-unix.inc.php b/includes/polling/device-unix.inc.php index 7f072a4abc..6ea38dc63b 100755 --- a/includes/polling/device-unix.inc.php +++ b/includes/polling/device-unix.inc.php @@ -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')"); } diff --git a/includes/syslog.php b/includes/syslog.php new file mode 100755 index 0000000000..c7a6ce6fa7 --- /dev/null +++ b/includes/syslog.php @@ -0,0 +1,58 @@ + diff --git a/process-syslog.php b/process-syslog.php index 957bab883d..e439f2688d 100755 --- a/process-syslog.php +++ b/process-syslog.php @@ -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)){