Add and update new os discovery functions

git-svn-id: http://www.observium.org/svn/observer/trunk@135 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2008-03-12 11:15:58 +00:00
parent f760bab01a
commit 748316484e
9 changed files with 92 additions and 17 deletions
+35 -17
View File
@@ -15,6 +15,24 @@ function rrdtool_update($rrdfile, $rrdupdate) {
return `$rrdtool update $rrdfile $rrdupdate`; return `$rrdtool update $rrdfile $rrdupdate`;
} }
function getHostOS($hostname, $community, $snmpver) {
$sysDescr_cmd = "snmpget -O qv -" . $snmpver . " -c " . $community . " " . $hostname . " sysDescr.0";
$sysDescr = str_replace("\"", "", trim(`$sysDescr_cmd`));
$dir_handle = @opendir("includes/osdiscovery") or die("Unable to open $path");
while ($file = readdir($dir_handle)) {
if( preg_match("/^discover-([a-z0-9]*).php/", $file) ) {
include("includes/osdiscovery/" . $file);
}
}
closedir($dir_handle);
if($os) { return $os; } else { return FALSE; }
}
function strgen ($length = 8) function strgen ($length = 8)
{ {
$entropy = array(0,1,2,3,4,5,6,7,8,9,'a','A','b','B','c','C','d','D','e', $entropy = array(0,1,2,3,4,5,6,7,8,9,'a','A','b','B','c','C','d','D','e',
@@ -522,23 +540,23 @@ function fixIOSHardware($hardware){
} }
function getHostOS($host, $community, $snmpver) { #function getHostOS($host, $community, $snmpver) {
$sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host sysDescr.0`); # $sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host sysDescr.0`);
if ($sysDescr == "") {$sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host 1.3.6.1.2.1.7526.2.4`);} # if ($sysDescr == "") {$sysDescr = trim(`snmpget -O qv -$snmpver -c $community $host 1.3.6.1.2.1.7526.2.4`);}
echo("\nsnmpget -O qv -$snmpver -c $community $host sysDescr.0\n$sysDescr\n"); # echo("\nsnmpget -O qv -$snmpver -c $community $host sysDescr.0\n$sysDescr\n");
if (strstr($sysDescr, "IOS") !== false) { $os = "IOS"; } # if (strstr($sysDescr, "IOS") !== false) { $os = "IOS"; }
if (strstr($sysDescr, "FreeBSD") !== false) { $os = "FreeBSD"; } # if (strstr($sysDescr, "FreeBSD") !== false) { $os = "FreeBSD"; }
if (strstr($sysDescr, "DragonFly")) { $os = "DragonFly"; } # if (strstr($sysDescr, "DragonFly")) { $os = "DragonFly"; }
if (strstr($sysDescr, "NetBSD") !== false) { $os = "NetBSD"; } # if (strstr($sysDescr, "NetBSD") !== false) { $os = "NetBSD"; }
if (strstr($sysDescr, "OpenBSD") !== false) { $os = "OpenBSD"; } # if (strstr($sysDescr, "OpenBSD") !== false) { $os = "OpenBSD"; }
if (strstr($sysDescr, "Linux") !== false) { $os = "Linux"; } # if (strstr($sysDescr, "Linux") !== false) { $os = "Linux"; }
if (strstr($sysDescr, "Windows")) { $os = "Windows"; } # if (strstr($sysDescr, "Windows")) { $os = "Windows"; }
if (strstr($sysDescr, "ProCurve")) { $os = "ProCurve"; } # if (strstr($sysDescr, "ProCurve")) { $os = "ProCurve"; }
if (strstr($sysDescr, "m0n0wall")) { $os = "m0n0wall"; } # if (strstr($sysDescr, "m0n0wall")) { $os = "m0n0wall"; }
if (strstr($sysDescr, "Voswall")) { $os = "Voswall"; } # if (strstr($sysDescr, "Voswall")) { $os = "Voswall"; }
if (strstr($sysDescr, "snom")) { $os = "Snom"; } # if (strstr($sysDescr, "snom")) { $os = "Snom"; }
return $os; # return $os;
} #}
function createHost ($host, $community, $snmpver){ function createHost ($host, $community, $snmpver){
+7
View File
@@ -0,0 +1,7 @@
<?
if(!$os) {
if(preg_match("/^FreeBSD/", $sysDescr)) { $os = "FreeBSD"; }
}
?>
+11
View File
@@ -0,0 +1,11 @@
<?php
if(!$os) {
if(strstr($sysDescr, "Cisco Internetwork Operating System Software")) { $os = "IOS"; }
if(strstr($sysDescr, "IOS (tm)")) { $os = "IOS"; }
if(strstr($sysDescr, "Cisco IOS Software")) { $os = "IOS"; }
}
?>
+3
View File
@@ -0,0 +1,3 @@
<?php
?>
+7
View File
@@ -0,0 +1,7 @@
<?php
if(!$os) {
if(preg_match("/^Linux/", $sysDescr)) { $os = "Linux"; }
}
?>
+12
View File
@@ -0,0 +1,12 @@
<?php
if(!$os) {
if(preg_match("/^m0n0wall/", $sysDescr)) { $os = "m0n0wall"; }
}
if(!$os) {
if(preg_match("/^Voswall/", $sysDescr)) { $os = "Voswall"; }
}
?>
+7
View File
@@ -0,0 +1,7 @@
<?
if(!$os) {
if(preg_match("/^NetBSD/", $sysDescr)) { $os = "NetBSD"; }
}
?>
+7
View File
@@ -0,0 +1,7 @@
<?
if(!$os) {
if(preg_match("/^OpenBSD/", $sysDescr)) { $os = "OpenBSD"; }
}
?>
+3
View File
@@ -0,0 +1,3 @@
<?php
?>