59 lines
1.7 KiB
Raku
Executable File
59 lines
1.7 KiB
Raku
Executable File
#!/usr/bin/perl
|
|
|
|
my %esxrz;
|
|
my %storagerz;
|
|
my %vmhostds;
|
|
|
|
my $addret=0;
|
|
my $ret=0;
|
|
# Fehler Flags MFD
|
|
# M: Montag
|
|
# F: File von RVTools nicht aktuell
|
|
# D: Datastore Verteilung nicht ok
|
|
|
|
my $M=`date +'%u'`;
|
|
$ret+=4 if ($M == "1");
|
|
|
|
if ( -e "VMsHostsDatastoresSchott.csv" ) {
|
|
`cp VMsHostsDatastoresSchott.csv VMsHostsDatastoresSchott.last.csv`;
|
|
} else {
|
|
$ret+=2;
|
|
}
|
|
|
|
open OUT, ">output2.html";
|
|
printf OUT "<html><body><p style=font-family:'Courier New'><br>\n";
|
|
printf OUT "Montags gibt's die Mail unabhängig vom Ergebnis der Prüfung.<br>\n" if ($ret & 4);
|
|
printf OUT "Die Prüfung kann nicht durchgeführt werden. Die Datei aus den RVTools fehlt.<br>\n" if ($ret & 2);
|
|
|
|
$rettxt=`cat VMsHostsDatastoresSchott.csv | grep -v "VMName" | grep -v "#TYPE" | egrep -v "citrix|iso" | egrep -v -i '".*","sdefras.*","sdefras.*"' | egrep -v -i '".*","sderums.*","sderums.*"' | tr -d '"' | tr ',' ' ' | sed -e 's/\\r/<br>\\n/' `;
|
|
|
|
unless ($rettxt eq "") {
|
|
# ungleiche Verteilung die nicht ignoriert werden kann
|
|
$addret=1;
|
|
my $line = $rettxt;
|
|
$line =~ s/ / /g;
|
|
printf OUT "$line";
|
|
}
|
|
|
|
$ret=$ret + $addret;
|
|
unless ($ret & 2) {
|
|
printf OUT "Keine Unstimmigkeiten in der Verteilung gefunden.<br>\n" unless ($ret & 1);
|
|
}
|
|
|
|
printf OUT "</p></body></html>";
|
|
close OUT;
|
|
|
|
$ret=$ret + $addret;
|
|
|
|
# montag rv file fehlt unstimmigkeiten
|
|
if ( ($ret & 4) or ($ret & 2) or ($ret & 1) ) {
|
|
$pwd=`pwd`; chomp $pwd;
|
|
$usr = $ENV{LOGNAME} || $ENV{USER} || getpwuid($<);
|
|
$hst=`hostname`; chomp $hst;
|
|
$bsn=`basename $0`; chomp $bsn;
|
|
$scr="$usr\@$hst:$pwd/$bsn";
|
|
`cat output2.html | mailx "help\@conet.de" -a 'X-CONET-SRC: $scr' -a "Content-Type: text/html" -s "Mismatch in Schott ESX Datastore Location"`;
|
|
}
|
|
unlink "VMsHostsDatastoresSchott.csv";
|
|
|