This commit is contained in:
conetadm
2025-03-10 08:26:47 +01:00
parent 7fe35abee0
commit fba07d666f
2 changed files with 166 additions and 142 deletions

View File

@@ -42,6 +42,9 @@ for $server (@servers) {
$vms{$1}{'tags'},
$vms{$1}{'cdrom'}
) = $_ =~ /([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*).([^|]*)$/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";
@@ -75,16 +78,15 @@ 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)|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";
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,
@@ -106,17 +108,51 @@ foreach $vm (sort keys %vms) {
printf $str;
# if tag = euregon : extra datei
printf EUREGON $str if ($vms{$vm}{'tags'} =~ /euregon/i);
# if disksize < 1072623616 : ignorieren
#printf EUREGON $str if ($vms{$vm}{'tags'} =~ /euregon/i);
# ausgabe
printf OUTPUT $str;
$vms{$vm}{'disksizes'} =~ s/,/<br>/g;
$vms{$vm}{'diskusages'} =~ s/,/<br>/g;
$vms{$vm}{'tags'} =~ s/;/<br>/g;
$alltags = $vms{$vm}{'tags'};
$alltags =~ s/;/<br>/g;
$allsizes = $vms{$vm}{'disksizes'};
$allsizes =~ s/;/<br>/g;
$allusages = $vms{$vm}{'diskusages'};
$allusages =~ 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'},
$allsizes,
$allusages,
$vms{$vm}{'diskusages'},
$vms{$vm}{'sockets'},
$vms{$vm}{'cores'},
$vms{$vm}{'memory'},
$vms{$vm}{'bootdisk'},
$vms{$vm}{'description'},
$alltags,
$vms{$vm}{'status'},
$vms{$vm}{'host'},
$vms{$vm}{'pid'},
$vms{$vm}{'cdrom'}
);
printf HTML $str;
}
close OUTPUT;
printf HTML "\n</table>\n</body></html>";
close HTML;
# 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\n",
$vm,
$vms{$vm}{'name'},
$vms{$vm}{'os'},
@@ -133,15 +169,12 @@ foreach $vm (sort keys %vms) {
$vms{$vm}{'pid'},
$vms{$vm}{'cdrom'}
);
printf HTML $str;
print OUT $str;
}
}
close OUT;
}
close OUTPUT;
close EUREGON;
printf HTML "\n</table>\n</body></html>";
close HTML;
print "-- send output1.txt as attachement via email\n";
print "-- send output1.csv as attachement via email\n";
# mail
open MAIL, ">mail1.tmp";
@@ -150,15 +183,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";

View File

@@ -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;
@@ -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";