check_mssql_health doesn't run as nagios user

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Goodie
Posts: 9
Joined: Thu Jun 11, 2015 6:51 am

check_mssql_health doesn't run as nagios user

Post by Goodie »

Hi,

I have installed Nagios Core 4.0.8 on Centos 7, I'm having issues running the check_mysql_health plugin as the standard user account `nagios` in terminal and through the nagios web front end.

I have installed the required pre-requisites for the check_mssql_health plugin i.e DBD::Sysbase etc.

i.e. running the below command as root from the terminal works, I have a server entry in freetds.conf

Code: Select all

./check_mssql_health --server=SERVER --username=DOMAIN\\NagiosSQL --password=Password --mode=connected-users
However running the command as user `nagios` receives the below error

Code: Select all

CRITICAL - cannot connect to SERVER. install_driver(Sybase) failed: Can't locate DBD/Sybase.pm in @INC (@INC contains: . /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at (eval 14) line 3.
Perhaps the DBD::Sybase perl module hasn't been fully installed,
or perhaps the capitalisation of 'Sybase' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge, mysql.
 at ./check_mssql_health line 3192.
Image

I believe it is an issue with permissions, however, I'm unsure where.

Any help will be appricated. Thanks
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: check_mssql_health doesn't run as nagios user

Post by jdalrymple »

Start with selinux:

Code: Select all

[jdalrymple@localhost ~]$ getenforce
Disabled
If Enabled do a

Code: Select all

[jdalrymple@localhost ~]$ sudo setenforce 0
If not that then perhaps Nagios embedded perl is giving you problems:
To tell Nagios to NOT use the embedded Perl interpreter for a particular script, add this line to the Perl script:

Code: Select all

# nagios: -epn
Either line must be located within the first 10 lines of a script for Nagios to detect it.
Goodie
Posts: 9
Joined: Thu Jun 11, 2015 6:51 am

Re: check_mssql_health doesn't run as nagios user

Post by Goodie »

Thanks for the quick reply jdairymple, selinux is in permissive mode, I'll try the other suggest when I'm back at work tomorrow.

I forgot to mention I have other nations plugins working, it' just the SQL one I'm having issue with.
Goodie
Posts: 9
Joined: Thu Jun 11, 2015 6:51 am

Re: check_mssql_health doesn't run as nagios user

Post by Goodie »

HI jdalrymple,

I have tried disabling SElinux and adding the extra line in to the perl script, I'm still getting the same error.

Any more idea's I can try?

Thanks
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mssql_health doesn't run as nagios user

Post by tgriep »

Could you run the following and post the output here?

Code: Select all

ll /usr/local/nagios/libexec/check_mssql_health
grep nag /etc/passwd
grep nag /etc/group
Can you show how you compiled the check_mssql_health plugin?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Goodie
Posts: 9
Joined: Thu Jun 11, 2015 6:51 am

Re: check_mssql_health doesn't run as nagios user

Post by Goodie »

I'll give it ago on Monday when I'm back in the office.

Thanks
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_mssql_health doesn't run as nagios user

Post by tgriep »

No problem. Keep us in the loop.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Goodie
Posts: 9
Joined: Thu Jun 11, 2015 6:51 am

Re: check_mssql_health doesn't run as nagios user

Post by Goodie »

HI tgriep,

Please see the information requested below

Code: Select all

[root@9-srv-nagios ~]# grep nag /etc/passwd
nagios:x:1001:1001::/home/nagios:/bin/bash
[root@9-srv-nagios ~]# grep nag /etc/group
nagios:x:1001:apache,nagios
nagcmd:x:1002:apache,nagios
I compiled the check_mssql_health plugin using the below commands following the readme file that came with the plugin

Code: Select all

./configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP --with-perl=PATH_TO_PERL --with-statefiles-dir=STATE_PATH
Where the
BASEDIRECTORY = /usr/local/nagios'
SOMEUSER = nagios
SOMEGROUP = i have tried `nagios` and `nagcmd`
PATH_TO_PERL = /usr/bin/perl
STATE_PATH = I left as the default `/tmp`

Additional info, I found a post that said if the plugin was ran by root it only allowed root to edit the contents of the folder /var/tmp/check_mssql_health where the plugin drops files in-between runs, I have since made the `nagios` account owner of this folder, however, I'm still getting the original error outlined in my first post.

Thanks
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_mssql_health doesn't run as nagios user

Post by ssax »

How did you install DBD::Sybase? (through yum or through cpan?)

Code: Select all

yum install perl-DBD-Sybase
Which would install in these locations:

Code: Select all

ls -ld /usr/lib64/perl5/vendor_perl/DBD
ls -l /usr/lib64/perl5/vendor_perl/DBD/Sybase.pm
Just compile the plugin with the defaults:

Code: Select all

./configure
make
make install
I was able to make it run as root and as nagios without any issues.
Goodie
Posts: 9
Joined: Thu Jun 11, 2015 6:51 am

Re: check_mssql_health doesn't run as nagios user

Post by Goodie »

Hi ssax,

I installed DBD::sybase through cpan, I'll try what you suggested and report back.

Thanks
Locked