Patch for logwatch, Version: 7.3.6-1ubuntu1 - Enhancement: print current uptime

Michael Meß michael at michaelmess.de
Wed Oct 1 22:25:02 UTC 2008


Hi,

Here is a patch for logwatch, that lets logwatch print the current
uptime in the head.
The result looks like the the following: (New is the line "Current Uptime")

 ################### Logwatch 7.3.6 (05/19/07) ####################
        Processing Initiated: Wed Oct  1 23:50:01 2008
        Date Range Processed: yesterday
                              ( 2008-Sep-30 )
                              Period is day.
      Detail Level of Output: 5
              Type of Output: unformatted
           Logfiles for Host: quad
              Current Uptime:  31 days, 21:24
  ##################################################################

To apply the patch on an installed logwatch, go to
/usr/share/logwatch/scripts and verify that you have the right version
of logwatch.pl by checking the md5sum. It should match the one for
logwatch-orig in the list below.
Make a backup copy of logwatch.pl and then execute:
patch logwatch.pl
and paste the output from the diff command below in, it gets read on
stdin by the patch command. Press CTRL-D to stop the patch command
reading from stdin.
The output should then be: patching file logwatch.pl
Check the md5sum of the resulting logwatch.pl. It should now match the
one for logwatch.pl below.

Cheers,

Michael


root at quad:/usr/share/logwatch/scripts# md5sum logwatch.pl*
8dbf0cc2156c4468fe9294a726f69874  logwatch.pl
86340029a511242fc3b38d3f03980cf1  logwatch.pl-orig
root at quad:/usr/share/logwatch/scripts# diff -u  logwatch.pl-orig logwatch.pl
--- logwatch.pl-orig    2008-02-21 15:22:45.000000000 +0100
+++ logwatch.pl 2008-10-01 23:39:08.000000000 +0200
@@ -1078,6 +1078,11 @@
    output( $index_par, "     Detail Level of Output:
$Config{'detail'}\n", "line");
    output( $index_par, "             Type of Output:
$Config{'output'}\n", "line");
    output( $index_par, "          Logfiles for Host:
$Config{'hostname'}\n", "line");
+   my @uptime_string_splitted = split( /,/ , `uptime` );
+   my $uptime_string = $uptime_string_splitted[0] . "," .
$uptime_string_splitted[1];
+   @uptime_string_splitted = split( /p/ , $uptime_string );
+   $uptime_string = $uptime_string_splitted[1];
+   output( $index_par, "             Current Uptime: $uptime_string\n",
"line");

    if ( $outtype_html ) {
       output( $index_par, "\n", "stop");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-devel-discuss/attachments/20081001/8b70aade/attachment.sig>


More information about the Ubuntu-devel-discuss mailing list