Forum Discussion
Hi Antony,
Thanks for this. I have been doing this sort of API device updating via datasource for some time now, and it is definitely not ideal. With propertysources only running once every 24 hours ?, there is definitely a huge need for collectors to be able to natively and dynamically update device properties when it needs to do so. I've been digging into some of the Java methods available under the hood on the collectors and I believe I have found a workaround. Here's the relevant snippet of groovy code:
import com.santaba.agent.debugger.* println "Updating property: system.${LMObj} :: OldValue: ${hostProps.get("system.${LMObj}")} :: NewValue: ${currentObj}" task = "!hostproperty action=add host=${hostProps.get("system.hostName")} property=${LMObj} value=${currentObj}" HostPropertyTask updater = new HostPropertyTask(task) updater.run() println updater.output return updater.exitCode
As you can see, I'm manually calling on the collector to run the !hostproperty debug command in order to update the property (I know. sneaky, eh?). I'm still watching to see if this gives me any trouble, but so far it appears to be working far better and faster than the API method I was using previously. Of course, any updates to the collectors might break this functionality, but hopefully by then we will see a native hostProps.set() method instead.
cheers!
Related Content
- 7 months ago
- 2 years ago
- 7 months ago