VBTK/Wrapper/Metastat.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran n/a Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 68 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
addVBObj
2.0
BEGIN
2.0
CRAP 2.0
1 #############################################################################
2 #
3 # NOTE: This file under revision control using RCS
4 # Any changes made without RCS will be lost
5 #
6 # $Source: /usr/local/cvsroot/vbtk/VBTK/Wrapper/Metastat.pm,v $
7 # $Revision: 1.8 $
8 # $Date: 2002/03/04 20:53:08 $
9 # $Author: bhenry $
10 # $Locker: $
11 # $State: Exp $
12 #
13 # Purpose: An extension of the VBTK::Wrapper library which defaults
14 # the proper settings necessary to run a Disk Suite metastat
15 # test.
16 #
17 # Depends on: VBTK::Common, VBTK::Wrapper
18 #
19 # Copyright (C) 1996 - 2002 Brent Henry
20 #
21 # This program is free software; you can redistribute it and/or
22 # modify it under the terms of version 2 of the GNU General Public
23 # License as published by the Free Software Foundation available at:
24 # http://www.gnu.org/copyleft/gpl.html
25 #
26 # This program is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 # GNU General Public License for more details.
30 #
31 #############################################################################
32 #
33 #
34 # REVISION HISTORY:
35 #
36 # $Log: Metastat.pm,v $
37 # Revision 1.8 2002/03/04 20:53:08 bhenry
38 # *** empty log message ***
39 #
40 # Revision 1.7 2002/03/04 16:49:10 bhenry
41 # Changed requirement back to perl 5.6.0
42 #
43 # Revision 1.6 2002/03/02 00:53:56 bhenry
44 # Documentation updates
45 #
46 # Revision 1.5 2002/02/13 07:36:14 bhenry
47 # Disabled RrdLogRecovery and removed use of @log
48 #
49 # Revision 1.4 2002/01/26 06:15:15 bhenry
50 # Changed to not specify absolute path
51 #
52 # Revision 1.3 2002/01/25 07:11:52 bhenry
53 # Changed to inherit from Wrapper
54 #
55 # Revision 1.2 2002/01/21 17:07:56 bhenry
56 # Disabled 'uninitialized' warnings
57 #
58 # Revision 1.1.1.1 2002/01/17 18:05:57 bhenry
59 # VBTK Project
60  
61 package VBTK::Wrapper::Metastat;
62  
63 use 5.6.0;
64 use strict;
65 use warnings;
66 # I like using undef as a value so I'm turning off the uninitialized warnings
67 no warnings qw(uninitialized);
68  
69 use VBTK::Common;
70 use VBTK::Wrapper;
71  
72 # Inherit methods from VBTK::Wrapper;
73 our @ISA=qw(VBTK::Wrapper);
74  
75 our $VERBOSE = $ENV{VERBOSE};
76  
77 #-------------------------------------------------------------------------------
78 # Function: new
79 # Description: Object constructor. Allocates memory for all class members
80 # Input Parms:
81 # Output Parms: Pointer to class
82 #-------------------------------------------------------------------------------
83 sub new
84 {
85 my $type = shift;
86 my $self = {};
87 bless $self, $type;
88  
89 # Store all passed input name pairs in the object
90 $self->set(@_);
91  
92 # Setup a hash of default parameters
93 my $defaultParms = {
94 Interval => 600,
95 Execute => "metastat",
96 VBServerURI => $::VBURI,
97 VBHeader => undef,
98 VBDetail => [ '$data' ],
99 LogFile => undef,
100 LogHeader => undef,
101 LogDetail => undef,
102 RotateLogAt => undef,
103 RotateLogOnEOF => undef,
104 Split => undef,
105 Filter => undef,
106 Ignore => undef,
107 SkipLines => undef,
108 Timeout => 40,
109 TimeoutStatus => 'Fail',
110 Follow => undef,
111 FollowTimeout => undef,
112 SuppressMessages => undef,
113 FollowHeartbeat => undef,
114 SetRunStatus => undef,
115 NonZeroExitStatus => undef,
116 SuppressStdout => undef,
117 SuppressMessages => undef,
118 DebugHeader => 'metastat'
119 };
120  
121 # Run a validation on the passed parms, using the default parms
122 $self->validateParms($defaultParms) || &fatal("Exiting");
123  
124 # Initialize a wrapper object.
125 $self->SUPER::new() || return undef;
126  
127 # Store the defaults for later
128 $self->{defaultParms} = $defaultParms;
129  
130 ($self);
131 }
132  
133 #-------------------------------------------------------------------------------
134 # Function: addVBObj
135 # Description: Add rules to the wrapper object.
136 # Input Parms:
137 # Output Parms: Pointer to class
138 #-------------------------------------------------------------------------------
139 sub addVBObj
140 {
141 my $self = shift;
142 my $Interval = $self->{Interval};
143 my %args = @_;
144  
145 # Setup some reasonable thresholds
146 my $expireAfterSec = int($Interval * 3);
147 my $description = qq(
148 This object uses the 'metastat' command to monitor the DiskSuite volumes
149 on $::HOST. It will set the status to 'Warning' or 'Failed' based on the
150 output of the 'metastat' command.
151 );
152  
153 # Setup a hash of default rules to be returned
154 my $defaultRules = {
155 VBObjName => ".$::HOST.md",
156 TextHistoryLimit => undef,
157 ReverseText => undef,
158 Rules => {
159 '$data =~ /error|fail|maintenance/i' => 'Fail' },
160 Requirements => undef,
161 StatusHistoryLimit => 30,
162 StatusChangeActions => undef,
163 StatusUpgradeRules => undef,
164 ExpireAfter => "$expireAfterSec seconds",
165 Description => $description,
166 BaselineDiffStatus => "Warn",
167 RrdTimeCol => undef,
168 RrdColumns => undef,
169 RrdFilter => undef,
170 RrdMin => undef,
171 RrdMax => undef,
172 RrdXFF => undef,
173 RrdCF => undef,
174 RrdDST => undef,
175 };
176  
177 # Run the validation
178 &validateParms(\%args,$defaultRules) || &fatal("Exiting");
179  
180 # Add the rule
181 my $vbObj = $self->SUPER::addVBObj(%args) || return undef;
182  
183 $self->{defaultRules} = $defaultRules;
184  
185 ($vbObj);
186 }
187  
188 1;
189 __END__