root/ext_comm.pl

Revision 37cbe43bf668696d2f26324ca62752e777b57d2b, 314 bytes (checked in by Theo Schlossnagle <jesus@omniti.com>, 13 years ago)

Initial revision

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

  • Property mode set to 100755
Line 
1 #!/usr/bin/perl
2
3 my %commhist;
4 my %commcache;
5
6 sub cache_command {
7   my $command = shift;
8   my $expiry = shift;
9   my $now = time;
10   if($commhist{$command}>$now) {
11     return $commcache{$command};
12   }
13   $commcache{$command} = `$command`;
14   $commhist{$command} = $now + $expiry;
15   return $commcache{$command};
16 }
17
18 1;
Note: See TracBrowser for help on using the browser.