<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>icinga &#8211; Scott Mcintyre</title>
	<atom:link href="https://scott.cm/tag/icinga/feed/" rel="self" type="application/rss+xml" />
	<link>https://scott.cm</link>
	<description>Web Operations Engineer,  Linux Systems Administrator,  mySQL DBA,  MongoDB DBA,  Python+PHP Developer,  Performance Engineer</description>
	<lastBuildDate>Wed, 02 Jul 2014 11:17:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.2.3</generator>
	<item>
		<title>Varnish Nagios Check</title>
		<link>https://scott.cm/varnish-nagios-check/</link>
				<comments>https://scott.cm/varnish-nagios-check/#comments</comments>
				<pubDate>Thu, 19 Apr 2012 20:34:35 +0000</pubDate>
		<dc:creator><![CDATA[Scott Mcintyre]]></dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[icinga]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[varnish]]></category>

		<guid isPermaLink="false">https://scott.cm/?p=157</guid>
				<description><![CDATA[**Update: 2 July 2014. Updated to new version 1.1 I have written a check for nagios/icinga to check the varnish backend health. You can get the latest version from github . The version at the time of posting at the bottom of this message. The defaults are RHEL defaults and]]></description>
								<content:encoded><![CDATA[<p><strong>**Update: 2 July 2014.  Updated to new version 1.1</strong></p>
<p>I have written a check for nagios/icinga to check the varnish backend health.  You can get the latest version from <a href="https://github.com/admingeekz/nagios-varnish" title="Check Varnish Backends" target="_blank">github </a>.  The version at the time of posting at the bottom of this message.</p>
<p>The defaults are RHEL defaults and ./check_varnishbackends.py should work without any options unless you want to override them.   Here is the Nagios/Icinga Setup,</p>
<p>Register the service</p><pre class="crayon-plain-tag">define service {
	register			0
	name				check_varnishbackends
	service_description		Varnish Backends
	use				generic-service
}</pre><p></p>
<p>Assign to host &#8220;server&#8221;</p><pre class="crayon-plain-tag">define service {
	service_description		Varnish Backend
	host_name			server
	use				check_varnishbackends
	check_command			remote_nrpe!check_varnishbackends -a &quot;127.0.0.1&quot; &quot;6082&quot; &quot;/etc/varnish/secret&quot; &quot;/usr/bin/varnishadm&quot;
}</pre><p></p>
<p>Setup NRPE (Make sure user has permission to varnish secret file or use sudo)</p><pre class="crayon-plain-tag">command[check_varnishbackends]=/usr/local/nagios/libexec/check_varnishbackends.py --host $ARG1$ --port $ARG2$ --secret $ARG3$ --path $ARG4$</pre><p></p>
<p>Version at time of posting,</p>
<p></p><pre class="crayon-plain-tag">#!/usr/bin/env python
# Nagios Varnish Backend Check
# v1.1
# URL: www.admingeekz.com
# Contact: sales@admingeekz.com
#
#
# Copyright (c) 2013, AdminGeekZ Ltd
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.

# 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

import sys
import optparse
import subprocess

def runcommand(command, exit_on_fail=True):
    try:
      process = subprocess.Popen(command.split(&quot; &quot;), stdout=subprocess.PIPE)
      output, unused_err = process.communicate()
      retcode = process.poll()
      return output

    except OSError, e:
      print &quot;Error: Executing command failed,  does it exist?&quot;
      sys.exit(2)


def main(argv):
  o = optparse.OptionParser(conflict_handler=&quot;resolve&quot;, description=&quot;Nagios plugin to check varnish backend health.&quot;)
  o.add_option('-H', '--host', action='store', type='string', dest='host', default='127.0.0.1', help='The ip varnishadm is listening on')
  o.add_option('-P', '--port', action='store', type='int', dest='port', default=6082, help='The port varnishadm is listening on')
  o.add_option('-s', '--secret', action='store', type='string', dest='secret', default='/etc/varnish/secret', help='The path to the secret file')
  o.add_option('-p', '--path', action='store', type='string', dest='path', default='/usr/bin/varnishadm', help='The path to the varnishadm binary')

  options=o.parse_args()[0]
  command = runcommand(&quot;%(path)s -S %(secret)s -T %(host)s:%(port)s debug.health&quot; % options.__dict__)
  backends = command.split(&quot;\n&quot;)
  backends_healthy, backends_sick = [], []
  for line in backends:
    if line.startswith(&quot;Backend&quot;) and line.find(&quot;test&quot;)==-1:
      if line.endswith(&quot;Healthy&quot;):
        backends_healthy.append(line.split(&quot; &quot;)[1])
      else:
        backends_sick.append(line.split(&quot; &quot;)[1])
 
  if backends_sick:
    print &quot;%s backends are down.  %s&quot; % (len(backends_sick), &quot;&quot;.join(backends_sick))
    sys.exit(2)

  if not backends_sick and not backends_healthy:
    print &quot;No backends detected.  If this is an error, see readme.txt&quot;
    sys.exit(1)

  print &quot;All %s backends are healthy&quot; % (len(backends_healthy))
  sys.exit(0)


if __name__ == &quot;__main__&quot;:
    main(sys.argv[1:])</pre><p></p>
]]></content:encoded>
							<wfw:commentRss>https://scott.cm/varnish-nagios-check/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
							</item>
	</channel>
</rss>
