Forum Discussion

acwhite0128's avatar
acwhite0128
Icon for Neophyte rankNeophyte
3 years ago

Active Discovery Groovy Script to Identify BGP Instances by Peer Group Name

We are looking to clone the existing BGP DataSource but modify the active discovery source to pull in BGP instances via Groovy Script in order to identify instances that are configured on devices by specific peer grouping. The snmp active discovery approach doesn't work for this purpose as there is not an effective SNMP OID to isolate BGP listen ranges based on peer grouping. Please see attached screen shot for reference. 

I have looked at the suggested Linux_SSH active discovery groovy script for reference to see how we might be able to build a script to accomplish this, but we are not seeing a correlation.

If anyone in the community currently has a successful example of polling networking switches/routers (mostly Cisco IOS) using Groovy script rather than SNMP, I would appreciate any guidance or suggestions you can provide.

3 Replies

  • Anonymous's avatar
    Anonymous

    Expect can be used to obtain any data through an SSH connection. Here's an example: https://github.com/sweenig/monitoring-recipes/blob/master/DataSources/Groovy/Expect/Groovy_Expect_Example.groovy

    If we're talking about the same Linux_SSH logicmodule, then that uses JSch, which is great, but all the examples I've seen only execute one command per session. With Expect, you can control the entire back and forth of the SSH session. Log in, set some parameters (like terminal width and height to 0), enter privileged exec mode and execute some commands. Then it's just a matter of figuring out how to do it manually through SSH and then programming Expect to do it. Once you have the command output, you can parse through the data however you need.

  • On 4/4/2022 at 12:04 PM, Stuart Weenig said:

    Expect can be used to obtain any data through an SSH connection. Here's an example: https://github.com/sweenig/monitoring-recipes/blob/master/DataSources/Groovy/Expect/Groovy_Expect_Example.groovy

    If we're talking about the same Linux_SSH logicmodule, then that uses JSch, which is great, but all the examples I've seen only execute one command per session. With Expect, you can control the entire back and forth of the SSH session. Log in, set some parameters (like terminal width and height to 0), enter privileged exec mode and execute some commands. Then it's just a matter of figuring out how to do it manually through SSH and then programming Expect to do it. Once you have the command output, you can parse through the data however you need.

    Thanks. I was looking over the Expect example you provided, and if we opt to go with the discovery script, this definitely looks like the way to go.

    However, I was also looking at an option to clone the BGP DataSource and keep the active discovery as snmp polling, but leverage the instance grouping with a regex expression to group the tropos peer group. I just need to figure out what that regex needs to look like to identify the peers by that peer group name. 

    Any comments or suggestions you might have on that solution path as opposed to using the groovy script to identify the instances?

  • Anonymous's avatar
    Anonymous

    If it were me, i would prefer to group by the value of an instance level property. It's simply simpler. But that would require discovering the instance level property in the first place. As I understand your issue, the peer group isn't something that's discoverable via SNMP. (If it is discoverable via SNMP, then we just need to augment the existing discovery to discover the peer group for each instance and group them that way.) Since it's not discoverable via SNMP, regex grouping is a logical choice. However, if you're not discovering each peer's peer group, then what is the regex going to evaluate against? How are you going to identify which peers go in which group?

    As far as the regex itself, you simply need to specify the group name and the corresponding regex. If an instance matches the regex, it will be in that instance group, like this

    To give you an example, I built a Santa Claus tracker just before the holidays last year. There are instances for each of the 9 reindeer and also for the big man himself. Each instance has an instance level property (auto.species). To group by species, I can simply choose "instance level property" in the group by and provide "auto.species". 

    To use regex, I simply provide this in the regex field: 

    Elves="S.*" Reindeer="[DPVCBR].*"

    That ends up creating two groups like this: