SlideShare a Scribd company logo
Writing plugins for Nagios and Opsview

Jose Luis Martinez
CTO
2014-02-11 Barcelona
architects of the digital society

www.capside.com
Nagios

What is Nagios?
Opsview? Icinga? Naemon? Shinken?

architects of the digital society

www.capside.com
Opsview
 Configures and runs Nagios for you

 Presents a frendlier and more powerfull user
interface
 Implements Nagios best practices
 Distributed Monitoring
 Datawarehouse

architects of the digital society

www.capside.com
Back to Nagios
 Monitoring tool that doesn’t know how to monitor
anything!?!?
• The real monitoring is done by plugins
• Just external programs with a defined interface to communicate with Nagios
• Written in any language

architects of the digital society

www.capside.com
Plugins

architects of the digital society

www.capside.com
Writing your plugins

architects of the digital society

www.capside.com
First rule
 Is it already done?
• www.monitoring-plugins.org
• Plugins project

• www.nagiosplugins.org
• Nagios official plugins

• www.monitoringexchange.org
• User contributed

• exchange.nagios.org
• User contributed

• Google “xxx nagios”

architects of the digital society

www.capside.com
We’ll take a look at
 Nagios::Plugin (Monitoring::Plugin)
 Nagios::Plugin::DieNicely
 Nagios::Plugin::WWW::Mechanize
 Nagios::Plugin::SNMP
 Nagios::Plugin::Differences

architects of the digital society

www.capside.com
Nagios::Plugin
 Lots of common functionality for free!
• When writing a plugin you have to

Handle Arguments
Get and manipulate the data
Calculate state (OK, CRITICAL, …)

architects of the digital society

www.capside.com
Nagios::Plugin
 Lots of common functionality for free!
• When writing a GREAT plugin you have to
Handle Arguments

-h –v arguments

-h has to output documentation

Get and manipulate the data

Calculate state (OK, CRITICAL, …)

In a flexible way (in f(x) of arguments)

Output performance data

architects of the digital society

www.capside.com
That’s a lot of work
I just wanted to monitor my app!

architects of the digital society

www.capside.com
Nagios::Plugin
 Lots of common functionality for free!
• When writing a GREAT plugin you have to
Handle Arguments

-h –v arguments

-h has to output documentation

Get and manipulate the data

Calculate state (OK, CRITICAL, …)

In a flexible way (in f(x) of arguments)

Output performance data

architects of the digital society

www.capside.com
3 Simple Steps
 Setup
 Data collection
 State calculation

architects of the digital society

www.capside.com
Setup
 Just make an instance of N::P
#!/usr/bin/env perl
use Nagios::Plugin;
my $np= Nagios::Plugin->new(
'usage' => 'Usage: %s'
);
$np->getopts;

 You’ve just obtained
• -t option (timeout)
• -v option (verbose)
• --help option

architects of the digital society

www.capside.com
Setup (II) Constructor options
 usage ("Usage: %s --foo --bar")
 version <- Version string
 url <- Help and Version
 blurb <- Help description
 license <- Help
 extra <- Help
 plugin <- overrides auto detected name

architects of the digital society

www.capside.com
Setup: GetOpt magic

$np->add_arg(
spec=> 'warning|w=s',
help=> "-w, --warning=RANGE",
required=> 1
);
$np->add_arg(
spec => 'user|u=s',
help => 'Username',
default => 'www-data'
);
$np->getopts;
if($np->opts->user) { … }

architects of the digital society

www.capside.com
Collect data
Now you have to work

architects of the digital society

www.capside.com
State calculation

architects of the digital society

www.capside.com
Ranges
 Most plugins suppose that
• OK<WARNING<CRITICAL

 But… what if…

architects of the digital society

www.capside.com
Ranges

Range definition

Generate alert if x…

10

Is not between 0 and 10

10:

Is not between 10 and infinity

~:10

Is not between –Inf and 10

10:20

Is not between 10 and 20

@10:20

Is between 10 and 20

$code= $np->check_threshold(
check => $value,
warning => $warning_threshold,
critical => $critical_threshold
);
$np->nagios_exit( $code, "Thresholdcheckfailed" ) if ($code!= OK);

architects of the digital society

www.capside.com
Output status

 $np->nagios_exit(CRITICAL, “Too many
connections”);
 $np->nagios_exit(OK, “Everything went fine”);
 $np->nagios_exit(WARNING, “Too few
connections”);
 $np->nagios_exit(UNKNOWN, “Bad options”);

architects of the digital society

www.capside.com
Performance Data

$np->add_perfdata(
label
=> "size",
value
=> $value,
uom
=> "kB",
warning => $warning,
critical => $critical
);

UOM Unit of measurement

Is for

No unit specified

Assume a number of things

s,ms,us

econds, miliseconds, nanoseconds

%

Percentage

B,KB,MB,TB

Bytes

c

A continuous counter

architects of the digital society

www.capside.com
Success!

Enjoy your shiny new plugin

architects of the digital society

www.capside.com
Nagios::Plugin::DieNicely

architects of the digital society

www.capside.com
Nagios::Plugin::DieNicely
 Software fails, and sometimes you don’t control it

architects of the digital society

www.capside.com
Nagios::Plugin::DieNicely
 What happened?

architects of the digital society

www.capside.com
Nagios::Plugin::DieNicely
 What happened?
• Output went to STDERR
• Nagios doesn’t care

• Exit code follows Perls rules
• Nagios understands 0-3

architects of the digital society

www.capside.com
Nagios::Plugin::DieNicely
 use Nagios::Plugin::DieNicely

architects of the digital society

www.capside.com
Nagios::Plugin::WWW::Mechanize

Nagios::Plugin
+
WWW::Mechanize

architects of the digital society

www.capside.com
Nagios::Plugin::WWW::Mechanize

Nagios::Plugin
+
WWW::Mechanize

You where going to do it anyway!

architects of the digital society

www.capside.com
Nagios::Plugin::WWW::Mechanize
 Again... Just create an instance. Use it as a
Nagios::Plugin object
 Automatically tracks response time for you
 $np->mech
 $np->content
 $np->get, $np->submit_form

architects of the digital society

www.capside.com
Nagios::Plugin::WWW::Mechanize
A couple of tricks
• Gzipped content
my $np = Nagios::Plugin::WWW::Mechanize->new(
'mech' => WWW::Mechanize::GZip->new(autocheck => 0)
);

• Proxy
my $proxy = $np->opts->proxy;
if (defined $proxy){
$np->mech->proxy(['http', 'https'], $proxy);
}

architects of the digital society

www.capside.com
Nagios::Plugin::SNMP

Nagios::Plugin
+
Net::SNMP

architects of the digital society

www.capside.com
Nagios::Plugin::SNMP
Again... Just create an instance. Use it as a
Nagios::Plugin object
Sets up a lot of arguments
Does delta between values of counters

architects of the digital society

www.capside.com
Any Questions?

Thanks to:
The Monitoring::Plugin module maintainers
Icanhazcheezburger for the cats
architects of the digital society

www.capside.com

More Related Content

What's hot

Leveraging parse.com for Speedy Development
Leveraging parse.com for Speedy DevelopmentLeveraging parse.com for Speedy Development
Leveraging parse.com for Speedy Development
Andrew Kozlik
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access RunbookTaha Shakeel
 
Zendcon 09
Zendcon 09Zendcon 09
Zendcon 09
Wade Arnold
 
Real-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampReal-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampAlexei Gorobets
 
Coolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & DeploymentCoolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & Deployment
Matthew Hodgkins
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular js
Marcin Wosinek
 
Log mining
Log miningLog mining
Log mining
Fan Jiang
 

What's hot (7)

Leveraging parse.com for Speedy Development
Leveraging parse.com for Speedy DevelopmentLeveraging parse.com for Speedy Development
Leveraging parse.com for Speedy Development
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access Runbook
 
Zendcon 09
Zendcon 09Zendcon 09
Zendcon 09
 
Real-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @MoldcampReal-time search in Drupal with Elasticsearch @Moldcamp
Real-time search in Drupal with Elasticsearch @Moldcamp
 
Coolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & DeploymentCoolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & Deployment
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular js
 
Log mining
Log miningLog mining
Log mining
 

Viewers also liked

Boosting MySQL (for starters)
Boosting MySQL (for starters)Boosting MySQL (for starters)
Boosting MySQL (for starters)
Jose Luis Martínez
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
Jose Luis Martínez
 
Plenv and carton
Plenv and cartonPlenv and carton
Plenv and carton
Jose Luis Martínez
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkMooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
Jose Luis Martínez
 
Paws - A Perl AWS SDK
Paws - A Perl AWS SDKPaws - A Perl AWS SDK
Paws - A Perl AWS SDK
Jose Luis Martínez
 
Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015
Jose Luis Martínez
 
θουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμαθουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμα
Efi Manousaka
 
iPad Game Design -- Develop Liverpool Dec' 2011
iPad Game Design -- Develop Liverpool Dec' 2011iPad Game Design -- Develop Liverpool Dec' 2011
iPad Game Design -- Develop Liverpool Dec' 2011
garethjenkins
 
Proposal
ProposalProposal
Proposal
ramcoza
 
Daniel & Ernesto's presentation
Daniel & Ernesto's presentationDaniel & Ernesto's presentation
Daniel & Ernesto's presentationErnesto Sepulveda
 
Pictures i have used in my magazine 2
Pictures i have used in my magazine 2Pictures i have used in my magazine 2
Pictures i have used in my magazine 2kamar95
 
Feedback from the first versions of my music
Feedback from the first versions of my musicFeedback from the first versions of my music
Feedback from the first versions of my musickamar95
 
Make Extra Income Online
Make Extra Income OnlineMake Extra Income Online
Make Extra Income Online
webwhisker
 
NRD: Nagios Result Distributor
NRD: Nagios Result DistributorNRD: Nagios Result Distributor
NRD: Nagios Result Distributor
Jose Luis Martínez
 
Garm2 raton sin pilas
Garm2 raton sin pilasGarm2 raton sin pilas
Garm2 raton sin pilasjaiip
 
Kutner and olsen
Kutner and olsenKutner and olsen
Kutner and olsen
kamar95
 
Questionnaire results
Questionnaire resultsQuestionnaire results
Questionnaire resultskamar95
 

Viewers also liked (20)

Boosting MySQL (for starters)
Boosting MySQL (for starters)Boosting MySQL (for starters)
Boosting MySQL (for starters)
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
 
Plenv and carton
Plenv and cartonPlenv and carton
Plenv and carton
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talkMooseX::Datamodel - Barcelona Perl Workshop Lightning talk
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
 
Paws - A Perl AWS SDK
Paws - A Perl AWS SDKPaws - A Perl AWS SDK
Paws - A Perl AWS SDK
 
Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015
 
θουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμαθουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμα
 
iPad Game Design -- Develop Liverpool Dec' 2011
iPad Game Design -- Develop Liverpool Dec' 2011iPad Game Design -- Develop Liverpool Dec' 2011
iPad Game Design -- Develop Liverpool Dec' 2011
 
Proposal
ProposalProposal
Proposal
 
Daniel & Ernesto's presentation
Daniel & Ernesto's presentationDaniel & Ernesto's presentation
Daniel & Ernesto's presentation
 
Huidobro&Sepulveda_2010
Huidobro&Sepulveda_2010Huidobro&Sepulveda_2010
Huidobro&Sepulveda_2010
 
Pictures i have used in my magazine 2
Pictures i have used in my magazine 2Pictures i have used in my magazine 2
Pictures i have used in my magazine 2
 
introduccion
introduccionintroduccion
introduccion
 
Feedback from the first versions of my music
Feedback from the first versions of my musicFeedback from the first versions of my music
Feedback from the first versions of my music
 
Make Extra Income Online
Make Extra Income OnlineMake Extra Income Online
Make Extra Income Online
 
NRD: Nagios Result Distributor
NRD: Nagios Result DistributorNRD: Nagios Result Distributor
NRD: Nagios Result Distributor
 
Polifonia_6.16
Polifonia_6.16Polifonia_6.16
Polifonia_6.16
 
Garm2 raton sin pilas
Garm2 raton sin pilasGarm2 raton sin pilas
Garm2 raton sin pilas
 
Kutner and olsen
Kutner and olsenKutner and olsen
Kutner and olsen
 
Questionnaire results
Questionnaire resultsQuestionnaire results
Questionnaire results
 

Similar to Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks

A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
Cloud Native NoVA
 
AppSec Pipelines and Event based Security
AppSec Pipelines and Event based SecurityAppSec Pipelines and Event based Security
AppSec Pipelines and Event based Security
Matt Tesauro
 
Thinking DevOps in the era of the Cloud - Demi Ben-Ari
Thinking DevOps in the era of the Cloud - Demi Ben-AriThinking DevOps in the era of the Cloud - Demi Ben-Ari
Thinking DevOps in the era of the Cloud - Demi Ben-Ari
Demi Ben-Ari
 
Introducing Neo4j 3.0
Introducing Neo4j 3.0Introducing Neo4j 3.0
Introducing Neo4j 3.0
Neo4j
 
Cf summit-2016-monitoring-cf-sensu-graphite
Cf summit-2016-monitoring-cf-sensu-graphiteCf summit-2016-monitoring-cf-sensu-graphite
Cf summit-2016-monitoring-cf-sensu-graphite
Jeff Barrows
 
2014 DATA @ NFLX (Tableau Customer Conference)
2014 DATA @ NFLX (Tableau Customer Conference)2014 DATA @ NFLX (Tableau Customer Conference)
2014 DATA @ NFLX (Tableau Customer Conference)
Albert Wong
 
Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019
ciberkleid
 
Under the Hood with Cognos Analytics R5: Say Hello to Portal Tabs Replacement
Under the Hood with Cognos Analytics R5: Say Hello to Portal Tabs ReplacementUnder the Hood with Cognos Analytics R5: Say Hello to Portal Tabs Replacement
Under the Hood with Cognos Analytics R5: Say Hello to Portal Tabs Replacement
Senturus
 
Thinking DevOps in the Era of the Cloud - Demi Ben-Ari
Thinking DevOps in the Era of the Cloud - Demi Ben-AriThinking DevOps in the Era of the Cloud - Demi Ben-Ari
Thinking DevOps in the Era of the Cloud - Demi Ben-Ari
Demi Ben-Ari
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
Soshi Nemoto
 
Continuous Deployment: The Dirty Details
Continuous Deployment: The Dirty DetailsContinuous Deployment: The Dirty Details
Continuous Deployment: The Dirty Details
Mike Brittain
 
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Daniel Gallego Vico
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)
DoiT International
 
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
Demi Ben-Ari
 
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
Codemotion
 
The Anchor Store: Four Confluence Examples to Root Your Deployment
The Anchor Store: Four Confluence Examples to Root Your DeploymentThe Anchor Store: Four Confluence Examples to Root Your Deployment
The Anchor Store: Four Confluence Examples to Root Your Deployment
Atlassian
 
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
Demi Ben-Ari
 
apidays LIVE Paris - Automation API Testing by Guillaume Jeannic
apidays LIVE Paris - Automation API Testing by Guillaume Jeannicapidays LIVE Paris - Automation API Testing by Guillaume Jeannic
apidays LIVE Paris - Automation API Testing by Guillaume Jeannic
apidays
 
German introduction to sp framework
German   introduction to sp frameworkGerman   introduction to sp framework
German introduction to sp framework
Bob German
 
Bringing JAMStack to the Enterprise
Bringing JAMStack to the EnterpriseBringing JAMStack to the Enterprise
Bringing JAMStack to the Enterprise
C4Media
 

Similar to Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks (20)

A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
A Love Story with Kubevirt and Backstage from Cloud Native NoVA meetup Feb 2024
 
AppSec Pipelines and Event based Security
AppSec Pipelines and Event based SecurityAppSec Pipelines and Event based Security
AppSec Pipelines and Event based Security
 
Thinking DevOps in the era of the Cloud - Demi Ben-Ari
Thinking DevOps in the era of the Cloud - Demi Ben-AriThinking DevOps in the era of the Cloud - Demi Ben-Ari
Thinking DevOps in the era of the Cloud - Demi Ben-Ari
 
Introducing Neo4j 3.0
Introducing Neo4j 3.0Introducing Neo4j 3.0
Introducing Neo4j 3.0
 
Cf summit-2016-monitoring-cf-sensu-graphite
Cf summit-2016-monitoring-cf-sensu-graphiteCf summit-2016-monitoring-cf-sensu-graphite
Cf summit-2016-monitoring-cf-sensu-graphite
 
2014 DATA @ NFLX (Tableau Customer Conference)
2014 DATA @ NFLX (Tableau Customer Conference)2014 DATA @ NFLX (Tableau Customer Conference)
2014 DATA @ NFLX (Tableau Customer Conference)
 
Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019
 
Under the Hood with Cognos Analytics R5: Say Hello to Portal Tabs Replacement
Under the Hood with Cognos Analytics R5: Say Hello to Portal Tabs ReplacementUnder the Hood with Cognos Analytics R5: Say Hello to Portal Tabs Replacement
Under the Hood with Cognos Analytics R5: Say Hello to Portal Tabs Replacement
 
Thinking DevOps in the Era of the Cloud - Demi Ben-Ari
Thinking DevOps in the Era of the Cloud - Demi Ben-AriThinking DevOps in the Era of the Cloud - Demi Ben-Ari
Thinking DevOps in the Era of the Cloud - Demi Ben-Ari
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
 
Continuous Deployment: The Dirty Details
Continuous Deployment: The Dirty DetailsContinuous Deployment: The Dirty Details
Continuous Deployment: The Dirty Details
 
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
Droidcon Spain 2105 - One app to rule them all: Methodologies, Tools & Tricks...
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)
 
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
 
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
 
The Anchor Store: Four Confluence Examples to Root Your Deployment
The Anchor Store: Four Confluence Examples to Root Your DeploymentThe Anchor Store: Four Confluence Examples to Root Your Deployment
The Anchor Store: Four Confluence Examples to Root Your Deployment
 
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Berlin 2017
 
apidays LIVE Paris - Automation API Testing by Guillaume Jeannic
apidays LIVE Paris - Automation API Testing by Guillaume Jeannicapidays LIVE Paris - Automation API Testing by Guillaume Jeannic
apidays LIVE Paris - Automation API Testing by Guillaume Jeannic
 
German introduction to sp framework
German   introduction to sp frameworkGerman   introduction to sp framework
German introduction to sp framework
 
Bringing JAMStack to the Enterprise
Bringing JAMStack to the EnterpriseBringing JAMStack to the Enterprise
Bringing JAMStack to the Enterprise
 

More from Jose Luis Martínez

Being cloudy with perl
Being cloudy with perlBeing cloudy with perl
Being cloudy with perl
Jose Luis Martínez
 
Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)
Jose Luis Martínez
 
Escribir plugins para Nagios en Perl
Escribir plugins para Nagios en PerlEscribir plugins para Nagios en Perl
Escribir plugins para Nagios en Perl
Jose Luis Martínez
 
Perl and AWS
Perl and AWSPerl and AWS
Perl and AWS
Jose Luis Martínez
 
Writing nagios plugins in perl
Writing nagios plugins in perlWriting nagios plugins in perl
Writing nagios plugins in perl
Jose Luis Martínez
 
Ficheros y directorios
Ficheros y directoriosFicheros y directorios
Ficheros y directorios
Jose Luis Martínez
 
DBIx::Class
DBIx::ClassDBIx::Class
DBIx::Class
Jose Luis Martínez
 
DBI
DBIDBI
The modern perl toolchain
The modern perl toolchainThe modern perl toolchain
The modern perl toolchain
Jose Luis Martínez
 
Introducción a las Expresiones Regulares
Introducción a las Expresiones RegularesIntroducción a las Expresiones Regulares
Introducción a las Expresiones Regulares
Jose Luis Martínez
 

More from Jose Luis Martínez (10)

Being cloudy with perl
Being cloudy with perlBeing cloudy with perl
Being cloudy with perl
 
Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)
 
Escribir plugins para Nagios en Perl
Escribir plugins para Nagios en PerlEscribir plugins para Nagios en Perl
Escribir plugins para Nagios en Perl
 
Perl and AWS
Perl and AWSPerl and AWS
Perl and AWS
 
Writing nagios plugins in perl
Writing nagios plugins in perlWriting nagios plugins in perl
Writing nagios plugins in perl
 
Ficheros y directorios
Ficheros y directoriosFicheros y directorios
Ficheros y directorios
 
DBIx::Class
DBIx::ClassDBIx::Class
DBIx::Class
 
DBI
DBIDBI
DBI
 
The modern perl toolchain
The modern perl toolchainThe modern perl toolchain
The modern perl toolchain
 
Introducción a las Expresiones Regulares
Introducción a las Expresiones RegularesIntroducción a las Expresiones Regulares
Introducción a las Expresiones Regulares
 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 

Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks

  • 1. Writing plugins for Nagios and Opsview Jose Luis Martinez CTO 2014-02-11 Barcelona architects of the digital society www.capside.com
  • 2. Nagios What is Nagios? Opsview? Icinga? Naemon? Shinken? architects of the digital society www.capside.com
  • 3. Opsview  Configures and runs Nagios for you  Presents a frendlier and more powerfull user interface  Implements Nagios best practices  Distributed Monitoring  Datawarehouse architects of the digital society www.capside.com
  • 4. Back to Nagios  Monitoring tool that doesn’t know how to monitor anything!?!? • The real monitoring is done by plugins • Just external programs with a defined interface to communicate with Nagios • Written in any language architects of the digital society www.capside.com
  • 5. Plugins architects of the digital society www.capside.com
  • 6. Writing your plugins architects of the digital society www.capside.com
  • 7. First rule  Is it already done? • www.monitoring-plugins.org • Plugins project • www.nagiosplugins.org • Nagios official plugins • www.monitoringexchange.org • User contributed • exchange.nagios.org • User contributed • Google “xxx nagios” architects of the digital society www.capside.com
  • 8. We’ll take a look at  Nagios::Plugin (Monitoring::Plugin)  Nagios::Plugin::DieNicely  Nagios::Plugin::WWW::Mechanize  Nagios::Plugin::SNMP  Nagios::Plugin::Differences architects of the digital society www.capside.com
  • 9. Nagios::Plugin  Lots of common functionality for free! • When writing a plugin you have to Handle Arguments Get and manipulate the data Calculate state (OK, CRITICAL, …) architects of the digital society www.capside.com
  • 10. Nagios::Plugin  Lots of common functionality for free! • When writing a GREAT plugin you have to Handle Arguments -h –v arguments -h has to output documentation Get and manipulate the data Calculate state (OK, CRITICAL, …) In a flexible way (in f(x) of arguments) Output performance data architects of the digital society www.capside.com
  • 11. That’s a lot of work I just wanted to monitor my app! architects of the digital society www.capside.com
  • 12. Nagios::Plugin  Lots of common functionality for free! • When writing a GREAT plugin you have to Handle Arguments -h –v arguments -h has to output documentation Get and manipulate the data Calculate state (OK, CRITICAL, …) In a flexible way (in f(x) of arguments) Output performance data architects of the digital society www.capside.com
  • 13. 3 Simple Steps  Setup  Data collection  State calculation architects of the digital society www.capside.com
  • 14. Setup  Just make an instance of N::P #!/usr/bin/env perl use Nagios::Plugin; my $np= Nagios::Plugin->new( 'usage' => 'Usage: %s' ); $np->getopts;  You’ve just obtained • -t option (timeout) • -v option (verbose) • --help option architects of the digital society www.capside.com
  • 15. Setup (II) Constructor options  usage ("Usage: %s --foo --bar")  version <- Version string  url <- Help and Version  blurb <- Help description  license <- Help  extra <- Help  plugin <- overrides auto detected name architects of the digital society www.capside.com
  • 16. Setup: GetOpt magic $np->add_arg( spec=> 'warning|w=s', help=> "-w, --warning=RANGE", required=> 1 ); $np->add_arg( spec => 'user|u=s', help => 'Username', default => 'www-data' ); $np->getopts; if($np->opts->user) { … } architects of the digital society www.capside.com
  • 17. Collect data Now you have to work architects of the digital society www.capside.com
  • 18. State calculation architects of the digital society www.capside.com
  • 19. Ranges  Most plugins suppose that • OK<WARNING<CRITICAL  But… what if… architects of the digital society www.capside.com
  • 20. Ranges Range definition Generate alert if x… 10 Is not between 0 and 10 10: Is not between 10 and infinity ~:10 Is not between –Inf and 10 10:20 Is not between 10 and 20 @10:20 Is between 10 and 20 $code= $np->check_threshold( check => $value, warning => $warning_threshold, critical => $critical_threshold ); $np->nagios_exit( $code, "Thresholdcheckfailed" ) if ($code!= OK); architects of the digital society www.capside.com
  • 21. Output status  $np->nagios_exit(CRITICAL, “Too many connections”);  $np->nagios_exit(OK, “Everything went fine”);  $np->nagios_exit(WARNING, “Too few connections”);  $np->nagios_exit(UNKNOWN, “Bad options”); architects of the digital society www.capside.com
  • 22. Performance Data $np->add_perfdata( label => "size", value => $value, uom => "kB", warning => $warning, critical => $critical ); UOM Unit of measurement Is for No unit specified Assume a number of things s,ms,us econds, miliseconds, nanoseconds % Percentage B,KB,MB,TB Bytes c A continuous counter architects of the digital society www.capside.com
  • 23. Success! Enjoy your shiny new plugin architects of the digital society www.capside.com
  • 24. Nagios::Plugin::DieNicely architects of the digital society www.capside.com
  • 25. Nagios::Plugin::DieNicely  Software fails, and sometimes you don’t control it architects of the digital society www.capside.com
  • 26. Nagios::Plugin::DieNicely  What happened? architects of the digital society www.capside.com
  • 27. Nagios::Plugin::DieNicely  What happened? • Output went to STDERR • Nagios doesn’t care • Exit code follows Perls rules • Nagios understands 0-3 architects of the digital society www.capside.com
  • 30. Nagios::Plugin::WWW::Mechanize Nagios::Plugin + WWW::Mechanize You where going to do it anyway! architects of the digital society www.capside.com
  • 31. Nagios::Plugin::WWW::Mechanize  Again... Just create an instance. Use it as a Nagios::Plugin object  Automatically tracks response time for you  $np->mech  $np->content  $np->get, $np->submit_form architects of the digital society www.capside.com
  • 32. Nagios::Plugin::WWW::Mechanize A couple of tricks • Gzipped content my $np = Nagios::Plugin::WWW::Mechanize->new( 'mech' => WWW::Mechanize::GZip->new(autocheck => 0) ); • Proxy my $proxy = $np->opts->proxy; if (defined $proxy){ $np->mech->proxy(['http', 'https'], $proxy); } architects of the digital society www.capside.com
  • 34. Nagios::Plugin::SNMP Again... Just create an instance. Use it as a Nagios::Plugin object Sets up a lot of arguments Does delta between values of counters architects of the digital society www.capside.com
  • 35. Any Questions? Thanks to: The Monitoring::Plugin module maintainers Icanhazcheezburger for the cats architects of the digital society www.capside.com