From fee2ed820bedb4613871aa9747b40121e3ae7879 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Fri, 28 Aug 2015 10:49:19 +0200 Subject: [PATCH 1/3] Add proxmox-agent --- agent-local/proxmox | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 agent-local/proxmox diff --git a/agent-local/proxmox b/agent-local/proxmox new file mode 100755 index 0000000..5c7b40b --- /dev/null +++ b/agent-local/proxmox @@ -0,0 +1,37 @@ +#!/usr/bin/perl -w + +use constant { + TIMEZONE => 'Europe/Amsterdam' +}; + +use strict; +use PVE::API2Client; +use PVE::AccessControl; +use PVE::INotify; +use Data::Dumper; + +my $hostname = PVE::INotify::read_file("hostname"); + +my $ticket = PVE::AccessControl::assemble_ticket('root@pam'); +my $csrftoken = PVE::AccessControl::assemble_csrf_prevention_token('root@pam'); + +my $conn = PVE::API2Client->new( + ticket => $ticket, + csrftoken => $csrftoken, +); + +my $clustername = $conn->get("/api2/json/cluster/ha/config")->{'data'}->{'children'}[0]{'name'}; +if (!defined($clustername)) { + $clustername = $hostname; +} + + +print "<<>>\n"; + +print "$clustername\n"; + +foreach my $vm (@{$conn->get("/api2/json/nodes/$hostname/netstat")->{'data'}}) { + my $vmid = $vm->{'vmid'}; + my $vmname = $conn->get("/api2/json/nodes/$hostname/qemu/$vmid/config")->{'data'}->{'name'}; + print "$vmid/$vm->{'dev'}/$vm->{'in'}/$vm->{'out'}/$vmname\n"; +}; From d6795c60a171eba023b8c0e5b151376c6bcfa0d1 Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Fri, 28 Aug 2015 10:49:24 +0200 Subject: [PATCH 2/3] Add proxmox-agent --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 7765710..a82b5bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +librenms-agent (1.0.2) stable; urgency=low + + - Include a Proxmox-agent + + -- Mark Schouten Fri, 28 Aug 2015 10:33:00 +0200 + librenms-agent (1.0.1) stable; urgency=low - Do not include the README in the repodir From 2b9625953240ade30cf5ccef22a9293a016b819b Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Fri, 28 Aug 2015 10:52:04 +0200 Subject: [PATCH 3/3] Add license --- agent-local/proxmox | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/agent-local/proxmox b/agent-local/proxmox index 5c7b40b..fd1f73a 100755 --- a/agent-local/proxmox +++ b/agent-local/proxmox @@ -1,5 +1,19 @@ #!/usr/bin/perl -w +# Copyright (C) 2015 Mark Schouten +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; version 2 dated June, +# 1991. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# See http://www.gnu.org/licenses/gpl.txt for the full license + use constant { TIMEZONE => 'Europe/Amsterdam' };