| 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/Prtdiag.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 Wrapper library which defaults the | ||
| 14 | # proper settings necessary to run a prtdiag test. | ||
| 15 | # | ||
| 16 | # Depends on: VBTK::Common.pm, VBTK::Wrapper | ||
| 17 | # | ||
| 18 | # Copyright (C) 1996 - 2002 Brent Henry | ||
| 19 | # | ||
| 20 | # This program is free software; you can redistribute it and/or | ||
| 21 | # modify it under the terms of version 2 of the GNU General Public | ||
| 22 | # License as published by the Free Software Foundation available at: | ||
| 23 | # http://http://www.gnu.org/copyleft/gpl.html | ||
| 24 | # | ||
| 25 | # This program is distributed in the hope that it will be useful, | ||
| 26 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 27 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 28 | # GNU General Public License for more details. | ||
| 29 | # | ||
| 30 | ############################################################################# | ||
| 31 | # | ||
| 32 | # | ||
| 33 | # REVISION HISTORY: | ||
| 34 | # | ||
| 35 | # $Log: Prtdiag.pm,v $ | ||
| 36 | # Revision 1.8 2002/03/04 20:53:08 bhenry | ||
| 37 | # *** empty log message *** | ||
| 38 | # | ||
| 39 | # Revision 1.7 2002/03/04 16:49:10 bhenry | ||
| 40 | # Changed requirement back to perl 5.6.0 | ||
| 41 | # | ||
| 42 | # Revision 1.6 2002/03/02 00:53:56 bhenry | ||
| 43 | # Documentation updates | ||
| 44 | # | ||
| 45 | # Revision 1.5 2002/02/13 07:36:14 bhenry | ||
| 46 | # Disabled RrdLogRecovery and removed use of @log | ||
| 47 | # | ||
| 48 | # Revision 1.4 2002/01/26 06:15:15 bhenry | ||
| 49 | # Changed to not specify absolute path | ||
| 50 | # | ||
| 51 | # Revision 1.3 2002/01/25 07:11:52 bhenry | ||
| 52 | # Changed to inherit from Wrapper | ||
| 53 | # | ||
| 54 | # Revision 1.2 2002/01/21 17:07:56 bhenry | ||
| 55 | # Disabled 'uninitialized' warnings | ||
| 56 | # | ||
| 57 | # Revision 1.1.1.1 2002/01/17 18:05:57 bhenry | ||
| 58 | # VBTK Project | ||
| 59 | # | ||
| 60 | |||
| 61 | package VBTK::Wrapper::Prtdiag; | ||
| 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 => "prtdiag -v", | ||
| 96 | SourceList => undef, | ||
| 97 | VBServerURI => $::VBURI, | ||
| 98 | VBHeader => undef, | ||
| 99 | VBDetail => [ '$data' ], | ||
| 100 | LogFile => undef, | ||
| 101 | LogHeader => undef, | ||
| 102 | LogDetail => undef, | ||
| 103 | RotateLogAt => undef, | ||
| 104 | RotateLogOnEOF => undef, | ||
| 105 | Split => undef, | ||
| 106 | Filter => undef, | ||
| 107 | Ignore => undef, | ||
| 108 | SkipLines => undef, | ||
| 109 | Timeout => 30, | ||
| 110 | TimeoutStatus => 'Fail', | ||
| 111 | Follow => undef, | ||
| 112 | FollowTimeout => undef, | ||
| 113 | SuppressMessages => undef, | ||
| 114 | FollowHeartbeat => undef, | ||
| 115 | SetRunStatus => undef, | ||
| 116 | NonZeroExitStatus => undef, | ||
| 117 | SuppressStdout => undef, | ||
| 118 | SuppressMessages => undef, | ||
| 119 | DebugHeader => 'prtdiag' | ||
| 120 | }; | ||
| 121 | |||
| 122 | # Run a validation on the passed parms, using the default parms | ||
| 123 | $self->validateParms($defaultParms) || &fatal("Exiting"); | ||
| 124 | |||
| 125 | # Initialize a wrapper object. | ||
| 126 | $self->SUPER::new() || return undef; | ||
| 127 | |||
| 128 | # Store the defaults for later | ||
| 129 | $self->{defaultParms} = $defaultParms; | ||
| 130 | |||
| 131 | ($self); | ||
| 132 | } | ||
| 133 | |||
| 134 | #------------------------------------------------------------------------------- | ||
| 135 | # Function: addVBObj | ||
| 136 | # Description: Add rules to the wrapper object. | ||
| 137 | # Input Parms: | ||
| 138 | # Output Parms: Pointer to class | ||
| 139 | #------------------------------------------------------------------------------- | ||
| 140 | sub addVBObj | ||
| 141 | { | ||
| 142 | my $self = shift; | ||
| 143 | my $Interval = $self->{Interval}; | ||
| 144 | my %args = @_; | ||
| 145 | |||
| 146 | # Setup some reasonable thresholds | ||
| 147 | my $expireAfterSec = int($Interval * 3); | ||
| 148 | my $description = qq( | ||
| 149 | This object uses the 'prtdiag' command to monitor the hardware on | ||
| 150 | $::HOST. It will set the status to 'Failed' if it sees errors in | ||
| 151 | the output of the command. | ||
| 152 | ); | ||
| 153 | |||
| 154 | # Setup a hash of rules to be returned | ||
| 155 | my $defaultRules = { | ||
| 156 | VBObjName => ".$::HOST.alert.prtdiag", | ||
| 157 | TextHistoryLimit => undef, | ||
| 158 | ReverseText => undef, | ||
| 159 | Rules => { | ||
| 160 | '$data =~ /error|Error|Warn|warn/' => 'Fail' }, | ||
| 161 | Requirements => undef, | ||
| 162 | StatusHistoryLimit => 30, | ||
| 163 | StatusChangeActions => undef, | ||
| 164 | StatusUpgradeRules => undef, | ||
| 165 | ExpireAfter => "$expireAfterSec seconds", | ||
| 166 | Description => $description, | ||
| 167 | BaselineDiffStatus => undef, | ||
| 168 | RrdTimeCol => undef, | ||
| 169 | RrdColumns => undef, | ||
| 170 | RrdFilter => undef, | ||
| 171 | RrdMin => undef, | ||
| 172 | RrdMax => undef, | ||
| 173 | RrdXFF => undef, | ||
| 174 | RrdCF => undef, | ||
| 175 | RrdDST => undef, | ||
| 176 | }; | ||
| 177 | |||
| 178 | # Run the validation | ||
| 179 | &validateParms(\%args,$defaultRules) || &fatal("Exiting"); | ||
| 180 | |||
| 181 | # Create the client-side VB object | ||
| 182 | my $vbObj = $self->SUPER::addVBObj(%args) || return undef; | ||
| 183 | |||
| 184 | $self->{defaultRules} = $defaultRules; | ||
| 185 | |||
| 186 | ($vbObj); | ||
| 187 | } | ||
| 188 | |||
| 189 | 1; | ||
| 190 | __END__ |