Discussion:
Run a script when deleting a device
tcaiazza
2012-04-13 13:59:14 UTC
Permalink
tcaiazza [http://community.zenoss.org/people/tcaiazza] created the discussion

"Run a script when deleting a device"

To view the discussion, visit: http://community.zenoss.org/message/65883#65883

--------------------------------------------------------------
Is there a way to run a script when a user deletes a device in zenoss?  I have a script that deletes a bunch of stuff that is stored outside of zenoss and would like it to run automagically when a user asks to delete a device.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/65883#65883]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
themactech
2012-04-13 14:23:59 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Run a script when deleting a device"

To view the discussion, visit: http://community.zenoss.org/message/65884#65884

--------------------------------------------------------------
I can't answer about the script triggering on a device delete GUI selection, but you could do a script that does regular garbage collection.

You could have a script that exports the devices in your zenoss to a file dump, check if that has changed since the last time, then parse the file to detect deleted devices and take appropriate steps (extra file deletions, etc...).  This could be run as a cron job at the interval of your choice (hourly, daily, weekly).

Manuel
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/65884#65884]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-04-13 18:25:12 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Run a script when deleting a device"

To view the discussion, visit: http://community.zenoss.org/message/65893#65893

--------------------------------------------------------------
I'll second themactech, I am not aware of a "trigger" approach, however, the approach we are in the middle of implementing is that users don't actually use the delete device from the UI, but rather create a "delete device" event. We then have a custom daemon, that runs on a one minute interval and reacts to the events taking care of the external cleanup tasks, such as updating our external CMDB, and such.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/65893#65893]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
tcaiazza
2012-04-13 18:38:09 UTC
Permalink
tcaiazza [http://community.zenoss.org/people/tcaiazza] created the discussion

"Re: Run a script when deleting a device"

To view the discussion, visit: http://community.zenoss.org/message/65895#65895

--------------------------------------------------------------
Now would you do the same thing for when adding new devices?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/65895#65895]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-04-13 18:39:33 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Run a script when deleting a device"

To view the discussion, visit: http://community.zenoss.org/message/65896#65896

--------------------------------------------------------------
In our case now, we don't that on the ADD, but you certainly could. For us, we add the device via the JSON API, and its called as part of a post-build script. For whatever reason, we just never had a "pre-decomm" script to do all the inverse steps.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/65896#65896]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
themactech
2012-04-13 18:43:38 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Run a script when deleting a device"

To view the discussion, visit: http://community.zenoss.org/message/65897#65897

--------------------------------------------------------------
Well if you make a script reacting to a change in your device inventory, you could have two routines within the script that trigger if a device was added or removed.

I.E. your script would do this.

-Rename last file dump to export.old (overwriting previous one)
-Export device list to export.txt
-Parse export.old and export.txt to determine device changes
     -Device remove: Do garbage collection
     -Device added: Do extra config steps

You might need to export more than the device list if you want to further automate your process if it varies on device class.  You garbage collection might be different if you remove a server than a temperature sensor, same for added devices, so you might add the device class to your export or any extra info from Zenoss you require to automate your process

Manuel
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/65897#65897]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
tcaiazza
2012-04-13 18:54:54 UTC
Permalink
tcaiazza [http://community.zenoss.org/people/tcaiazza] created the discussion

"Re: Run a script when deleting a device"

To view the discussion, visit: http://community.zenoss.org/message/65898#65898

--------------------------------------------------------------
Alright thanks for the help.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/65898#65898]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...