monitors:rpi-apt

Error loading plugin struct
ParseError: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
More info is available in the error log.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
monitors:rpi-apt [2018/01/20 11:40] – created wnelismonitors:rpi-apt [2020/01/28 09:50] (current) – [Table] wnelis
Line 1: Line 1:
 ====== rpi-apt ====== ====== rpi-apt ======
  
-^ Author | [[ wim.nelis@nlr.nl | Wim Nelis ]] | +^ Author         | [[wim.nelis@nlr.nl| Wim Nelis ]]  
-^ Compatibility | Xymon 4.2 | +^ Compatibility  | Xymon 4.2                         
-^ Requirements | Perl | +^ Requirements   | Perl                              
-^ Download | None | +^ Download       | None                              
-^ Last Update | 2018-01-20 |+^ Last Update    2020-01-28                        |
  
 ===== 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. Moreover, the package list cache is updated periodically.+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 related upgrades, the normal upgrades and the upgrades which will not be installed. An alert is generated if at least one upgrade in the first two classes is found. The upgrades which are kept back are only reportedas a reminder. 
 +Script rpi-apt.pl will update the package list cache periodically.
  
  
Line 22: Line 23:
 #!/usr/bin/perl -w #!/usr/bin/perl -w
 # #
-# Script apt.pl is a xymon client-side script. It retrieves the list of+# Script rpi-apt.pl is a xymon client-side script. It retrieves the list of
 # 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  = $ENV{XYMSRV} ; # Name of monitor server my $XyDisp  = $ENV{XYMSRV} ; # Name of monitor server
 my $XySend  = $ENV{XYMON} ; # Monitor interface program my $XySend  = $ENV{XYMON} ; # Monitor interface program
-my $XyLife  = '+13h' ; # Status lifetime, default 30m+my $XyLife  = '+19h' ; # Status lifetime, default 30m
 my $FmtDate = "%Y.%m.%d %H:%M:%S" ; # Default date format my $FmtDate = "%Y.%m.%d %H:%M:%S" ; # Default date format
    $FmtDate = $ENV{XYMONDATEFORMAT} if exists $ENV{XYMONDATEFORMAT} ;    $FmtDate = $ENV{XYMONDATEFORMAT} if exists $ENV{XYMONDATEFORMAT} ;
Line 70: Line 71:
 my $Result= '' ; # Message to sent to Xymon my $Result= '' ; # Message to sent to Xymon
  
-my %Class= ( High => 'red', Normal => 'yellow' ) ;+my %Class= ( High => 'red', Normal => 'yellow', Postponed => 'green' ) ;
 my %UPL  = () ; my %UPL  = () ;
 $UPL{$_} = {} foreach ( keys %Class ) ; $UPL{$_} = {} foreach ( keys %Class ) ;
Line 85: Line 86:
 sub UpdatePackageListCache() { sub UpdatePackageListCache() {
   my (@Time,$Time) ; # Time of last change of cache   my (@Time,$Time) ; # Time of last change of cache
-  +
   @Lines= `stat $uplcFileName` ; # Cache file statistics   @Lines= `stat $uplcFileName` ; # Cache file statistics
-  next unless @Lines ; # Ignore error condition +  return unless @Lines ; # Ignore error condition 
-  +
   foreach ( @Lines ) {   foreach ( @Lines ) {
     next unless @Time= m/^Modify: (\d{4})-(\d+)-(\d+) (\d+):(\d+):(\d+)\./ ;     next unless @Time= m/^Modify: (\d{4})-(\d+)-(\d+) (\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:
 + #  The following packages have been kept back:
 + #    firmware-brcm80211
 + #
 +    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 / ) { +
-    next ; # Do nothing +
- +
-    } else { +
-      next unless $upCnt ; +
-      print "$Now : $_\n" ; +
-    }  # of else+
   }  # of foreach   }  # of foreach
 }  # of GetListOfUpdates }  # of GetListOfUpdates
Line 155: Line 174:
   $Result.= "</table>\n" ;   $Result.= "</table>\n" ;
  
-  return if $upCnt == 0 ; +  return if $upCnt == 0  and  keys(%{$UPL{Postponed}}) == 0 ; 
-   + 
-  $Result.= "\nList of upgradable packages\n\n" ;+  $Result.= "\nList of upgradeable packages\n\n" ;
   $Result.= "<table>\n" ;   $Result.= "<table>\n" ;
   $Result.= " <tr><th>Package</th><th>Priority</th>" .   $Result.= " <tr><th>Package</th><th>Priority</th>" .
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( 'Package updates' ) ; # Send message to xymon server+InformXymon( 'Package upgrades' ) ; # Send message to xymon server
 </code> </code>
 </hidden> </hidden>
Line 215: Line 234:
 === Server side === === Server side ===
  
-There is nothing to install or to configure at the server-size, except possibly for the alerting.+There is nothing to install or to configure at the server-side, except possibly for the alerting.
  
  
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
  
  • monitors/rpi-apt.1516448450.txt.gz
  • Last modified: 2018/01/20 11:40
  • by wnelis