SlideShare uma empresa Scribd logo
1 de 35
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

Mais conteúdo relacionado

Mais procurados

Leveraging parse.com for Speedy Development
Leveraging parse.com for Speedy DevelopmentLeveraging parse.com for Speedy Development
Leveraging parse.com for Speedy DevelopmentAndrew Kozlik
 
VPN Access Runbook
VPN Access RunbookVPN Access Runbook
VPN Access RunbookTaha Shakeel
 
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 & DeploymentMatthew Hodgkins
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular jsMarcin Wosinek
 

Mais procurados (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
 

Destaque

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 2014Jose 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 talkJose 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 2015Jose 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' 2011garethjenkins
 
Proposal
ProposalProposal
Proposalramcoza
 
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 Onlinewebwhisker
 
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 olsenkamar95
 
Questionnaire results
Questionnaire resultsQuestionnaire results
Questionnaire resultskamar95
 

Destaque (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
 

Semelhante a 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 2024Cloud Native NoVA
 
AppSec Pipelines and Event based Security
AppSec Pipelines and Event based SecurityAppSec Pipelines and Event based Security
AppSec Pipelines and Event based SecurityMatt 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-AriDemi Ben-Ari
 
Introducing Neo4j 3.0
Introducing Neo4j 3.0Introducing Neo4j 3.0
Introducing Neo4j 3.0Neo4j
 
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-graphiteJeff 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 @deliverAgile2019ciberkleid
 
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 ReplacementSenturus
 
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-AriDemi 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 DetailsMike 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 DeploymentAtlassian
 
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 2017Demi 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 Jeannicapidays
 
German introduction to sp framework
German   introduction to sp frameworkGerman   introduction to sp framework
German introduction to sp frameworkBob German
 
Bringing JAMStack to the Enterprise
Bringing JAMStack to the EnterpriseBringing JAMStack to the Enterprise
Bringing JAMStack to the EnterpriseC4Media
 

Semelhante a 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
 

Mais de Jose Luis Martínez

Mais de 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
 

Último

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
🐬 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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
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...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

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