diff --git a/includes/functions.php b/includes/functions.php index 61ae9f47e..802a9843b 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -15,6 +15,24 @@ function 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) { $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) { - $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`);} - echo("\nsnmpget -O qv -$snmpver -c $community $host sysDescr.0\n$sysDescr\n"); - if (strstr($sysDescr, "IOS") !== false) { $os = "IOS"; } - if (strstr($sysDescr, "FreeBSD") !== false) { $os = "FreeBSD"; } - if (strstr($sysDescr, "DragonFly")) { $os = "DragonFly"; } - if (strstr($sysDescr, "NetBSD") !== false) { $os = "NetBSD"; } - if (strstr($sysDescr, "OpenBSD") !== false) { $os = "OpenBSD"; } - if (strstr($sysDescr, "Linux") !== false) { $os = "Linux"; } - if (strstr($sysDescr, "Windows")) { $os = "Windows"; } - if (strstr($sysDescr, "ProCurve")) { $os = "ProCurve"; } - if (strstr($sysDescr, "m0n0wall")) { $os = "m0n0wall"; } - if (strstr($sysDescr, "Voswall")) { $os = "Voswall"; } - if (strstr($sysDescr, "snom")) { $os = "Snom"; } - return $os; -} +#function getHostOS($host, $community, $snmpver) { +# $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`);} +# echo("\nsnmpget -O qv -$snmpver -c $community $host sysDescr.0\n$sysDescr\n"); +# if (strstr($sysDescr, "IOS") !== false) { $os = "IOS"; } +# if (strstr($sysDescr, "FreeBSD") !== false) { $os = "FreeBSD"; } +# if (strstr($sysDescr, "DragonFly")) { $os = "DragonFly"; } +# if (strstr($sysDescr, "NetBSD") !== false) { $os = "NetBSD"; } +# if (strstr($sysDescr, "OpenBSD") !== false) { $os = "OpenBSD"; } +# if (strstr($sysDescr, "Linux") !== false) { $os = "Linux"; } +# if (strstr($sysDescr, "Windows")) { $os = "Windows"; } +# if (strstr($sysDescr, "ProCurve")) { $os = "ProCurve"; } +# if (strstr($sysDescr, "m0n0wall")) { $os = "m0n0wall"; } +# if (strstr($sysDescr, "Voswall")) { $os = "Voswall"; } +# if (strstr($sysDescr, "snom")) { $os = "Snom"; } +# return $os; +#} function createHost ($host, $community, $snmpver){ diff --git a/includes/osdiscovery/discover-freebsd.php b/includes/osdiscovery/discover-freebsd.php new file mode 100755 index 000000000..b705f4912 --- /dev/null +++ b/includes/osdiscovery/discover-freebsd.php @@ -0,0 +1,7 @@ + diff --git a/includes/osdiscovery/discover-ios.php b/includes/osdiscovery/discover-ios.php new file mode 100755 index 000000000..afa5a41ff --- /dev/null +++ b/includes/osdiscovery/discover-ios.php @@ -0,0 +1,11 @@ + diff --git a/includes/osdiscovery/discover-linksys.php b/includes/osdiscovery/discover-linksys.php new file mode 100755 index 000000000..62a2de0c8 --- /dev/null +++ b/includes/osdiscovery/discover-linksys.php @@ -0,0 +1,3 @@ + diff --git a/includes/osdiscovery/discover-linux.php b/includes/osdiscovery/discover-linux.php new file mode 100755 index 000000000..51b9b60a2 --- /dev/null +++ b/includes/osdiscovery/discover-linux.php @@ -0,0 +1,7 @@ + diff --git a/includes/osdiscovery/discover-m0n0wall.php b/includes/osdiscovery/discover-m0n0wall.php new file mode 100755 index 000000000..b5c686e27 --- /dev/null +++ b/includes/osdiscovery/discover-m0n0wall.php @@ -0,0 +1,12 @@ + diff --git a/includes/osdiscovery/discover-netbsd.php b/includes/osdiscovery/discover-netbsd.php new file mode 100755 index 000000000..84d97d4e4 --- /dev/null +++ b/includes/osdiscovery/discover-netbsd.php @@ -0,0 +1,7 @@ + diff --git a/includes/osdiscovery/discover-openbsd.php b/includes/osdiscovery/discover-openbsd.php new file mode 100755 index 000000000..d84b6fa1c --- /dev/null +++ b/includes/osdiscovery/discover-openbsd.php @@ -0,0 +1,7 @@ + diff --git a/includes/osdiscovery/discover-procurve.php b/includes/osdiscovery/discover-procurve.php new file mode 100755 index 000000000..62a2de0c8 --- /dev/null +++ b/includes/osdiscovery/discover-procurve.php @@ -0,0 +1,3 @@ +