PHP sybase_connect from nagios script

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.
Post Reply
WilnarMasonik
Posts: 4
Joined: Mon Jul 18, 2022 1:46 am

PHP sybase_connect from nagios script

Post by WilnarMasonik »

Has anyone had problems connecting to a sybase database using sybase_connect in PHP running as a nagios plugin?

My script runs perfectly under the same nagios user on the command line but if I run it via nagios it can never connect to the database, sybase_connect always returns a false connector and sybase_get_last_message is empty.

I've checked the environment settings and even though I'm doing, putenv the only thing I can see is the SYBASE variable may not be set

putenv ("SYBPLATFORM=linux");
putenv ("LC_ALL=default");
putenv ("DSQUERY=SYBASE");
putenv ("SYBASE=/usr/local/freetds");
putenv ("LD_LIBRARY_PATH=/usr/local/freetds/lib");
putenv ('PATH=/usr/local/freetds/bin'); // With this on or off makes no difference

$connector = sybase_connect ( "HOST-IN-FREETDS", "USER", "PASSWORD" );
if ($connector === false) {
// Always falls into here if run via nagios, works if run as the same user from the command line
}
I've compared the settings by running:

$return = `set`;
trigger_error ($return, E_USER_NOTICE);
And checked the php error log, I've also pushed phpinfo to a file and done a diff when running it manually and via nagios.

Environment - Ubuntu LTS 14.04, Nagios echatspin echatrandom Core 4.0


Any ideas anyone? Thanks in advance
Post Reply