Created
August 24, 2015 12:55
-
-
Save tuxis-ie/1df19bb377c4afd96c07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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'}; | |
print "<<<proxmox-$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 "$vmname/$vm->{'dev'}/$vm->{'in'}/$vm->{'out'}\n"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment