Forum Discussion

rdeluher's avatar
2 years ago
Solved

snmp location field

We use snmp location field on cisco devices.  it is like this:

“snmp-server location B23 Floor1”

How can we make that show up in logicmonitor in a easy to find place?

  • While it is a bit disappointing this is not something LM has support for out of the box, using that string is actually one of the least good ways to accomplish the goal.  Going “the LM way” we, we’ve developed a method using a per-client property source module to scan each device IP address looking for matches within known per-site networks, then we assign auto.locationtag accordingly (typically a short site code similar to how you’d name devices at the site). With auto.locationtag set, you then create a dynamic group and assign the location string once to that group. This does rely on knowing the network layout for your environment and that it be somewhat reasonable, but otherwise it is rock solid.  You can also create an “Unknown Location” group to identify devices without the auto.locationtag set to help find gaps.

    Here is a sanitized version of one of our PS modules:

    hostProps.get("system.ips").split(",").each { ip ->
        if (ip ==~ /(172\.(24|30)|10\.188)\..*/) {
            locationtag = "loc1"
        }
        else if (ip ==~ /(172\.(20|23)|10\.178)\..*/) {
            locationtag = "loc2"
        }
    }
    if (locationtag) {
        println "locationtag=$locationtag"
    }

    return(0)

    I have been watching one of our clients adding the SNMP location to devices since they are moving from LM to Datadog and it is one of the poorer solutions out there for network monitoring.  Kinda funny watching it happen :).

4 Replies

  • I thought it was built in, but couldn’t find it. Just build a property source applied to devices that should have snmp (like `snmp.community`, but that would only catch the v2 snmp devices). 

    import com.santaba.agent.groovyapi.snmp.Snmp
    def snmp_timeout = 10000
    try {
    println("auto.snmp.location=" + Snmp.get(hostProps.get('system.hostname'), '1.3.6.1.2.1.1.6.0', hostProps.toProperties(), snmp_timeout))
    return 0
    }
    catch (Exception e) {println e;return 1}
  • While it is a bit disappointing this is not something LM has support for out of the box, using that string is actually one of the least good ways to accomplish the goal.  Going “the LM way” we, we’ve developed a method using a per-client property source module to scan each device IP address looking for matches within known per-site networks, then we assign auto.locationtag accordingly (typically a short site code similar to how you’d name devices at the site). With auto.locationtag set, you then create a dynamic group and assign the location string once to that group. This does rely on knowing the network layout for your environment and that it be somewhat reasonable, but otherwise it is rock solid.  You can also create an “Unknown Location” group to identify devices without the auto.locationtag set to help find gaps.

    Here is a sanitized version of one of our PS modules:

    hostProps.get("system.ips").split(",").each { ip ->
        if (ip ==~ /(172\.(24|30)|10\.188)\..*/) {
            locationtag = "loc1"
        }
        else if (ip ==~ /(172\.(20|23)|10\.178)\..*/) {
            locationtag = "loc2"
        }
    }
    if (locationtag) {
        println "locationtag=$locationtag"
    }

    return(0)

    I have been watching one of our clients adding the SNMP location to devices since they are moving from LM to Datadog and it is one of the poorer solutions out there for network monitoring.  Kinda funny watching it happen :).

  • Yeah, we don’t do it that way either. We have custom stuff that sync’s in from our source of truth including a location tag. That location tag sets the actual location property (not auto property) so that location can be used on a google map widget. Don’t get me started on how long that feed has been sitting in the queue. The intelligence that @mnagel references lives outside our LM entirely.