Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
monitors:rpi-apt [2018/03/11 10:04] – [Installation] wnelis | monitors:rpi-apt [2020/01/28 09:48] – wnelis | ||
---|---|---|---|
Line 5: | Line 5: | ||
^ Requirements | Perl | | ^ Requirements | Perl | | ||
^ Download | None | | ^ Download | None | | ||
- | ^ Last Update | 2018-01-20 | | + | ^ Last Update | 2018-03-11 | |
===== Description ===== | ===== Description ===== | ||
- | Script rpi-apt.pl is a client-side script, which determines if there are any packages which can be upgraded at a Raspberry Pi running Raspbian. The upgrades are grouped into two classes, the security upgrades and the rest. An alert is generated if at least one upgrade is found. | + | Script rpi-apt.pl is a client-side script, which determines if there are any packages which can be upgraded at a Raspberry Pi running Raspbian. The upgrades are grouped into three classes, the security |
+ | Script rpi-apt.pl will update | ||
Line 22: | Line 23: | ||
# | # | ||
# | # | ||
- | # Script apt.pl is a xymon client-side script. It retrieves the list of | + | # Script |
# outstanding patches for raspbian. These are divided into two groups, | # outstanding patches for raspbian. These are divided into two groups, | ||
# security-related and the rest. At the same time, this script will reguarly | # security-related and the rest. At the same time, this script will reguarly | ||
Line 39: | Line 40: | ||
my $XyDisp | my $XyDisp | ||
my $XySend | my $XySend | ||
- | my $XyLife | + | my $XyLife |
my $FmtDate = " | my $FmtDate = " | ||
| | ||
Line 70: | Line 71: | ||
my $Result= '' | my $Result= '' | ||
- | my %Class= ( High => ' | + | my %Class= ( High => ' |
my %UPL = () ; | my %UPL = () ; | ||
$UPL{$_} = {} foreach ( keys %Class ) ; | $UPL{$_} = {} foreach ( keys %Class ) ; | ||
Line 85: | Line 86: | ||
sub UpdatePackageListCache() { | sub UpdatePackageListCache() { | ||
my (@Time, | my (@Time, | ||
- | | + | |
@Lines= `stat $uplcFileName` ; # Cache file statistics | @Lines= `stat $uplcFileName` ; # Cache file statistics | ||
- | | + | |
- | + | ||
foreach ( @Lines ) { | foreach ( @Lines ) { | ||
next unless @Time= m/^Modify: (\d{4})-(\d+)-(\d+) (\d+): | next unless @Time= m/^Modify: (\d{4})-(\d+)-(\d+) (\d+): | ||
Line 94: | Line 95: | ||
$Time= timelocal( reverse @Time ) ; # Compute time stamp | $Time= timelocal( reverse @Time ) ; # Compute time stamp | ||
return if time - $Time < $uplcRefreshAge ; | return if time - $Time < $uplcRefreshAge ; | ||
- | | + | |
`$uplcRefreshCmd` ; # Update package list cache | `$uplcRefreshCmd` ; # Update package list cache | ||
last ; # Skip rest of lines | last ; # Skip rest of lines | ||
Line 108: | Line 109: | ||
# | # | ||
sub GetListOfUpdates() { | sub GetListOfUpdates() { | ||
+ | my $InPostponed= 0 ; # Flag: in list of kept back packages | ||
+ | |||
@Lines= `$upCmd` ; # Current list of updatable packages | @Lines= `$upCmd` ; # Current list of updatable packages | ||
foreach ( @Lines ) { | foreach ( @Lines ) { | ||
chomp ; | chomp ; | ||
+ | |||
+ | # Handle the list of packages which are not to be upgraded (which are kept | ||
+ | # back). The format of such a list is as follows: | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | if ( $InPostponed ) { | ||
+ | if ( m/^\s\s\S/ ) { | ||
+ | foreach my $pn ( split ) { | ||
+ | next unless defined $pn; | ||
+ | $UPL{Postponed}{$pn}= [ $pn, '?', | ||
+ | $upCnt++ ; | ||
+ | } # of foreach | ||
+ | |||
+ | next ; # Line is handled | ||
+ | } else { | ||
+ | $InPostponed= 0 ; # End of section found | ||
+ | } # of else | ||
+ | } elsif ( m/^The following packages have been kept back/ ) { | ||
+ | $InPostponed= 1 ; # Start of section found | ||
+ | next ; # Line is handled | ||
+ | } # of elsif | ||
+ | |||
if ( m/^Inst (.+?) \[(.+?)] \((.+?) / ) { | if ( m/^Inst (.+?) \[(.+?)] \((.+?) / ) { | ||
if ( m/securi/i ) { | if ( m/securi/i ) { | ||
Line 118: | Line 144: | ||
} # of else | } # of else | ||
$upCnt++ ; | $upCnt++ ; | ||
- | + | } # of if | |
- | } elsif ( m/^Conf / ) { | + | |
- | # | + | |
- | + | ||
- | } else { | + | |
- | next unless $upCnt ; | + | |
- | print "$Now : $_\n" ; | + | |
- | | + | |
} # of foreach | } # of foreach | ||
} # of GetListOfUpdates | } # of GetListOfUpdates | ||
Line 155: | Line 174: | ||
$Result.= "</ | $Result.= "</ | ||
- | return if $upCnt == 0 ; | + | return if $upCnt |
- | + | ||
- | $Result.= " | + | $Result.= " |
$Result.= "< | $Result.= "< | ||
$Result.= " < | $Result.= " < | ||
Line 191: | Line 210: | ||
GetListOfUpdates ; # Retrieve list of outstanding updates | GetListOfUpdates ; # Retrieve list of outstanding updates | ||
BuildMessage ; # Build message for xymon | BuildMessage ; # Build message for xymon | ||
- | InformXymon( ' | + | InformXymon( ' |
</ | </ | ||
</ | </ | ||
Line 227: | Line 246: | ||
* **2018-01-20** | * **2018-01-20** | ||
* Initial release | * Initial release | ||
+ | * **2018-03-11** | ||
+ | * Report the packages which are kept back too | ||
+ | * **2020-01-28** | ||
+ | * Improve detection of kept-back-upgrades | ||