/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/nagios-ndpf-sensors/scripts/check_tivoli
ViewVC logotype

Diff of /trunk/nl.nikhef.ndpf.tools/nagios-ndpf-sensors/scripts/check_tivoli

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2699 by dennisvd, Thu Apr 17 13:53:36 2014 UTC revision 2728 by dennisvd, Mon Aug 25 10:18:32 2014 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2  #  #
3  # Copyright (c) Stichting FOM 2014  # Copyright 2014 Stichting Fundamenteel Onderzoek der Materie (FOM-Nikhef)
4  #  #
5  # Licensed under the Apache License, Version 2.0 (the "License");  # Licensed under the Apache License, Version 2.0 (the "License");
6  # you may not use this file except in compliance with the License.  # you may not use this file except in compliance with the License.
# Line 24  use Getopt::Long; Line 24  use Getopt::Long;
24  use Time::Local;  use Time::Local;
25  use POSIX qw{strftime};  use POSIX qw{strftime};
26    
27    use File::ReadBackwards;
28    
29  my $verbose=0;  my $verbose=0;
30  my $debug;  my $debug;
31  # the logfile to parse  # the logfile to parse
# Line 59  alarm($TIMEOUT); Line 61  alarm($TIMEOUT);
61    
62  # find the last such entry in /var/log/dsmsched.log  # find the last such entry in /var/log/dsmsched.log
63  my $loghandle;  my $loghandle;
64  if ( ! open $loghandle, "<$log" ) {  $loghandle = File::ReadBackwards->new($log);
65    if (!defined($loghandle)) {
66    $message = "ERROR: cannot open $log";    $message = "ERROR: cannot open $log";
67    $result = $ERRORS{"CRITICAL"};    $result = $ERRORS{"CRITICAL"};
68    print "$message\n";    print "$message\n";
# Line 67  if ( ! open $loghandle, "<$log" ) { Line 70  if ( ! open $loghandle, "<$log" ) {
70  }  }
71    
72  my $lastentry;  my $lastentry;
73    my $logline = "";
74  while (<$loghandle>) {  while (defined($logline = $loghandle->readline ) ) {
75    next unless m{(\d\d)/(\d\d)/(\d\d)   (\d\d):(\d\d):(\d\d) Scheduled event .* completed successfully\.};    next unless $logline =~ m{(\d\d)/(\d\d)/(\d\d)   (\d\d):(\d\d):(\d\d) Scheduled event .* completed successfully\.};
76    # just like localtime(), months range 0..11    # just like localtime(), months range 0..11
77    my ($month, $day, $year, $hours, $minutes, $seconds) = ($1-1, $2, $3, $4, $5, $6);    my ($month, $day, $year, $hours, $minutes, $seconds) = ($1-1, $2, $3, $4, $5, $6);
78    $lastentry = timelocal($seconds, $minutes, $hours, $day, $month, $year);    $lastentry = timelocal($seconds, $minutes, $hours, $day, $month, $year);
79      last;
80  }  }
81    
82  close $loghandle;  $loghandle->close;
83    
84  if (!defined $lastentry) {  if (!defined $lastentry) {
85    $message = "ERROR: no successful events in $log";    $message = "ERROR: no successful events in $log";

Legend:
Removed from v.2699  
changed lines
  Added in v.2728

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28