Re: Collecting bgp data using shell script (5745 Views)
Reply
Honored Contributor
ramesh9
Posts: 1,034
Registered: ‎04-19-2011
Message 1 of 4 (5,766 Views)
Accepted Solution

Collecting bgp data using shell script

Hello All

 

Is it possible to collect following bgp Variables using shell script,

 

bgpPeerRemoteAddr  .1.3.6.1.2.1.15.3.1.7

bgpPeerState   .1.3.6.1.2.1.15.3.1.2

bgpPeerAdminStatus  .1.3.6.1.2.1.15.3.1.3

 

Please help..

Please use plain text.
HP Expert
DSimon
Posts: 83
Registered: ‎04-04-2011
Message 2 of 4 (5,745 Views)

Re: Collecting bgp data using shell script

Hi Ramesh,

 

     Note that my example is for unix.  You can do the same thing with windows scripting.

 

     I do not have a Sarian (bgp) device but below is an example of something similar with a cisco device in my lab.  You can use nnmsnmpwalk.ovpl to collect the information you need. 

 

     In the following example, I want to check the status for a power supply.  The Management Information Base (MIB) variable I want to check is called ciscoEnvMonSupplyState and is part of a table called ciscoEnvMonSupplyStatusTable.  In order to determine the table name, I output a full nnmsnmpwalk.ovpl for the device to a file and found the variable I was looking for.  Why is this important?  An nnmsnmpwalk.ovpl can take minutes to run.  If you know which table contains the information you are looking for, you can increase performance by querying only that table.  Here is the table I want dumped from an nnmsnmpwalk.ovpl:

 

# $NNM_BIN/nnmsnmpwalk.ovpl mycisco.abc.com ciscoEnvMonSupplyStatusTable


ciscoEnvMonSupplyStatusTable.ciscoEnvMonSupplyStatusEntry.ciscoEnvMonSupplyStatusDescr.1 : OCTET STRING- (ascii): AC Power Supply
ciscoEnvMonSupplyStatusTable.ciscoEnvMonSupplyStatusEntry.ciscoEnvMonSupplyState.1 : INTEGER: normal
ciscoEnvMonSupplyStatusTable.ciscoEnvMonSupplyStatusEntry.ciscoEnvMonSupplySource.1 : INTEGER: 2

 

Note that I have highlighted the table name in red and the variable name in blue.  Also note that the actual value for each variable is the third piece of the line using the colon (:) as a delimiter.

 

If you want to obtain the status of the AC Power Supply, the following script will pull that value:

 

--- begin script ---

#!/bin/bash

#

# Script:  cisco_status - print value of ciscoEnvMonSupplyState

#

$NNM_BIN/nnmsnmpwalk.ovpl mycisco.abc.com ciscoEnvMonSupplyStatusTable | grep ciscoEnvMonSupplyState | awk -F: '{print $3}'

#

--- end script ---

 

Here I run the script:

 

# ./cisco_status
 normal

 

You would likely want to print the device description and other information and you would want to format the output but this is a quick example of how to pull the information you want from the nnmsnmpwalk.ovpl using a script.

 

 

HP Support
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution, If you are satisfied with anyone’s response please remember to give them a KUDOS and show your appreciation.
Please use plain text.
Trusted Contributor
mostafa_hassan
Posts: 258
Registered: ‎12-11-2011
Message 3 of 4 (5,729 Views)

Re: Collecting bgp data using shell script

what if want to check for multi devices , what would be the script ! and got the as followign format as aresult

 

Device name   || Power Status || Power source

 

Regards

Mostafa hassan

All the best .
Saying Thanks by hitting Kudos :)

Regards
Mostafa Hassan
HP AIS NNM-NA-OO
CCNA-CCNP-ITIL-VCA-Cloud-VCA DataCenter
Please use plain text.
Honored Contributor
ramesh9
Posts: 1,034
Registered: ‎04-19-2011
Message 4 of 4 (5,724 Views)

Re: Collecting bgp data using shell script

Dear Mostafa

 

Can you please elaborate on what do you mean?

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation