mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Initial Import
git-svn-id: http://www.observium.org/svn/observer/trunk@2 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
21
scan-snmp.php
Executable file
21
scan-snmp.php
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$search = $argv[1] . "$";
|
||||
|
||||
$data = trim(`cat ips-scanned.txt | grep alive | cut -d" " -f 1 | egrep $search`);
|
||||
|
||||
foreach( explode("\n", $data) as $ip) {
|
||||
$snmp = `snmpget -t 0.1 -v2c -c $community $ip sysName.0`;
|
||||
if(strstr($snmp, "STRING")) {
|
||||
$hostname = trim(str_replace("SNMPv2-MIB::sysName.0 = STRING: ","", $snmp));
|
||||
if(mysql_result(mysql_query("SELECT COUNT(id) FROM devices WHERE hostname = '$hostname'"),0) == '0') {
|
||||
`./add-host.php $hostname $community v2c`;
|
||||
echo("Adding $hostname \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user