Question

Bulk add of monitored instance - Ping (Multi)-

  • 18 April 2023
  • 6 replies
  • 226 views

Userlevel 2
Badge

I have been tasked with adding a large number of ping only monitored instances.  Is there so way to automate this process similar to the csv file for adding resource/devices? 


6 replies

Userlevel 7
Badge +20

What I’ve done in situations like this is change the DS so that it uses ActiveDiscovery to create the instances based on a list I put in a property. Then I can apply that property to a group of devices and they’ll each get the same list of instances.

Clone the PingMulti- DS (or use the existing one but understand the ramifications of enabling ActiveDiscovery).

Turn on discovery

Switch to script

Use this script:

hostProps.get("ping_destinations").tokenize("|").each{pair->
println(pair.tokenize(",")[0] + "##" + pair.tokenize(",")[1])
}
return 0

Then create the property called `ping_destinations` on the device or group of devices in the following format:

destination_1_IP,destination_1_displayName|destination_2_IP,destination_2_displayName|destination_3_IP,destination_3_displayName

Userlevel 2
Badge

What about cloning the datasource to a new one dependent upon a custom system category applied to the appropriate targets and having the IP’s in an array built into the script giving a central management point for what in my case is a pretty long list?

Userlevel 7
Badge +20

You could clone it either way. Whether you hard code the list into the script or pull them in dynamically is up to you. It’ll be easier to manage if you do it dynamically with the property (because you can apply it at a group level and have overrides at the device level in case the group needs one set, but one server needs a slightly different set).

Userlevel 6
Badge +13

The way we have done it is we have a script that loops through and creates the instances. We can’t go with the way Stuart does as we need to create instance level properties as well to pass on in alerting. You get your device id, device datasource id, then a simple loops.

datasourceinstancespath = "/device/devices/" + deviceid + "/devicedatasources/" + devicedatasourceid + "/instances"
with open('CLIENTPingOnly.csv', newline='', encoding='utf-8-sig') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print(row['wildValue'])
targetbody = json.dumps({
"wildValue": row['wildValue'],
"displayName": row['displayName'],
"customProperties": [{"name": "sn.sys_id", "value": row['customProperties']}]
})
addinstance = lm_rest("POST", datasourceinstancespath, targetbody, "")

 

Userlevel 2
Badge

I won’t say it was the best result, but it worked for the concerns I have.  End result was to clone the PingMulti- datasource and modify it to only apply to a custom hasCategory that is attached to any collector needed.  The groovy script is a very ugly line by line entry:

println("<ip1>" + "##" + "<description1>")
println("<ip2>" + "##" + "<description2>")
return 0

Reasoning was to give myself a neatly formatted list I could quickly skim and edit vs a messy array and loop or single use CSV.  Having this info in a datasource also lets me replace, change or add collectors as monitor points with only needed the single system category and the list itself not be device dependent.   I think Joe’s answer would have worked well enough but the environment and target devices we ping change just often enough or require multiple collectors to check.

Userlevel 1
Badge +4

About 9 months too late (I stumbled across this post by mistake) But I wrote a Python script to do this if you want. 

Reply