Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to use Monit to check the permissions of a particular directory, but I only care that it's readable to all users. I don't care about any other permissions (write, execute) for the owner, group, or all. I also don't care about any special permissions.

Knowing that I can't change the permissions of this directory, and with the possibility of another administrator changing these permissions without affecting my processes that rely on this directory (i.e., granting or revoking write access to the group), is it possible to check for a minimum permission in Monit?

I have this which is currently working:

check directory archive path /var/home/archive/
    if failed perm 0755 then alert

But I would like to have something like tihs:

check directory archive path /var/home/archive/
    if failed perm > 444 then alert

This is failing for me. Is it possible to use comparison operators in Monit's permissions checking? If not, are there any workarounds?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You could substitute this type of check, with running a program and checking its exit status.

From the monit manual: (NOTE: myscript.sh has to be minimum 555 permission).

" An example:

 check program myscript with path "/usr/local/bin/myscript.sh" with timeout 1000 seconds
       if status != 0 then alert

Sample script for the above example (/usr/local/bin/myscript.sh):

 #!/bin/bash
 echo test
 exit $?

"

You could construct a program doing the check you want (consider using the find command), or even using the find command as the specific monit program. You could even customize the exit statuses so that different exit codes mean different things.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.