• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 14 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ruby API for scraping Nagios

nagiosharder

Query and command a Nagios install using the power of ruby (and lots of screen-scaping)! Do the usual gem install jig:

gem install nagiosharder

Now you have access to both a Ruby interface and a command line interface.

Here are some examples to get you started with the Ruby API:

require 'nagiosharder'

cgi         = 'https://path/to/nagios/cgi/directory'
user        = 'user'
pass        = 'pass'
version     = 3
time_format = 'iso8601'
verify_ssl  = true

site = NagiosHarder::Site.new(cgi, user, pass, version, time_format, verify_ssl)
# version defaults to 3
# time_format defaults to 'strict-iso8601' for version 3 and 'us' for all other versions
# verify_ssl defaults to true, pass false to override

Get details back about a host's services:

puts site.host_status('myhost')

Schedule a host to have services checks run again right now:

site.schedule_host_check('myhost')

Get details on all services:

site.service_status

Or just things with problems:

site.service_status(
  :service_status_types => [
    :critical,
    :warning,
    :unknown
  ]
)

Or just muted services, sorted desc by duration:

site.service_status(
  :service_props => [
    :notifications_disabled,
  ],
  :sort_type    => :descending,
  :sort_option  => :state_duration,
)

Or get the details for a single service group:

site.service_status(:group => "AWESOME")

Schedule a host to have services checks run again right now:

site.schedule_service_check('myhost', 'myservice')

Schedule 20 minutes of downtime, starting now:

site.schedule_host_downtime('myhost', :start_time => Time.now, :end_time => Time.now + 20.minutes)

Schedule a flexible 20 minutes of downtime between now and 2 hours from now:

site.schedule_host_downtime('myhost', :type => :flexible, :start_time => Time.now, :end_time => Time.now + 2.hours, :hours => 0, :minutes => 20)

Schedule 20 minutes of downtime for a service, starting now:

site.schedule_service_downtime('myhost', 'myservice', :start_time => Time.now, :end_time => Time.now + 20.minutes)

Cancel a scheduled host downtime:

site.cancel_downtime('downtime_id')

Cancel a scheduled service downtime:

site.cancel_downtime('downtime_id', :service_downtime)

Acknowledge a down service:

site.acknowledge_service('myhost', 'myservice', 'something bad happened')

Or unacknowledge a down service:

site.unacknowledge_service('myhost', 'myservice')

Acknowledge a down host:

site.acknowledge_host('myhost', 'something bad happened')

Or unacknowledge a down host:

site.unacknowledge_host('myhost')

Schedule next host check for right now:

site.schedule_host_check('myhost')

Schedule next service check for right now:

site.schedule_service_check('myhost', 'myservice')

Disable notifications for a service:

site.disable_service_notifications('myhost', 'myservice')

Check if notifications are disabled:

site.service_notifications_disabled?('myhost', 'myservice')

Enable notifications for a service:

site.enable_service_notifications('myhost', 'myservice')

Disable notifications, and wait for nagios to process it:

site.disable_service_notifications('myhost', 'myservice')
until site.service_notifications_disabled?('myhost', 'myservice')
  sleep 3
end

Get a summary on all hostgroups:

site.hostgroups_summary

Or a summary for a specific hostgroup:

site.hostgroups_summary('myhostgroup')

Get a summary on all servicegroups:

site.servicegroups_summary

Or a summary for a specific servicegroup:

site.servicegroups_summary('myservicegroup')

Get detailed output for all hostgroups:

site.hostgroups_detail

Get detailed output for a specific hostgroup:

site.hostgroups_detail('myhostgroup')

Get alert history:

site.alert_history

Or all HARD state alerts:

site.alert_history(:state_type => :hard, :type => :all)

Then there's the command line. Start with --help

nagiosharder --help

This will show you how you configure nagiosharder enough to talk to your nagios. You need at least a username, password, and nagios url. These can alternatively be in a config file.

For example:

nagiosharder --config /path/to/yaml

This will display all available commands.


Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Unless otherwise specified, all content copyright © 2014, Rails Machine, LLC

More Repositories

1

moonshine

Simple Rails deployment and configuration management. 15 minute deploys of Rails 2, 3, or 4 apps.
Ruby
666
star
2

rump

Do Puppet runs locally from a Git checkout. puppet-solo?!
Ruby
113
star
3

shadow_puppet

A Ruby DSL for Puppet
Ruby
84
star
4

railsmachine

RailsMachine is a collection of libraries for automating deployment and hosting configuration for Ruby on Rails applications using Capistrano and Rake.
Ruby
29
star
5

capistrano-cowboy

Deploy like a cowboy, pew pew!
Ruby
25
star
6

lita-ext

A collection of Lita extensions.
Ruby
18
star
7

moonshine_god

Simple installation and configuration management for god
Ruby
15
star
8

plover

Ruby
14
star
9

pagerduty-shift-announcer

Campfire and SMS announcer for pagerduty shift changes
Ruby
11
star
10

shadow_facter

ShadowFacter is a Ruby DSL for Facter
Ruby
8
star
11

moonshine_astrails_safe

Install and configure astrails-safe
Ruby
8
star
12

moonshine_wordpress

Configures a WordPress blog to run alongside your Rails app
Ruby
8
star
13

galera_cluster_migrations

A gem to help perform Rails database migrations with MariaDB Galera Cluster.
Ruby
8
star
14

plugger

We need plugins in Rails 4. So we put them back.
Ruby
7
star
15

moonshine_memcached

Install and configure memcached
Ruby
7
star
16

moonshine_sphinx

Install and configure sphinx
Ruby
7
star
17

utf8mb4_conversion_scripts

Scripts to help with converting a Rails database to utf8mb4
Ruby
6
star
18

libshadow

Provides /etc/shadow password management.
C
6
star
19

moonshine_scout

Install and configure the Scout agent
Ruby
6
star
20

moonshine_redis

A Moonshine plugin for installing and managing Redis, the advanced persistent key-value store.
HTML
5
star
21

moonshine_iptables

Iptables setup and configuration through your Moonshine manifest
Ruby
5
star
22

moonshine_mariadb

A Moonshine plugin for installing and configuring MariaDb Galera Cluster
Ruby
5
star
23

moonshine_ssh

A Moonshine plugin providing secure SSH defaults and simple configuration management
Ruby
4
star
24

parseconfig

simple config parser for files in the format of "param = value"
Ruby
4
star
25

moonshine_xsendfile

Install and configure mod_xsendfile
Ruby
3
star
26

moonshine_mysql_slave

Simple installation and configuration management for a MySQL slave.
Ruby
3
star
27

moonshine_ar_mailer

Simple installation and configuration management for ar_mailer
Ruby
3
star
28

moonshine_vagrant

A plugin for building all the configuration for a local version of an existing stage (like staging or production).
Ruby
3
star
29

moonshine_mmm

A plugin for installing and managing mysql_mmm
Ruby
3
star
30

moonshine_no_www

Moonshine plugin for handling no-www redirects
Ruby
3
star
31

moonshine_heartbeat

This Moonshine plugin allows you to easily integrate heartbeat into your deployment.
Ruby
2
star
32

moonshine_sidekiq

Moonshine plugin for basic Sidekiq configuration and deployment
Ruby
2
star
33

moonshine_omnipitr

Install and manage OmniPITR
Ruby
2
star
34

resque-oink

Resque extension to identify jobs which significantly increase VM heap size using oink
Ruby
2
star
35

moonshine_imagemagick

Ruby
2
star
36

moonshine_geoip

Duty-free, a Moonshine plugin for simple installation and configuration management of GeoIP
Ruby
2
star
37

moonshine_denyhosts

A denyhosts plugin for Moonshine
HTML
2
star
38

moonshine_haproxy

Simple installation and configuration management for haproxy
Ruby
1
star
39

moonshine_pagespeed

A Moonshine plugin for Google's mod_pagespeed Apache module
HTML
1
star
40

moonshine_vsftpd

Install and manage an FTP server
Ruby
1
star
41

moonshine_dj

Moonshine plugin for basic DelayedJob configuration and deployment
Ruby
1
star
42

moonshine_mysql_tools

A plugin for installing some commonly used mysql tools with Moonshine
Ruby
1
star
43

moonshine_moxi

Ruby
1
star
44

moonshine_ordered_hash

Ruby
1
star
45

moonshine_upload_progress

Install and configure mod_upload_progress
Ruby
1
star
46

moonshine_cijoe

Installs and configures cijoe using moonshine
Ruby
1
star
47

moonshine_sysctl

Tune kernel parameters with Moonshine.
Ruby
1
star
48

moonshine_msttcorefonts

A moonshine plugin for installing msttcorefonts
Ruby
1
star
49

moonshine_java

Moonshine plugin for configuring and installing Java
Ruby
1
star
50

moonshine_prince

Moonshine Plugin to Install Prince XML
Ruby
1
star
51

moonshine_pdfkit

Moonshine Plugin for managing PDFKit
Ruby
1
star
52

moonshine_syslog_ng

A syslog_ng recipe for Moonshine
Ruby
1
star
53

moonshine_passenger_monitor

Passenger Memory Monitor
Ruby
1
star
54

moonshine_couchdb

A moonshine plugin for installing and managing couchdb
Ruby
1
star