[Nagiosplug-devel] check_mysql should support aommand line option for a MySQL defaults file

Brian A. Seklecki lavalamp at spiritual-machines.org
Sun Nov 26 02:54:11 CET 2006

That patch was "relatively recent" given Nagios releng schedule:

Revision 1.27 - (view) (download) (annotate) - [select for diffs]
Thu Oct 13 09:55:31 2005 UTC (13 months, 1 week ago) by seanius
Branch: MAIN
Changes since 1.26: +4 -2 lines
Diff to previous 1.26

check mysql now reads [client] defaults from my.cnf (debian bug #278817)


But it's good to see it in there.  Thank you.  I guess the surprising 
thing here is that you have to tell libmysql manually to use ~/.my.cnf. 
With most libraries (OpenLDAP, PostgreSQL come to mind), it's the exact 

I don't know much about Gentoo, but it sounds like they need to implment 
some RC mechanisms similar NetBSD/FreeBSD RCNG as featured in rc.subr(8) 
where you can simplify delcare $servicename_user="foo" and it will 
appropriately exec the command under "su -m sh -c '$start_command'":

$ egrep -B 3 -i -- "su -" /etc/rc.subr
${_nice:+nice -n $_nice }\
$command $rc_flags $command_args"
                         if [ -n "$_user" ]; then
                               _doit="su -m $_user -c 'sh -c \"$_doit\"'"

That way the RC has a uniform method and each script doesn't have to play 
guesswork on alt user exec, chroot(8), and privsep services.

Another option is a shared RC subroutine that utilized sudo(8) if you 
maintain it in-tree as part of base distro.


On Sat, 25 Nov 2006, Wolfram Schlich wrote:

> * sean finney <seanius at seanius.net> [2006-11-24 20:53]:
>> On Fri, 2006-11-24 at 12:33 -0500, Brian A. Seklecki wrote:
>>> Yea it's always been beyond my belief why/if/that check_mysql doesn't
>>> honor ~nagios/.my.cnf.  I remember the pain clearly.  Vivid.
>> doesn't it do so now?
>> <snip>
>>         /* initialize mysql  */
>>         mysql_init (&mysql);
>>         mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");
>> <snip>
> Yes, it does. But there is a problem with it :)
> On Gentoo, the init script runs start-stop-daemon to start the nagios
> daemon as user 'nagios', which is fine. But the nagios daemon
> does not get the 'right' HOME environment variable, the home of the
> user nagios for example, but instead HOME=/root.
> So, I patched the init-script to add '-e HOME=/var/nagios' to the
> start-stop-daemon call. Now, check_mysql (and others) get the
> correct HOME and are able to use ~/.whatever files.
> -- 
> Wolfram Schlich
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________________
> Nagios Plugin Development Mailing List Nagiosplug-devel at lists.sourceforge.net
> Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
> ::: Please include plugins version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null

 	-lava (Brian A. Seklecki - Pittsburgh, PA, USA)

"...from back in the heady days when "helpdesk" meant nothing, "diskquota"
meant everything, and lives could be bought and sold for a couple of pages
of laser printout - and frequently were."

More information about the Devel mailing list