#!/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"); read_csv ("esx-rz.csv", \%esxrz); read_csv ("storage-rz.csv", \%storagerz); if ( -e "VMsHostsDatastores.csv" ) { read_csv2 ("VMsHostsDatastores.csv", \%vmhostds, \%esxrz, \%storagerz); `cp VMsHostsDatastores.csv VMsHostsDatastores.last.csv`; } else { $ret+=2; } open OUT, ">output.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);
foreach ( sort keys %vmhostds) {
if ($vmhostds{$_}->{esx}->{dc} ne $vmhostds{$_}->{ds}->{dc}) {
# Üerspringe Hosts deren Datastore "images" oder "tso_install" ist
next if ($vmhostds{$_}->{ds}->{datastore} eq "images" );
next if ($vmhostds{$_}->{ds}->{datastore} eq "tso_install" );
# Üerspringe bestimmte Hostnamen
next if ($_ eq "tsoltlxlomd");
next if ($_ eq "tsoltlxlomu");
next if ($_ eq "tsolwebfeu");
next if ($_ eq "tsolwservicesd");
next if ($_ eq "tsolwservicesu");
# Üerspringe VMs deren Name ... enthä
next if ($_ =~ /BOW/);
next if ($_ =~ /CTX/);
next if ($_ =~ /^vCLS-/);
# FLW VM in FR4, DS in FR2 ist OK
next if ($_ =~ /^FLW/ and $vmhostds{$_}->{esx}->{dc} =~ /FR4/ );
# ungleiche Verteilung die nicht ignoriert werden kann
$addret=1;
my $line = sprintf "%-25s %-25s (%-3s) %-20s (%-3s)
\n", $_, $vmhostds{$_}->{esx}->{hostname}, $vmhostds{$_}->{esx}->{dc}, $vmhostds{$_}->{ds}->{datastore}, $vmhostds{$_}->{ds}->{dc};
$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 "