VMWARE SUPPORT!! :)

- Support for VMware hosts AND Virtual Machines.
- VMware MIB files added.
- SVN property ignore on MIB .index files.


git-svn-id: http://www.observium.org/svn/observer/trunk@1976 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Geert Hauwaerts
2011-03-26 17:16:09 +00:00
parent dac063c0f6
commit 80f6b2dcc2
24 changed files with 3359 additions and 4 deletions
+3 -1
View File
@@ -224,4 +224,6 @@ $config['astext'][65333] = "Cymru Bogon Feed";
### What should we warn about?
$config['warn']['ifdown'] = false;
?>
## INCLUDE THE VMWARE DEFINITION FILE.
require_once("vmware_guestid.inc.php");
?>
+8
View File
@@ -0,0 +1,8 @@
<?php
if (!$os)
{
if (preg_match("/^VMware ESX/", $sysDescr)) { $os = "vmware"; }
}
?>
+1
View File
@@ -31,6 +31,7 @@ foreach (explode("\n", $ports) as $entry){
if (empty($ifDescr)) { $nullintf = 1; }
if ($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; }
if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $ifDescr, $matches)) { $ifDescr = $matches[1]; }
$ifDescr = fixifName($ifDescr);
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; }
if (isset($config['allow_ng']) && !$config['allow_ng']) {
+118
View File
@@ -0,0 +1,118 @@
<?php
/*
* Try to discover any Virtual Machines.
*/
if ($device['os'] == "vmware") {
/*
* Variable to hold the discovered Virtual Machines.
*/
$vmw_vmlist = array();
/*
* CONSOLE: Start the VMware discovery process.
*/
echo("VMware VM: ");
/*
* Fetch the list is Virtual Machines.
*
* VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
* VMWARE-VMINFO-MIB::vmwVmVMID.416 = INTEGER: 416
* ...
*/
$oids = snmp_walk($device, "VMWARE-VMINFO-MIB::vmwVmVMID", "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$oids = explode("\n", $oids);
foreach ($oids as $oid) {
/*
* Fetch the Virtual Machine information.
*
* VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
* VMWARE-VMINFO-MIB::vmwVmDisplayName.416 = STRING: My Second VM
* VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
* VMWARE-VMINFO-MIB::vmwVmGuestOS.416 = STRING: winLonghornGuest
* VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
* VMWARE-VMINFO-MIB::vmwVmMemSize.416 = INTEGER: 8192 megabytes
* VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
* VMWARE-VMINFO-MIB::vmwVmState.416 = STRING: poweredOn
* VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
* VMWARE-VMINFO-MIB::vmwVmVMID.416 = INTEGER: 416
* VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2
* VMWARE-VMINFO-MIB::vmwVmCpus.416 = INTEGER: 2
*/
$vmwVmDisplayName = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmDisplayName." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vmwVmGuestOS = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmGuestOS." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vmwVmMemSize = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmMemSize." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vmwVmState = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmState." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vmwVmCpus = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmCpus." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
/*
* VMware does not return an INTEGER but a STRING of the vmwVmMemSize. This bug
* might be resolved by VMware in the future making this code absolete.
*/
if (preg_match("/^([0-9]+) .*$/", $vmwVmMemSize, $matches)) {
$vmwVmMemSize = $matches[1];
}
/*
* Check whether the Virtual Machine is already known for this host.
*/
if (mysql_result(mysql_query("SELECT COUNT(id) FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "' AND vmwVmVMID = '" . $oid . "'"), 0) == 0) {
mysql_query("INSERT INTO vmware_vminfo (device_id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState) VALUES (" . $device["device_id"] . ", " . $oid . ", '" . mres($vmwVmDisplayName) . "', '" . mres($vmwVmGuestOS) . "', " . $vmwVmMemSize . ", " . $vmwVmCpus . ", '" . mres($vmwVmState) . "')");
echo("+");
} else {
echo ".";
}
/*
* Save the discovered Virtual Machine.
*/
$vmw_vmlist[] = $oid;
}
/*
* Get a list of all the known Virtual Machines for this host.
*/
$db_vm_list = mysql_query("SELECT id, vmwVmVMID FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "'");
while ($db_vm = mysql_fetch_array($db_vm_list)) {
/*
* Delete the Virtual Machines that are removed from the host.
*/
if (!in_array($db_vm["vmwVmVMID"], $vmw_vmlist)) {
mysql_query("DELETE FROM vmware_vminfo WHERE id = '" . $db_vm["id"] . "'");
echo("-");
}
}
/*
* Finished discovering VMware information.
*/
echo("\n");
}
?>
+102
View File
@@ -0,0 +1,102 @@
<?php
/*
* Fetch the VMware product version.
*
* VMWARE-SYSTEM-MIB::vmwProdName.0 = STRING: VMware ESXi
* VMWARE-SYSTEM-MIB::vmwProdVersion.0 = STRING: 4.1.0
* VMWARE-SYSTEM-MIB::vmwProdBuild.0 = STRING: 348481
*
* version: ESXi 4.1.0
* features: build-348481
*/
$data = snmp_get_multi($device, "VMWARE-SYSTEM-MIB::vmwProdName.0 VMWARE-SYSTEM-MIB::vmwProdVersion.0 VMWARE-SYSTEM-MIB::vmwProdBuild.0", "-OQUs", "+VMWARE-ROOT-MIB:VMWARE-SYSTEM-MIB", "+" . $config['install_dir'] . "/mibs/vmware");
$version = preg_replace("/^VMware /", "", $data[0]["vmwProdName"]) . " " . $data[0]["vmwProdVersion"];
$features = "build-" . $data[0]["vmwProdBuild"];
/*
* VMware ESXi returns "not set" instead of a NULL value.
*/
if ($sysLocation == "not set") {
$sysLocation = "";
}
if ($sysContact == "not set") {
$sysContact = "";
}
/*
* CONSOLE: Start the VMware discovery process.
*/
echo("VMware VM: ");
/*
* Get a list of all the known Virtual Machines for this host.
*/
$db_info_list = mysql_query("SELECT id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "'");
while ($db_info = mysql_fetch_array($db_info_list)) {
/*
* Fetch the Virtual Machine information.
*
* VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
* VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
* VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
* VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
* VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
* VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2
*/
$vm_info = array();
$vm_info["vmwVmDisplayName"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmDisplayName." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vm_info["vmwVmGuestOS"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmGuestOS." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vm_info["vmwVmMemSize"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmMemSize." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vm_info["vmwVmState"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmState." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
$vm_info["vmwVmCpus"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmCpus." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
/*
* VMware does not return an INTEGER but a STRING of the vmwVmMemSize. This bug
* might be resolved by VMware in the future making this code absolete.
*/
if (preg_match("/^([0-9]+) .*$/", $vm_info["vmwVmMemSize"], $matches)) {
$vm_info["vmwVmMemSize"] = $matches[1];
}
/*
* Proceess all the VMware Virtual Machine properties.
*/
foreach ($vm_info as $property => $value) {
/*
* Check the property for any modifications.
*/
if ($vm_info[$property] != $db_info[$property]) {
mysql_query("UPDATE vmware_vminfo SET " . $property ." = '" . mres($vm_info[$property]) ."' WHERE id = '" . $db_info["id"] . "'");
log_event($db_info["vmwVmDisplayName"] . " (" . preg_replace("/^vmwVm/", "", $property) . ") -> " . $vm_info[$property], $device['device_id']);
}
}
}
/*
* Finished discovering VMware information.
*/
echo("\n");
?>
+1 -1
View File
@@ -105,7 +105,7 @@ while ($port = mysql_fetch_array($port_query))
if ($port_stats[$port['ifIndex']] && $port['disabled'] != "1")
{ // Check to make sure Port data is cached.
$this_port = &$port_stats[$port['ifIndex']];
if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $this_port['ifDescr'], $matches)) { $this_port['ifDescr'] = $matches[1]; }
$polled_period = $polled - $port['poll_time'];
$update .= "`poll_time` = '".$polled."'";
+7
View File
@@ -660,6 +660,13 @@ $config['os'][$os]['over'][0]['graph'] = "device_current";
$config['os'][$os]['over'][0]['text'] = "Current";
$config['os'][$os]['icon'] = "servertech";
$os = "vmware";
$config['os'][$os]['type'] = "server";
$config['os'][$os]['text'] = "VMware";
$config['os'][$os]['ifXmcbc'] = 1;
$config['os'][$os]['over'][0]['graph'] = "device_bits";
$config['os'][$os]['over'][0]['text'] = "Device Traffic";
$device_types = array('server', 'network', 'firewall', 'workstation', 'printer', 'power', 'environment');
### Graph Types
+100
View File
@@ -0,0 +1,100 @@
<?php
/*
* Translate the VMware guestId properties to their
* corresponding full OS name.
*/
$config['vmware_guestid']['asianux3_64Guest'] = 'Asianux Server 3 (64 bit)';
$config['vmware_guestid']['asianux3Guest'] = 'Asianux Server 3';
$config['vmware_guestid']['asianux4_64Guest'] = 'Asianux Server 4 (64 bit)';
$config['vmware_guestid']['asianux4Guest'] = 'Asianux Server 4';
$config['vmware_guestid']['centos64Guest'] = 'CentOS 4/5 (64-bit)';
$config['vmware_guestid']['centosGuest'] = 'CentOS 4/5';
$config['vmware_guestid']['darwin64Guest'] = 'Mac OS 10.5 (64 bit)';
$config['vmware_guestid']['darwinGuest'] = 'Mac OS 10.5';
$config['vmware_guestid']['debian4_64Guest'] = 'Debian GNU/Linux 4 (64 bit)';
$config['vmware_guestid']['debian4Guest'] = 'Debian GNU/Linux 4';
$config['vmware_guestid']['debian5_64Guest'] = 'Debian GNU/Linux 5 (64 bit)';
$config['vmware_guestid']['debian5Guest'] = 'Debian GNU/Linux 5';
$config['vmware_guestid']['dosGuest'] = 'MS-DOS.';
$config['vmware_guestid']['eComStationGuest'] = 'eComStation';
$config['vmware_guestid']['freebsd64Guest'] = 'FreeBSD x64';
$config['vmware_guestid']['freebsdGuest'] = 'FreeBSD';
$config['vmware_guestid']['mandriva64Guest'] = 'Mandriva Linux (64 bit)';
$config['vmware_guestid']['mandrivaGuest'] = 'Mandriva Linux';
$config['vmware_guestid']['netware4Guest'] = 'Novell NetWare 4';
$config['vmware_guestid']['netware5Guest'] = 'Novell NetWare 5.1';
$config['vmware_guestid']['netware6Guest'] = 'Novell NetWare 6.x';
$config['vmware_guestid']['nld9Guest'] = 'Novell Linux Desktop 9';
$config['vmware_guestid']['oesGuest'] = 'Open Enterprise Server';
$config['vmware_guestid']['openServer5Guest'] = 'SCO OpenServer 5';
$config['vmware_guestid']['openServer6Guest'] = 'SCO OpenServer 6';
$config['vmware_guestid']['oracleLinux64Guest'] = 'Oracle Linux 4/5 (64-bit)';
$config['vmware_guestid']['oracleLinuxGuest'] = 'Oracle Linux 4/5';
$config['vmware_guestid']['os2Guest'] = 'OS/2';
$config['vmware_guestid']['other24xLinux64Guest'] = 'Linux 2.4x Kernel (64 bit) (experimental)';
$config['vmware_guestid']['other24xLinuxGuest'] = 'Linux 2.4x Kernel';
$config['vmware_guestid']['other26xLinux64Guest'] = 'Linux 2.6x Kernel (64 bit) (experimental)';
$config['vmware_guestid']['other26xLinuxGuest'] = 'Linux 2.6x Kernel';
$config['vmware_guestid']['otherGuest'] = 'Other Operating System';
$config['vmware_guestid']['otherGuest64'] = 'Other Operating System (64 bit) (experimental)';
$config['vmware_guestid']['otherLinux64Guest'] = 'Linux (64 bit) (experimental)';
$config['vmware_guestid']['otherLinuxGuest'] = 'Other Linux';
$config['vmware_guestid']['redhatGuest'] = 'Red Hat Linux 2.1';
$config['vmware_guestid']['rhel2Guest'] = 'Red Hat Enterprise Linux 2';
$config['vmware_guestid']['rhel3_64Guest'] = 'Red Hat Enterprise Linux 3 (64 bit)';
$config['vmware_guestid']['rhel3Guest'] = 'Red Hat Enterprise Linux 3';
$config['vmware_guestid']['rhel4_64Guest'] = 'Red Hat Enterprise Linux 4 (64 bit)';
$config['vmware_guestid']['rhel4Guest'] = 'Red Hat Enterprise Linux 4';
$config['vmware_guestid']['rhel5_64Guest'] = 'Red Hat Enterprise Linux 5 (64 bit) (experimental)';
$config['vmware_guestid']['rhel5Guest'] = 'Red Hat Enterprise Linux 5';
$config['vmware_guestid']['rhel6_64Guest'] = 'Red Hat Enterprise Linux 6 (64 bit)';
$config['vmware_guestid']['rhel6Guest'] = 'Red Hat Enterprise Linux 6';
$config['vmware_guestid']['sjdsGuest'] = 'Sun Java Desktop System';
$config['vmware_guestid']['sles10_64Guest'] = 'Suse Linux Enterprise Server 10 (64 bit) (experimental)';
$config['vmware_guestid']['sles10Guest'] = 'Suse linux Enterprise Server 10';
$config['vmware_guestid']['sles11_64Guest'] = 'Suse Linux Enterprise Server 11 (64 bit)';
$config['vmware_guestid']['sles11Guest'] = 'Suse linux Enterprise Server 11';
$config['vmware_guestid']['sles64Guest'] = 'Suse Linux Enterprise Server 9 (64 bit)';
$config['vmware_guestid']['slesGuest'] = 'Suse Linux Enterprise Server 9';
$config['vmware_guestid']['solaris10_64Guest'] = 'Solaris 10 (64 bit) (experimental)';
$config['vmware_guestid']['solaris10Guest'] = 'Solaris 10 (32 bit) (experimental)';
$config['vmware_guestid']['solaris6Guest'] = 'Solaris 6';
$config['vmware_guestid']['solaris7Guest'] = 'Solaris 7';
$config['vmware_guestid']['solaris8Guest'] = 'Solaris 8';
$config['vmware_guestid']['solaris9Guest'] = 'Solaris 9';
$config['vmware_guestid']['suse64Guest'] = 'Suse Linux (64 bit)';
$config['vmware_guestid']['suseGuest'] = 'Suse Linux';
$config['vmware_guestid']['turboLinux64Guest'] = 'Turbolinux (64 bit)';
$config['vmware_guestid']['turboLinuxGuest'] = 'Turbolinux';
$config['vmware_guestid']['ubuntu64Guest'] = 'Ubuntu Linux (64 bit)';
$config['vmware_guestid']['ubuntuGuest'] = 'Ubuntu Linux';
$config['vmware_guestid']['unixWare7Guest'] = 'SCO UnixWare 7';
$config['vmware_guestid']['win2000AdvServGuest'] = 'Windows 2000 Advanced Server';
$config['vmware_guestid']['win2000ProGuest'] = 'Windows 2000 Professional';
$config['vmware_guestid']['win2000ServGuest'] = 'Windows 2000 Server';
$config['vmware_guestid']['win31Guest'] = 'Windows 3.1';
$config['vmware_guestid']['win95Guest'] = 'Windows 95';
$config['vmware_guestid']['win98Guest'] = 'Windows 98';
$config['vmware_guestid']['windows7_64Guest'] = 'Windows 7 (64 bit)';
$config['vmware_guestid']['windows7Guest'] = 'Windows 7';
$config['vmware_guestid']['windows7Server64Guest'] = 'Windows Server 2008 R2 (64 bit)';
$config['vmware_guestid']['winLonghorn64Guest'] = 'Windows Longhorn (64 bit) (experimental)';
$config['vmware_guestid']['winLonghornGuest'] = 'Windows Longhorn (experimental)';
$config['vmware_guestid']['winMeGuest'] = 'Windows Millenium Edition';
$config['vmware_guestid']['winNetBusinessGuest'] = 'Windows Small Business Server 2003';
$config['vmware_guestid']['winNetDatacenter64Guest'] = 'Windows Server 2003, Datacenter Edition (64 bit) (experimental)';
$config['vmware_guestid']['winNetDatacenterGuest'] = 'Windows Server 2003, Datacenter Edition';
$config['vmware_guestid']['winNetEnterprise64Guest'] = 'Windows Server 2003, Enterprise Edition (64 bit)';
$config['vmware_guestid']['winNetEnterpriseGuest'] = 'Windows Server 2003, Enterprise Edition';
$config['vmware_guestid']['winNetStandard64Guest'] = 'Windows Server 2003, Standard Edition (64 bit)';
$config['vmware_guestid']['winNetStandardGuest'] = 'Windows Server 2003, Standard Edition';
$config['vmware_guestid']['winNetWebGuest'] = 'Windows Server 2003, Web Edition';
$config['vmware_guestid']['winNTGuest'] = 'Windows NT 4';
$config['vmware_guestid']['winVista64Guest'] = 'Windows Vista (64 bit)';
$config['vmware_guestid']['winVistaGuest'] = 'Windows Vista';
$config['vmware_guestid']['winXPHomeGuest'] = 'Windows XP Home Edition';
$config['vmware_guestid']['winXPPro64Guest'] = 'Windows XP Professional Edition (64 bit)';
$config['vmware_guestid']['winXPProGuest'] = 'Windows XP Professional';
?>