#!/bin/perl # # genOra # Michael Han, (c) 4/2002 # # Generate an appropriate targets file for monitoring an Oracle database # via cricket # # This work is based on Mike Fisher's contributed scripts for monitoring # Cisco equipment. I originally wrote this in shell instrumenting the # net-snmp commands, but adapted the snmpUtil library as utilized in Mike # Fisher's work # # $Id: genOra,v 1.1 2002/06/25 19:06:06 mikehan Exp $ BEGIN { $gInstallRoot = (($0 =~ m:^(.*/):)[0] || "./") . ".."; } use lib "$gInstallRoot/lib"; use snmpUtils; use Common::Log; use Getopt::Std; my %opts; getopts( "c:h:p:12", \%opts ); if ( scalar @ARGV != 1 ) { print "Usage: $0 [-c community|-h host|-p port|{-1|-2}] {ORACLE_SID}\n"; exit 2; } $sid = shift; $community = $opts{'c'} ? $opts{'c'} : "public"; $host = $opts{'h'} ? $opts{'h'} : "localhost"; $port = $opts{'p'} ? $opts{'p'} : "161"; $proto = $opts{'2'} ? "2" : "1"; $snmp = "$community\@${host}:$port"; if ( $proto == 2 ) { $snmp .= ":::::2c"; } @sid = snmpUtils::walk( $snmp, "1.3.6.1.2.1.39.1.1.1.4" ); %inst = map( {reverse split /:/, $_, 2 } @sid ); $inst = $inst{ $sid }; if ( ! "$inst" ) { print "SID $sid not handled by given SNMP agent\n"; exit 1; } print <