Network Management

last person joined: 2 hours ago 

Keep an informative eye on your network with HPE Aruba Networking network management solutions
Expand all | Collapse all

using SNMP to list transceivers

This thread has been viewed 2 times
  • 1.  using SNMP to list transceivers

    Posted Mar 06, 2018 02:24 PM

    Hello community,

     

    We are preparing to replace our 5 year old Aruba switches with new ones and we need to know exactly what is out there. I've been able to use Airwave for most reports. I need to know what optics are in each switch and really don't want to compile this list by hand. Ideally, I can script an SNMP command to do this but, as of yet, have not had any success. Any tips?

     

    -Mike



  • 2.  RE: using SNMP to list transceivers

    Posted Mar 12, 2018 04:38 AM

    no way via SNMP, you could consider to do it via ssh (e.g. using airrecorder) or via the webUI interface (e.g. using a curl script)

     

    if you need a sample of the above let me know.

     



  • 3.  RE: using SNMP to list transceivers

    Posted Mar 12, 2018 09:02 AM

    Those are great ideas. Any samples you could provide would be helpful (and save me time). Thanks!



  • 4.  RE: using SNMP to list transceivers
    Best Answer

    Posted Mar 12, 2018 09:40 AM

    hi Mike

     

    for airrecorder you can look here

    https://community.arubanetworks.com/t5/Community-Tribal-Knowledge-Base/AirRecorder-Tutorial-Part-1/ta-p/157646

    and

    https://community.arubanetworks.com/t5/Community-Tribal-Knowledge-Base/AirRecorder-Tutorial-Part-2/ta-p/221390

     

    it does a lot of stuff, TL;DR; if you just want to run a bunch of commands once and collect the output you can read the below for the quick summary.

     

    Put the credentials for each controller just go in a text file each (i.e. 1.2.3.4.txt and 1.2.3.5.txt), e.g.

     

     

    root@kali:/tmp/airr# cat 192.168.1.123 
    admin
    admin123
    root@kali:/tmp/airr# 

     

    and you put your commands in another file, something like this. the 0, in the front says "run it once"

     

    0,show interface gigabitethernet 0/0/0 transceiver
    0,show interface gigabitethernet 0/0/1 transceiver
    0,show interface gigabitethernet 0/0/2 transceiver
    0,show interface gigabitethernet 0/0/3 transceiver
    0,show interface gigabitethernet 0/0/4 transceiver
    0,show interface gigabitethernet 0/0/5 transceiver

    then run it with the JAR file (you can get it from the support site in the software tools section). Runs on windows or mac or linux (anywhere you can run java). You can specify multiple IP addresses (as long as the corresponding .txt exists with the creds), results go in separate files.

     

     

    root@kali:/tmp/airr# java -jar /home/nd/latest/lib/AirRecorder-1.5.3-release.jar -c cmd.com 192.168.1.123
    AirRecorder (c)2011-2017 Thomas Bastian, Aruba Networks, a Hewlett Packard Enterprise company
    No enable password set, assuming enable mode when connected
    A new log file will be created every: 100 Mbytes
    Recording to file: air-recorder-192.168.1.123-20180312-212016-00.log
    Connecting to controller with hostname: 192.168.1.123, protocol: ssh, port: 22, username: admin
    Processing command: [show interface gigabitethernet 0/0/0 transceiver] at schedule specification of 0
    Processing command: [show interface gigabitethernet 0/0/1 transceiver] at schedule specification of 0
    Processing command: [show interface gigabitethernet 0/0/2 transceiver] at schedule specification of 0
    Processing command: [show interface gigabitethernet 0/0/3 transceiver] at schedule specification of 0
    Processing command: [show interface gigabitethernet 0/0/4 transceiver] at schedule specification of 0
    Processing command: [show interface gigabitethernet 0/0/5 transceiver] at schedule specification of 0
    Running command: [show interface gigabitethernet 0/0/0 transceiver] once
    Running command: [show interface gigabitethernet 0/0/1 transceiver] once
    Running command: [show interface gigabitethernet 0/0/2 transceiver] once
    Running command: [show interface gigabitethernet 0/0/3 transceiver] once
    Running command: [show interface gigabitethernet 0/0/4 transceiver] once
    Running command: [show interface gigabitethernet 0/0/5 transceiver] once
    All commands processed. Recording now. Interrupt with CTRL-C
    All commands completed. Exitinge: 0 kbps, File size: 0 MB  root@kali:/tmp/airr# 
    root@kali:/tmp/airr# 

    then you will have an output file of the CLI commands (plus some timing headers etc., they can be suppressed with some of the CLI args, see the --help etc). My output below is empty because i ran this on a controller that doesn't have any transceivers, but you get the general idea

     

     

     

    root@kali:/tmp/airr# cat air-recorder-192.168.1.123-20180312-212016-00.log
    ///// 
    .....
    ///// 
    ///// Message: RESULT
    ///// Status: 701
    ///// LocalBeginTime: 1520860817743 (2018-03-12T21:20:17.743+0800)
    ///// LocalEndTime: 1520860817774 (2018-03-12T21:20:17.774+0800)
    ///// Command: show version
    ///// Section: Stdout
    Aruba Operating System Software.
    ArubaOS (MODEL: Aruba7010), Version 6.5.4.4
    Website: http://www.arubanetworks.com
    (c) Copyright 2017 Hewlett Packard Enterprise Development LP.
    Compiled on 2017-12-20 at 00:37:40 UTC (build 62887) by p4build
    
    ROM: System Bootstrap, Version CPBoot 1.0.7.0 (build 56553)
    Built: 2016-09-22 04:52:29
    Built by: p4build@re_client_56553
    
    Switch uptime is 8 days 2 hours 24 minutes 36 seconds
    .....
    ///// 
    ///// Message: RESULT
    ///// Status: 46
    ///// LocalBeginTime: 1520860817776 (2018-03-12T21:20:17.776+0800)
    ///// LocalEndTime: 1520860817788 (2018-03-12T21:20:17.788+0800)
    ///// Command: show clock
    ///// Section: Stdout
    
    Mon Mar 12 21:20:17 GMT 2018
    
    .....
    ///// 
    ///// Message: RESULT
    ///// Status: 50
    ///// LocalBeginTime: 1520860817812 (2018-03-12T21:20:17.812+0800)
    ///// LocalEndTime: 1520860817820 (2018-03-12T21:20:17.820+0800)
    ///// QueryTag: airrecorder.command=0,show interface gigabitethernet 0/0/0 transceiver
    ///// Command: show interface gigabitethernet 0/0/0 transceiver
    ///// Section: Stdout
    .....
    ///// 
    ///// Message: RESULT
    ///// Status: 50
    ///// LocalBeginTime: 1520860817820 (2018-03-12T21:20:17.820+0800)
    ///// LocalEndTime: 1520860817829 (2018-03-12T21:20:17.829+0800)
    ///// QueryTag: airrecorder.command=0,show interface gigabitethernet 0/0/1 transceiver
    ///// Command: show interface gigabitethernet 0/0/1 transceiver
    ///// Section: Stdout
    .....

    For curl, you can consider it a bit of a ghetto API interface. You need to log in, get the session cookie, then append that to your queries. It is in effect mimicking the same way the webUI works (you can follow it in any http inspector).

     

     

    First log in with curl using username and password, substituting your creds for where i have $USER and $PASS below and obviously the IP.

     

    curl --silent --output login.out --insecure --cookie-jar .cookie --data "opcode=login&uid=$USER&passwd=$PASS" https://192.168.1.123:4343/screens/wms/wms.login

    then dump the cookie file, finding the session ID

     

     

    root@kali:/tmp/airr# cat .cookie 
    # Netscape HTTP Cookie File
    # https://curl.haxx.se/docs/http-cookies.html
    # This file was generated by libcurl! Edit at your own ris
    
    192.168.1.123   FALSE   /       TRUE    0       SESSION 5e6059bc-d5ae-401a-83a3-affb273c9624

    Copy out the session, e.g. "5e6059bc-d5ae-401a-83a3-affb273c9624" and use it in the subsequent command:

    root@kali:/tmp/airr# CMD="show interface gigabitethernet 0/0/1"
    root@kali:/tmp/airr# SID="5e6059bc-d5ae-401a-83a3-affb273c9624"
    
    root@kali:/tmp/airr# curl --silent --insecure --output exec.out --cookie .cookie --data "$CMD&UIDARUBA=$SID" https://192.168.1.123:4343/screens/cmnutil/execCommandReturnResult.xml

    the problem with this method, whilst programtical and you can more easily pass a list of IPs or ports etc to it, is that the output is in some nasty mangled "xml" style format, that will require some parsing to chop out what you want. 

     

     

     

    root@kali:/tmp/airr# cat exec.out 
    <re><data name="T1" pn="false">GE 0/0/1 is up, line protocol is down</data><data name="T2" pn="false">Hardware is Gigabit Ethernet, address is 20:4C:03:11:FF:14 (bia 20:4C:03:11:FF:14)</data><data name="T3" pn="false">Description: GE0/0/1 (RJ45 Connector)</data><data name="T6" pn="false">Encapsulation ARPA, loopback not set</data><data name="T7" pn="false">Configured: Duplex ( AUTO ), speed ( AUTO )</data><data name="T8" pn="false">MTU 1500 bytes, BW is 1000 Mbit</data><data name="T9" pn="false"><![CDATA[Last clearing of &quot;show interface&quot; counters 8 day 2 hr 35 min 6 sec&#32;]]></data><data name="T10" pn="false">link status last changed 8 day 2 hr 35 min 6 sec&#32;</data><data name="T11" pn="false">&#32;&#32;&#32;&#32;0 packets input, 0 bytes</data><data name="T12" pn="false">&#32;&#32;&#32;&#32;Received 0 broadcasts, 0 runts, 0 giants, 0 throttles</data><data name="T13" pn="false">&#32;&#32;&#32;&#32;0 input error bytes, 0 CRC, 0 frame</data><data name="T14" pn="false">&#32;&#32;&#32;&#32;0 multicast, 0 unicast</data><data name="T15" pn="false">&#32;&#32;&#32;&#32;0 packets output, 0 bytes</data><data name="T16" pn="false">&#32;&#32;&#32;&#32;0 output errors bytes, 0 deferred</data><data name="T17" pn="false">&#32;&#32;&#32;&#32;0 collisions, 0 late collisions, 0 throttles</data><data name="T18" pn="false">This port is TRUSTED&#32;</data><data name="T19" pn="false">POE Status of the port is OFF&#32;</data></re>
    root@kali:/tmp/airr#

    if you grok python, then you can easily use something like beautifulsoup to parse it (most strict xml parsers will puke on it), e.g.

     

     

    root@kali:/tmp/airr# python
    Python 2.7.14 (default, Sep 17 2017, 18:50:44) 
    [GCC 7.2.0] on linux2
    >>> import BeautifulSoup as bs  
    >>> soup = bs.BeautifulSoup(open("exec.out").read())
    >>> print soup.prettify()
    <re>
     <data name="T1" pn="false">
      GE 0/0/1 is up, line protocol is down
     </data>
     <data name="T2" pn="false">
      Hardware is Gigabit Ethernet, address is 20:4C:03:11:FF:14 (bia 20:4C:03:11:FF:14)
     </data>
     <data name="T3" pn="false">
      Description: GE0/0/1 (RJ45 Connector)
     </data>
     <data name="T6" pn="false">
      Encapsulation ARPA, loopback not set
     </data>
     <data name="T7" pn="false">
      Configured: Duplex ( AUTO ), speed ( AUTO )
     </data>
     <data name="T8" pn="false">
      MTU 1500 bytes, BW is 1000 Mbit
     </data>
     <data name="T9" pn="false">
      <![CDATA[Last clearing of &quot;show interface&quot; counters 8 day 2 hr 35 min 6 sec&#32;]]>
     </data>
     <data name="T10" pn="false">
      link status last changed 8 day 2 hr 35 min 6 sec&#32;
     </data>
     <data name="T11" pn="false">
      &#32;&#32;&#32;&#32;0 packets input, 0 bytes
     </data>
     <data name="T12" pn="false">
      &#32;&#32;&#32;&#32;Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
     </data>
     <data name="T13" pn="false">
      &#32;&#32;&#32;&#32;0 input error bytes, 0 CRC, 0 frame
     </data>
    .......
    >>> 

     

    hth.