1

I have a Cisco catalyst switch and there is a task to code some web gate which will allow billing to control ports in switch, gather different statistics, etc. What is the modern way to achieve that? Earlier with a supermicro switch I just wrote a PHP script which did a shell_exec passing commands to netcat which connected to the switch. I don't think this the best way to do that so I am asking for help.

Maybe there are some libraries for that? For Perl I saw a library called Net::Appliance::Session and it looks really good as I see, but I am not that good in Perl so I am looking for something PHP/Ppython based.

Update What I found so far for Python is Trigger and Exscript. Looks pretty nice for my simple port on/off and speed change tasks:

from Exscript.util.interact import read_login
from Exscript.protocols import SSH2

account = read_login()              
conn = SSH2()                       
conn.connect('14.45.43.5')     
conn.login(account)                 
conn.execute('conf t')              
print conn.response
conn.send('exit\r')           
conn.close()                        

But I still think I am going to have some headache parsing different status reports, so maybe I need to do that using something different or split stats gathering and operation functionality. Use SNMP for stats for example.

8
  • 1
    Have a good, hard look at SNMP. This is still a good way to gather that kind of data from a switch.
    – Sven
    Oct 2, 2014 at 11:34
  • 1
    Look at Cisco's own CiscoWorks software
    – Chopper3
    Oct 2, 2014 at 12:00
  • 1
    Documentation on it so awful ... I haven't even found concrete CLI examples. Besides i do not see the point of it. It's a standalone solution and i see how to communicate with it from code.
    – Glueon
    Oct 2, 2014 at 12:04
  • 1
    You might try the clogin expect script (part of RANCID) Oct 2, 2014 at 23:53
  • 1
    You may wish to look at SNMP for writing, too. See stackoverflow.com/questions/9170644/… for an example.
    – Mitch
    Oct 4, 2014 at 4:23

1 Answer 1

1

I ended up using PySNMP. It wasn't clear that SNMP v3 has pretty encryption and it also allows not only to gather data but also manipulate the device.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .