Util.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 35 CC 4 SCAR 25.1
CC
4
Cov
0%
AUTOLOAD
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.3
1 =head1 NAME
2  
3 Watchdog::Util - Watchdog utility functions
4  
5 =head1 SYNOPSIS
6  
7 use Watchdog::Util;
8  
9 =head1 DESCRIPTION
10  
11 =cut
12  
13 package Watchdog::Util;
14  
15 use strict;
16 use vars qw($AUTOLOAD $conf);
17 use Getopt::Long;
18 #use Log::Service;
19  
20 my $dir = '/usr/local/watchdog';
21 my $status_dir = "$dir/status";
22 $conf = "$dir/watchdog.conf";
23  
24 #------------------------------------------------------------------------------
25  
26 sub AUTOLOAD {
27 my $self = shift;
28 my $type = ref($self) or die "$self is not an object";
29  
30 my $name = $AUTOLOAD;
31 $name =~ s/.*://; # strip fully-qualified portion
32  
33 # accessor methods
34 $name = uc($name);
35 return if ( $name eq 'DESTROY' ); # don't catch 'DESTROY'
36 unless ( exists $self->{_PERMITTED}->{$name} ) {
37 die "Can't access `$name' field in class $type";
38 }
39 return @_ ? $self->{$name} = shift : $self->{$name};
40 }
41  
42 #------------------------------------------------------------------------------
43  
44 #=head2 init_dog($host,$service,$frequency)
45  
46 #Returns the number of seconds that a watchdog should sleep between
47 #polling its service based on I<$frequency> and a B<Log::Service>
48 #object configured to log to the file I<$status_dir/$service.$host>.
49  
50 #=cut
51  
52 #sub init_dog($$$) {
53 # my($host,$service,$frequency) = @_;
54 # my($sleep,$opt_frequency);
55  
56 # if ( defined($frequency) ) {
57 # my %units = ( 's' => 1, 'm' => 60 );
58 # $frequency =~ /^(\d+)([m|s])$/ || die("Invalid frequency: $frequency");
59 # $sleep = $1 * $units{$2};
60 # } else {
61 # $sleep = 60;
62 # }
63  
64 # my $status = "$status_dir/$service.$host";
65 #my %stream = ( 'status' => new Log::File($status,"w") );
66 #my $logger = new Log::Service($service,\%stream);
67 # set hostname where service we're watching is running
68 #$logger->host->name($host);
69  
70 #return($sleep,$logger);
71 #}
72  
73 #------------------------------------------------------------------------------
74  
75 =head1 AUTHOR
76  
77 Paul Sharpe I<lt>paul@miraclefish.comE<gt>
78  
79 =head1 COPYRIGHT
80  
81 Copyright (c) 1998 Paul Sharpe. England. All rights reserved. This
82 program is free software; you can redistribute it and/or modify it
83 under the same terms as Perl itself.
84  
85 =cut
86  
87 1;