git-svn-id: http://www.observium.org/svn/observer/trunk@2199 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-04-28 21:12:16 +00:00
parent 811680e1b5
commit a8852e2f72
4 changed files with 21 additions and 13 deletions

View File

@@ -2,19 +2,23 @@
## Common Functions
function sgn($int){
function sgn($int)
{
if ($int < 0)
{
return -1;
elseif($int == 0)
} elseif ($int == 0) {
return 0;
else
} else {
return 1;
}
}
function get_sensor_rrd($device, $sensor)
{
global $config;
# For IPMI, sensors tend to change order, and there is no index, so we prefer to use the description as key here.
if ($config['os'][$device['os']]['sensor_descr'] || $sensor['poller_type'] == "ipmi")
{
$rrd_file = $config['rrd_dir']."/".$device['hostname']."/".safename("sensor-".$sensor['sensor_class']."-".$sensor['sensor_type']."-".$sensor['sensor_descr'] . ".rrd");
@@ -23,7 +27,6 @@ function get_sensor_rrd($device, $sensor)
}
return($rrd_file);
}
function get_port_by_id($port_id)

View File

@@ -1,7 +1,9 @@
<?php
unset($ports);
$ports = snmp_cache_ifIndex($device); // Cache Port List
# FIXME Removed 28/4/2011 - this can go, right?
#unset($ports);
#$ports = snmp_cache_ifIndex($device); // Cache Port List
# /FIXME
#mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`) VALUES ('".$device['device_id']."','$ifIndex')");

View File

@@ -350,7 +350,7 @@ while ($device = mysql_fetch_assoc($device_query))
if ($debug) { echo("Updating " . $device['hostname'] . " - $poll_update_query \n"); }
if (!mysql_query($poll_update_query))
{
echo "ERROR: " . mysql_error() . "\nSQL: $poll_update_query\n";
echo("ERROR: " . mysql_error() . "\nSQL: $poll_update_query\n");
}
if (mysql_affected_rows() == "1") { echo("UPDATED!\n"); } else { echo("NOT UPDATED!\n"); }

View File

@@ -9,11 +9,14 @@ $search = $argv[1] . "$";
$data = trim(`cat ips-scanned.txt | grep alive | cut -d" " -f 1 | egrep $search`);
foreach( explode("\n", $data) as $ip) {
foreach (explode("\n", $data) as $ip)
{
$snmp = shell_exec("snmpget -t 0.2 -v2c -c ".$config['community']." $ip sysName.0");
if(strstr($snmp, "STRING")) {
if (strstr($snmp, "STRING"))
{
$hostname = trim(str_replace("SNMPv2-MIB::sysName.0 = STRING: ","", $snmp));
if(mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE hostname = '$hostname'"),0) == '0') {
if (mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE hostname = '$hostname'"),0) == '0')
{
if (gethostbyname($hostname) == gethostbyname($hostname.".".$config['mydomain'])) { $hostname = $hostname . ".".$config['mydomain']; }
addHost($hostname, $community, 'v2c');
echo("Adding $hostname \n");