Specifically for the management of IP networks & equipment - routers, switches, etc
1. Connection automation:
Because it’s really handy to update, say, the passwords on all 1000 of your network devices in a couple of hours by kicking off a single script. It’s faster and more reliable. Of course, if you fat-finger the password in the script, you’ve just fat-fingered it on your entire network, so please test it first.
Net::Telnet::Cisco - this is really cool, but doesn’t work on older equipment, due to Cisco’s lack of a standardized interface. So, we roll our own with Expect.pm.
—–
2. IP Addressing:
Socket.pm of course, though not being a C programmer I have a hard time remembering the syntax off the top of my head so I keep a couple of examples around.
my $ip = $ARGV[0];
my @addr = split(/\./, $ip);
my $addr = pack(’C4′, @addr);
my $name = gethostbyaddr($addr, AF_INET);
print (”Name: $name\n”);
my $host = $ARGV[0];
my $ip = scalar gethostbyname($host);
my @ip = unpack(”C4″,$ip);
my $ip = join(”.”,@ip);
print (”IP: $ip\n”);
—–
3. Subnetting:
Net::Netmask, baby! For figuring out network & bcast addresses, accept no substitutes.
my $ip = “10.1.1.1″;
my $netmask = “255.255.255.0″;
my $block = new Net::Netmask($ip, $netmask);
my $bcast_addr = $block->broadcast();
print (”Broadcast address: $bcast_addr\n”);
—–
4. SNMP. Y’all knew I would have to talk about this.
Several options, two I have actual experience with.
A lot of people use Net::SNMP I use SNMP.pm (which comes with Net-SNMP - confused?*
) It’s probably the most complex, but also (to me) the most useful. I can get pretty much any data I want with this module.
SNMP-Simple - much more user-friendly than SNMP.pm. Lighter, faster, but you can only get *values* back from this, you can not get the OIDs, so it requires some pre-knowledge of what you want to monitor, which isn’t always possible.
—–
5. RRD.pm - perl module for Tobi Oetiker’s RRDTool. Many network performance tools are based on RRDTool: mrtg, cacti, orca, NMIS. It’s indispensable if you’re going to write your own monitoring app, or tinker with one of the aforementioned tools.
—–
6. Date::Format and Date::Manip. I use Date::Format because it’s so easy to create timestamps for log files & reports - it follows the Unix strftime format. Date::Manip is huge and slow, but it’s the only thing I found that could handle some complex user time reporting I was doing a while back, and I love it.
—–
7. Net::Mac. I haven’t had time to experiment with this to the extent I’d like, but I have a feeling it’s going to be as useful as Net::Netmask. I’ll let you know in a couple of weeks.
*One of my favorite jokes, just for me.