Permission denied on unionfs directory

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
gmdune
Posts: 8
Joined: Thu Feb 24, 2011 11:43 am

Permission denied on unionfs directory

Post by gmdune »

All,

I'm getting a permission denied when running check_disk on a unionfs mounted directory. Oddly enough, when manually running the check, from the command line, no error gets posted other than a disk warning:

./check_disk "-w 15% -c 5% -W 50% -K 25% -X none -X cifs -X fuse -X nfs -X nfsd"
DISK WARNING - free space: / 57208 MB (60% inode=99%); /dev/shm 3921 MB (100% inode=99%); /boot 40 MB (43% inode=99%); /backups 2578907 MB (24% inode=95%); /mnt/nfs/backup-02 2068228 MB (18% inode=98%); /mnt/nfs/backup-03 5278630 MB (46% inode=98%); /mnt/nfs/backup-04 2178515 MB (21% inode=99%); /mnt/unionfs/backups 2578907 MB (6% inode=23%);| /=37399MB;84720;;0;99671 /dev/shm=0MB;3332;;0;3921 /boot=53MB;83;;0;98 /backups=7904814MB;8911162;;0;10483721 /mnt/nfs/backup-02=8825094MB;9259323;;0;10893322 /mnt/nfs/backup-03=6024292MB;9607483;;0;11302922 /mnt/nfs/backup-04=8059447MB;8702267;;0;10237962 /mnt/unionfs/backups=40339020MB;36480237;;0;42917927

On nagios server, I'm getting the following output:

DISK CRITICAL - /mnt/unionfs/backups is not accessible: Permission denied

BTW: /mnt/union/backups permissions are all at least 766 starting at /mnt; this mount is manually mounted not through fstab or autofs.

Thanks
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Permission denied on unionfs directory

Post by slansing »

Does the nagios user/group have access? It is likely that it worked from the CLI as it was probably ran as root.
technick
Posts: 49
Joined: Tue Feb 04, 2014 10:30 am
Location: Denver, CO

Re: Permission denied on unionfs directory

Post by technick »

I agree, sounds like a permissions issue.

You can manually test it by running sudo -u nagios /usr/local/nagios/libexec/check_disk "-w 15% -c 5% -W 50% -K 25% -X none -X cifs -X fuse -X nfs -X nfsd"
----------------------
Nagios Jedi in training.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Permission denied on unionfs directory

Post by sreinhardt »

Thanks for the continued helpful posts technick! I was just going to suggest the same thing, it's very important to make sure that when checking plugin execution you are running as the nagios user not root, as that is how the plugin would be run when executed from the nagios daemon.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
gmdune
Posts: 8
Joined: Thu Feb 24, 2011 11:43 am

Re: Permission denied on unionfs directory

Post by gmdune »

Guys,

You were right, the nagios user can't read the /mnt/unionfs/backups directory:

[root@sr-backup-01-p ~]# sudo -u nagios /usr/local/nagios/libexec/check_disk "-w 15% -c 5% -W 50% -K 25% -X none -X cifs -X fuse -X nfs -X nfsd"
DISK CRITICAL - /mnt/unionfs/backups is not accessible: Permission denied
[root@sr-backup-01-p ~]# su - nagios
[nagios@sr-backup-01-p ~]$ cd /mnt/
[nagios@sr-backup-01-p mnt]$ ls -l
total 8
drwxrwxr-x 5 root root 4096 Jan 23 12:29 nfs
drwxrwxrwx 3 root root 4096 Oct 21 12:25 unionfs
[nagios@sr-backup-01-p mnt]$ cd unionfs/
[nagios@sr-backup-01-p unionfs]$ ls -l
ls: cannot access backups: Permission denied
total 0
d????????? ? ? ? ? ? backups

I have no idea why the permissions are all messed up when the nagios user tries to look at that directory, but the directory can be read as root. I'm trying to come up with a one liner that will ignore that directory, but every iteration I try doesn't work:

[nagios@sr-backup-01-p unionfs]$ sudo -u nagios /usr/local/nagios/libexec/check_disk "-w 15% -c 5% -W 50% -K 25% -i /mnt/unionfs/backups -X none -X cifs -X fuse -X nfs -X nfsd -X unionfs"
DISK CRITICAL - /mnt/unionfs/backups is not accessible: Permission denied
[nagios@sr-backup-01-p unionfs]$ sudo -u nagios /usr/local/nagios/libexec/check_disk "-w 15% -c 5% -W 50% -K 25% -i=/mnt/unionfs/backups -X none -X cifs -X fuse -X nfs -X nfsd -X unionfs"
DISK CRITICAL - /mnt/unionfs/backups is not accessible: Permission denied

What am I doing wrong?

Thanks
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Permission denied on unionfs directory

Post by sreinhardt »

Have you tried removing the " " around your flags? I would not be suprised if this was causing it to come in as one argument and not get processed correctly. Otherwise everything looks like it should.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
gmdune
Posts: 8
Joined: Thu Feb 24, 2011 11:43 am

Re: Permission denied on unionfs directory

Post by gmdune »

All,

Thanks so much!

What you suggested worked from the command line just fine. Now my only questions is how do I code this in the commands.cfg file. Right now it looks like this:

command_name check_local_disk
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$

Would I just add a "-i"

command_name check_local_disk
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ -i $ARG4

Thanks again for your help
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Permission denied on unionfs directory

Post by lmiltchev »

You should have "-i $ARG4$" instead of "-i $ARG4". Let us know if this worked for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
gmdune
Posts: 8
Joined: Thu Feb 24, 2011 11:43 am

Re: Permission denied on unionfs directory

Post by gmdune »

Yet is it did!
Thanks everyone for your help!
Locked