TECHZEN Zenoss User Community ARCHIVE  

Monitor for Presence of a file

Subject: Monitor for Presence of a file
Author: Mike Barone
Posted: 2018-03-26 23:43

Very simply, I need to monitor for the presence of a file on a remote system.  If the file exists, it is critical, if it doesn't it is OK.

I've written a bash script to run this check, but I'm really confused by the different options I've seen for a way to implement it.  IS there a simple method you guys could suggest?

------------------------------
Mike Barone
------------------------------


Subject: RE: Monitor for Presence of a file
Author: Jane Curry
Posted: 2018-03-28 03:23

Hi Mike - it depends on how you have written your bash script.

Fundamentally, you want to create a COMMAND template to run the script.  The "it depends" bit depends on whether your script exista on all your target systems, or whether you have written your script so that it is executed on the Zenoss server and uses something like ssh or scp within the script to talk to a bunch of systems?

If the script runs on your target systems then you need to setup a userid and password for ssh communications (or setup a user and ssh keys if you are going to work with key encryption - Zenoss can cope either way).  Once you have tested your ssh access from a command line, ensure each of your target systems is in Zenoss and setup the zCommandUsername, and the zCommandPassword  or zKeyPath.  If you have a whole bunch of such systems, you may find it easier to create a subclass of whatever device class they are currently under (or even change these zCommand configuration properties for the class the devices are in).  Either way, it is the "Configuration Properties" menu you want - if you are changing a device class then you need to use the DETAILS button at the top of the left-hand menu on the INFRASTRUCTURE panel, once you have selected your class.

Then you need to create a COMMAND template - I think the Admin guide is reasonable on that.  Have your script at least deliver an exit code that will be returned to the command template.  I would probably also have it deliver a numeric value - 1 for success and 0 for failure.

You might get some more clues on running command templates if you look at the ZenPack developers' Guide - https://github.com/Zhttps://github.com/ZenossDevGuide/DevGuideenossDevGuide/DevGuide  .  You do NOT need to go to the extent of writing a ZenPack but Chapter 12 talks in some detail about creating COMMAND performance templates.

Cheers,
Jane

------------------------------
Jane Curry
Skills 1st United Kingdom
jane.curry@skills-1st.co.uk
------------------------------


Subject: RE: Monitor for Presence of a file
Author: Mike Barone
Posted: 2018-08-09 22:01

Jane, thank you for taking the time to help on this, we ended up building this into a service and can monitor that.

------------------------------
Mike Barone
------------------------------


< Previous
Error message, FileSystem template (SSH Linux)
  Next
How to get logs details of device
>