Forum Discussion

Vitor_Santos's avatar
4 years ago
Solved

Resource Inventory report - Extracting instance level props (instance group??)

Hello, We had a recent need of compiling a list of what we monitor for a client of ours. This client in question has a LOT of 'PingMulti' stuff through its different collectors. We've thei...
  • Anonymous's avatar
    Anonymous
    4 years ago

    How are you getting the instances into the groups? If you're doing it manually, it'll take a bit more work to do what you want to do. However, if you are automatically sorting instances into groups, you should be basing that on an instance level property. If so, you should be able to just use that property.

    Since this is fairly obvious and you're still having difficulties, I assume that's not an option. Your best bet would be to automatically discover the group during discovery of the instances. Active discovery is not enabled by default for that DS, but that doesn't mean you can't set it up. Setting it up might also solve some management headaches. 

    For a different but similar DS, I use the following script as my active discovery script:

    targets = hostProps.get("ping.targets")
    try {
        targets.tokenize(", ").each{
            target = it.tokenize(":")
            println("${target[1]}##${target[0]}")
        }
        return 0
    }
    catch (Exception e){return 1}

    This allows me to create a property on the device called ping.targets. That property contains a value in this format:

    MyGateway:192.168.1.1, MyServer:10.0.0.35,SomeOtherDevice.example.com:172.16.35.18, GooglePing:4.2.2.2

    The above string would result in 4 instances pinging 4 different IP addresses with four different names. It wouldn't take much to modify this script to also set a parent group for each instance based on the value in the ping.targets property:

    targets = hostProps.get("ping.targets")
    try {
        targets.tokenize(", ").each{
            target = it.tokenize(":")
            println("${target[1]}##${target[0]######auto.parentGroup=${target[2]}")
        }
        return 0
    }
    catch (Exception e){return 1}

    Then your property syntax would look like this:

    MyGateway:192.168.1.1:GroupA, MyServer:10.0.0.35:GroupB,SomeOtherDevice.example.com:172.16.35.18:GroupA, GooglePing:4.2.2.2:GroupC

    This would create four instances in three groups. Then you could automatically group instances, automatically discover instances, and you could use instance level properties on your reports. You'd want to tweak the first tokenize statement if you want to allow spaces in the group names. (targets.tokenize(",").each vs. targets.tokenize(", ").each).