I want to write a script that will log into several switches and check the status of several ports. I am running RHEL 4, and I have HP ProCurve 3500yl switches. I want to run something like the following:
ssh myhost -l myuser show interface A3
But when I do so, the ssh command just hangs until I hit ctrl-c. The manual seems to think I want to check the switch status through a web interface, so I can't find much guidance on getting the status remotely. Is there a way to do this over ssh? Is there another way that would be better but still scriptable?
The usual method for checking switch status is by using SNMP. I would check to see if your switch supports SNMP (most managed switches should) and if it exposes the information you want via SNMP.
If you can program Perl, I'd recommend looking at the SNMP::Info module to make querying them easy.
You're doing it the correct way[1] - I would suggest opening up a ticket with HP to get this bug fixed.
You could one of these as a workaround:
[1] i.e. works on a Cisco :)
I don't know about the 3500yl, but on the 2600 and 2800, remote ssh commands are not supported. Running ssh with the
-v
(verbose) option gives the following:This can be because of the HP welcome screen.
Install rancid, configure and run ~rancid/bin/hlogin -c "show version" switch1 switch2
(confirmed with HP 2626, just wait, it will log out)
Rancid rocks. If you're not using it, start now.
Use Linux expect command. The HP banner will stop your ssh commands from running. I open sourced ProCurve Commander to address this issue. Note that the same strategy could be used with any system that for whatever exoteric reason does not allow remote ssh command invocation.