| 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/Vxprint.pm,v $ | ||
| 7 | # $Revision: 1.7 $ | ||
| 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 Veritas volume manager | ||
| 15 | # vxprint command. | ||
| 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: Vxprint.pm,v $ | ||
| 37 | # Revision 1.7 2002/03/04 20:53:08 bhenry | ||
| 38 | # *** empty log message *** | ||
| 39 | # | ||
| 40 | # Revision 1.6 2002/03/04 16:49:10 bhenry | ||
| 41 | # Changed requirement back to perl 5.6.0 | ||
| 42 | # | ||
| 43 | # Revision 1.5 2002/03/02 00:53:56 bhenry | ||
| 44 | # Documentation updates | ||
| 45 | # | ||
| 46 | # Revision 1.4 2002/02/13 07:36:14 bhenry | ||
| 47 | # Disabled RrdLogRecovery and removed use of @log | ||
| 48 | # | ||
| 49 | # Revision 1.3 2002/01/26 06:14:28 bhenry | ||
| 50 | # Changed to inherit from VBTK::Wrapper | ||
| 51 | # | ||
| 52 | # Revision 1.2 2002/01/21 17:07:56 bhenry | ||
| 53 | # Disabled 'uninitialized' warnings | ||
| 54 | # | ||
| 55 | # Revision 1.1.1.1 2002/01/17 18:05:57 bhenry | ||
| 56 | # VBTK Project | ||
| 57 | # | ||
| 58 | |||
| 59 | package VBTK::Wrapper::Vxprint; | ||
| 60 | |||
| 61 | use 5.6.0; | ||
| 62 | use strict; | ||
| 63 | use warnings; | ||
| 64 | # I like using undef as a value so I'm turning off the uninitialized warnings | ||
| 65 | no warnings qw(uninitialized); | ||
| 66 | |||
| 67 | use VBTK::Common; | ||
| 68 | use VBTK::Wrapper; | ||
| 69 | |||
| 70 | # Inherit methods from VBTK::Wrapper; | ||
| 71 | our @ISA=qw(VBTK::Wrapper); | ||
| 72 | |||
| 73 | our $VERBOSE = $ENV{VERBOSE}; | ||
| 74 | |||
| 75 | #------------------------------------------------------------------------------- | ||
| 76 | # Function: new | ||
| 77 | # Description: Object constructor. Allocates memory for all class members | ||
| 78 | # Input Parms: | ||
| 79 | # Output Parms: Pointer to class | ||
| 80 | #------------------------------------------------------------------------------- | ||
| 81 | sub new | ||
| 82 | { | ||
| 83 | my $type = shift; | ||
| 84 | my $self = {}; | ||
| 85 | bless $self, $type; | ||
| 86 | |||
| 87 | # Store all passed input name pairs in the object | ||
| 88 | $self->set(@_); | ||
| 89 | |||
| 90 | # Setup a hash of default parameters | ||
| 91 | my $defaultParms = { | ||
| 92 | Interval => 600, | ||
| 93 | Execute => "vxprint -ht", | ||
| 94 | VBServerURI => $::VBURI, | ||
| 95 | VBHeader => undef, | ||
| 96 | VBDetail => [ '$data' ], | ||
| 97 | LogFile => undef, | ||
| 98 | LogHeader => undef, | ||
| 99 | LogDetail => undef, | ||
| 100 | RotateLogAt => undef, | ||
| 101 | RotateLogOnEOF => undef, | ||
| 102 | Split => undef, | ||
| 103 | Filter => undef, | ||
| 104 | Ignore => undef, | ||
| 105 | SkipLines => undef, | ||
| 106 | Timeout => 30, | ||
| 107 | TimeoutStatus => 'Fail', | ||
| 108 | Follow => undef, | ||
| 109 | FollowTimeout => undef, | ||
| 110 | SuppressMessages => undef, | ||
| 111 | FollowHeartbeat => undef, | ||
| 112 | SetRunStatus => undef, | ||
| 113 | NonZeroExitStatus => undef, | ||
| 114 | SuppressStdout => undef, | ||
| 115 | SuppressMessages => undef, | ||
| 116 | DebugHeader => 'vxprint' | ||
| 117 | }; | ||
| 118 | |||
| 119 | # Run a validation on the passed parms, using the default parms | ||
| 120 | $self->validateParms($defaultParms) || &fatal("Exiting"); | ||
| 121 | |||
| 122 | # Initialize a wrapper object. | ||
| 123 | $self->SUPER::new() || return undef; | ||
| 124 | |||
| 125 | # Store the defaults for later | ||
| 126 | $self->{defaultParms} = $defaultParms; | ||
| 127 | |||
| 128 | ($self); | ||
| 129 | } | ||
| 130 | |||
| 131 | #------------------------------------------------------------------------------- | ||
| 132 | # Function: addVBObj | ||
| 133 | # Description: Add rules to the wrapper object. | ||
| 134 | # Input Parms: | ||
| 135 | # Output Parms: Pointer to class | ||
| 136 | #------------------------------------------------------------------------------- | ||
| 137 | sub addVBObj | ||
| 138 | { | ||
| 139 | my $self = shift; | ||
| 140 | my $Interval = $self->{Interval}; | ||
| 141 | my %args = @_; | ||
| 142 | |||
| 143 | # Setup some reasonable thresholds | ||
| 144 | my $expireAfterSec = int($Interval * 3); | ||
| 145 | my $description = qq( | ||
| 146 | This object uses the 'vxprint' command to monitor the Veritas Volumes on | ||
| 147 | $::HOST. It will set the status to 'Warning' or 'Failed' based on the | ||
| 148 | output of the 'vxprint' command. | ||
| 149 | ); | ||
| 150 | |||
| 151 | # Setup a hash of default rules to be returned | ||
| 152 | my $defaultRules = { | ||
| 153 | VBObjName => ".$::HOST.vm.vxprint", | ||
| 154 | TextHistoryLimit => undef, | ||
| 155 | ReverseText => undef, | ||
| 156 | Rules => { | ||
| 157 | '$data =~ /error|fail/i' => 'Fail' }, | ||
| 158 | Requirements => undef, | ||
| 159 | StatusHistoryLimit => 30, | ||
| 160 | StatusChangeActions => undef, | ||
| 161 | StatusUpgradeRules => undef, | ||
| 162 | ExpireAfter => "$expireAfterSec seconds", | ||
| 163 | Description => $description, | ||
| 164 | BaselineDiffStatus => "Warn", | ||
| 165 | RrdTimeCol => undef, | ||
| 166 | RrdColumns => undef, | ||
| 167 | RrdFilter => undef, | ||
| 168 | RrdMin => undef, | ||
| 169 | RrdMax => undef, | ||
| 170 | RrdXFF => undef, | ||
| 171 | RrdCF => undef, | ||
| 172 | RrdDST => undef, | ||
| 173 | }; | ||
| 174 | |||
| 175 | # Run the validation | ||
| 176 | &validateParms(\%args,$defaultRules) || &fatal("Exiting"); | ||
| 177 | |||
| 178 | # Add the rule | ||
| 179 | my $vbObj = $self->SUPER::addVBObj(%args); | ||
| 180 | |||
| 181 | $self->{defaultRules} = $defaultRules; | ||
| 182 | |||
| 183 | ($vbObj); | ||
| 184 | } | ||
| 185 | |||
| 186 | 1; | ||
| 187 | __END__ |