#!/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 "


\n"; printf OUT "Montags gibt's die Mail unabhängig vom Ergebnis der Prüfung.
\n" if ($ret & 4); printf OUT "Die Prüfung kann nicht durchgeführt werden. Die Datei aus den RVTools fehlt.
\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/
\\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.
\n" unless ($ret & 1); } printf OUT "

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