hostadding stuff

git-svn-id: http://www.observium.org/svn/observer/trunk@187 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-03-22 15:18:15 +00:00
parent 18accc6541
commit f77d294b6c
2 changed files with 6 additions and 4 deletions
+2 -1
View File
@@ -14,7 +14,8 @@ if($argv[1] && $argv[2] && $argv[3]) {
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0' ) {
$snmphost = trim(`snmpget -Oqv -$snmpver -c $community $host sysName.0 | sed s/\"//g`);
if ($snmphost == $host || $hostshort = $host) {
createHost ($host, $community, $snmpver);
$return = createHost ($host, $community, $snmpver);
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"); }
} else { echo("Could not ping $host\n"); }
+4 -3
View File
@@ -14,7 +14,6 @@ include("cisco-entities.php");
function rrdtool_update($rrdfile, $rrdupdate) {
global $rrdtool;
return `$rrdtool update $rrdfile $rrdupdate`;
}
function getHostOS($hostname, $community, $snmpver) {
@@ -551,9 +550,11 @@ function createHost ($host, $community, $snmpver){
$host_os = getHostOS($host, $community, $snmpver);
if($host_os) {
$sql = mysql_query("INSERT INTO `devices` (`hostname`, `community`, `os`, `status`) VALUES ('$host', '$community', '$host_os', '1')");
return("Created host : $host ($host_os)");
if(mysql_affected_rows()) {
return("Created host : $host ($host_os)");
} else { return FALSE; }
} else {
return("Not added bad host : $host");
return FALSE;
}
}