SNMP

Let’s move away from security and towards more general monitoring topics. In the previous section we looked at a method for monitoring a specific network service. The Simple Network Management Protocol (SNMP) takes a quantum leap forward by offering 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 E, for a tutorial on it.

Using SNMP from Perl

One way we could use SNMP from Perl is to call command-line programs like the UCD-SNMP ones used for demonstration purposes in Appendix E. It would be a straightforward process, no different any of the examples of calling external programs we’ve seen earlier in this book. Since there’s nothing new to learn there, we won’t spend any time with this technique. I will offer one caveat: if you are using SNMPv1 or SNMPv2C, chances are you’ll have to put the community name on the command line. If this 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 E, but it becomes more acute with automated programs that repeatedly make ...

Get Perl for System Administration now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.