How to search for device types using the CLI in Spectrum
search cancel

How to search for device types using the CLI in Spectrum

book

Article ID: 385026

calendar_today

Updated On:

Products

Network Observability Spectrum

Issue/Introduction

To find devices based on SystemOID in Spectrum, you can use the command line (CLI) and VNM shell (vnmsh).

Environment

DX NetOps Spectrum all currently supported releases

Resolution

You can script the commands as follows:

#!/bin/bash

 

export CLISESSID=$$

export CLIMNAMEWIDTH=38

 

OUTPUT=SysOIDs.txt

./connect

 

echo "checking All Devices on `date` $1" >$OUTPUT

 

# find MHhandle for mth types all - create list - and update per MHandle

 

for MHandle in `./show devices | grep "^0x" | cut -d' ' -f1 `

        do

                echo ========= $MHandle =========  >>$OUTPUT

                echo ========= $MHandle =========

                sysOID=`./show attributes mh=$MHandle | grep Internal_sysObjectID | awk '{print $3}'`

                if [[ "$sysOID" == $1 ]]; then

                        ./show attributes mh=$MHandle | grep -E"Modeltype_Name|0x1006e|$1" >>$OUTPUT

                elif [[ $# -eq 0 ]]; then

                        ./show attributes mh=$MHandle | grep -E"Modeltype_Name|0x1006e|Internal_sysObjectID" >>$OUTPUT

                fi

        done

 

./disconnect


You can copy the above into a file and put the SysOID as an argument when running it on the command line. For example:

./get_device_types.sh 1.3.6.1.4.1.12356.103.3.64

The script will check only for that SysOID. The output will be like:

checking All Devices on Thu Dec  5 12:44:14 UTC 2024 1.3.6.1.4.1.12356.103.3.64

========= 0x10000142 =========

0x10000     Modeltype_Name                                         FortinetFortiAnalyzer

0x10053     sysObjectID                                            1.3.6.1.4.1.12356.103.3.64

0x1006e     Model_Name                                             Mydevice

0x12910     SysOIDVerifyList                                       1.3.6.1.4.1.12356.103.3.64

0x12965     Internal_sysObjectID                                   1.3.6.1.4.1.12356.103.3.64

========= 0x100000cd =========


NOTE
: The above script assumes it is to be run from the $SPECROOT/vnmsh directory. If you run it from any other directory, then you will need to specify the path in all the commands in green. For example, if you run it from /usr/Spectrum/scripts, then you would need to specify the path as:

/usr/Spectrum/vnmsh/connect

Instead of:

./connect