Ad Widget

Collapse

SSH command line Check

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Evan.Anderson
    Member
    • Jun 2009
    • 42

    #1

    SSH command line Check

    On my network hardware I can run this command:

    show mac-address-table int fa 1/0/1
    Mac Address Table
    -------------------------------------------

    Vlan Mac Address Type Ports
    ---- ----------- -------- -----
    22 0019.55e6.36be DYNAMIC Fa1/0/1

    Would it be possible to use a script to retieve this info? If so, what would it look like?
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    Yes, you will have to use either expect or ssh keys and pass the parameters you are looking for.

    If you have ssh keys working you might be able to do the following

    ssh switch-host-name "show mac-address-table int fa 1/0/1"

    The quotes are not exactly needed, but they force the full string to be pushed to the remote host. This is useful if you're using a | character.

    Otherwise you could create an expect script which passes keystrokes to ssh and performs the action for you. If a password is required in any way, expect is likely the easiest route to go, however you are now left with a potential security issue of secure storage of the password, or use an account which read only privilege. Your best bet is to use ssh keys which do not require a password for an account with read only privs.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • troffasky
      Senior Member
      • Jul 2008
      • 567

      #3
      Originally posted by nelsonab
      Otherwise you could create an expect script which passes keystrokes to ssh and performs the action for you. If a password is required in any way, expect is likely the easiest route to go,
      Somebody has already done this, it's called RANCID:

      Solaris, SunOS, NetBSD, FreeBSD, Linux, Fedora, Redhat, OSPF, BGP, ATM, Juniper, Cisco.


      However I would be surprised if the info that Evan.Anderson is looking for isn't available via SNMP. Something else interesting is Netdisco:

      Netdisco is a web-based network management tool suitable for small to very large networks. IP and MAC address data is collected into a PostgreSQL database using SNMP, CLI, or device APIs.

      Comment

      • Evan.Anderson
        Member
        • Jun 2009
        • 42

        #4
        http://www.zabbix.com/forum/showthread.php?t=13322 is another thread I started in the wrong forum(on accident, forum newbie), but I think I'm getting close to what I'm looking for with that one. I'm hoping I can use snmptrapd to catch data sent from the switch.

        Comment

        Working...