Лупайте сю скалу...

Іван Франко

 RSS | Atom

19 June 2015


Selected projects See all »

Banalize: Bash static code analyzerDBIx::Report::ExcelShell settings, AKA dotfilesNagios Monitoring for Couchbase serverNagira: RESTful API for NagiosStartpack for Github pages developmentWeb iPhoto

Travel Blog Витрішки »

Україномовний блог Витрішки - блог про все, крім роботи. Цикл статей "Літо на півночі Японії" з цього блогу тепер опублікований у Витрішках

Computer Blog All posts »

iPhoto and files permission Is MacOSX 10.9 == MacOS 9.x? Running Chef roles from Capistrano und Capiche Github & Jekyll: Speeding up Jekyll siteGithub & Jekyll: More experience with Jekyll and setup changesBuild new hosts with Capistrano and Chef Request Tracker: More about custom CSS for RT4Ruby 2 test drive Nagira v0.2.5 release It's UNIX my dear Watson

Slides See all »

Nagira @TLUG, 2012Rspec and Guard


Ярило Yarylo, Jarilo me @ github me @ CPAN Dmytro (CV)

Nagios RESTful API (old)
Table Of Contents

Please note

There’s is different Open Source implementation of the RESTful API for Nagios, which superseeds this — Nagira . Nagira implemented with Ruby and Sinatra, provides more functionality/test suite, easier configuration.

Although similar in functionality code bases of two systems are not related.

This page only gives description of older API, if you are looking for working software look at Nagira instead. Source code for described here API is not available.


This is implementation of RESTful Ruby-on-Rails service for Nagios monitoring system. It provides read-only access via Web service to Nagios hosts and services monitoring status.

This is a ‘faceless’ web application, i.e. it does not have Web GUI suitable for human use. It is intended to be used as data source for other web-applications and/or scripts.


Following routes and actions implemented in hosts controller:

         root  /(.:format)                                      {:controller=>"hosts", :action=>"index"}
   hosts_list  /hosts/list(.:format)                            {:controller=>"hosts", :action=>"list"}
        hosts  /hosts(.:format)                                 {:controller=>"hosts", :action=>"index"}
 hosts_states  /hosts/states(.:format)                          {:controller=>"hosts", :action=>"states"}
               /host/:hostname(.:format)                        {:controller=>"hosts", :action=>"show"}
               /host/:hostname/:action(.:format)                {:action=>/(show|state|services)/, :controller=>"hosts"}
               /host/:hostname/services/state(.:format)         {:controller=>"hosts", :action=>"services_states"}
               /host/:hostname/services/list(.:format)          {:controller=>"hosts", :action=>"services_list"}
               /host/:hostname/service/:service(.:format)       {:controller=>"hosts", :action=>"service"}
               /host/:hostname/service/:service/state(.:format) {:controller=>"hosts", :action=>"service_state"}
‘Catch-all’ route for routing errors

               /*a(.:format)                                    {:controller=>"application", :action=>"routing"}

Programming language

  • Ruby
  • Ruby on Rails


Hosts controller provides data in 3 formats: XML (.xml or empty), JSON (.json) or YAML (.yaml)

No HTML formatted output is provided.


  • Get list of all hosts
   curl http://localhost:3000/hosts/list
  • Get information of all hosts’ status (full status)
   curl http://localhost:3000/hosts
  • Get information of all hosts’ status (hostname and state only)
   curl http://localhost:3000/hosts/states
  • Get single host’s information in XML, YAML and JSON respectively
   curl http://localhost:3000/host/production001
   curl http://localhost:3000/host/production001.yaml
   curl http://localhost:3000/host/production001.json
  • Get services on the host in XML and YAML
  curl http://localhost:3000/host/production001/services
  curl http://localhost:3000/host/production001/services.xml (same as above)
  curl http://localhost:3000/host/production001/services.yaml
  • List of services on the host
  curl http://localhost:3000/host/production001/services/list
  curl http://localhost:3000/host/production001/services/list.json
  curl http://localhost:3000/host/production001/services/list.yaml


Nagios RESTful assumes that Nagios configuration file is located in /etc/nagios/nagios.cfg and finds information about status.dat file location from this file. If your Nagios configuration is in different location please change it in config/application.rb (or in one of config/environments/*) files(s).

дмитро ковальов
dmytro @ github