Пример #1
0
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
// Try to discover any Virtual Machines.
// Variable to hold the discovered Virtual Machines.
$vmw_vmlist = array();
/*
 * 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
 */
$oids = snmpwalk_cache_multi_oid($device, 'vmwVmTable', array(), 'VMWARE-VMINFO-MIB');
foreach ($oids as $index => $entry) {
    // Call VM discovery
    discover_virtual_machine($valid, $device, array('id' => $entry['vmwVmUUID'], 'name' => $entry['vmwVmDisplayName'], 'cpucount' => $entry['vmwVmCpus'], 'memory' => $entry['vmwVmMemSize'] * 1024 * 1024, 'status' => $entry['vmwVmState'], 'os' => $entry['vmwVmGuestOS'], 'type' => 'vmware', 'source' => 'vmware-snmp'));
}
// Clean up removed VMs (our type - vmware-snmp - only, so we don't clean up other modules' VMs)
check_valid_virtual_machines($device, $valid, 'vmware-snmp');
echo PHP_EOL;
// EOF
Пример #2
0
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$qemu = json_decode($agent_data['proxmox']['qemu']);
unset($agent_data['proxmox']['qemu']);
echo "Proxmox VE QEMU: ";
foreach ($qemu as $vm) {
    // [cpu] => 0
    // [cpus] => 2
    // [disk] => 0
    // [diskread] => 0
    // [diskwrite] => 0
    // [maxdisk] => 53687091200
    // [maxmem] => 1610612736
    // [mem] => 1158195243
    // [name] => testvm.example.com
    // [netin] => 32192265743
    // [netout] => 1538266557
    // [pid] => 760125
    // [status] => running
    // [template] =>
    // [uptime] => 1135198
    // [vmid] => 100
    discover_virtual_machine($valid['vm'], $device, array('id' => $vm->vmid, 'name' => $vm->name, 'cpucount' => $vm->cpus, 'memory' => $vm->maxmem, 'status' => $vm->status, 'type' => 'proxmox', 'source' => 'agent'));
}
echo PHP_EOL;
unset($qemu);
// EOF
Пример #3
0
                    //   <os>
                    //     <type arch='x86_64' machine='pc-0.12'>hvm</type>
                    //     <boot dev='hd'/>
                    //   </os>
                    //   <features>
                    //     <acpi/>
                    //   (...)
                    // Convert array to string
                    $vm_info_xml = implode('', $vm_info_array);
                    // Parse XML, add xml header in front as this is required by the parser but not supplied by libvirt
                    $xml = simplexml_load_string('<?xml version="1.0"?> ' . $vm_info_xml);
                    if (OBS_DEBUG && $xml) {
                        print_vars($xml);
                    }
                    // Call VM discovery
                    discover_virtual_machine($valid, $device, array('id' => $xml->uuid, 'name' => $vm_DisplayName, 'cpucount' => $xml->vcpu, 'memory' => $xml->currentMemory * 1024, 'status' => $vm_State, 'type' => 'libvirt', 'source' => 'libvirt'));
                    // Save the discovered Virtual Machine.
                    $libvirt_vmlist[] = $vm_DisplayName;
                }
            }
        }
        // If we found VMs, don't cycle the other protocols anymore.
        if (count($libvirt_vmlist)) {
            break;
        }
    }
    unset($libvirt_vmlist);
    // Clean up removed VMs (our type - libvirt - only, so we don't clean up other modules' VMs)
    check_valid_virtual_machines($device, $valid, 'libvirt');
    echo PHP_EOL;
}