mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 16:26:55 +02:00
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:
+35
-17
@@ -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){
|
||||||
|
|||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
if(preg_match("/^FreeBSD/", $sysDescr)) { $os = "FreeBSD"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Executable
+11
@@ -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"; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
if(preg_match("/^Linux/", $sysDescr)) { $os = "Linux"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
if(preg_match("/^m0n0wall/", $sysDescr)) { $os = "m0n0wall"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
if(preg_match("/^Voswall/", $sysDescr)) { $os = "Voswall"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
if(preg_match("/^NetBSD/", $sysDescr)) { $os = "NetBSD"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
if(!$os) {
|
||||||
|
if(preg_match("/^OpenBSD/", $sysDescr)) { $os = "OpenBSD"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user