SlideShare une entreprise Scribd logo
1  sur  47
Writing Custom Nagios Pluginsin Perl Nathan Vonnahme Nathan.Vonnahme@bannerhealth.com To get the most out of this session, make sure you have Perl and the Nagios::Plugin module is installed.
Why write Nagiosplugins? ,[object Object]
Life is complicated.
“OK” is complicated.,[object Object]
Cross-platform
CPAN
Mature Nagios::Plugin API
Embeddable in Nagios (ePN)
Examples and documentation
“Swiss army chainsaw”2011
Buuuuut I don’t like Perl Nagios plugins are very simple. Use any language you like. Eventually, imitate Nagios::Plugin. 2011
2011 5 got Perl? perl.org/get.html Linux and Mac already have it:  which perl On Windows, I prefer Cygwin (N.B.make, gcc4) Strawberry Perl ActiveState Perl Any version Perl 5 should work.
got Documentation? http://nagiosplug.sf.net/developer-guidelines.html Or,goo.gl/kJRTI 2011 Case sensitive!    Save for later with your phone?
got an idea? Check the validity of my backup file F. 2011
SimplestPlugin Ever #!/usr/bin/perlif(-e $ARGV[0]){# File in first arg exists.print"OK";exit(0);}else{print"CRITICAL";exit(2);} 2011 8 Nagios World Conference
SimplestPlugin Ever Save, then run with one argument: $ ./simple_check_backup.plfoo.tar.gz CRITICAL $ touch foo.tar.gz $ ./simple_check_backup.plfoo.tar.gz OK But: Will it succeed tomorrow? 2011
But “OK” is complicated. ,[object Object]
Existent
Less than X hours old
Between Y and Z MB in size* further opportunity: check the restore process! BTW: Gavin Carr with Open Fusion in Australia has already written a check_filepluginthat could do this, but we’re learning here.Also confer2001 check_backup plugin by Patrick Greenwell, butit’s pre-Nagios::Plugin. 2011
Bells and Whistles ,[object Object]
Help/documentation
Thresholds
Performance dataThese things makeup the majority ofthe code in any real plugin. 2011
Bells, Whistles, and Cowbell ,[object Object]
Ton Voon rocks
Gavin Carr too
Used in production Nagiosplugins everywhere
Since ~ 20062011
Bells, Whistles, and Cowbell ,[object Object],sudocpan Configure CPAN if necessary... cpan>  install Nagios::Plugin ,[object Object]
Configure http_proxyenvironment variable if behind firewall
cpan> o conf prerequisites_policyfollowcpan> o conf commit
cpan> install Params::Validate2011
got an example plugin template? ,[object Object],goo.gl/vpBnh ,[object Object]
We’re going to be turning check_stuff.pl into the finishedcheck_backup.pl example.2011
got the finished example? Published with Gist: https://gist.github.com/1218081 or goo.gl/hXnSm ,[object Object]
The roman numerals in the comments match the next series of slides.2011
Check your setup Save check_stuff.pl (goo.gl/vpBnh) as e.g. my_check_backup.pl. Change the first “shebang” line to point to the Perl executable on your machine. 	#!c:/strawberry/bin/perl Run it 	./my_check_backup.pl You should get: MY_CHECK_BACKUP UNKNOWN -  you didn't supply a threshold argument If yours works, help your neighbors. 2011
Design: Which arguments do we need? ,[object Object]
Age in hours
Size in MB2011
Design: Thresholds ,[object Object]
Age problem: CRITICAL if over agethreshold
Size problem: WARNING if outside size threshold (min:max)2011
I. Prologue (working from check_stuff.pl) use strict;use warnings;use Nagios::Plugin; use File::stat; usevarsqw($VERSION$PROGNAME$verbose$timeout$result);$VERSION='1.0';# get the base name of this script for use in the examplesuse File::Basename;$PROGNAME=basename($0); 2011
II. Usage/Help Changes from check_stuff.pl in bold my$p= Nagios::Plugin->new(  usage =>"Usage: %s [ -v|--verbose ] [-t <timeout>][ -f|--file=<path/to/backup/file> ][ -a|--age=<max age in hours> ] [ -s|--size=<acceptable min:max size in MB> ]",  version =>$VERSION,  blurb =>"Check the specified backup file's age and size",  extra =>"Examples:$PROGNAME -f /backups/foo.tgz -a 24 -s 1024:2048 Check that foo.tgz exists, is less than 24 hours old, and is between1024 and 2048 MB.“); 2011
III. Command line arguments/options Replace the 3 add_arg calls from check_stuff.pl with: # See Getopt::Long for more$p->add_arg(    spec =>'file|f=s',    required =>1,    help =>"-f, --file=STRING        The backup file to check. REQUIRED.");$p->add_arg(    spec =>'age|a=i',    default =>24,    help =>"-a, --age=INTEGER        Maximum age in hours. Default 24.");$p->add_arg(    spec =>'size|s=s',    help =>"-s, --size=INTEGER:INTEGERMinimum:maximum acceptable size in MB (1,000,000 bytes)"); # Parse arguments and process standard ones (e.g. usage, help, version)$p->getopts; 2011

Contenu connexe

Tendances

Centralize your Business Logic with Pipelines in Elixir
Centralize your Business Logic with Pipelines in ElixirCentralize your Business Logic with Pipelines in Elixir
Centralize your Business Logic with Pipelines in ElixirMichael Viveros
 
What i got wrong when somebody asked me to deploy a web app
What i got wrong when somebody asked me to deploy a web appWhat i got wrong when somebody asked me to deploy a web app
What i got wrong when somebody asked me to deploy a web apptalkingquickly
 
From zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and ElasticsearchFrom zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and ElasticsearchRafał Kuć
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Wim Godden
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctestmitnk
 
Logstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtimeLogstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtimeAndrea Cardinale
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Ilya Grigorik
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webminpostrational
 
"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł Maziarz"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł MaziarzPROIDEA
 
A reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webA reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webWallace Reis
 
NSClient Workshop: 04 Protocols
NSClient Workshop: 04 ProtocolsNSClient Workshop: 04 Protocols
NSClient Workshop: 04 ProtocolsMichael Medin
 
Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Workhorse Computing
 
OpenERP Benchmark : How to test performance and robustness against your volum...
OpenERP Benchmark : How to test performance and robustness against your volum...OpenERP Benchmark : How to test performance and robustness against your volum...
OpenERP Benchmark : How to test performance and robustness against your volum...Odoo
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWim Godden
 
HTTP For the Good or the Bad
HTTP For the Good or the BadHTTP For the Good or the Bad
HTTP For the Good or the BadXavier Mertens
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
Keep it simple web development stack
Keep it simple web development stackKeep it simple web development stack
Keep it simple web development stackEric Ahn
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to productionSean Hess
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-pythonEric Ahn
 

Tendances (20)

Centralize your Business Logic with Pipelines in Elixir
Centralize your Business Logic with Pipelines in ElixirCentralize your Business Logic with Pipelines in Elixir
Centralize your Business Logic with Pipelines in Elixir
 
What i got wrong when somebody asked me to deploy a web app
What i got wrong when somebody asked me to deploy a web appWhat i got wrong when somebody asked me to deploy a web app
What i got wrong when somebody asked me to deploy a web app
 
From zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and ElasticsearchFrom zero to hero - Easy log centralization with Logstash and Elasticsearch
From zero to hero - Easy log centralization with Logstash and Elasticsearch
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctest
 
Logstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtimeLogstash for SEO: come monitorare i Log del Web Server in realtime
Logstash for SEO: come monitorare i Log del Web Server in realtime
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
 
DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webmin
 
"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł Maziarz"Powershell kung-fu" - Paweł Maziarz
"Powershell kung-fu" - Paweł Maziarz
 
A reviravolta do desenvolvimento web
A reviravolta do desenvolvimento webA reviravolta do desenvolvimento web
A reviravolta do desenvolvimento web
 
NSClient Workshop: 04 Protocols
NSClient Workshop: 04 ProtocolsNSClient Workshop: 04 Protocols
NSClient Workshop: 04 Protocols
 
Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.
 
OpenERP Benchmark : How to test performance and robustness against your volum...
OpenERP Benchmark : How to test performance and robustness against your volum...OpenERP Benchmark : How to test performance and robustness against your volum...
OpenERP Benchmark : How to test performance and robustness against your volum...
 
When dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniquesWhen dynamic becomes static: the next step in web caching techniques
When dynamic becomes static: the next step in web caching techniques
 
HTTP For the Good or the Bad
HTTP For the Good or the BadHTTP For the Good or the Bad
HTTP For the Good or the Bad
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Web::Scraper
Web::ScraperWeb::Scraper
Web::Scraper
 
Keep it simple web development stack
Keep it simple web development stackKeep it simple web development stack
Keep it simple web development stack
 
How to deploy node to production
How to deploy node to productionHow to deploy node to production
How to deploy node to production
 
Py conkr 20150829_docker-python
Py conkr 20150829_docker-pythonPy conkr 20150829_docker-python
Py conkr 20150829_docker-python
 

En vedette

Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in Perl
Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in PerlNagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in Perl
Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in PerlNagios
 
Writing Nagios Plugins in Python
Writing Nagios Plugins in PythonWriting Nagios Plugins in Python
Writing Nagios Plugins in Pythonguesta6e653
 
Janice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios PluginsJanice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios PluginsNagios
 
Free Sorftware Research at Irill (highlights)
Free Sorftware Research at Irill (highlights)Free Sorftware Research at Irill (highlights)
Free Sorftware Research at Irill (highlights)Roberto Di Cosmo
 
Nagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios Plugins
Nagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios PluginsNagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios Plugins
Nagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios PluginsNagios
 
Jesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture OverviewJesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture OverviewNagios
 
Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best PracticesNagios
 

En vedette (7)

Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in Perl
Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in PerlNagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in Perl
Nagios Conference 2012 - Nathan Vonnahme - Writing Custom Nagios Plugins in Perl
 
Writing Nagios Plugins in Python
Writing Nagios Plugins in PythonWriting Nagios Plugins in Python
Writing Nagios Plugins in Python
 
Janice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios PluginsJanice Singh - Writing Custom Nagios Plugins
Janice Singh - Writing Custom Nagios Plugins
 
Free Sorftware Research at Irill (highlights)
Free Sorftware Research at Irill (highlights)Free Sorftware Research at Irill (highlights)
Free Sorftware Research at Irill (highlights)
 
Nagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios Plugins
Nagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios PluginsNagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios Plugins
Nagios Conference 2013 - William Leibzon - SNMP Protocol and Nagios Plugins
 
Jesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture OverviewJesse Olson - Nagios Log Server Architecture Overview
Jesse Olson - Nagios Log Server Architecture Overview
 
Nagios XI Best Practices
Nagios XI Best PracticesNagios XI Best Practices
Nagios XI Best Practices
 

Similaire à Nagios Conference 2011 - Nathan Vonnahme - Writing Custom Nagios Plugins In Perl

Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as codeJulian Simpson
 
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...Nagios
 
Multiprocessing with python
Multiprocessing with pythonMultiprocessing with python
Multiprocessing with pythonPatrick Vergain
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachJinal Jhaveri
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneVincenzo Barone
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
Server Logs: After Excel Fails
Server Logs: After Excel FailsServer Logs: After Excel Fails
Server Logs: After Excel FailsOliver Mason
 
Nagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton VoonNagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton VoonNETWAYS
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 
Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부Hyun-Mook Choi
 
Introduction to Go language
Introduction to Go languageIntroduction to Go language
Introduction to Go languageTzar Umang
 
Distributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component worldDistributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component worldRachael L Moore
 
Modern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextModern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextAlexander Mostovenko
 
Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!Joel Farris
 
Teflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceTeflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceSaumil Shah
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciAtlassian
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksGlen Ogilvie
 
Continuous integration with Git & CI Joe
Continuous integration with Git & CI JoeContinuous integration with Git & CI Joe
Continuous integration with Git & CI JoeShawn Price
 
php & performance
 php & performance php & performance
php & performancesimon8410
 

Similaire à Nagios Conference 2011 - Nathan Vonnahme - Writing Custom Nagios Plugins In Perl (20)

Adventures in infrastructure as code
Adventures in infrastructure as codeAdventures in infrastructure as code
Adventures in infrastructure as code
 
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
 
Multiprocessing with python
Multiprocessing with pythonMultiprocessing with python
Multiprocessing with python
 
Scaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approachScaling python webapps from 0 to 50 million users - A top-down approach
Scaling python webapps from 0 to 50 million users - A top-down approach
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
Server Logs: After Excel Fails
Server Logs: After Excel FailsServer Logs: After Excel Fails
Server Logs: After Excel Fails
 
Nagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton VoonNagios Conference 2007 | State of the Plugins by Ton Voon
Nagios Conference 2007 | State of the Plugins by Ton Voon
 
Revoke-Obfuscation
Revoke-ObfuscationRevoke-Obfuscation
Revoke-Obfuscation
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부
 
Introduction to Go language
Introduction to Go languageIntroduction to Go language
Introduction to Go language
 
Distributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component worldDistributing UI Libraries: in a post Web-Component world
Distributing UI Libraries: in a post Web-Component world
 
Modern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettextModern javascript localization with c-3po and the good old gettext
Modern javascript localization with c-3po and the good old gettext
 
Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!Howto Test A Patch And Make A Difference!
Howto Test A Patch And Make A Difference!
 
Teflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surfaceTeflon - Anti Stick for the browser attack surface
Teflon - Anti Stick for the browser attack surface
 
Becoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola PaolucciBecoming a Git Master - Nicola Paolucci
Becoming a Git Master - Nicola Paolucci
 
Aucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricksAucklug slides - desktop tips and tricks
Aucklug slides - desktop tips and tricks
 
Continuous integration with Git & CI Joe
Continuous integration with Git & CI JoeContinuous integration with Git & CI Joe
Continuous integration with Git & CI Joe
 
php & performance
 php & performance php & performance
php & performance
 

Plus de Nagios

Trevor McDonald - Nagios XI Under The Hood
Trevor McDonald  - Nagios XI Under The HoodTrevor McDonald  - Nagios XI Under The Hood
Trevor McDonald - Nagios XI Under The HoodNagios
 
Sean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient NotificationsSean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient NotificationsNagios
 
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise EditionMarcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise EditionNagios
 
Dave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical ExperienceDave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical ExperienceNagios
 
Mike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service ChecksMike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service ChecksNagios
 
Mike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios InstallationMike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios InstallationNagios
 
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...Nagios
 
Matt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With NagiosMatt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With NagiosNagios
 
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.Nagios
 
Eric Loyd - Fractal Nagios
Eric Loyd - Fractal NagiosEric Loyd - Fractal Nagios
Eric Loyd - Fractal NagiosNagios
 
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...Nagios
 
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...Nagios
 
Nagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson OpeningNagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson OpeningNagios
 
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNagios
 
Nagios Log Server - Features
Nagios Log Server - FeaturesNagios Log Server - Features
Nagios Log Server - FeaturesNagios
 
Nagios Network Analyzer - Features
Nagios Network Analyzer - FeaturesNagios Network Analyzer - Features
Nagios Network Analyzer - FeaturesNagios
 
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing NagiosNagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing NagiosNagios
 
Nagios Conference 2014 - Mike Weber - Nagios Rapid Deployment Options
Nagios Conference 2014 - Mike Weber - Nagios Rapid Deployment OptionsNagios Conference 2014 - Mike Weber - Nagios Rapid Deployment Options
Nagios Conference 2014 - Mike Weber - Nagios Rapid Deployment OptionsNagios
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios
 
Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...
Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...
Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...Nagios
 

Plus de Nagios (20)

Trevor McDonald - Nagios XI Under The Hood
Trevor McDonald  - Nagios XI Under The HoodTrevor McDonald  - Nagios XI Under The Hood
Trevor McDonald - Nagios XI Under The Hood
 
Sean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient NotificationsSean Falzon - Nagios - Resilient Notifications
Sean Falzon - Nagios - Resilient Notifications
 
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise EditionMarcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
Marcus Rochelle - Landis+Gyr - Monitoring with Nagios Enterprise Edition
 
Dave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical ExperienceDave Williams - Nagios Log Server - Practical Experience
Dave Williams - Nagios Log Server - Practical Experience
 
Mike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service ChecksMike Weber - Nagios and Group Deployment of Service Checks
Mike Weber - Nagios and Group Deployment of Service Checks
 
Mike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios InstallationMike Guthrie - Revamping Your 10 Year Old Nagios Installation
Mike Guthrie - Revamping Your 10 Year Old Nagios Installation
 
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
Bryan Heden - Agile Networks - Using Nagios XI as the platform for Monitoring...
 
Matt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With NagiosMatt Bruzek - Monitoring Your Public Cloud With Nagios
Matt Bruzek - Monitoring Your Public Cloud With Nagios
 
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
Lee Myers - What To Do When Nagios Notification Don't Meet Your Needs.
 
Eric Loyd - Fractal Nagios
Eric Loyd - Fractal NagiosEric Loyd - Fractal Nagios
Eric Loyd - Fractal Nagios
 
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
Marcelo Perazolo, Lead Software Architect, IBM Corporation - Monitoring a Pow...
 
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
Thomas Schmainda - Tracking Boeing Satellites With Nagios - Nagios World Conf...
 
Nagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson OpeningNagios World Conference 2015 - Scott Wilkerson Opening
Nagios World Conference 2015 - Scott Wilkerson Opening
 
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios CoreNrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
Nrpe - Nagios Remote Plugin Executor. NRPE plugin for Nagios Core
 
Nagios Log Server - Features
Nagios Log Server - FeaturesNagios Log Server - Features
Nagios Log Server - Features
 
Nagios Network Analyzer - Features
Nagios Network Analyzer - FeaturesNagios Network Analyzer - Features
Nagios Network Analyzer - Features
 
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing NagiosNagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
Nagios Conference 2014 - Dorance Martinez Cortes - Customizing Nagios
 
Nagios Conference 2014 - Mike Weber - Nagios Rapid Deployment Options
Nagios Conference 2014 - Mike Weber - Nagios Rapid Deployment OptionsNagios Conference 2014 - Mike Weber - Nagios Rapid Deployment Options
Nagios Conference 2014 - Mike Weber - Nagios Rapid Deployment Options
 
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios CoreNagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
 
Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...
Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...
Nagios Conference 2014 - Trevor McDonald - Monitoring The Physical World With...
 

Dernier

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Nagios Conference 2011 - Nathan Vonnahme - Writing Custom Nagios Plugins In Perl

  • 1. Writing Custom Nagios Pluginsin Perl Nathan Vonnahme Nathan.Vonnahme@bannerhealth.com To get the most out of this session, make sure you have Perl and the Nagios::Plugin module is installed.
  • 2.
  • 4.
  • 11. Buuuuut I don’t like Perl Nagios plugins are very simple. Use any language you like. Eventually, imitate Nagios::Plugin. 2011
  • 12. 2011 5 got Perl? perl.org/get.html Linux and Mac already have it: which perl On Windows, I prefer Cygwin (N.B.make, gcc4) Strawberry Perl ActiveState Perl Any version Perl 5 should work.
  • 13. got Documentation? http://nagiosplug.sf.net/developer-guidelines.html Or,goo.gl/kJRTI 2011 Case sensitive! Save for later with your phone?
  • 14. got an idea? Check the validity of my backup file F. 2011
  • 15. SimplestPlugin Ever #!/usr/bin/perlif(-e $ARGV[0]){# File in first arg exists.print"OK";exit(0);}else{print"CRITICAL";exit(2);} 2011 8 Nagios World Conference
  • 16. SimplestPlugin Ever Save, then run with one argument: $ ./simple_check_backup.plfoo.tar.gz CRITICAL $ touch foo.tar.gz $ ./simple_check_backup.plfoo.tar.gz OK But: Will it succeed tomorrow? 2011
  • 17.
  • 19. Less than X hours old
  • 20. Between Y and Z MB in size* further opportunity: check the restore process! BTW: Gavin Carr with Open Fusion in Australia has already written a check_filepluginthat could do this, but we’re learning here.Also confer2001 check_backup plugin by Patrick Greenwell, butit’s pre-Nagios::Plugin. 2011
  • 21.
  • 24. Performance dataThese things makeup the majority ofthe code in any real plugin. 2011
  • 25.
  • 28. Used in production Nagiosplugins everywhere
  • 30.
  • 32. cpan> o conf prerequisites_policyfollowcpan> o conf commit
  • 34.
  • 35. We’re going to be turning check_stuff.pl into the finishedcheck_backup.pl example.2011
  • 36.
  • 37. The roman numerals in the comments match the next series of slides.2011
  • 38. Check your setup Save check_stuff.pl (goo.gl/vpBnh) as e.g. my_check_backup.pl. Change the first “shebang” line to point to the Perl executable on your machine. #!c:/strawberry/bin/perl Run it ./my_check_backup.pl You should get: MY_CHECK_BACKUP UNKNOWN - you didn't supply a threshold argument If yours works, help your neighbors. 2011
  • 39.
  • 42.
  • 43. Age problem: CRITICAL if over agethreshold
  • 44. Size problem: WARNING if outside size threshold (min:max)2011
  • 45. I. Prologue (working from check_stuff.pl) use strict;use warnings;use Nagios::Plugin; use File::stat; usevarsqw($VERSION$PROGNAME$verbose$timeout$result);$VERSION='1.0';# get the base name of this script for use in the examplesuse File::Basename;$PROGNAME=basename($0); 2011
  • 46. II. Usage/Help Changes from check_stuff.pl in bold my$p= Nagios::Plugin->new( usage =>"Usage: %s [ -v|--verbose ] [-t <timeout>][ -f|--file=<path/to/backup/file> ][ -a|--age=<max age in hours> ] [ -s|--size=<acceptable min:max size in MB> ]", version =>$VERSION, blurb =>"Check the specified backup file's age and size", extra =>"Examples:$PROGNAME -f /backups/foo.tgz -a 24 -s 1024:2048 Check that foo.tgz exists, is less than 24 hours old, and is between1024 and 2048 MB.“); 2011
  • 47. III. Command line arguments/options Replace the 3 add_arg calls from check_stuff.pl with: # See Getopt::Long for more$p->add_arg( spec =>'file|f=s', required =>1, help =>"-f, --file=STRING The backup file to check. REQUIRED.");$p->add_arg( spec =>'age|a=i', default =>24, help =>"-a, --age=INTEGER Maximum age in hours. Default 24.");$p->add_arg( spec =>'size|s=s', help =>"-s, --size=INTEGER:INTEGERMinimum:maximum acceptable size in MB (1,000,000 bytes)"); # Parse arguments and process standard ones (e.g. usage, help, version)$p->getopts; 2011
  • 48. Now it’s RTFM-enabled If you run it with no args, it shows usage: $ ./check_backup.pl Usage: check_backup.pl [ -v|--verbose ] [-t <timeout>] [ -f|--file=<path/to/backup/file> ] [ -a|--age=<max age in hours> ] [ -s|--size=<acceptable min:max size in MB> ] 2011
  • 49. Now it’s RTFM-enabled $ ./check_backup.pl --help check_backup.pl 1.0 This nagiosplugin is free software, and comes with ABSOLUTELY NO WARRANTY. It may be used, redistributed and/or modified under the terms of the GNU General Public Licence (see http://www.fsf.org/licensing/licenses/gpl.txt). Check the specified backup file's age and size Usage: check_backup.pl [ -v|--verbose ] [-t <timeout>] [ -f|--file=<path/to/backup/file> ] [ -a|--age=<max age in hours> ] [ -s|--size=<acceptable min:max size in MB> ] -?, --usage Print usage information -h, --help Print detailed help screen -V, --version Print version information 2011
  • 50. Now it’s RTFM-enabled --extra-opts=[section][@file] Read options from an ini file. See http://nagiosplugins.org/extra-opts for usage and examples. -f, --file=STRING The backup file to check. REQUIRED. -a, --age=INTEGER Maximum age in hours. Default 24. -s, --size=INTEGER:INTEGER Minimum:maximum acceptable size in MB (1,000,000 bytes) -t, --timeout=INTEGER Seconds before plugin times out (default: 15) -v, --verbose Show details for command-line debugging (can repeat up to 3 times) Examples: check_backup.pl -f /backups/foo.tgz -a 24 -s 1024:2048 Check that foo.tgz exists, is less than 24 hours old, and is between 1024 and 2048 MB. 2011
  • 51.
  • 52. Ooops At first I used -M, which Perl defines as “Script start time minus file modification time, in days.” Nagios uses embedded Perl so the “script start time” may be hours or days ago. 2011
  • 53. V. Check the stuff # Check the backup file.my$f=$p->opts->file;unless(-e $f){$p->nagios_exit(CRITICAL,"File $f doesn't exist");}my$mtime= File::stat::stat($f)->mtime;my$age_in_hours=(time-$mtime)/ 60 /60;my$size_in_mb=(-s$f)/1_000_000;my$message=sprintf "Backup exists, %.0f hours old, %.1f MB.",$age_in_hours,$size_in_mb; 2011
  • 54.
  • 55. VII. Compare to thresholds Add this section. check_stuff.plcombines check_thresholdwith nagios_exit at the very end. # We already checked for file existence. my$result=$p->check_threshold( check =>$age_in_hours, warning =>undef, critical =>$p->opts->age);if($result== OK){$result=$p->check_threshold( check =>$size_in_mb, warning =>$p->opts->size, critical =>undef,);} 2011
  • 56. VIII. Exit Code # Output the result and exit.$p->nagios_exit(return_code=>$result, message =>$message); 2011
  • 57. Testing theplugin $ ./check_backup.pl -f foo.gz BACKUP OK - Backup exists, 3 hours old, 0.5 MB | age=3.04916666666667hours;; size=0.515007MB;; $ ./check_backup.pl -f foo.gz -s 100:900 BACKUP WARNING - Backup exists, 23 hours old, 0.5 MB | age=23.4275hours;; size=0.515007MB;; $ ./check_backup.pl -f foo.gz -a 8 BACKUP CRITICAL - Backup exists, 23 hours old, 0.5 MB | age=23.4388888888889hours;; size=0.515007MB;; 2011
  • 58. OK? How’s yourplugin going? Can you help your neighbor? 2011 Subject: ** PROBLEM alert – my plugin is WARNING **
  • 59. TellingNagios to use your plugin 1. misccommands.cfg* define command{ command_namecheck_backup command_line$USER1$/myplugins/check_backup.pl -f $ARG1$ -a $ARG2$ -s $ARG3$ } * Lines wrapped for slide presentation 2011
  • 60. Telling Nagios to use your plugin 2. services.cfg (wrapped) define service{ use generic-service normal_check_interval 1440 # 24 hours host_name fai01337 service_descriptionMySQL backups check_commandcheck_backup!/usr/local/backups /mysql/fai01337.mysql.dump.bz2!24!0.5:100 contact_groupslinux-admins } 3. Reload config: $ sudo /usr/bin/nagios -v /etc/nagios/nagios.cfg && sudo /etc/rc.d/init.d/nagios reload 2011
  • 61.
  • 65. Remote Example: Windows 2008 (This is annoyingly complex today. Anyone?) Install latest NC_Net MSI on Windows machine Let it through Windows Firewall (port 1248) Install Perl and Nagios::Plugin Put my check_backup.pl in C:rogram FilesontiTechc_net_Setup_v5cript Compile the NC_Net version of check_nt on the Nagios server.* Make wrapper C:rogram FilesontiTechc_net_Setup_v5cript check_my_backup.bat :@echo off C:ygwininerl .heck_backup.pl -f foo.bak 2011
  • 66. Profit $ plugins/check_nt -H winhost -p 1248 -v RUNSCRIPT -l check_my_backup.bat OK - Backup exists, 12 hours old, 35.7 MB | age=12.4527777777778hours;; size=35.74016MB;; 2011
  • 68.
  • 69. TAP – Test Anything Protocol
  • 70. See check_tap.pl from my other talk
  • 72. Shell
  • 73. Ruby? C#? VB? JavaScript?
  • 75. A horrifying/inspiring example The worst things need the most monitoring. 2011
  • 76.
  • 78. Runs in user session
  • 79. Need about a dozen2011
  • 80.
  • 81. Not even a process
  • 82. 100% CPU is normal
  • 85. AutoIt to the rescue FuncCompareTitles() For $title=1 To $all_window_titles[0][0] Step 1 $state=WinGetState($all_window_titles[$title][0]) $foo=0 $do_test=0 For $foo In $valid_states If $state=$foo Then $do_test +=1 EndIf Next If $all_window_titles[$title][0] <> "" AND $do_test>0 Then $window_is_valid=0 For $string=0 To $num_of_strings-1 Step 1 $match=StringRegExp($all_window_titles[$title][0], $valid_windows[$string]) $window_is_valid += $match Next if $window_is_valid=0 Then $return=2 $detailed_status="Unexpected window *" & $all_window_titles[$title][0] & "* present" & @LF & "***" & $all_window_titles[$title][0] & "*** doesn't match anything we expect." NagiosExit() EndIf If StringRegExp($all_window_titles[$title][0], $valid_windows[0])=1 Then $expression=ControlGetText($all_window_titles[$title][0], "", 1013) EndIf EndIf Next $no_bad_windows=1 EndFunc FuncNagiosExit() ConsoleWrite($detailed_status) Exit($return) EndFunc CompareTitles() if $no_bad_windows=1 Then $detailed_status="No chartserver anomalies at this time -- " & $expression $return=0 EndIf NagiosExit() 2011
  • 86. Nagios now knows when they’re broken 2011
  • 87. Life is complicated “OK” is complicated. Custom plugins make Nagios much smarter about your environment. 2011

Notes de l'éditeur

  1. Max 5 minute wait here. Again, we may not have time to troubleshoot your CPAN configuration right now. If you can&apos;t get it to work immediately, just watch or look on with someone else, or use another language. Unix people, you may want to help or observe someone with Windows because you&apos;ll want to do it too eventually.This worked like a dream for me with fresh Strawberry Perl, after I got the proxy configured.
  2. Again, replacing the section in check_stuff.pl
  3. This isn’t in check_stuff.pl
  4. *Hint: compilenagios-plugins but replace its plugins/check_nt.c with check_nc_net.c from nc-net.sf.net
  5.  This is not working for me in production anymore.