dmytro / nagira Goto Github PK
View Code? Open in Web Editor NEWNAGIos Restful Api
License: MIT License
NAGIos Restful Api
License: MIT License
Hi there,
Is there any way to speed up how long it takes for Nagira to return a 404 when a hostname is not found?
Also is there a more efficient way of getting 'current_state' for a host other than doing this?
10.1.0.1:4567/_status/hostname
performance numbers all over the place:
10.1.0.9 - - [29/Feb/2016:15:09:35 -0500] "GET /_status/srv181 HTTP/1.1" 404 59 0.3411
10.1.0.9 - - [29/Feb/2016:15:09:35 -0500] "GET /_status/srv183 HTTP/1.1" 404 59 0.0024
10.1.0.9 - - [29/Feb/2016:15:09:36 -0500] "GET /_status/srv184 HTTP/1.1" 404 59 0.0021
10.1.0.9 - - [29/Feb/2016:15:09:38 -0500] "GET /_status/srv185 HTTP/1.1" 404 59 0.0021
10.1.0.9 - - [29/Feb/2016:15:09:40 -0500] "GET /_status/srv186 HTTP/1.1" 404 59 0.0021
10.1.0.9 - - [29/Feb/2016:15:09:40 -0500] "GET /_status/srv187 HTTP/1.1" 404 59 0.0021
10.1.0.9 - - [29/Feb/2016:15:09:43 -0500] "GET /_status/srv189 HTTP/1.1" 404 59 0.1617
10.1.0.9 - - [29/Feb/2016:15:09:43 -0500] "GET /_status/srv193 HTTP/1.1" 404 59 0.0022
10.1.0.9 - - [29/Feb/2016:15:09:43 -0500] "GET /_status/srv194 HTTP/1.1" 404 59 0.0020
10.1.0.9 - - [29/Feb/2016:15:09:43 -0500] "GET /_status/srv195 HTTP/1.1" 404 59 0.0020
10.1.0.9 - - [29/Feb/2016:15:09:44 -0500] "GET /_status/srv197 HTTP/1.1" 404 59 0.0028
10.1.0.9 - - [29/Feb/2016:15:09:44 -0500] "GET /_status/srv141 HTTP/1.1" 404 59 0.0138
10.1.0.9 - - [29/Feb/2016:15:09:45 -0500] "GET /_status/srv156 HTTP/1.1" 404 59 0.0022
10.1.0.9 - - [29/Feb/2016:15:09:45 -0500] "GET /_status/srv198 HTTP/1.1" 404 59 0.0021
10.1.0.9 - - [29/Feb/2016:15:09:45 -0500] "GET /_status/srv199 HTTP/1.1" 404 59 0.0021
10.1.0.9 - - [29/Feb/2016:15:09:45 -0500] "GET /_status/srv201 HTTP/1.1" 404 59 0.0024
Covert all YARD documentation to use YARD macros below:
# @method get_config
# @overload get("/_config")
It's only partial now.
I haven't been able to figure out a way to get service comments from the API. I see that it's implemented in the ruby gem "ruby-nagios-0.1.0" but don't see any end point in the API that lets me get to it. I'd love to be able to get the comment from a service alert that has been acknowledged.
Hi, Its possible to use authentication to http requests to nagira?
I dont want all my nagios info to be public.
Thanks for your work.
Cheers,
echo $(ps -C ruby -o pid,cmd | awk '$2 ~ /^\/usr.*bin\/nagira *$/ {print $1}')
running
root@nagios:~# echo $(ps -C ruby -o pid,cmd | awk '$2 ~ /^\/usr.*bin\/nagira *$/ {print $1}')
returns nothing..
The process is being spawned, but the get_pid function is failing.
# sherlock
OS=Linux
MACH=x86_64
KERNEL=3.13.0-48-generic
DISTRIBUTION=debian
FAMILY=debian
DERIVATIVE=Ubuntu
RELEASE=14.04
CODENAME=trusty
Code switched to
echo $(ps aux| grep nagira| grep ruby| awk '{print $2}')
root@nagios:~# service nagira start
Starting Sinatra Nagira services: [OK]
Process Sinatra Nagira services is running with PID: 2185
root@nagios:~# service nagira status
Process Sinatra Nagira services is running with PID: 2185
root@nagios:~# service nagira stop
Shutting down Sinatra Nagira services: OK
Start messages are implemented as configure
in nagira.rb
. When running rspec, messages are printed to STDOUT.
Find a way to use Sinatra logger for this.
$ rspec
[2013-02-15 12:07:40 +0900] -- Starting Nagira apllication
[2013-02-15 12:07:40 +0900] -- Using nagios file config: /data/nagios.cfg
[2013-02-15 12:07:40 +0900] -- Using nagios file status: /data/status.dat
[2013-02-15 12:07:40 +0900] -- Using nagios file objects: /data/objects.cache
[2013-02-15 12:07:40 +0900] -- Using nagios file commands: /tmp/nagios.cmd
[2013-02-15 12:07:40 +0900] Starting background parser thread with interval 4.9 sec
...................................................................................................
Finished in 1.31 seconds
When nagira installed as part of bundle, for example from Gemfile in Rails app, its start script fails to run. Can not find sherlock command.
Running from capistrano:
* executing "/etc/init.d/nagira restart"
servers: ["192.168.56.99"]
[192.168.56.99] executing command
** [out :: 192.168.56.99] Process Sinatra Nagira services is not running
** [out :: 192.168.56.99] Starting Sinatra Nagira services:
** [out :: 192.168.56.99] sherlock not found
command finished in 307ms
Provide information about configuration files:
List of configuration files used, environment setting etc.
https://travis-ci.org/dmytro/nagira/jobs/3769887
$ rvm use rbx-19mode
Using /home/travis/.rvm/gems/rbx-head-d19
$ ruby --version
rubinius 2.0.0rc1 (1.9.3 release 2012-11-02 JI) [i686-pc-linux-gnu]
$ gem --version
1.8.24
....
$ bundle exec rspec spec
....F.F.F.F........................................................................................
Nagira is a great tool and it give pretty comprehensive information. I wanted to use it to bring a host in downtime / remove it from downtime. The docs have a method to update host status http://dmytro.github.io/nagira/doc/root/Nagira.html#update_host_status-instance_method but is it exposed via the REST API? I could not find any documentation / pointers for it.
How could we do performance improvement of Nagira / Sinatra frame work to get better results. We have certain integrations that are utilizing Nagira to get the _full dump but its taking lot of time (output is approximately 45MB size). many times in a day it fails with 500 internal error - particularly there are overlapping _full calls:
"GET /_status/_full HTTP/1.1" 500 30 15.5245"
Often I'm seeing below in nagira.logs so I was wondering if I can increase the max thread count (or something similar) to achieve better performance? I've much beefier box.
Snippet form the logs:
Puma 2.8.2 starting...
In app.rb, Parse nagios files
##
# TODO: This stuff breaks XML valid. Will have to wait.
#
# idx = 0
# @status.keys.uniq.each do |hostname|
# @status[idx] = @status[hostname]
# idx += 1
# end
To add full ActiveSupport need to have routes like: /_status/0
additionally to /_status/hostname
. But because of tags like <0>
XML validation breaks completely.
Is there a way to run this on top of the nagios web server so I don't have to open up another port? That would be very useful.
This would be very useful as a read-only REST API for Nagios 4.
Add testing for init script installation
We have huge status file(16M) so I was hoping that background parsing would help us a lot. Unfortunately I had to rollback due to an issue when api calls are made while nagios[:status] still being populated - this causes 404 errors in cases where we get hostgroups and then query hostgroup members for particular service (that is present for every hostgroup member).
I tried to fix this issue with simple mutex.synchronize around parse! in bg thread and having mutex.synchronize in "before do", but it essentially disables background parsing because all http threads have to wait for bg thread to complete parsing.
The right way of dealing with this situation would be having an active nagios[:status] instance and "being populated" instance and swap them (or reference) once parsing is complete. I'll try to implement something like this myself, but I wonder if Dmytro has any better ideas on how to tackle this problem.
OS: Red Hat 4.4.7-3
when run: /etc/init.d/nagira status it always returns the service is not running
it seems the following command need some fix:
echo $(ps -C ruby -o pid,cmd | awk '$2 ~ /^/usr.*bin/nagira *$/ {print $1}')
[root@nagios log]# service nagira start
Starting Sinatra Nagira services: sherlock not found
[root@nagios log]# sherlock
OS=Linux
MACH=x86_64
KERNEL=2.6.18-308.el5
DISTRIBUTION=redhat
FAMILY=rh
DERIVATIVE=centos
RELEASE=5.8
[root@nagios log]# /etc/init.d/nagira start
Starting Sinatra Nagira services: [OK]
Process Sinatra Nagira services is running with PID: 7399
[root@nagios log]#
https://travis-ci.org/dmytro/nagira/jobs/5522168
Installing rack-test (0.6.2)
Installing redcarpet (2.2.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/travis/.rvm/rubies/jruby-1.7.3-d19/bin/jruby extconf.rb
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.
(root) at /home/travis/.rvm/rubies/jruby-1.7.3-d19/lib/ruby/shared/mkmf.rb:8
require at org/jruby/RubyKernel.java:1027
(root) at /home/travis/.rvm/rubies/jruby-1.7.3-d19/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
(root) at extconf.rb:1
Gem files will remain installed in /home/travis/.rvm/gems/jruby-1.7.3-d19/gems/redcarpet-2.2.2 for inspection.
Results logged to /home/travis/.rvm/gems/jruby-1.7.3-d19/gems/redcarpet-2.2.2/ext/redcarpet/gem_make.out
An error occurred while installing redcarpet (2.2.2), and Bundler cannot
continue.
Make sure that `gem install redcarpet -v '2.2.2'` succeeds before bundling.
The command "bundle install" failed and exited with 5 during install.
Your build has been stopped.
Have an alias route /_host_status, which should be the same as /_status, but it's not implemented.
When I run the nagira-setup config:all everything works except when the services have to start.
And I check on the log file and I got this error:
/usr/local/rvm/gems/ruby-1.9.2-p320/gems/nagira-0.3.3/lib/app.rb:70:in block in <class:Nagira>': undefined method
status_file' for #Nagios::Config:0x00000015b5fcb0 (NoMethodError)
from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/sinatra-1.3.6/lib/sinatra/base.rb:1356:in configure' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/nagira-0.3.3/lib/app.rb:62:in
class:Nagira'
from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/nagira-0.3.3/lib/app.rb:53:in <top (required)>' from /usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in
require'
from /usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in require' from /usr/local/rvm/gems/ruby-1.9.2-p320/gems/nagira-0.3.3/bin/nagira:4:in
<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.2-p320/bin/nagira:23:in load' from /usr/local/rvm/gems/ruby-1.9.2-p320/bin/nagira:23:in
eval' from /usr/local/rvm/gems/ruby-1.9.2-p320/bin/ruby_executable_hooks:15:in
'
It strange because I try with different version of nagira and different version of ruby.
Maybe I do something wrong but I don't know.
For the moment nagira works only in test when I run it in the command line "nagira"
Thanks in advance.
Dependencies:
Need to add switch to /etc/init.d/nagira to run tests, similar to Nagios -v flag.
I'm using Rails 3.2.13 with a number of other gems, notably carrierwave and a jQuery UI gem, both of which now require json 1.8.0. I can't install the nagira_active_resource gem because it requires json 1.7.7.
: jkirk@imac:my_rails_app ; bundle install
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "json":
In Gemfile:
nagira_active_resource (>= 0) ruby depends on
json (= 1.7.7) ruby
carrierwave (>= 0) ruby depends on
json (1.8.0)
Is it possible to have an API call that dumps all the status information about all services in a given hostgroup?
Something linke this:
http://nagios-server.4567/_status/hostgroups/<hostgroup_name>/_services
Namespace cleanup - for all attributes, used in Nagios, their names should correspond to variable names in code.
For example:
hostname -> to host_name, etc
This is more an issue in ruby-nagios but I couldn't add an issue on that project. In objects.rb the objects.cache file is parsed and an assumption that all blocks have _name is made:
@objects[handler][block["#{handler.to_s}_name".to_sym]] = block
Unfortunately service blocks use service_description and not service_name.
In addition, in order to be unique, the host_name + service_description need to be combined somehow.
I know that OP5 and nagios are similar. Just checking if this has worked in the past.
https://travis-ci.org/dmytro/nagira/jobs/5522395
Installing sinatra (1.3.5)
Psych::SyntaxError: (<unknown>): 'reader' unacceptable character '�' (0x82) special characters are not allowed
in "'reader'", position 278 at line 0 column 0
An error occurred while installing sinatra-contrib (1.3.2), and Bundler cannot
continue.
Make sure that `gem install sinatra-contrib -v '1.3.2'` succeeds before
bundling.
The command "bundle install" failed and exited with 5 during install.
Your build has been stopped.
Current version of init.d is tested only in Debian
Add background thread to parse status.dat file periodically even if there are no client requests.
Client requests will not have delay waiting for parsing.
Add test scenarios for testing:
Hello I am able to install the gem and run ''nagira', then when I try to setup test configuration i am facing this problem
Students-iMac:student1 student1$ nagira-setup config:test:install
(in /Users/student1/.rvm/gems/ruby-2.2.3/gems/nagira-0.5.0)
rake aborted!
NameError: uninitialized constant ActiveSupport::Concern
/Users/student1/.rvm/gems/ruby-2.2.3/gems/activemodel-4.2.5/lib/active_model/serializers/xml.rb:11:in <module:Xml>' /Users/student1/.rvm/gems/ruby-2.2.3/gems/activemodel-4.2.5/lib/active_model/serializers/xml.rb:10:in
module:Serializers'
/Users/student1/.rvm/gems/ruby-2.2.3/gems/activemodel-4.2.5/lib/active_model/serializers/xml.rb:8:in <module:ActiveModel>' /Users/student1/.rvm/gems/ruby-2.2.3/gems/activemodel-4.2.5/lib/active_model/serializers/xml.rb:7:in
<top (required)>'
/Users/student1/.rvm/gems/ruby-2.2.3/gems/nagira-0.5.0/lib/nagira.rb:2:in <top (required)>' /Users/student1/.rvm/gems/ruby-2.2.3/gems/nagira-0.5.0/Rakefile:2:in
require_relative'
/Users/student1/.rvm/gems/ruby-2.2.3/gems/nagira-0.5.0/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)
Any help will be appreciated.
Ravanliyski
Add check to /etc/init.d script to check permissions of Nagira installation directory.
If nagira started as nagios user and dir is not accessible init script fails without reporting an error.
# /etc/init.d/nagira start
Starting Sinatra Nagira services: [FAIL]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.