1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| use CGI;
use strict;
use Switch;
use warnings;
use Text::CSV;
my $system_report ="/path_to_report/system_report.csv";
my %state = (0 => ["CHECK_OK", "#008000"],
1 => ["CHECK_WARNING", "#FFA500"],
2 => ["CHECK_CRITICAL", "#FF0000"],
3 => ["CHECK_UNKNOWN", "#FFA07A"]);
my $csv_source = Text::CSV->new ({
binary => 1,
auto_diag => 1,
sep_char => ';'
});
open(my $fh, '<:encoding(utf8)', $system_report) or die "Could not open '$system_report' $!\n";
#$csv_source->getline($fh);
$csv_source->column_names ($csv_source->getline($fh));
my $query = CGI->new;
print $query->header(-type => 'text/html');
print $query->start_html(-title=>'Systems Check Report',
-author=>'toto',
-base=>'true',
-target=>'_blank',
-meta=>{'keywords'=>'pharaoh secret mummy',
'copyright'=>'copyright 1996 King Tut'},
-style=>{'src'=>'/styles/system_report.css'},
-BGCOLOR=>'blue');
print $query->br(), $query->br(), $query->hr(), $query->h3({-align => 'center'}, 'Systems Check Report'); $query->hr();
print $query->start_table({-class => "gridtable", -align => "center"},
$query->Tr($query->th(['System Name', 'IP Address', 'Category', 'Environment', 'Location', 'Description', 'List Of Services', 'Service Status', 'Service Information'])));
while (my $fields = $csv_source->getline_hr( $fh ))
{
#if ($fields->{"Service Status"} eq $state{0}[0])
#print '$fields->{"Service Status"}', "\n";
#my $status = $fields->{"Service Status"};
if ($fields->{'Service Status'} eq $state{0}[0])
{
print $query->Tr($query->td([$fields->{"System Name"},
$fields->{"IP Address"},
$fields->{"Category"},
$fields->{"Environment"},
$fields->{"Location"},
$fields->{"Description"},
$fields->{"List Of Services"},
({-bgcolor => $state{0}[1]}, $fields->{"Service Status"}),
$fields->{"Service Information"}]));
}
if ($fields->{'Service Status'} eq $state{1}[0])
{
print $query->Tr($query->td([$fields->{"System Name"},
$fields->{"IP Address"},
$fields->{"Category"},
$fields->{"Environment"},
$fields->{"Location"},
$fields->{"Description"},
$fields->{"List Of Services"},
({-bgcolor => $state{1}[1]}, $fields->{"Service Status"}),
$fields->{"Service Information"}]));
}
if ($fields->{'Service Status'} eq $state{2}[0])
{
print $query->Tr($query->td([$fields->{"System Name"},
$fields->{"IP Address"},
$fields->{"Category"},
$fields->{"Environment"},
$fields->{"Location"},
$fields->{"Description"},
$fields->{"List Of Services"},
({-bgcolor => $state{2}[1]}, $fields->{"Service Status"}),
$fields->{"Service Information"}]));
}
if ($fields->{'Service Status'} eq $state{3}[0])
{
print $query->Tr($query->td([$fields->{"System Name"},
$fields->{"IP Address"},
$fields->{"Category"},
$fields->{"Environment"},
$fields->{"Location"},
$fields->{"Description"},
$fields->{"List Of Services"},
({-bgcolor => $state{3}[1]}, $fields->{"Service Status"}),
$fields->{"Service Information"}]));
}
}
print $query->end_table();
print $query->end_html();
close $fh; |
Partager