mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
hostadding stuff
git-svn-id: http://www.observium.org/svn/observer/trunk@187 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+2
-1
@@ -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"); }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user