On 04/04/2012 15:54, Christoph Kluenter wrote: > Hi, > > i tried to search for "nagios plugin file permission" but obviously got lots > of > wrong results :) > > I need a plugin that ensures that files in a given directory all belong to > one user/group. > Has anybody here ever seen a script for this purpose ? > do you have any specific about one directory? or a recursive lookup? if you will use the commands: ls -l| awk '{ print $3 }' ls -l| awk '{ print $4 }'
will give you the owner(3) and the group (4) of all files in a directory. also you can use the stat command on specific file: stat -c %U /full_file/path stat -c %G /full_file/path so you can try to do a "for" or "while" loop on all the results and in a case you find different owner then expected change a variable. you can also use a "xargs" with a nested if that will make sure that $1 is the same as you want to check. pretty simple to write cause it's a either every file is owned by the same owner or not so it's OK or CRITICAL. in case you need more help i will have sometime next week. Regards, Eliezer > > Cheers, > christoph > -- Eliezer Croitoru https://www1.ngtech.co.il IT consulting for Nonprofit organizations eliezer <at> ngtech.co.il ------------------------------------------------------------------------------ Better than sec? Nothing is better than sec when it comes to monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free. http://p.sf.net/sfu/Boundary-dev2dev _______________________________________________ Nagios-users mailing list Nagios-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagios-users ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null