mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Do not run the Proxmox-stuff unless it is explicitly enabled in the config
This commit is contained in:
@@ -20,6 +20,10 @@ include('includes/application/proxmox.inc.php');
|
||||
|
||||
global $config;
|
||||
|
||||
if (!isset($config['enable_proxmox']) || !$config['enable_proxmox']) {
|
||||
print_error('Proxmox agent was discovered on this host. Please enable Proxmox in your config.');
|
||||
} else {
|
||||
|
||||
$graphs = array(
|
||||
'proxmox_traffic' => 'Traffic',
|
||||
);
|
||||
@@ -52,3 +56,4 @@ foreach (proxmox_node_vms(var_get('device')) as $nvm) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!empty($agent_data['app']['proxmox'])) {
|
||||
if (isset($config['enable_proxmox']) && $config['enable_proxmox'] && !empty($agent_data['app']['proxmox'])) {
|
||||
$proxmox = $agent_data['app']['proxmox'];
|
||||
}
|
||||
|
||||
$pmxlines = explode("\n", $proxmox);
|
||||
$pmxcluster = array_shift($pmxlines);
|
||||
|
||||
$pmxcdir = join('/', array($config['rrd_dir'],'proxmox',$pmxcluster));
|
||||
if (!is_dir($pmxcdir)) {
|
||||
mkdir($pmxcdir, 0775, true);
|
||||
}
|
||||
|
||||
dbUpdate(array('device_id' => $device['device_id'], 'app_type' => 'proxmox', 'app_instance' => $pmxcluster), 'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], 'proxmox'));
|
||||
|
||||
$pmxcache = [];
|
||||
|
||||
function proxmox_port_exists($i, $c, $p) {
|
||||
if ($row = dbFetchRow("SELECT pmp.id FROM proxmox_ports pmp, proxmox pm WHERE pm.id = pmp.vm_id AND pmp.port = ? AND pm.cluster = ? AND pm.vmid = ?", array($p, $c, $i))) {
|
||||
return $row['id'];
|
||||
@@ -37,6 +25,20 @@ function proxmox_vm_exists($i, $c, &$pmxcache) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pmxlines = explode("\n", $proxmox);
|
||||
|
||||
if (count($pmxlines) > 2) {
|
||||
$pmxcluster = array_shift($pmxlines);
|
||||
|
||||
$pmxcdir = join('/', array($config['rrd_dir'],'proxmox',$pmxcluster));
|
||||
if (!is_dir($pmxcdir)) {
|
||||
mkdir($pmxcdir, 0775, true);
|
||||
}
|
||||
|
||||
dbUpdate(array('device_id' => $device['device_id'], 'app_type' => 'proxmox', 'app_instance' => $pmxcluster), 'applications', '`device_id` = ? AND `app_type` = ?', array($device['device_id'], 'proxmox'));
|
||||
|
||||
$pmxcache = [];
|
||||
|
||||
foreach ($pmxlines as $vm) {
|
||||
list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5);
|
||||
|
||||
@@ -72,3 +74,4 @@ unset($pmxcluster);
|
||||
unset($pmxcdir);
|
||||
unset($proxmox);
|
||||
unset($pmxcache);
|
||||
}
|
||||
|
Reference in New Issue
Block a user