| 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/Snmp/Dynamo.pm,v $ | ||
| 7 | # $Revision: 1.9 $ | ||
| 8 | # $Date: 2002/03/04 20:53:08 $ | ||
| 9 | # $Author: bhenry $ | ||
| 10 | # $Locker: $ | ||
| 11 | # $State: Exp $ | ||
| 12 | # | ||
| 13 | # Purpose: An extension of the VBTK::Snmp library which defaults | ||
| 14 | # to common settings used in monitoring dynamo | ||
| 15 | # | ||
| 16 | # Depends on: VBTK::Common, VBTK::Snmp | ||
| 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://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: Dynamo.pm,v $ | ||
| 36 | # Revision 1.9 2002/03/04 20:53:08 bhenry | ||
| 37 | # *** empty log message *** | ||
| 38 | # | ||
| 39 | # Revision 1.8 2002/03/04 16:49:10 bhenry | ||
| 40 | # Changed requirement back to perl 5.6.0 | ||
| 41 | # | ||
| 42 | # Revision 1.7 2002/03/02 00:53:55 bhenry | ||
| 43 | # Documentation updates | ||
| 44 | # | ||
| 45 | # Revision 1.6 2002/02/20 20:41:35 bhenry | ||
| 46 | # *** empty log message *** | ||
| 47 | # | ||
| 48 | # Revision 1.5 2002/02/19 19:13:59 bhenry | ||
| 49 | # Changed to use inheritance | ||
| 50 | # | ||
| 51 | # Revision 1.4 2002/02/13 08:01:57 bhenry | ||
| 52 | # *** empty log message *** | ||
| 53 | # | ||
| 54 | # Revision 1.3 2002/02/13 07:36:43 bhenry | ||
| 55 | # Disabled RrdLogRecovery and removed use of @log | ||
| 56 | # | ||
| 57 | # Revision 1.2 2002/01/21 17:07:53 bhenry | ||
| 58 | # Disabled 'uninitialized' warnings | ||
| 59 | # | ||
| 60 | # Revision 1.1.1.1 2002/01/17 18:05:57 bhenry | ||
| 61 | # VBTK Project | ||
| 62 | # | ||
| 63 | |||
| 64 | package VBTK::Snmp::Dynamo; | ||
| 65 | |||
| 66 | use 5.6.0; | ||
| 67 | use strict; | ||
| 68 | use warnings; | ||
| 69 | # I like using undef as a value so I'm turning off the uninitialized warnings | ||
| 70 | no warnings qw(uninitialized); | ||
| 71 | |||
| 72 | use VBTK::Common; | ||
| 73 | use VBTK::Snmp; | ||
| 74 | |||
| 75 | # Inherit methods from VBTK::Snmp; | ||
| 76 | our @ISA=qw(VBTK::Snmp); | ||
| 77 | |||
| 78 | our $VERBOSE = $ENV{VERBOSE}; | ||
| 79 | |||
| 80 | #------------------------------------------------------------------------------- | ||
| 81 | # Function: new | ||
| 82 | # Description: Object constructor. Allocates memory for all class members | ||
| 83 | # Input Parms: | ||
| 84 | # Output Parms: Pointer to class | ||
| 85 | #------------------------------------------------------------------------------- | ||
| 86 | sub new | ||
| 87 | { | ||
| 88 | my $type = shift; | ||
| 89 | my $self = {}; | ||
| 90 | bless $self, $type; | ||
| 91 | |||
| 92 | # Store all passed input name pairs in the object | ||
| 93 | $self->set(@_); | ||
| 94 | |||
| 95 | # Setup the header and detail formats for the pmobjects and log | ||
| 96 | my $stdHeader = [ 'Time Reqs Avg ms New Sess Val Sess Total KB Free KB Status', | ||
| 97 | '----------------- ---- ------ -------- -------- --------- --------- -----------------------' ]; | ||
| 98 | my $stdDetail = [ '@<<<<<<<<<<<<<<<< @>>> @>>>>> @>>>>>>> @>>>>>>> @>>>>>>>> @>>>>>>>> @<<<<<<<<<<<<<<<<<<<<<<', | ||
| 99 | '$time,$delta[0],($delta[0] > 0) ? ($delta[1]/($delta[0])) : 0,$delta[2],$data[3],int($data[4]/1024),int($data[5]/1024),$data[6]' ]; | ||
| 100 | |||
| 101 | # Setup a hash of default parameters | ||
| 102 | my $defaultParms = { | ||
| 103 | Interval => 60, | ||
| 104 | Labels => [ | ||
| 105 | 'drpTotalReqsServed', | ||
| 106 | 'drpTotalReqTime', | ||
| 107 | 'stCreatedSessionCnt', | ||
| 108 | 'stValidSessionCnt', | ||
| 109 | 'sysTotalMem', | ||
| 110 | 'sysFreeMem', | ||
| 111 | 'sysStatus' ], | ||
| 112 | Host => 'localhost', | ||
| 113 | Port => '8870', | ||
| 114 | Community => undef, | ||
| 115 | VBServerURI => undef, | ||
| 116 | VBHeader => $stdHeader, | ||
| 117 | VBDetail => $stdDetail, | ||
| 118 | LogFile => undef, | ||
| 119 | LogHeader => $stdHeader, | ||
| 120 | LogDetail => $stdDetail, | ||
| 121 | RotateLogAt => "12:00am", | ||
| 122 | Timeout => 5, | ||
| 123 | Retries => 1, | ||
| 124 | ErrorStatus => 'Warn', | ||
| 125 | GetMultRows => 0 | ||
| 126 | }; | ||
| 127 | |||
| 128 | # Run a validation on the passed parms, using the default parms | ||
| 129 | $self->validateParms($defaultParms); | ||
| 130 | |||
| 131 | # Add in the dynamo-specific MIB | ||
| 132 | VBTK::Snmp::addMibFiles("$::VBHOME/mib/Dynamo3Mib.mib"); | ||
| 133 | |||
| 134 | # Initialize an snmp object. | ||
| 135 | $self->SUPER::new() || return undef; | ||
| 136 | |||
| 137 | # Store the defaults for later | ||
| 138 | $self->{defaultParms} = $defaultParms; | ||
| 139 | |||
| 140 | ($self); | ||
| 141 | } | ||
| 142 | |||
| 143 | #------------------------------------------------------------------------------- | ||
| 144 | # Function: addVBObj | ||
| 145 | # Description: Add rules to the wrapper object. | ||
| 146 | # Input Parms: | ||
| 147 | # Output Parms: Pointer to class | ||
| 148 | #------------------------------------------------------------------------------- | ||
| 149 | sub addVBObj | ||
| 150 | { | ||
| 151 | my $self = shift; | ||
| 152 | my $Host = $self->{Host}; | ||
| 153 | my $Port = $self->{Port}; | ||
| 154 | my $Interval = $self->{Interval}; | ||
| 155 | |||
| 156 | my %args = @_; | ||
| 157 | |||
| 158 | # Setup some reasonable thresholds | ||
| 159 | my $expireAfterSec = int($Interval * 3); | ||
| 160 | my $description = qq( | ||
| 161 | This object uses SNMP to monitor a dynamo instance. | ||
| 162 | ); | ||
| 163 | |||
| 164 | # Remove any '.' chars from the Host string, so we don't confuse | ||
| 165 | # the object's position in the hierarchy. | ||
| 166 | $Host =~ s/\./-/g; | ||
| 167 | |||
| 168 | # Setup a hash of default rules to be returned | ||
| 169 | my $defaultRules = { | ||
| 170 | VBObjName => ".$Host.dynamo.$Port", | ||
| 171 | TextHistoryLimit => 100, | ||
| 172 | ReverseText => 1, | ||
| 173 | # Warn if % free memory < 10% | ||
| 174 | Rules => { | ||
| 175 | '($data[5]/($data[4]+.01)) < .10' => 'Warn' }, | ||
| 176 | Requirements => undef, | ||
| 177 | StatusHistoryLimit => 30, | ||
| 178 | StatusChangeActions => undef, | ||
| 179 | StatusUpgradeRules => | ||
| 180 | "Upgrade to Failed if Warning occurs 2 times in $expireAfterSec seconds", | ||
| 181 | ExpireAfter => "$expireAfterSec seconds", | ||
| 182 | Description => $description, | ||
| 183 | BaselineDiffStatus => undef, | ||
| 184 | RrdTimeCol => undef, | ||
| 185 | RrdColumns => | ||
| 186 | # Pages Srvd, New Sess, Curr Sess, Free Mem, Tot Mem | ||
| 187 | [ '$delta[0]','$delta[2]','$data[3]','$data[5]','$data[4]' ], | ||
| 188 | RrdFilter => undef, | ||
| 189 | RrdMin => undef, | ||
| 190 | RrdMax => undef, | ||
| 191 | RrdXFF => undef, | ||
| 192 | RrdCF => undef, | ||
| 193 | RrdDST => undef, | ||
| 194 | }; | ||
| 195 | |||
| 196 | # Run the validation | ||
| 197 | &validateParms(\%args,$defaultRules); | ||
| 198 | |||
| 199 | # Add the rule | ||
| 200 | my $vbObj = $self->SUPER::addVBObj(%args); | ||
| 201 | |||
| 202 | return undef if ($vbObj eq undef); | ||
| 203 | |||
| 204 | # Now define what graphs to show on this object's page | ||
| 205 | $vbObj->addGraphGroup ( | ||
| 206 | GroupNumber => 1, | ||
| 207 | DataSourceList => ':0', | ||
| 208 | Labels => 'pageViews', | ||
| 209 | Title => "$Host:$Port dynamo", | ||
| 210 | ); | ||
| 211 | |||
| 212 | # Now define what graphs to show on this object's page | ||
| 213 | $vbObj->addGraphGroup ( | ||
| 214 | GroupNumber => 2, | ||
| 215 | DataSourceList => ':1,:2', | ||
| 216 | Labels => 'new sessions,valid sessions', | ||
| 217 | Title => "$Host:$Port dynamo", | ||
| 218 | ); | ||
| 219 | |||
| 220 | # Now define what graphs to show on this object's page | ||
| 221 | $vbObj->addGraphGroup ( | ||
| 222 | GroupNumber => 3, | ||
| 223 | DataSourceList => ':3,:4', | ||
| 224 | Labels => 'freeMem,totMem', | ||
| 225 | Title => "$Host:$Port dynamo", | ||
| 226 | ); | ||
| 227 | |||
| 228 | $self->{defaultRules} = $defaultRules; | ||
| 229 | |||
| 230 | ($vbObj); | ||
| 231 | } | ||
| 232 | |||
| 233 | 1; | ||
| 234 | __END__ |