Chapter 12. Adapting SNMP to Fit Your EnvironmentContents:General Trap-Generation ProgramWho's Logging into My Machine? (I-Am-in) Throw Core Veritas Disk Check Disk-Space Checker Port Monitor
12.1. General Trap-Generation ProgramChapter 10, "Traps" contained some scripts for collecting SNMP information using Perl, OpenView's snmptrap program, and some other tools. Here's how we used snmptrap to generate a trap giving us information about some problems with the database:
The way you send a trap in Perl is a little more involved, but it's still easy to use:$ /opt/OV/bin/snmptrap -c public nms .1.3.6.1.4.1.2789.2500 "" 6 3003 "" \ .1.3.6.1.4.1.2500.3003.1 octetstringascii "Oracle" \ .1.3.6.1.4.1.2500.3003.2 octetstringascii "Backup Not Running" \ .1.3.6.1.4.1.2500.3003.3 octetstringascii "Call the DBA Now for Help"
In this chapter, we won't look so much at how to write commands like these, but at how to use them in clever ways. We might want to include commands like these in startup scripts, or invoke them via hooks into other programs. We'll start by writing some code that records successful logins.#!/usr/local/bin/perl # Filename: /opt/local/perl_scripts/snmptrap.pl use SNMP_util "0.54"; # This will load the BER and SNMP_Session snmptrap("public\@nms:162", ".1.3.6.1.4.1.2789", "sunserver1", 6, 1247, ".1.3.6.1.4.1.2789.1247.1", "int", "2448816");
Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|