diff --git a/html/includes/graphs/application/auth.inc.php b/html/includes/graphs/application/auth.inc.php
index 15c8f01ca1..23eea41418 100644
--- a/html/includes/graphs/application/auth.inc.php
+++ b/html/includes/graphs/application/auth.inc.php
@@ -3,7 +3,11 @@
if (is_numeric($vars['id']) && ($auth || application_permitted($vars['id']))) {
$app = get_application_by_id($vars['id']);
$device = device_by_id_cache($app['device_id']);
- $title = generate_device_link($device);
- $title .= $graph_subtype;
+ if ($app['app_type'] != 'proxmox') {
+ $title = generate_device_link($device);
+ $title .= $graph_subtype;
+ } else {
+ $title = $vars['port'].'@'.$vars['hostname'].' on '.generate_device_link($device);
+ }
$auth = true;
}
diff --git a/html/includes/graphs/application/proxmox_traffic.inc.php b/html/includes/graphs/application/proxmox_traffic.inc.php
new file mode 100644
index 0000000000..e37cd00d96
--- /dev/null
+++ b/html/includes/graphs/application/proxmox_traffic.inc.php
@@ -0,0 +1,15 @@
+= '5' && ($app_count) > "0") {
0) {
+?>
+
+ Proxmox
+ ');
+ }
+?>
+
+
+
+Proxmox » ";
+
+unset($sep);
+
+foreach ($pmxcl as $pmxc) {
+ if (isset($sep)) { echo $sep; };
+
+ if (var_eq('cluster', $pmxc['app_instance'])) {
+ echo "';
+ }
+
+ $sep = ' | ';
+}
+
+print_optionbar_end();
+
+if (!var_isset('cluster')) {
+ echo 'Select a cluster:';
+ echo '';
+ foreach ($pmxcl as $pmxc) {
+ echo '- '.generate_link(nicecase($pmxc['app_instance']), array('page' => 'proxmox', 'cluster' => $pmxc['app_instance'])).'
';
+ }
+ echo '
';
+} elseif (!var_isset('vmid')) {
+ echo '';
+ foreach (proxmox_cluster_vms(var_get('cluster')) as $pmxvm) {
+ echo '- '.generate_link($pmxvm['vmid']." (".$pmxvm['description'].")", array('page' => 'proxmox', 'cluster' => $pmxc['app_instance'], 'vmid' => $pmxvm['vmid'])).'
';
+ }
+ echo '
';
+} else {
+ include("pages/proxmox/vm.inc.php");
+}
+
+$pagetitle[] = 'Proxmox';
diff --git a/html/pages/proxmox/vm.inc.php b/html/pages/proxmox/vm.inc.php
new file mode 100644
index 0000000000..cb43e3c9f7
--- /dev/null
+++ b/html/pages/proxmox/vm.inc.php
@@ -0,0 +1,48 @@
+';
+var_dump($vm);
+print '';
+$graphs = array(
+ 'proxmox_traffic' => 'Traffic',
+);
+
+foreach ($vm['ports'] as $port) {
+ foreach ($graphs as $key => $text) {
+ $graph_type = 'proxmox_traffic';
+
+ $graph_array['height'] = '100';
+ $graph_array['width'] = '215';
+ $graph_array['to'] = $config['time']['now'];
+ $graph_array['id'] = $vm['app_id'];
+ $graph_array['device_id'] = $vm['device_id'];
+ $graph_array['type'] = 'application_'.$key;
+ $graph_array['port'] = $port['port'];
+ $graph_array['vmid'] = $vm['vmid'];
+ $graph_array['cluster'] = $vm['cluster'];
+ $graph_array['hostname'] = $vm['description'];
+
+ echo ''.$text.' '.$port['port'].'@'.$vm['description'].'
';
+
+ echo "";
+
+ include 'includes/print-graphrow.inc.php';
+
+ echo ' |
';
+ }
+}
+
+
+#if (is_numeric($vars['id']) && ($auth || application_permitted($vars['id']))) {
+# $app = get_application_by_id($vars['id']);
+# $device = device_by_id_cache($app['device_id']);
+# $title = generate_device_link($device);
+# $title .= $graph_subtype;
+# $auth = true;
+#}
+
diff --git a/includes/polling/applications/proxmox.inc.php b/includes/polling/applications/proxmox.inc.php
new file mode 100644
index 0000000000..65214d229a
--- /dev/null
+++ b/includes/polling/applications/proxmox.inc.php
@@ -0,0 +1,74 @@
+ $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'];
+ }
+
+ return false;
+}
+
+function proxmox_vm_exists($i, $c, &$pmxcache) {
+
+ if (isset($pmxcache[$c][$i]) && $pmxcache[$c][$i] > 0) {
+ return true;
+ }
+ if ($row = dbFetchRow("SELECT id FROM proxmox WHERE vmid = ? AND cluster = ?", array($i, $c))) {
+ $pmxcache[$c][$i] = (integer) $row['id'];
+ return true;
+ }
+
+ return false;
+}
+
+foreach ($pmxlines as $vm) {
+ list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5);
+
+ $rrd_filename = join('/', array(
+ $pmxcdir,
+ $vmid.'_netif_'.$vmport.'.rrd'));
+
+ if (!is_file($rrd_filename)) {
+ rrdtool_create(
+ $rrd_filename,
+ ' --step 300 \
+ DS:INOCTETS:DERIVE:600:0:12500000000 \
+ DS:OUTOCTETS:DERIVE:600:0:12500000000 '.$config['rrd_rra']);
+ }
+
+ rrdtool_update($rrd_filename, 'N:'.$vmpin.':'.$vmpout);
+ if (proxmox_vm_exists($vmid, $pmxcluster, $pmxcache) === true) {
+ dbUpdate(array('device_id' => $device['device_id'], 'last_seen' => array('NOW()'), 'description' => $vmdesc), 'proxmox', '`vmid` = ? AND `cluster` = ?', array($vmid, $pmxcluster));
+ } else {
+ $pmxcache[$pmxcluster][$vmid] = dbInsert(array('cluster' => $pmxcluster, 'vmid' => $vmid, 'description' => $vmdesc, 'device_id' => $device['device_id']), 'proxmox');
+ }
+
+ if ($portid = proxmox_port_exists($vmid, $pmxcluster, $vmport) !== false) {
+ dbUpdate(array('last_seen' => array('NOW()')), 'proxmox_ports', '`vm_id` = ? AND `port` = ?', array($pmxcache[$pmxcluster][$vmid], $vmport));
+ } else {
+ dbInsert(array('vm_id' => $pmxcache[$pmxcluster][$vmid], 'port' => $vmport), 'proxmox_ports');
+ }
+
+}
+
+unset($pmxlines);
+unset($pmxcluster);
+unset($pmxcdir);
+unset($proxmox);
+unset($pmxcache);
diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php
index 3d1754498c..5b78b682c9 100644
--- a/includes/polling/unix-agent.inc.php
+++ b/includes/polling/unix-agent.inc.php
@@ -50,6 +50,7 @@ if ($device['os_group'] == 'unix') {
"mysql",
"nginx",
"bind",
+ "proxmox",
"tinydns");
if (in_array($section, $agentapps)) {
@@ -99,7 +100,7 @@ if ($device['os_group'] == 'unix') {
if (file_exists("includes/polling/applications/$key.inc.php")) {
d_echo("Enabling $key for ".$device['hostname']." if not yet enabled\n");
- if (in_array($key, array('apache', 'mysql', 'nginx'))) {
+ if (in_array($key, array('apache', 'mysql', 'nginx', 'proxmox'))) {
if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') {
echo "Found new application '$key'\n";
dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key), 'applications');