Reporting, Analysis and Analytics

Expand all | Collapse all

Monitor for Presence of a file

  • 1.  Monitor for Presence of a file

    Posted 03-26-2018 10:43 PM
    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


  • 2.  RE: Monitor for Presence of a file

    Posted 03-28-2018 02:23 AM
    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 -  .  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.


    Jane Curry
    Skills 1st United Kingdom

  • 3.  RE: Monitor for Presence of a file

    Posted 08-09-2018 09:01 PM
    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