Compare commits
10 Commits
e107e90123
...
37e21abf02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37e21abf02 | ||
|
|
dea2938a93 | ||
|
|
b863e9ca19 | ||
|
|
ca4ba7a6e0 | ||
|
|
350fb13fe8 | ||
|
|
fba07d666f | ||
|
|
7fe35abee0 | ||
|
|
abfae634e1 | ||
|
|
c70146bd73 | ||
|
|
e0cdf870df |
@@ -8,4 +8,4 @@ Dieses Repository wird gespiegelt
|
||||
|
||||
> ÄNDERUNGEEN DIE NICHT AN DER QUELLE DURCHGEFÜHRT WERDEN WERDEN ÜBERSCHRIEBEN
|
||||
|
||||
# Tools und Monitoring-Skripte auf conlxsyslog03
|
||||
# Tools und Monitoring-Skripte auf conlxsyslog03
|
||||
@@ -24,5 +24,7 @@ do
|
||||
ta=`qm config ${vmid} | egrep "tags" | awk '{print $2}'`
|
||||
# get cdrom
|
||||
cd=`qm config ${vmid} | grep cdrom | awk -F' ' '{print $2}' | awk -F, '{print $1}'`
|
||||
echo "$vmid|$os|$ds|$us|$so|$co|$de|$ta|$cd"
|
||||
# get nics
|
||||
net=`qm config ${vmid} | egrep "^net" | perl -ne 'chomp; ($m,$v)=$_=~/virtio=(.*),bridge=(.*)/; print "$v($m);";'`
|
||||
echo "$vmid|$os|$ds|$us|$so|$co|$de|$ta|$cd|$net"
|
||||
done
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#use Data::Dumper;
|
||||
|
||||
if ($ARGV[0] eq "") {
|
||||
printf "no mail address given to send report to. exit\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
@servers = qw/conpve28 conpve29 conpve20/;
|
||||
|
||||
print "-- get general info from every host\n";
|
||||
for $server (@servers) {
|
||||
print "--- server $server\n";
|
||||
@serverinfo = `ssh -q -l root $server qm list | sed "s/\$/$server/" | grep -v VMID 2> /dev/null`;
|
||||
foreach (@serverinfo) {
|
||||
($vmid,
|
||||
$vms{$1}{'name'},
|
||||
$vms{$1}{'status'},
|
||||
$vms{$1}{'memory'},
|
||||
$vms{$1}{'bootdisk'},
|
||||
$vms{$1}{'pid'},
|
||||
$vms{$1}{'host'}
|
||||
) = $_ =~ / *([0-9]{3,4}) *([^ ]*) *([a-z]*) *([0-9]*) *([0-9.]*) *([0-9]*) *($server)/gm;
|
||||
}
|
||||
$vmlist="";
|
||||
foreach $vmid (keys %vms) {
|
||||
$vmlist = $vmlist . "$vmid " if ($vms{$vmid}{'host'} eq $server);
|
||||
}
|
||||
|
||||
print "--- get more details from vms $vmlist\n";
|
||||
@more = `ssh -q -l root $server bash /opt/pve-reporting/get_vmid_info.sh $vmlist 2> /dev/null`;
|
||||
foreach (@more) {
|
||||
chomp;
|
||||
( $vmid,
|
||||
$vms{$1}{'os'},
|
||||
$vms{$1}{'disksizes'},
|
||||
$vms{$1}{'usages'},
|
||||
$vms{$1}{'sockets'},
|
||||
$vms{$1}{'cores'},
|
||||
$vms{$1}{'description'},
|
||||
$vms{$1}{'tags'},
|
||||
$vms{$1}{'cdrom'}
|
||||
) = $_ =~ /([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*)$/gm;
|
||||
}
|
||||
}
|
||||
|
||||
#print Dumper(%vms);
|
||||
|
||||
open OUTPUT, ">output.txt";
|
||||
print "-- print vm information to console and in file output.txt\n";
|
||||
$str = sprintf "VMID|NAME|OS|DISKSIZE(S)|DISKUSAG(S)|SOCKETS|CORES|MEMORY(MB)|BOOTDISK(GB)|DESCRIPTION|TAGS|STATUS|HOST|PID|CDROM\n";
|
||||
printf $str;
|
||||
printf OUTPUT $str;
|
||||
foreach $vm (sort keys %vms) {
|
||||
$str = sprintf ("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
printf $str;
|
||||
printf OUTPUT $str;
|
||||
}
|
||||
close OUTPUT;
|
||||
|
||||
|
||||
print "-- send output.txt as attachement via email\n";
|
||||
|
||||
open MAIL, ">mail.tmp";
|
||||
printf MAIL "TO: $ARGV[0]\n";
|
||||
printf MAIL "FROM: CONET Services Monitoing Reporter <help\@conet.de\n";
|
||||
printf MAIL "SUBJECT: Proxmox VE Report\n";
|
||||
printf MAIL "X-CONET-SRC: conetadm\@conlxsyslog03:/scripts/conetadm/pve-reporting/get_vminfo.pl\n";
|
||||
printf MAIL "\n\n";
|
||||
`echo "" | mutt -H mail.tmp -a output.txt -- $ARGV[0]`;
|
||||
unlink "mail.tmp";
|
||||
|
||||
75
opt/observium/scripts/agent-local/proxmox-qemu-runner
Normal file
75
opt/observium/scripts/agent-local/proxmox-qemu-runner
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Proxmox VE virtual machine listing
|
||||
# (c) 2015-2019, Tom Laermans for Observium
|
||||
|
||||
PVESH=`which pvesh`
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
echo "<<<proxmox-qemu>>>"
|
||||
|
||||
VERSION=$(pveversion | awk -F/ '{print $2}' | sed 's/\..*//')
|
||||
if [[ ${VERSION} -ge 5 ]]
|
||||
then
|
||||
JSON=`pvesh get /nodes/$(hostname)/qemu --output-format=json-pretty 2>/dev/null`
|
||||
else
|
||||
pvesh get /nodes/$(hostname)/qemu 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
count=`echo $JSON | jq '. | length' `
|
||||
CACHE="/usr/lib/observium_agent/scripts-enabled/cached"
|
||||
touch $CACHE
|
||||
|
||||
#for ((i=$count-1; i>=0; i--)); do
|
||||
# JSON=`echo $JSON | jq 'del(.['$i']|select(.["name"] | startswith("VM ")))'`
|
||||
# JSON=`echo $JSON | jq 'del(.['$i']|select(.["name"] | startswith("veeam-")))'`
|
||||
#done
|
||||
#last=$(($count-1))
|
||||
|
||||
JSON=`echo $JSON | jq 'del(.[]|select(.["name"] | startswith("VM ")))'`
|
||||
JSON=`echo $JSON | jq 'del(.[]|select(.["name"] | startswith("veeam")))'`
|
||||
count=`echo $JSON | jq '. | length' `
|
||||
|
||||
for ((i=0; i<$count; i++)); do
|
||||
name=`echo $JSON | jq -r '.['$i'].name'`
|
||||
vmid=`echo $JSON | jq -r '.['$i'].vmid'`
|
||||
|
||||
#if [[ ! $name =~ $ignoRE ]]; then
|
||||
exec 2>/dev/null
|
||||
var1=`qm guest cmd ${vmid} get-osinfo | jq -r '.["pretty-name"]'`
|
||||
var2=`cat ${CACHE} | grep ${vmid} | awk -F':' '{print $2}'`
|
||||
var3=`cat /etc/pve/qemu-server/${vmid}.conf | grep -m 1 ostype | awk '{print $2}'`
|
||||
|
||||
ostype=$var1
|
||||
if [[ -z "$ostype" || "$ostype" == *"is not running"* || "$ostype" == *"QEMU guest agent configured"* ]]; then
|
||||
ostype=$var2
|
||||
if [[ -z "$ostype" ]]; then
|
||||
ostype="$var3 (more precise information not yet available)"
|
||||
fi
|
||||
else
|
||||
sed -i "s|$vmid:.*|$vmid:$var1|" $CACHE
|
||||
fi
|
||||
|
||||
if [[ -z "$var2" ]]; then
|
||||
grep $vmid $CACHE > /dev/null
|
||||
if [ "$?" == "1" ]; then
|
||||
echo "$vmid:" >> $CACHE
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$i" == "0" ]
|
||||
then
|
||||
CMD=".[$i] += {\"os\":\"$ostype\"}"
|
||||
else
|
||||
CMD=$CMD" | .[$i] += {\"os\":\"$ostype\"}"
|
||||
fi
|
||||
#echo "$name is $vmid # $var1 ## $var2 ### $var3" ; echo "---"
|
||||
#fi
|
||||
done
|
||||
|
||||
jqcmd=(jq "$CMD")
|
||||
|
||||
#echo run it now
|
||||
echo "$JSON" | "${jqcmd[@]}"
|
||||
|
||||
3
opt/observium/scripts/proxmox-qemu
Normal file
3
opt/observium/scripts/proxmox-qemu
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat /lib/observium_agent/scripts-available/proxmox-qemu-runner-data
|
||||
0
opt/observium/scripts/proxmox-qemu-runner-data
Normal file
0
opt/observium/scripts/proxmox-qemu-runner-data
Normal file
@@ -2,8 +2,8 @@
|
||||
#use Data::Dumper;
|
||||
|
||||
if ($ARGV[0] eq "") {
|
||||
printf "no mail address given to send report to. exit\n";
|
||||
exit 1;
|
||||
printf "no mail address given to send report to. exit\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
@servers = qw/conpve29 conpve28 conpve20 conpve17/;
|
||||
@@ -14,37 +14,41 @@ for $server (@servers) {
|
||||
@serverinfo = `ssh -q -l root $server qm list | sed "s/\$/$server/" | grep -v VMID 2> /dev/null`;
|
||||
foreach (@serverinfo) {
|
||||
($vmid,
|
||||
$vms{$1}{'name'},
|
||||
$vms{$1}{'status'},
|
||||
$vms{$1}{'memory'},
|
||||
$vms{$1}{'bootdisk'},
|
||||
$vms{$1}{'pid'},
|
||||
$vms{$1}{'host'}
|
||||
) = $_ =~ / *([0-9]{3,4}) *([^ ]*) *([a-z]*) *([0-9]*) *([0-9.]*) *([0-9]*) *($server)/gm;
|
||||
$vms{$1}{'name'},
|
||||
$vms{$1}{'status'},
|
||||
$vms{$1}{'memory'},
|
||||
$vms{$1}{'bootdisk'},
|
||||
$vms{$1}{'pid'},
|
||||
$vms{$1}{'host'}
|
||||
) = $_ =~ / *([0-9]{3,4}) *([^ ]*) *([a-z]*) *([0-9]*) *([0-9.]*) *([0-9]*) *($server)/gm;
|
||||
}
|
||||
$vmlist="";
|
||||
foreach $vmid (keys %vms) {
|
||||
$vmlist = $vmlist . "$vmid " if ($vms{$vmid}{'host'} eq $server);
|
||||
}
|
||||
chomp $vmlist;
|
||||
chomp $vmlist;
|
||||
|
||||
print "---- get more details from vms $vmlist\n";
|
||||
@more = `ssh -q -l root $server bash /opt/pve-reporting/get_vmid_info.sh $vmlist 2> /dev/null`;
|
||||
foreach (@more) {
|
||||
chomp;
|
||||
( $vmid,
|
||||
$vms{$1}{'os'},
|
||||
$vms{$1}{'disksizes'},
|
||||
$vms{$1}{'diskusages'},
|
||||
$vms{$1}{'sockets'},
|
||||
$vms{$1}{'cores'},
|
||||
$vms{$1}{'description'},
|
||||
$vms{$1}{'tags'},
|
||||
$vms{$1}{'cdrom'}
|
||||
) = $_ =~ /([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*)$/gm;
|
||||
print "----- ID $vmid\n";
|
||||
$vms{$1}{'os'},
|
||||
$vms{$1}{'disksizes'},
|
||||
$vms{$1}{'diskusages'},
|
||||
$vms{$1}{'sockets'},
|
||||
$vms{$1}{'cores'},
|
||||
$vms{$1}{'description'},
|
||||
$vms{$1}{'tags'},
|
||||
$vms{$1}{'cdrom'},
|
||||
$vms{$1}{'nets'}
|
||||
) = $_ =~ /([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*)$/gm;
|
||||
@tags=split ";", $vms{$1}{'tags'};
|
||||
print "tags $vms{$1}{'tags'}\n";
|
||||
foreach (@tags) { print "tag $_\n"; $tag{$_}{'name'}=$_; }
|
||||
print "----- ID $vmid\n";
|
||||
}
|
||||
print "\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
open HTML, ">output1.html";
|
||||
@@ -75,73 +79,107 @@ printf HTML '<meta name=viewport content=width=device-width,initial-scale=1/>
|
||||
';
|
||||
printf HTML "<head>\n<body>\n";
|
||||
|
||||
open OUTPUT, ">output1.txt";
|
||||
open EUREGON, ">output_euregon.txt";
|
||||
print "-- print vm information to console and in file output1.txt\n";
|
||||
$str = sprintf "VMID|NAME|OS|DISKSIZE(S)|DISKUSAGE(S)|SOCKETS|CORES|MEMORY(MB)|BOOTDISK(GB)|DESCRIPTION|TAGS|STATUS|HOST|PID|CDROM\n";
|
||||
printf $str;
|
||||
printf OUTPUT $str;
|
||||
printf EUREGON $str;
|
||||
open OUTPUT, ">output1.csv";
|
||||
print "-- print vm information to console and in file output1.csv\n";
|
||||
$hstr = sprintf "VMID|NAME|OS|DISKSIZE(S)|DISKUSAGE(S)|SOCKETS|CORES|MEMORY(MB)|BOOTDISK(GB)|NETS|DESCRIPTION|TAGS|STATUS|HOST|PID|CDROM\n";
|
||||
printf $hstr;
|
||||
printf OUTPUT $hstr;
|
||||
|
||||
$str = sprintf "<table border='1' id='example' class='display compact' width='100%'>\n<thead><tr><th>VMID</th><th>NAME</th><th>OS</th><th>DISKSIZE(S)</th><th>DISKUSAGE(S)</th><th>SOCKETS</th><th>CORES</th><th>MEMORY(MB)</th><th>BOOTDISK(GB)</th><th>DESCRIPTION</th><th>TAGS</th><th>STATUS</th><th>HOST</th><th>PID</th><th>CDROM</th></tr></thead>\n";
|
||||
$str = sprintf "<table border='1' id='example' class='display compact' width='100%'>\n<thead><tr><th>VMID</th><th>NAME</th><th>OS</th><th>DISKSIZE(S)</th><th>DISKUSAGE(S)</th><th>SOCKETS</th><th>CORES</th><th>MEMORY(MB)</th><th>BOOTDISK(GB)</th><th>NETS</th><th>DESCRIPTION</th><th>TAGS</th><th>STATUS</th><th>HOST</th><th>PID</th><th>CDROM</th></tr></thead>\n";
|
||||
printf HTML $str;
|
||||
|
||||
foreach $vm (sort keys %vms) {
|
||||
$str = sprintf ("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
$str = sprintf ("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'nets'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
printf $str;
|
||||
|
||||
# if tag = euregon : extra datei
|
||||
printf EUREGON $str if ($vms{$vm}{'tags'} =~ /euregon/i);
|
||||
# if tag = euregon : extra datei
|
||||
#printf EUREGON $str if ($vms{$vm}{'tags'} =~ /euregon/i);
|
||||
|
||||
# if disksize < 1072623616 : ignorieren
|
||||
|
||||
# ausgabe
|
||||
# ausgabe
|
||||
printf OUTPUT $str;
|
||||
|
||||
$vms{$vm}{'disksizes'} =~ s/,/<br>/g;
|
||||
$vms{$vm}{'diskusages'} =~ s/,/<br>/g;
|
||||
$vms{$vm}{'tags'} =~ s/;/<br>/g;
|
||||
$str = sprintf ("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
$alltags = $vms{$vm}{'tags'};
|
||||
$alltags =~ s/;/<br>/g;
|
||||
$allsizes = $vms{$vm}{'disksizes'};
|
||||
$allsizes =~ s/;/<br>/g;
|
||||
$allusages = $vms{$vm}{'diskusages'};
|
||||
$allusages =~ s/;/<br>/g;
|
||||
$allnets = $vms{$vm}{'nets'};
|
||||
$allnets =~ s/;/<br>/g;
|
||||
|
||||
$str = sprintf ("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$allsizes,
|
||||
$allusages,
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$allnets,
|
||||
$vms{$vm}{'description'},
|
||||
$alltags,
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
printf HTML $str;
|
||||
}
|
||||
close OUTPUT;
|
||||
close EUREGON;
|
||||
printf HTML "\n</table>\n</body></html>";
|
||||
close HTML;
|
||||
|
||||
|
||||
print "-- send output1.txt as attachement via email\n";
|
||||
# schreibe einzelne tagfiles
|
||||
foreach $t (keys %tag) {
|
||||
print "t $t\n";
|
||||
open OUT, ">output1_$t.csv";
|
||||
printf OUT $hstr;
|
||||
foreach $vm (sort keys %vms) {
|
||||
print "1 $vms{$vm}{'tags'} 2 $tag{$t}{'name'}\n";
|
||||
if ( $vms{$vm}{'tags'} =~ /$t/ ) {
|
||||
$str = sprintf ("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'nets'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
print OUT $str;
|
||||
}
|
||||
}
|
||||
close OUT;
|
||||
}
|
||||
print "-- send output1.csv as attachement via email\n";
|
||||
|
||||
# mail
|
||||
open MAIL, ">mail1.tmp";
|
||||
@@ -150,15 +188,5 @@ printf MAIL "FROM: CONET Services Monitoring Reporter <help\@conet.de\n";
|
||||
printf MAIL "SUBJECT: Proxmox VE Report Cluster 1\n";
|
||||
printf MAIL "X-CONET-SRC: conetadm\@conlxobs1:/scripts/conetadm/pve-reporting/get_vminfo_clu1.pl\n";
|
||||
printf MAIL "\n\n";
|
||||
`echo "" | mutt -H mail1.tmp -a output1.txt -- $ARGV[0]`;
|
||||
unlink "mail1.tmp";
|
||||
|
||||
# euregon
|
||||
open MAIL, ">mail1.tmp";
|
||||
printf MAIL "TO: $ARGV[0]\n";
|
||||
printf MAIL "FROM: CONET Services Monitoring Reporter <help\@conet.de\n";
|
||||
printf MAIL "SUBJECT: Proxmox VE Report Euregon\n";
|
||||
printf MAIL "X-CONET-SRC: conetadm\@conlxobs1:/scripts/conetadm/pve-reporting/get_vminfo_clu1.pl\n";
|
||||
printf MAIL "\n\n";
|
||||
`echo "" | mutt -H mail1.tmp -a output_euregon.txt -- $ARGV[0]`;
|
||||
`echo "" | mutt -H mail1.tmp -a output1.csv -- $ARGV[0]`;
|
||||
unlink "mail1.tmp";
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#use Data::Dumper;
|
||||
|
||||
if ($ARGV[0] eq "") {
|
||||
printf "no mail address given to send report to. exit\n";
|
||||
exit 1;
|
||||
printf "no mail address given to send report to. exit\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
@servers = qw/pveadmin4.conadm.de/;
|
||||
@@ -14,37 +14,37 @@ for $server (@servers) {
|
||||
@serverinfo = `ssh -q -l root $server qm list | sed "s/\$/$server/" | grep -v VMID 2> /dev/null`;
|
||||
foreach (@serverinfo) {
|
||||
($vmid,
|
||||
$vms{$1}{'name'},
|
||||
$vms{$1}{'status'},
|
||||
$vms{$1}{'memory'},
|
||||
$vms{$1}{'bootdisk'},
|
||||
$vms{$1}{'pid'},
|
||||
$vms{$1}{'host'}
|
||||
) = $_ =~ / *([0-9]{3,4}) *([^ ]*) *([a-z]*) *([0-9]*) *([0-9.]*) *([0-9]*) *($server)/gm;
|
||||
$vms{$1}{'name'},
|
||||
$vms{$1}{'status'},
|
||||
$vms{$1}{'memory'},
|
||||
$vms{$1}{'bootdisk'},
|
||||
$vms{$1}{'pid'},
|
||||
$vms{$1}{'host'}
|
||||
) = $_ =~ / *([0-9]{3,4}) *([^ ]*) *([a-z]*) *([0-9]*) *([0-9.]*) *([0-9]*) *($server)/gm;
|
||||
}
|
||||
$vmlist="";
|
||||
foreach $vmid (keys %vms) {
|
||||
$vmlist = $vmlist . "$vmid " if ($vms{$vmid}{'host'} eq $server);
|
||||
}
|
||||
chomp $vmlist;
|
||||
chomp $vmlist;
|
||||
|
||||
print "---- get more details from vms $vmlist\n";
|
||||
@more = `ssh -q -l root $server bash /opt/pve-reporting/get_vmid_info.sh $vmlist 2> /dev/null`;
|
||||
foreach (@more) {
|
||||
chomp;
|
||||
( $vmid,
|
||||
$vms{$1}{'os'},
|
||||
$vms{$1}{'disksizes'},
|
||||
$vms{$1}{'diskusages'},
|
||||
$vms{$1}{'sockets'},
|
||||
$vms{$1}{'cores'},
|
||||
$vms{$1}{'description'},
|
||||
$vms{$1}{'tags'},
|
||||
$vms{$1}{'cdrom'}
|
||||
) = $_ =~ /([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*)$/gm;
|
||||
print "----- ID $vmid\n";
|
||||
$vms{$1}{'os'},
|
||||
$vms{$1}{'disksizes'},
|
||||
$vms{$1}{'diskusages'},
|
||||
$vms{$1}{'sockets'},
|
||||
$vms{$1}{'cores'},
|
||||
$vms{$1}{'description'},
|
||||
$vms{$1}{'tags'},
|
||||
$vms{$1}{'cdrom'}
|
||||
) = $_ =~ /([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*)$/gm;
|
||||
print "----- ID $vmid\n";
|
||||
}
|
||||
print "\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
open HTML, ">output2.html";
|
||||
@@ -75,8 +75,8 @@ printf HTML '<meta name=viewport content=width=device-width,initial-scale=1/>
|
||||
';
|
||||
printf HTML "<head>\n<body>\n";
|
||||
|
||||
open OUTPUT, ">output2.txt";
|
||||
print "-- print vm information to console and in file output2.txt\n";
|
||||
open OUTPUT, ">output2.csv";
|
||||
print "-- print vm information to console and in file output2.csv\n";
|
||||
$str = sprintf "VMID|NAME|OS|DISKSIZE(S)|DISKUSAGE(S)|SOCKETS|CORES|MEMORY(MB)|BOOTDISK(GB)|DESCRIPTION|TAGS|STATUS|HOST|PID|CDROM\n";
|
||||
printf $str;
|
||||
printf OUTPUT $str;
|
||||
@@ -85,45 +85,45 @@ $str = sprintf "<table border='1' id='example' class='display compact' width='10
|
||||
printf HTML $str;
|
||||
foreach $vm (sort keys %vms) {
|
||||
$str = sprintf ("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
printf $str;
|
||||
printf OUTPUT $str;
|
||||
|
||||
$vms{$vm}{'disksizes'} =~ s/,/<br>/g;
|
||||
$vms{$vm}{'diskusages'} =~ s/,/<br>/g;
|
||||
$vms{$vm}{'tags'} =~ s/;/<br>/g;
|
||||
$vms{$vm}{'disksizes'} =~ s/,/<br>/g;
|
||||
$vms{$vm}{'diskusages'} =~ s/,/<br>/g;
|
||||
$vms{$vm}{'tags'} =~ s/;/<br>/g;
|
||||
$str = sprintf ("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
$vm,
|
||||
$vms{$vm}{'name'},
|
||||
$vms{$vm}{'os'},
|
||||
$vms{$vm}{'disksizes'},
|
||||
$vms{$vm}{'diskusages'},
|
||||
$vms{$vm}{'sockets'},
|
||||
$vms{$vm}{'cores'},
|
||||
$vms{$vm}{'memory'},
|
||||
$vms{$vm}{'bootdisk'},
|
||||
$vms{$vm}{'description'},
|
||||
$vms{$vm}{'tags'},
|
||||
$vms{$vm}{'status'},
|
||||
$vms{$vm}{'host'},
|
||||
$vms{$vm}{'pid'},
|
||||
$vms{$vm}{'cdrom'}
|
||||
);
|
||||
printf HTML $str;
|
||||
}
|
||||
close OUTPUT;
|
||||
@@ -131,7 +131,7 @@ printf HTML "\n</table>\n</body></html>";
|
||||
close HTML;
|
||||
|
||||
|
||||
print "-- send output2.txt as attachement via email\n";
|
||||
print "-- send output2.csv as attachement via email\n";
|
||||
|
||||
open MAIL, ">mail2.tmp";
|
||||
printf MAIL "TO: $ARGV[0]\n";
|
||||
@@ -139,5 +139,6 @@ printf MAIL "FROM: CONET Services Monitoring Reporter <help\@conet.de\n";
|
||||
printf MAIL "SUBJECT: Proxmox VE Report Cluster Admin\n";
|
||||
printf MAIL "X-CONET-SRC: conetadm\@conlxobs1:/scripts/conetadm/pve-reporting/get_vminfo_clu2.pl\n";
|
||||
printf MAIL "\n\n";
|
||||
`echo "" | mutt -H mail2.tmp -a output2.txt -- $ARGV[0]`;
|
||||
`echo "" | mutt -H mail2.tmp -a output2.csv -- $ARGV[0]`;
|
||||
unlink "mail2.tmp";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user