Tuesday, November 1, 2011

Turn Outlets On & Off via SNMP


APC makes a line of switched rack PDUs that is very popular amongst home network labs.  These PDUs have the ability to selectively turn individual outlets on and off.  The units also have a display on them that shows the current AMP usage flowing though the PDU.
The PDU has a RJ-45 network interface that allows you to connect to the web interface where you can configure the unit as well as interact with it to turn outlets on and off.
While it is possible to do it from the web interface, I prefer to turn the outlets on and off via a snmp script.
You need some kind of SNMP client capable of sending snmpset commands
  • Net-SNMP is a good client, they have a version for Windows so I’m down with that one
If you are installing on Windows you will also need to install the following items:
So after you get all that setup, you need to configure your PDU to allow SNMP ( I’m using SNMP v 2c in tis example… ).  Then make a batch file and add this stuff, obviously change it to cd where every you have snmpset is installed.
@echo off
cd C:\tools\usr\bin
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.1 integer 1
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.2 integer 1
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.3 integer 1
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.4 integer 1
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.5 integer 1
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.6 integer 1
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.7 integer 1
snmpset -v 2c -c <COMMUNITYSTRING> <PDU-IPADDRESS> 1.3.6.1.4.1.318.1.1.4.4.2.1.3.8 integer 1
exit

This script above will shutoff the ports on the 8 port pdu, if you have the 16 port PDU instead just double all those statements and change the last number in the OID to the port numbers.  If you want to turn off the ports instead change the integer to 2.  Now you can turn your lab on or off with the click of a file instead of logging on and all that other who-ha to get them on.  I have have added it to a lab startup script that launches that script and then loads some other stuff after a while after things have booted up.

Try it out, it makes a fun sound… click click boom !!!! OK no boom but it’s pretty cool.

Thursday, October 13, 2011

Hack a Cisco Console Cable

If you’re a network admin (of Cisco Networks) you probably have these scattered all over the place; I have a few at home, one in my car, and normally always have one in what ever bag I’m carrying all my junk in.  It seems that whenever you need to pull out one of the bad boys out in a data closet there is no where with in reach of that cable to sit down.  I used to carry that cable along with a 10 foot serial cable that I found to work between my USB -> serial adapter and my good ol’ Cisco console cable.  Problem is that i started to just have too much stuff with me and I was getting sick of hauling around a bag full of cables; then in walked the 5-in-1 network cable website.

I’m still in the process of trying to get things working using the suggestions on that site but started to think about another alternative.

I took a serial to RJ-45 Cisco console cable and chopped most of it off and wired a network jack on the end of it so I could then just have that and use the Cat5e cable, that I would normally be carrying anyway with my gear, to connect to the console port on whatever I was working on.

T568-B StandardCisco Console Cable
Orange/White <===>Black
Orange             <===> Brown
Green/White   <===>Orange
Blue                  <===>Red
Blue/White      <===>Yellow
Green                <===>Green
Brown/White   <===>Blue
Brown               <===>Gray



A buddy of mine, who also does this kind of stuff for a job, said, “Same as Console Cable + RJ-45 coupler + Cat5 cable. Cool though!”.  Yes he is right, but I am always loosing my couplers, or using them on jobs when jerkoffs don’t install things where you tell them and you have to string 2 cables together to reach an access point while offsite in a stinky farm building.

After my buddy made that comment, I made another one that was just and RJ-45 end crimped on an inch from the serial connector. So now I can use the precious coupler as well, either way it has reduced some of the stuff I have to carry, now I just stash one of these in the spots I used to stash regular Cisco console cables.


 
 


 Well that’s about it… Have a good one…