X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=aptcheck%2Faptcheck.pl;h=2b769f22c9860c2ac2bf6610b06844a5046e6ba5;hb=69a6a467da589cfa124afba38c964635d38396e8;hp=23dab9d3a9290378337e81d8d3f524ef3a9e6fb2;hpb=fb0a04d2b6adb5906df39518729087f8c4d0254f;p=git-tools-moved-to-github.git diff --git a/aptcheck/aptcheck.pl b/aptcheck/aptcheck.pl index 23dab9d..2b769f2 100755 --- a/aptcheck/aptcheck.pl +++ b/aptcheck/aptcheck.pl @@ -5,44 +5,178 @@ # Depends heavily on having ssh key authentication set up to all # boxes. That's why I run it on my own workstation. # +# Regular debian upgrades are detected by running +# apt-get upgrade -s +# on every machine, and parsing the output. + +# We have decided to maintain some packages manually on some +# machines, so that system-level upgrades will not disturb +# applications, which may need more hand-holding. These are +# extracted from our apt repository, and queried on every +# server with apt-cache policy. This way, as soon as a package +# is released on our repo, it will get listed here. +# # 11-Mar-2011 Heikki: Started this +# 22-Mar-2011 Heikki: Adding manually maintained packages +# 15-Aug-2011 Heikki: Adding a total in the headline, for nagiosgrapher +# +# TODO: Assumes that we release our restricted packages for all versions +# and architectures at the same time. Gets only the highest version from +# all, and reports anything less than this. Good enough for now. +# +# TODO: Get the dates from ls --full-time /var/cache/apt/archives/ +# and display next to the packages, so we can see how long they have +# been lingering. Boldface them if older than some limit #### Init +use strict; my $debug= $ARGV[0] || 0; # 0=none, 1=some, 2=more, 3=much my $year =`date +%Y`; my $wikilink = 'http://twiki.indexdata.dk/cgi-bin/twiki/view/ID/'; +my $restrictedpackages = "ssh -q kebab cat /home/ftp/pub/debian/dists/*/restricted/*/Packages"; + +#### Host comments +my %hostcomments = ( + "ariel" => "Niels Erik does the manual upgrades", + "bellone" => "Niels Erik does the manual upgrades", + "cfrepous" => "Wolfram does the manual upgrades", + "leopard" => "Wolfram does the manual upgrades", + "lsd" => "Heikki takes care of all upgrades", + ); + #### Get list of hosts # I could use a hard-coded list, but I would forget to maintain it. -# Nagios knows most of our hosts. +# Nagios knows most of our hosts. It even knows which are worth +# checking, they have a command to check apts! my $hostlist = `ssh nagios grep -l Apt /etc/nagios3/indexdata-conf.d/*.cfg` or die "Could not get host list"; print "Got list:\n$hostlist\n" if $debug>2; -my $table = "
$H (skipped)\n"; + $skiphosts{$H}=1; next; } print "Got apts for $H: \n$apt\n" if $debug>2; - my $det = ""; + my $det = ""; # detail lines my $pkgs = 0; my $secs = 0; my $own = 0; - for $p ( split("\n",$apt) ) { + my $man = 0; + my $restrname = ""; + my $restrinst = ""; + my $restrcand = ""; + for my $p ( split("\n",$apt) ) { + # parse apt-cache output + $restrname = $1 if $p =~ /^(\S+):$/; + $restrinst = $1 if $p =~ /^\s+Installed:\s+(\S+)$/; + $restrcand = $1 if $p =~ /^\s+Candidate:\s+(\S+)$/; + if ( $p =~ /^\s+Version table:/ ) { # have all for that package + my $bver = $restrpkgs{$restrname}; + if ( ( $restrinst eq $restrcand ) && + ( $restrinst ne $bver ) ) { + # if different, it is a regular apt upgrade, and will be seen + # later. AND we want to have a different version in our repo + `dpkg --compare-versions "$bver" lt "$restrinst" `; + if ( $? ) { # It was not a downgrade + # manual packages may be ahead of the repo! + $mantot++; + $man++; + $pkgs++; + $manhosts{$H} = 1; + $manpkgs{$restrname} = 1; + $det .= " | ||
$restrname (M) | "; + $det .= "". strdiff($bver,$restrinst)." | "; + $det .= "". strdiff($restrinst,$bver)." | "; + $det .= "$cur | "; $det .= "$new | "; $det .= "\n"; } $table .= "
$H \n"; + $table .= " | ||
$H \n"; if ( $pkgs ) { $table .= "$pkgs packages to upgrade. "; $table .= "$secs security. " if $secs; - $table .= " $own from indexdata " if $own; + $table .= " $own from indexdata. " if $own; + $table .= " $man manual. " if $man; } else { $table .= "ok"; + $okhosts{$H} = 1; } my $updlink = $wikilink . ucfirst($H) . "Updates" . $year; + # Fix some pages that do not follow the convention. + # Mostly because the host names would not make proper WikiWords + $updlink =~ s/Bugzilla3Updates/BugzillaUpdates/; + $updlink =~ s/Opencontent-solrUpdates/OpenContentSolrUpdates/; + $updlinks{$H} = $updlink; $table .= " Upd"; $table .= " | ||
$hostcomments{$H} |
" ; +print F " | Hosts | \n"; +print F "Packages |
Security " . scalar(keys(%sechosts)) . + " / " . scalar(keys(%secpkgs)) . " / $sectot | \n" ;
+ print F ""; + for my $HH ( sort(keys(%sechosts)) ) { + my $upd = $updlinks{$HH} || "#" ; + print F "$HH, "; + } + print F " | "; + print F ""; + for my $PP ( sort(keys(%secpkgs)) ) { + print F "$PP "; + } + print F " | "; + print F "
Indexdata " . scalar(keys(%ownhosts)) . + " / " . scalar(keys(%ownpkgs)) . " / $owntot | \n" ;
+ print F ""; + for my $HH ( sort(keys(%ownhosts)) ) { + my $upd = $updlinks{$HH} || "#" ; + print F "$HH, "; + #print F "$HH "; + } + print F " | "; + print F ""; + for my $PP ( sort(keys(%ownpkgs)) ) { + print F "$PP "; + } + print F " | "; + print F "
Manual " . scalar(keys(%manhosts)) . + " / " . scalar(keys(%manpkgs)) . " / $mantot | \n" ;
+ print F ""; + for my $HH ( sort(keys(%manhosts)) ) { + my $upd = $updlinks{$HH} || "#" ; + print F "$HH, "; + #print F "$HH "; + } + print F " | "; + print F ""; + for my $PP ( sort(keys(%manpkgs)) ) { + print F "$PP "; + } + print F " | "; + print F "
Normal " . scalar(keys(%normhosts)) . + " / " . scalar(keys(%normpkgs)) . " / $normtot | \n" ;
+ print F ""; + for my $HH ( sort(keys(%normhosts)) ) { + my $upd = $updlinks{$HH} || "#" ; + print F "$HH, "; + #print F "$HH "; + } + print F " | "; + print F ""; + for my $PP ( sort(keys(%normpkgs)) ) { + print F "$PP "; + } + print F " | "; + print F "
Skipped " . scalar(keys(%skiphosts)) . " | \n"; + print F ""; + for my $HH ( sort(keys(%skiphosts)) ) { + my $upd = $updlinks{$HH} || + $wikilink . ucfirst($HH) . "Updates" . $year; + print F "$HH, "; + #print F "$HH "; + } + print F " | |
Ok " . scalar(keys(%okhosts)) . " | \n"; + print F ""; + for my $HH ( sort(keys(%okhosts)) ) { + my $upd = $updlinks{$HH} || "#" ; + print F "$HH, "; + #print F "$HH "; + } + if ( !%okhosts ) { + print F "None at all!"; + } + print F " |
$PN | \n"; + print F ""; + for my $HH ( split(' ',$summary{$P} )) { + print F "$HH "; + } + print F " | \n"; + +} +print F "