Chapter 12. SNMP

The Simple Network Management Protocol (SNMP) offers a general way to remotely monitor and configure network devices and networked computers. Once you master the basics of SNMP, you can use it to keep tabs on (and often configure) practically every device on your network.

Truth be told, the “Simple” Network Management Protocol isn’t particularly simple. There’s a respectable learning curve associated with this subject. If you aren’t already familiar with SNMP, see Appendix G for a tutorial.

Using SNMP from Perl

One way you can use SNMP from Perl is to call command-line programs. In Appendix G I show how to use the programs in the Net-SNMP distribution as one example of this. It’s a straightforward process, no different from any of the examples of calling external programs earlier in this book. Since there’s nothing new to learn there, we won’t spend any time on this technique.

One caveat: if you are using SNMPv1 or SNMPv2c, chances are you’ll be tempted to put the community name on the command line. But if the program runs on a multiuser box, anyone who can list the process table may be able to see this community name and steal the keys to the kingdom. This threat is present in our command-line examples in Appendix G, but it becomes more acute with automated programs that repeatedly make external program calls. For demonstration purposes only, the examples in this chapter are invoked with the target hostname and community name string on the command line. You should ...

Get Automating System Administration with Perl, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.