GithubHelp home page GithubHelp logo

nagiosharder's Issues

no output from service_status

Hi,

service_status won't give me any output, even with filtering only crit/warn/unknown.

But for example:
hostgroups_summary
host_status('myhost')
servicegroups_summary
alert_history
alert_history(:state_type => :hard, :type => :all)

gives me much output. What is wrong?

Are whitespaces a problem?
site.hostgroups_summary('myhostgroup')
with whitespaces in a hostgroup wont work, but without.

Undefined method `gsub' for nil:NilClass

The plugin works fine until I restart the nagios service. An entry like "Nagios 4.X.X starting..." will be logged in nagios.log. Afterwards

scheduler caught exception: undefined method gsub' for nil:NilClass /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/bundler/gems/nagiosharder-c850f759f457/lib/nagiosharder.rb:671:in block in parse_history_html' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.4/lib/nokogiri/xml/node_set.rb:204:in block in each' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.4/lib/nokogiri/xml/node_set.rb:203:in upto' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.4/lib/nokogiri/xml/node_set.rb:203:in each' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/bundler/gems/nagiosharder-c850f759f457/lib/nagiosharder.rb:654:in parse_history_html' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/bundler/gems/nagiosharder-c850f759f457/lib/nagiosharder.rb:388:in alert_history' /mnt/c/Users/sj/Documents/Git/iti-dashboard/jobs/nagios_history.rb:24:in block in get_alerts' /mnt/c/Users/sj/Documents/Git/iti-dashboard/jobs/nagios_history.rb:22:in each' /mnt/c/Users/sj/Documents/Git/iti-dashboard/jobs/nagios_history.rb:22:in get_alerts' /mnt/c/Users/sj/Documents/Git/iti-dashboard/jobs/nagios_history.rb:53:in block in <top (required)>' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in trigger_block' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:204:in block in trigger' /mnt/c/Users/sj/Documents/Git/iti-dashboard/vendor/bundle/ruby/2.3.0/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in block in trigger_job'

After removing the entry via sed -i '/Nagios \ 4/d' /usr/local/nagios/var/nagios.log; all things are fine again.

Invalid date when parsing service_status

I'm getting these errors from nagiosharder when running ledbetter against a Nagios 3.3.1 server. It looks like nagiosharder expects date_format = iso8601 while we're using date_format = us.

read 12959 bytes
Conn close
parsed host column
parsed service column
parsed status column
Need to parse 08-02-2013 18:16:47 in %Y-%m-%d %H:%M:%S
/home/jdixon/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:482:in `strptime': invalid date (ArgumentError)
        from /home/jdixon/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:482:in `block in parse_status_html'
        from /home/jdixon/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:237:in `block in each'
        from /home/jdixon/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:in `upto'
        from /home/jdixon/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:in `each'
        from /home/jdixon/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:419:in `parse_status_html'
        from /home/jdixon/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:243:in `service_status'
        from ledbetter.rb:40:in `<main>'

/cc @jnewland

Freshly installed nagiosharder, can't "require 'nagiosharder'"

I'm probably doing something wrong, but I don't know what:

bweiss@mybox ~ % sudo gem install nagiosharder
Fetching: rest-client-1.6.7.gem (100%)
Fetching: terminal-table-1.4.5.gem (100%)
WARNING: terminal-table-1.4.5 has an invalid nil value for @cert_chain
Fetching: crack-0.1.8.gem (100%)
Fetching: httparty-0.6.1.gem (100%)
When you HTTParty, you must party hard!
Fetching: hashie-1.0.0.gem (100%)
Fetching: nagiosharder-0.4.0.gem (100%)
Successfully installed rest-client-1.6.7
Successfully installed terminal-table-1.4.5
Successfully installed crack-0.1.8
Successfully installed httparty-0.6.1
Successfully installed hashie-1.0.0
Successfully installed nagiosharder-0.4.0
6 gems installed
Installing ri documentation for rest-client-1.6.7...
Installing ri documentation for terminal-table-1.4.5...
Installing ri documentation for crack-0.1.8...
Installing ri documentation for httparty-0.6.1...
Installing ri documentation for hashie-1.0.0...
Installing ri documentation for nagiosharder-0.4.0...
Installing RDoc documentation for rest-client-1.6.7...
Installing RDoc documentation for terminal-table-1.4.5...
Installing RDoc documentation for crack-0.1.8...
Installing RDoc documentation for httparty-0.6.1...
Installing RDoc documentation for hashie-1.0.0...
Installing RDoc documentation for nagiosharder-0.4.0...
bweiss@mybox ~ % irb
irb(main):001:0> require 'nagiosharder'
TypeError: can't convert Pathname to String
    from /usr/lib/ruby/1.9.1/rubygems.rb:991:in `escape'
    from /usr/lib/ruby/1.9.1/rubygems.rb:991:in `block in loaded_path?'
    from /usr/lib/ruby/1.9.1/rubygems.rb:990:in `each'
    from /usr/lib/ruby/1.9.1/rubygems.rb:990:in `find'
    from /usr/lib/ruby/1.9.1/rubygems.rb:990:in `loaded_path?'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from /var/lib/gems/1.9.1/gems/httparty-0.6.1/lib/httparty.rb:10:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /var/lib/gems/1.9.1/gems/nagiosharder-0.4.0/lib/nagiosharder.rb:20:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from (irb):1
    from /usr/bin/irb:12:in `<main>'
irb(main):002:0> 
bweiss@mybox ~ % nagiosharder
/usr/lib/ruby/1.9.1/rubygems.rb:991:in `escape': can't convert Pathname to String (TypeError)
    from /usr/lib/ruby/1.9.1/rubygems.rb:991:in `block in loaded_path?'
    from /usr/lib/ruby/1.9.1/rubygems.rb:990:in `each'
    from /usr/lib/ruby/1.9.1/rubygems.rb:990:in `find'
    from /usr/lib/ruby/1.9.1/rubygems.rb:990:in `loaded_path?'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from /var/lib/gems/1.9.1/gems/httparty-0.6.1/lib/httparty.rb:10:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /var/lib/gems/1.9.1/gems/nagiosharder-0.4.0/lib/nagiosharder.rb:20:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /var/lib/gems/1.9.1/gems/nagiosharder-0.4.0/lib/nagiosharder/cli.rb:3:in `<top (required)>'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
    from /var/lib/gems/1.9.1/gems/nagiosharder-0.4.0/bin/nagiosharder:2:in `<top (required)>'
    from /usr/local/bin/nagiosharder:19:in `load'
    from /usr/local/bin/nagiosharder:19:in `<main>'

Any ideas?

alert_history is not returning any output

Hiya,

the alert_history is not returning any output.
I have nagios monitoring a server, and there is a critical alert in hard state.

When I do a print of alert_history(:state_type => :hard, :type => :all), it is giving me an empty array.
Does anybody know why that might be?

This is how I am calling the alert_history function

I have my cgi defined

nagios_address = http://<host_name>/nagios/cgi-bin
user = 'user'
pass = 'password'
version = 3
time_format = 'euro'

nag = NagiosHarder::Site.new(nagios_address, user, pass, version, time_format)
print nag.alert_history(:state_type => hard, :type => all)

Thank you.

Better 3.0.6 support

Split off from #1

There's a few things needed for 3.0.6 support:

  • Correct time format (see #1)
  • Confirm if service_status works correctly

Getting stats at a host level

Hey,

We needed stats at a host level in addition to hostgroup and servicegroup levels. I've made the required changes and we are currently using this to retrieve stats on production. Is there a reason I've missed as to why this hasn't been added yet? Is there an interest in this commit?

Thanks and keep up the good work!

How to verify host status instead of services?

In our Nagios, we have a host list and a services list. NagiosHarder seems to be able to only check the services list. Is there also a way to verify that the hosts are up? (from the hosts list)

How to filter alerts for a particular hostgroup

I want to filter the alerts for a particular hostgroup for example: DEV. I added like this but instead of getting the alerts for DEV environment. I am getting alerts for all the environments.

environments = {
emint: { url: 'https://xxxxxxxxx/em/nagios/cgi-bin/', username: 'xxxxxxxxx', password: xxxxx' },
}

environments.each do |key, env|
nag = NagiosHarder::Site.new(env[:url], env[:username], env[:password], 3, 'iso8601')
unacked = nag.service_status(:hostgroup => [:DEV], :host_status_types => [:all], :service_status_types => [:warning, :critical], :service_props => [:hard_state, :no_scheduled_downtime, :state_unacknowledged, :checks_enabled])

critical_count = 0
warning_count = 0
unacked.each do |alert|
  if alert["status"].eql? "CRITICAL"
    critical_count += 1
  elsif alert["status"].eql? "WARNING"
    warning_count += 1
  end
end

# nagiosharder may not alert us to a problem querying nagios.
# If no problems found check that we fetch service status and
# expect to find more than 0 entries.
error = false
if critical_count == 0 and warning_count == 0
  if nag.service_status.length == 0
    error = true
  end
end

Can you please help me with this

invalid date

Hi,

I'm using nagiosharder with Nagios 3.4.1 and I'm getting this error:

scheduler caught exception:
invalid date
/Users/include/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:482:in strptime' /Users/include/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:482:inblock in parse_status_html'
/Users/include/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:237:in block in each' /Users/include/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:inupto'
/Users/include/.rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:in each' /Users/include/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:419:inparse_status_html'
/Users/include/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nagiosharder-eb09a864d77d/lib/nagiosharder.rb:243:in service_status' /Users/include/Documents/dev/WORK/OPS/mydev/D/mdfcks/jobs/nagios.rb:11:inblock (2 levels) in <top (required)>'
/Users/include/Documents/dev/OPS/mydev/D/mdfcks/jobs/nagios.rb:9:in each' /Users/include/Documents/dev/OPS/mydev/D/mdfcks/jobs/nagios.rb:9:inblock in <top (required)>'
/Users/include/.rvm/gems/ruby-2.0.0-p247/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in call' /Users/include/.rvm/gems/ruby-2.0.0-p247/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:intrigger_block'
/Users/include/.rvm/gems/ruby-2.0.0-p247/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:204:in block in trigger' /Users/include/.rvm/gems/ruby-2.0.0-p247/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:incall'
/Users/include/.rvm/gems/ruby-2.0.0-p247/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in `block in trigger_job'

version used:
nagiosharder (0.5.0.rc1 eb09a86)
rufus-scheduler (3.0.3, 2.0.24)
nokogiri (1.6.0)

any help? 10x in advance :)

Host status details

I have a working copy of a new method hostgroups_hostdetail that grabs the junk out of /status.cgi?hostgroup=all&style=hostdetail&embedded=1&noheader=1&limit=0 which covers a lot of what I'd like to see.

[5] pry(main)> nagios.hostgroups_hostdetail
=> {"admin4-01.foo.com "=>
  {"host"=>"admin4-01.foo.com ",
   "host_extinfo_url"=>
    "https://nagios/nagios/cgi-bin/extinfo.cgi?type=1&host=admin4-01.foo.com",
   "status"=>"UP",
   "last_check"=>"2014-01-18T21:01:58+00:00",
   "duration"=>"58d 23h 52m 3s",
   "started_at"=>2013-11-20 21:11:12 -0500,
   "extended_info"=>"PING OK - Packet loss = 0%, RTA = 0.99 ms&#160;"},
 "admin4-02.foo.com "=>
  {"host"=>"admin4-02.foo.com ",
   "host_extinfo_url"=>
    "https://nagios/nagios/cgi-bin/extinfo.cgi?type=1&host=admin4-02.foo.com",
   "status"=>"UP",
   "last_check"=>"2014-01-18T21:00:58+00:00",
   "duration"=>"58d 23h 52m 33s",
   "started_at"=>2013-11-20 21:10:42 -0500,
   "extended_info"=>"PING OK - Packet loss = 0%, RTA = 1.01 ms&#160;"}}

The only downside is that it doesn't include data on attempts, acknowledged, flapping, comments_url, notifications_disabled, or downtime. Some of those are important to me but I don't see a better view for parsing host status.

Anyone know of a better url I can work with?

refs #13

ArgumentError: invalid date

I see there are a couple other issues about date problems, but I dont' think they are the same as this.

On a fresh gem install of nagiosharder 0.4.0, pointing to a nagios 3.3.1 installation, I get the following error:
[3] pry(main)> site.service_status(:all_problems)
ArgumentError: invalid date
from /Users/jalberts/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/date.rb:1688:in `new_by_frags'

site.service_status doesn't parse all services only first 100 elements.

I use your nagiosnarder to parse data from nagios page.
I found bug or little defect in the method :
def service_status(options = {})

When i tried to receive all services using this:

site.service_status

I got only first 100 elements.

Since you parse this page:
http://.../nagios/cgi-bin/status.cgi?host=all

and this page with default settings has limit result = 100 elements.

So, we need to add "&limit=0" key after this URL to get all service statuses -->
/nagios/cgi-bin/status.cgi?host=all&limit=0

I hope my explanation is clear.

Thank you in advance.

Issue with cgi

Hello,

I am trying to get a the dashing-nagios dashboard, up and ready but I am encountering a couple of issues.
Please find below more information on what is going on.
aelse/dashing-nagios#6 (comment)

I am using nagios vshell and whenever I hit my nagios instance with status-cgi? in it, I have a 404.
Here is the issue:
scheduler caught exception:
wtf http://nagios.instance.com/status.cgi?hoststatustypes=2&servicestatustypes=20&serviceprops=42&servicegroup=all&style=detail&embedded=1&noheader=1&limit=0? 404

Any help would be much appreciated.

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.