<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Monitor number of active connections to MySQL using Nagios</title>
	<atom:link href="http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/feed/" rel="self" type="application/rss+xml" />
	<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 06 Mar 2012 08:56:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Administrator</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-48291</link>
		<dc:creator>Administrator</dc:creator>
		<pubDate>Mon, 02 May 2011 14:21:10 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-48291</guid>
		<description>@Andy: You need &lt;code&gt;nagios-plugins-basic&lt;/code&gt; installed (this is how the package is named in Debian, it should give you an idea what to install for other distros).</description>
		<content:encoded><![CDATA[<p>@Andy: You need <code>nagios-plugins-basic</code> installed (this is how the package is named in Debian, it should give you an idea what to install for other distros).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-48289</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Mon, 02 May 2011 14:09:41 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-48289</guid>
		<description>need HowTo to Use.

./check_mysql_conn.pl -H -u root -p MyPassw -q

Can&#039;t locate utils.pm in @INC (@INC contains: /usr/lib/nagios/plugins /usr/lib/perl5/5.8.8/i586-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at ./check_mysql_conn.pl line 6.
BEGIN failed--compilation aborted at ./check_mysql_conn.pl line 6.</description>
		<content:encoded><![CDATA[<p>need HowTo to Use.</p>
<p>./check_mysql_conn.pl -H -u root -p MyPassw -q</p>
<p>Can&#8217;t locate utils.pm in @INC (@INC contains: /usr/lib/nagios/plugins /usr/lib/perl5/5.8.8/i586-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at ./check_mysql_conn.pl line 6.<br />
BEGIN failed&#8211;compilation aborted at ./check_mysql_conn.pl line 6.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thilo</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-35519</link>
		<dc:creator>Thilo</dc:creator>
		<pubDate>Thu, 25 Nov 2010 10:36:45 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-35519</guid>
		<description>I had to remove a &quot;;&quot; in the perfdata output to make it work with pnp-0.4:
&lt;code&gt;
my $perfdata =
  &quot;mysql_connections=$threads_connected;$warn_threshold;$critical_threshold;0;0&quot;;
&lt;/code&gt;
http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201</description>
		<content:encoded><![CDATA[<p>I had to remove a &#8220;;&#8221; in the perfdata output to make it work with pnp-0.4:<br />
<code><br />
my $perfdata =<br />
  "mysql_connections=$threads_connected;$warn_threshold;$critical_threshold;0;0";<br />
</code><br />
<a href="http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201" rel="nofollow">http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Administrator</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-32098</link>
		<dc:creator>Administrator</dc:creator>
		<pubDate>Thu, 09 Sep 2010 16:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-32098</guid>
		<description>@Paul: Yes, I am. Please send me your update and I will include it. Thanks!</description>
		<content:encoded><![CDATA[<p>@Paul: Yes, I am. Please send me your update and I will include it. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-32085</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Thu, 09 Sep 2010 08:53:42 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-32085</guid>
		<description>Hi

I wanted to be able to take the password from .my.cnf to avoid exposing it in the command line.  So I made a few quick changes to your code to do that.

Are you interested in me feeding them back to you?</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I wanted to be able to take the password from .my.cnf to avoid exposing it in the command line.  So I made a few quick changes to your code to do that.</p>
<p>Are you interested in me feeding them back to you?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Administrator</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-18139</link>
		<dc:creator>Administrator</dc:creator>
		<pubDate>Sat, 27 Jun 2009 19:47:48 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-18139</guid>
		<description>I have also submitted my plugin to &lt;a href=&quot;http://www.monitoringexchange.org/cgi-bin/page.cgi?g=Detailed%2F3119.html;d=1&quot; rel=&quot;nofollow&quot;&gt;MonitoringExchange&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>I have also submitted my plugin to <a href="http://www.monitoringexchange.org/cgi-bin/page.cgi?g=Detailed%2F3119.html;d=1" rel="nofollow">MonitoringExchange</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Administrator</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17568</link>
		<dc:creator>Administrator</dc:creator>
		<pubDate>Sat, 13 Jun 2009 19:12:57 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17568</guid>
		<description>Below find an updated version of my script with Berny&#039;s extensions. It also includes a proper license (the GPL). You can download the updated version from &lt;a href=&quot;http://bergs.biz/blog/static/check_mysql_conn.pl&quot; rel=&quot;nofollow&quot;&gt;this&lt;/a&gt; URL.
&lt;pre&gt;
#!/usr/bin/perl -w

use strict;
use Getopt::Std;
use lib &quot;/usr/lib/nagios/plugins&quot;;
use utils qw(%ERRORS);

use vars qw/ %opt /;
sub debug($);

getopts(&#039;c:dhH:Lp:P:S:u:w:V&#039;, \%opt);

if (exists $opt{h}) {
    usage();
    exit(0);
}

if (exists $opt{V}) {
    print &#039;$Id: check_mysql_conn.pl 27 2009-06-13 19:14:27Z rabe $&#039;, &quot;\n&quot;;
    exit(0);
}

if (exists $opt{L}) {
    print &lt; &lt; &quot;EOF&quot;;
Copyright (C) 2008-2009 Ralf G. R. Bergs

Thanks for bugfixes and feature updates to Ian K. and Bernd
Stroessenreuther.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see &lt;http://www.gnu.org/licenses/&gt;.
EOF
    exit(0);
}

my $debug = 0;
if (exists $opt{d}) {
    print &quot;Enabling debug mode...\n&quot;;
    $debug = 1;
}

my $warn_threshold = 5;
if (exists $opt{w}) {
    $warn_threshold = $opt{w};
}
debug(&quot;\$warn_threshold=$warn_threshold\n&quot;);

my $critical_threshold = 10;
if (exists $opt{c}) {
    $critical_threshold = $opt{c};
}
debug(&quot;\$critical_threshold=$critical_threshold\n&quot;);

my $username = &quot;monitoring&quot;;
if (exists $opt{u}) {
    $username = $opt{u};
}

my $password = &quot;monitoring&quot;;
if (exists $opt{p}) {
    $password = $opt{p};
}

my $host = &quot;127.0.0.1&quot;;
if (exists $opt{H}) {
	$host = $opt{H};
}

my $port = 3306;
if (exists $opt{P}) {
	$port = $opt{P};
}

my $socket = &quot;&quot;;
if (exists $opt{S}) {
	$socket = $opt{S};
}

my $cmdline = &quot;/usr/bin/mysql -u $username -p$password&quot;;
if ($socket eq &quot;&quot;) {
	$cmdline = &quot;$cmdline -h $host -P $port&quot;;
} else {
	$cmdline = &quot;$cmdline -S $socket&quot;;
}

debug(&quot;\$cmdline=\&quot;$cmdline\&quot;\n&quot;);
my $query_output = `/bin/echo &quot;SHOW GLOBAL STATUS LIKE &#039;Threads_connected&#039;;&quot; \&#124; $cmdline 2&gt;/dev/null \&#124; /bin/grep &quot;Threads_connected&quot;`;
debug(&quot;\$query_output=\&quot;$query_output\&quot;\n&quot;);
unless ($query_output =~ /^Threads_connected\s+(\d+)\s+$/) {
    print &quot;Unknown: Unable to read output from MySQL\n&quot;;
    exit $ERRORS{&#039;UNKNOWN&#039;};
}

my $threads_connected = $1;
debug(&quot;\$threads_connected=$threads_connected\n&quot;);

my $perfdata = &quot;mysql_connections=$threads_connected;$warn_threshold;$critical_threshold;0;0;&quot;;

if ($threads_connected &gt; $critical_threshold) {
    print &quot;Critical: $threads_connected active connections&#124;$perfdata\n&quot;;
    exit $ERRORS{&#039;CRITICAL&#039;}
} elsif ($threads_connected &gt; $warn_threshold) {
    print &quot;Warning: $threads_connected active connections&#124;$perfdata\n&quot;;
    exit $ERRORS{&#039;WARNING&#039;}
} else {
    print &quot;OK: $threads_connected active connections&#124;$perfdata\n&quot;;
    exit $ERRORS{&#039;OK&#039;}
}



###########################################################################

sub usage {
    if (@_ == 1) {
	print &quot;$0: $_[0].\n&quot;;
    }
    print &lt; &lt; &quot;EOF&quot;;
Usage: $0 [options]
  -w THRESHOLD
     Warning threshold for number of active connections (default: 5)
  -c THRESHOLD
     critical threshold for number of active connections (default: 10)
  -H HOST
  	 Connect to TCP address/DNS name (default: 127.0.0.1).
  -P PORT
  	 Use this alternate TCP port (default: 3306).
  -S SOCKET
  	 Use this MySQL socket instead of the default/or TCPIP.
  -u USERNAME
     The MySQL username to use when connecting to the server.
  -p PASSWORD
     The password to use when connecting to the server.
  -d
     enable debug mode (mutually exclusive to -q)
  -h
     display usage information
  -L
     display license
  -V
     display version number      
EOF
}

sub debug($) {
    if ($debug) {
	print STDERR $_[0];
    }
}
&lt;/pre&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Below find an updated version of my script with Berny&#8217;s extensions. It also includes a proper license (the GPL). You can download the updated version from <a href="http://bergs.biz/blog/static/check_mysql_conn.pl" rel="nofollow">this</a> URL.</p>
<pre>
#!/usr/bin/perl -w

use strict;
use Getopt::Std;
use lib "/usr/lib/nagios/plugins";
use utils qw(%ERRORS);

use vars qw/ %opt /;
sub debug($);

getopts('c:dhH:Lp:P:S:u:w:V', \%opt);

if (exists $opt{h}) {
    usage();
    exit(0);
}

if (exists $opt{V}) {
    print '$Id: check_mysql_conn.pl 27 2009-06-13 19:14:27Z rabe $', "\n";
    exit(0);
}

if (exists $opt{L}) {
    print < < "EOF";
Copyright (C) 2008-2009 Ralf G. R. Bergs

Thanks for bugfixes and feature updates to Ian K. and Bernd
Stroessenreuther.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see <<a href="http://www.gnu.org/licenses/" rel="nofollow">http://www.gnu.org/licenses/>.
EOF
    exit(0);
}

my $debug = 0;
if (exists $opt{d}) {
    print "Enabling debug mode...\n";
    $debug = 1;
}

my $warn_threshold = 5;
if (exists $opt{w}) {
    $warn_threshold = $opt{w};
}
debug("\$warn_threshold=$warn_threshold\n");

my $critical_threshold = 10;
if (exists $opt{c}) {
    $critical_threshold = $opt{c};
}
debug("\$critical_threshold=$critical_threshold\n");

my $username = "monitoring";
if (exists $opt{u}) {
    $username = $opt{u};
}

my $password = "monitoring";
if (exists $opt{p}) {
    $password = $opt{p};
}

my $host = "127.0.0.1";
if (exists $opt{H}) {
	$host = $opt{H};
}

my $port = 3306;
if (exists $opt{P}) {
	$port = $opt{P};
}

my $socket = "";
if (exists $opt{S}) {
	$socket = $opt{S};
}

my $cmdline = "/usr/bin/mysql -u $username -p$password";
if ($socket eq "") {
	$cmdline = "$cmdline -h $host -P $port";
} else {
	$cmdline = "$cmdline -S $socket";
}

debug("\$cmdline=\"$cmdline\"\n");
my $query_output = `/bin/echo "SHOW GLOBAL STATUS LIKE 'Threads_connected';" \| $cmdline 2>/dev/null \| /bin/grep "Threads_connected"`;
debug("\$query_output=\"$query_output\"\n");
unless ($query_output =~ /^Threads_connected\s+(\d+)\s+$/) {
    print "Unknown: Unable to read output from MySQL\n";
    exit $ERRORS{'UNKNOWN'};
}

my $threads_connected = $1;
debug("\$threads_connected=$threads_connected\n");

my $perfdata = "mysql_connections=$threads_connected;$warn_threshold;$critical_threshold;0;0;";

if ($threads_connected > $critical_threshold) {
    print "Critical: $threads_connected active connections|$perfdata\n";
    exit $ERRORS{'CRITICAL'}
} elsif ($threads_connected > $warn_threshold) {
    print "Warning: $threads_connected active connections|$perfdata\n";
    exit $ERRORS{'WARNING'}
} else {
    print "OK: $threads_connected active connections|$perfdata\n";
    exit $ERRORS{'OK'}
}

###########################################################################

sub usage {
    if (@_ == 1) {
	print "$0: $_[0].\n";
    }
    print < < "EOF";
Usage: $0 [options]
  -w THRESHOLD
     Warning threshold for number of active connections (default: 5)
  -c THRESHOLD
     critical threshold for number of active connections (default: 10)
  -H HOST
  	 Connect to TCP address/DNS name (default: 127.0.0.1).
  -P PORT
  	 Use this alternate TCP port (default: 3306).
  -S SOCKET
  	 Use this MySQL socket instead of the default/or TCPIP.
  -u USERNAME
     The MySQL username to use when connecting to the server.
  -p PASSWORD
     The password to use when connecting to the server.
  -d
     enable debug mode (mutually exclusive to -q)
  -h
     display usage information
  -L
     display license
  -V
     display version number
EOF
}

sub debug($) {
    if ($debug) {
	print STDERR $_[0];
    }
}
</pre>
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17521</link>
		<dc:creator>Christian</dc:creator>
		<pubDate>Fri, 12 Jun 2009 15:49:13 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17521</guid>
		<description>Re: check_mysql doesn&#039;t support tracking the currently running threads.

check_mysql does show that, if you pass -S (or --check-slave). Sure, it isn&#039;t completely desirable to show the complete load of information if you just wish to parse the amount of current running threads.

Also, if you want a completed version of the plugin (like what Berny added $host and perfdata, and $port and $socket), you&#039;ll be finding it here: http://chrischie.users.barfoo.org/check_mysql_connections.pl</description>
		<content:encoded><![CDATA[<p>Re: check_mysql doesn&#8217;t support tracking the currently running threads.</p>
<p>check_mysql does show that, if you pass -S (or &#8211;check-slave). Sure, it isn&#8217;t completely desirable to show the complete load of information if you just wish to parse the amount of current running threads.</p>
<p>Also, if you want a completed version of the plugin (like what Berny added $host and perfdata, and $port and $socket), you&#8217;ll be finding it here: <a href="http://chrischie.users.barfoo.org/check_mysql_connections.pl" rel="nofollow">http://chrischie.users.barfoo.org/check_mysql_connections.pl</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berny</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17479</link>
		<dc:creator>Berny</dc:creator>
		<pubDate>Wed, 10 Jun 2009 11:35:53 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17479</guid>
		<description>Hi,

also added perfdata now...

Berny</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>also added perfdata now&#8230;</p>
<p>Berny</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Berny</title>
		<link>http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17478</link>
		<dc:creator>Berny</dc:creator>
		<pubDate>Wed, 10 Jun 2009 11:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://bergs.biz/blog/2007/05/08/monitor-number-of-active-connections-to-mysql-using-nagios/#comment-17478</guid>
		<description>Hi,

I corrected an error in use of parameter password and and added an option to tell the plugin on which host the mysql is running (if not localhost).
Please contact me by eMail, if You are interested in these changes.

Berny</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I corrected an error in use of parameter password and and added an option to tell the plugin on which host the mysql is running (if not localhost).<br />
Please contact me by eMail, if You are interested in these changes.</p>
<p>Berny</p>
]]></content:encoded>
	</item>
</channel>
</rss>

