Changeset 7a0ad41bb3ce9260cc3136a0afcdfaddbffb60b9

Show
Ignore:
Timestamp:
09/01/09 16:54:20 (9 years ago)
Author:
Sergey Ivanov <seriv@omniti.com>
git-committer:
Sergey Ivanov <seriv@omniti.com> 1251824060 +0000
git-parent:

[0cac1359fb43c5a58bf076503688973833ec006f]

git-author:
Sergey Ivanov <seriv@omniti.com> 1251824060 +0000
Message:

fixes: can not get parameter outside of subroutine, and use zfs get -H -p -ovalue as Eric suggested

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

Files:

Legend:

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

    rd1eb3d5 r7a0ad41  
    11package Resmon::Module::ZFSYNCHECK; 
     2use strict; 
    23use Resmon::ExtComm qw/cache_command/; 
    34use vars qw/@ISA/; 
    45use Time::Local; 
    5 use Time::Local;($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time-84600); print "$mon/$mday/$year"; 
    66@ISA = qw/Resmon::Module/; 
    7 my $arg=shift; 
    8 my $zfs=$arg->{'object'}; 
    9 my $age=$arg->{'age'}*86400+43200; 
    107sub handler { 
    11   my $output = cache_command("zfs list -t snapshot -s creation | grep $zfs | tail -1", 300); 
    12   if ($output =~ m!$zfs.%?([0-9]{4,4})([0-9]{2,2})([0-9]{2,2})!){ 
    13     my ($sy,$sm,$sd)=($1,$2,$3); 
    14     my $snaptime=timelocal(0,15,23,$sd,$sm-1,$sy-1900); 
    15     my $yesterday=time-$age; 
    16     if($yesterday < $snaptime) { 
    17       return "OK(snapshot is fresh $sm/$sd $sy)"; 
    18     }else{ 
    19       return "BAD(no fresh snapshot, recent is $sm/$sd $sy)"; 
    20     } 
     8  my $arg=shift; 
     9  my $zfs=$arg->{'object'}; 
     10  my $age=$arg->{'age'}*86400; 
     11  my $recentsnap = cache_command("zfs list -tsnapshot -H -Screation -oname| grep '^$zfs\@' | head -1", 300); 
     12  return "BAD(no snapshot of $zfs)" if not $recentsnap; 
     13  my $snaptime = cache_command("zfs get -H -p -ovalue creation $recentsnap", 300); 
     14  my $snapage=time()-$snaptime; 
     15  if($snapage < $age) { 
     16    return "OK($snapage < $age)"; 
     17  }elsif ($snapage >= $age){ 
     18    return "BAD($snapage >= $age)"; 
    2119  } 
    22   return "BAD(unexpected output $output)"; 
     20  return "BAD(for snapshot $recentsnap we have unexpected creation $snaptime)"; 
    2321}; 
    24221;