Changeset 627a96772d62dfc3c4d65c35f81a7f266d5a4719

Show
Ignore:
Timestamp:
03/22/07 21:28:16 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1174598896 +0000
git-parent:

[736d17033260fb886cb4627c6f05277ee834c5bc]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1174598896 +0000
Message:

make this more extensible and make Resmon auto 'use lib' based off \-tcsh

git-svn-id: https://labs.omniti.com/resmon/trunk@29 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Status.pm

    r736d170 r627a967  
    223223} 
    224224sub store { 
    225   my ($self, $type, $name, $state, $mess) = @_; 
    226   $self->{store}->{$type}->{$name} = { 
    227     last_update => time, 
    228     state => $state, 
    229     message => $mess 
    230   }; 
     225  my ($self, $type, $name, $info) = @_; 
     226  %{$self->{store}->{$type}->{$name}} = %$info; 
     227  $self->{store}->{$type}->{$name}->{last_update} = time; 
    231228  $self->store_shared_state(); 
    232229  if($self->{handle}) { 
    233     $self->{handle}->print("$name($type) :: $state($mess)\n"); 
     230    $self->{handle}->print("$name($type) :: $info->{state}($info->{message})\n"); 
    234231  } else { 
    235     print "$name($type) :: $state($mess)\n"; 
     232    print "$name($type) :: $info->{state}($info->{message})\n"; 
    236233  } 
    237234} 
  • resmon

    re5d09e8 r627a967  
    11#!/usr/bin/perl 
    22 
    3 use lib '/opt/resmon/lib'; 
     3BEGIN { 
     4  (my $dir = $0) =~ s/\/?[^\/]+$//; 
     5  print "use lib '$dir/lib';\n"; 
     6  eval "use lib '$dir/lib';"; 
     7  die $@ if($@); 
     8}; 
    49 
    510use strict; 
     
    2328); 
    2429 
    25 $config_file ||= 'resmon.conf'
     30$config_file ||= "$0.conf"
    2631die "Cannot open configuration file: $config_file" unless (-r $config_file); 
    2732 
     
    6873      my $check_rv = 'BAD', 
    6974      my $check_mess = 'no data'; 
     75      my $starttime = [gettimeofday]; 
    7076      if($coderef) { 
    7177        eval { ($check_rv, $check_mess) = $coderef->($monobj); }; 
     
    7379        eval { ($check_rv, $check_mess) = $monobj->handler(); }; 
    7480      } 
     81      my $results = { last_runtime_seconds => tv_interval($starttime) }; 
    7582      if($@) { 
    76         $status->store($module_name,$monobj->{'object'},'BAD',$@); 
     83        $results->{state} = 'BAD'; 
     84        $results->{message} = $@; 
    7785      } else { 
    78         $status->store($module_name,$monobj->{'object'},$check_rv,$check_mess); 
     86        $results->{state} = $check_rv; 
     87        $results->{message} = $check_mess; 
    7988      } 
     89      $status->store($module_name,$monobj->{'object'}, $results); 
    8090    } 
    8191  }