Example #1
0
                    // $app = @dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?", array($device['device_id'],$key));
                    // print_debug('Including: applications/'.$key.'.inc.php');
                    // echo($key);
                    //include('includes/polling/applications/'.$key.'.inc.php');
                    $valid_applications[$key] = $key;
                }
            }
        }
        // Processes
        // FIXME unused
        if (!empty($agent_data['ps'])) {
            echo "\nProcesses: ";
            foreach (explode("\n", $agent_data['ps']) as $process) {
                $process = preg_replace("/\\((.*),([0-9]*),([0-9]*),([0-9\\.]*)\\)\\ (.*)/", "\\1|\\2|\\3|\\4|\\5", $process);
                list($user, $vsz, $rss, $pcpu, $command) = explode("|", $process, 5);
                $processlist[] = array('user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'pcpu' => $pcpu, 'command' => $command);
            }
            #print_vars($processlist);
            echo "\n";
        }
    }
    echo "Sensors: ";
    foreach (array_keys($config['sensor_types']) as $sensor_class) {
        check_valid_sensors($device, $sensor_class, $valid['sensor'], 'agent');
    }
    echo "\n";
    echo "Virtual machines: ";
    check_valid_virtual_machines($device, $valid['vm'], 'agent');
    echo "\n";
}
// EOF
 * @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
Example #3
0
                    //     <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;
}
// EOF