From: Heikki Levanto Date: Fri, 18 Mar 2011 12:50:39 +0000 (+0100) Subject: Turned the table around, added lines X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=d57c0508b74bf0b6bc7917ae3674d22376faebeb;p=git-tools-moved-to-github.git Turned the table around, added lines --- diff --git a/aptcheck/aptcheck.pl b/aptcheck/aptcheck.pl index c5d17be..22ad13f 100755 --- a/aptcheck/aptcheck.pl +++ b/aptcheck/aptcheck.pl @@ -31,6 +31,7 @@ my %normhosts; my %normpkgs; my %okhosts; my %skiphosts; +my %allhosts; my $sectot = 0; my $owntot = 0; my $normtot = 0; @@ -43,6 +44,7 @@ for $hline ( split("\n",$hostlist) ) { next if ($H =~ /^commands/ ); next if ($H =~ /^servicegroups/ ); print "Checking $H\n" if $debug; + $allhosts{$H}=1; my $apt = `ssh $H apt-get upgrade -s -o 'Debug::NoLocking=true' `; # Note, do not append -qq, we want some output even when nothing to do if ( !$apt ) { @@ -103,6 +105,7 @@ for $hline ( split("\n",$hostlist) ) { $table .= " $own from indexdata " if $own; } else { $table .= "ok"; + $okhosts{$H} = 1; } my $updlink = $wikilink . ucfirst($H) . "Updates" . $year; $table .= " Upd"; @@ -113,7 +116,7 @@ for $hline ( split("\n",$hostlist) ) { } $table .= "\n"; -# Produce page +# Page header my $outfile = "/tmp/aptcheck.html"; open F, ">$outfile" or die "Could not open $outfile for writing: $!"; @@ -123,43 +126,63 @@ print F "\n"; print F "

Apt package status

\n"; -# Summary table +# Summary table - NEW: one row for per host group +print F "

\n"; print F "\n"; print F "" ; -print F "\n"; +print F "\n"; + +if ( $sectot ) { + print F "\n" ; -print F ""; + print F "\n"; +} +if ( $owntot ) { + print F "\n" ; -print F "" . "\n"; -print F "\n"; - - -print F ""; + print F "\n"; } -print F " \n"; -#print F ""; -#print F ""; -print F "\n" ; + print F ""; + print F "\n"; } -print F " \n"; -#print F "\n"; -print F "\n"; + print F "\n"; +} +if ( %okhosts ) { + print F "\n"; + print F "\n"; } -print F " \n"; - -print F "\n"; -print F ""; -print F ""; -print F "\n"; print F "
 Security
" . scalar(keys(%sechosts)) . +print F "
HostsPackages
Security
" . scalar(keys(%sechosts)) . " / " . scalar(keys(%secpkgs)) . " / $sectot
Indexdata
" . scalar(keys(%ownhosts)) . + print F "
"; + for $HH ( sort(keys(%sechosts)) ) { + print F "$HH "; + } + print F "" . join(" ",sort(keys(%secpkgs))) . " 
Indexdata
" . scalar(keys(%ownhosts)) . " / " . scalar(keys(%ownpkgs)) . " / $owntot
Normal
" . scalar(keys(%normhosts)) . - " / " . scalar(keys(%normpkgs)) . " / $normtot
Hosts"; -for $HH ( sort(keys(%sechosts)) ) { - print F "$HH "; + print F ""; + for $HH ( sort(keys(%ownhosts)) ) { + print F "$HH "; + } + print F "" . join(" ",sort(keys(%ownpkgs))) . " 
" . join(" ",sort(keys(%sechosts))) . " " . join(" ",sort(keys(%ownhosts))) . " "; -for $HH ( sort(keys(%ownhosts)) ) { - print F "$HH "; +if ( $normtot ) { + print F "
Indexdata
" . scalar(keys(%normhosts)) . + " / " . scalar(keys(%normpkgs)) . " / $normtot
"; + for $HH ( sort(keys(%normhosts)) ) { + print F "$HH "; + } + print F "" . join(" ",sort(keys(%normpkgs))) . " 
" . join(" ",sort(keys(%normhosts))) . " 
"; -for $HH ( sort(keys(%normhosts)) ) { - print F "$HH "; +if ( %skiphosts ) { + print F "
Skipped: " . scalar(keys(%skiphosts)) . ""; + for $HH ( sort(keys(%skiphosts)) ) { + print F "$HH "; + } + print F "
Ok: " . scalar(keys(%okhosts)) . ""; + for $HH ( sort(keys(%okhosts)) ) { + print F "$HH "; + } + print F "
Packages" . join(" ",sort(keys(%secpkgs))) . " " . join(" ",sort(keys(%ownpkgs))) . " " . join(" ",sort(keys(%normpkgs))) . " 
\n"; + +# The host table print F $table; print F "

Produced " . `date`. @@ -172,6 +195,8 @@ close(F) system "scp -q $outfile nagios:/var/www/heikki/index.html"; +exit(0); + # Helper to take two strings and highligt that part of the second # that is different from the first. sub strdiff {