Coder Social home page Coder Social logo

Comments (13)

sbotman avatar sbotman commented on August 16, 2024

I will take a look for you tomorrow.
Basically you first need to create the command.
It's probably an order issue with the data bag import.
But unable to check this at the moment.

Greetings sander

Sent from my iPhone

On 30 Mar 2015, at 23:16, Joshua Seidel <[email protected]mailto:[email protected]> wrote:

anyone know how to get passed this? i cant get this to do updates, when i create contacts, it either asks me for the commands in the contact databag or throws the error in the subject.


Reply to this email directly or view it on GitHubhttps://github.com//issues/353.

from nagios.

blueharford avatar blueharford commented on August 16, 2024

@sbotman thanks sander, also if i want to disable or limit the search by a attribute?

we want to create a nagios instance for each region. so usva should only find nodes that start with usva-. is there a way to disable finding things by environment and only find things by "region"?

from nagios.

sbotman avatar sbotman commented on August 16, 2024

@blueharford Joshua, can you please test if this branch is working for you https://github.com/tas50/nagios/tree/fixing_353

About the search question:
We have disabled the default config and databag loading by setting the attributes within a wrapper cookbook:

default['nagios']['server']['load_default_config'] = false
default['nagios']['server']['load_databag_config'] = false

Then we use partial search (to offload the searches) to lookup the nodes and grab all the attributes that we would like to enable.

example:

nodes = []
multi_env = node['nagios']['monitored_environments']
multi_env_search = multi_env.empty? ? '' : ' AND (chef_environment:' + multi_env.join(' OR chef_environment:') + ')'

if node['nagios']['multi_environment_monitoring']
  nodes = partial_search(:node, "name:*#{multi_env_search}",
    :keys => { 'hostname' => ['hostname'],
               'name'     => ['name'],
               'fqdn'     => ['fqdn'],
               'os'       => ['os'],
               'family'   => ['platform_family'],
               'roles'    => ['roles'],
               'env'      => ['chef_environment'],
               'nagios'   => ['nagios'],
             }
  )
else
  nodes = partial_search(:node, "name:* AND chef_environment:#{node.chef_environment}",
    :keys => { 'hostname' => ['hostname'],
               'name'     => ['name'],
               'fqdn'     => ['fqdn'],
               'os'       => ['os'],
               'family'   => ['platform_family'],
               'roles'    => ['roles'],
               'env'      => ['chef_environment'],
               'nagios'   => ['nagios'],
             }
  )
end

nodes.each do |v|
  Chef::Log.debug("Nagios: Adding host to configuration with name: #{v['name']}")
  if v[node['nagios']['hostname_selection']].nil?
    host = Nagios::Host.create(v['name'])
  else
    host = Nagios::Host.create(v[node['nagios']['hostname_selection']])
  end

  groups = v['roles'].nil? ? [] : v['roles']
  groups += [v['os']] unless v['os'].nil?
  groups += [v['env']] unless v['env'].nil?

  groups.each do |group|
    hg = Nagios::Hostgroup.create(group)
    hg.push(host)
    host.push(hg)
  end

end

search(:role, '*:*') do |role|
  Nagios::Hostgroup.create(role.name)
end

Something like this.... If this doesn't help you then we might need to talk about this :)

from nagios.

blueharford avatar blueharford commented on August 16, 2024

hmm so i want the databags to be used but i just want to customize the search for what gets added.

so all databags load, but when it searches for nodes in chef, instead of it looking by environment i'd like it to look at the first 3 letters of the node name for matching.

from nagios.

blueharford avatar blueharford commented on August 16, 2024

@sbotman

Recipe: nagios::default

  • directory[/etc/nagios/dist] action create (up to date)

  • directory[/var/lib/nagios] action create (up to date)

  • directory[/var/lib/nagios/rw] action create (up to date)

  • execute[archive-default-nagios-object-definitions] action run (skipped due to not_if)

  • directory[/etc/nagios/certificates] action create (up to date)

  • bash[Create SSL Certificates] action run

    • execute "bash" "/tmp/chef-script20150401-14297-1lz48q9"
  • template[/etc/nagios/nagios.cfg] action create (up to date)

  • template[/etc/nagios/cgi.cfg] action create (up to date)

  • nagios_resourcelist_items[update] action update

    Error executing action update on resource 'nagios_resourcelist_items[update]'

    RuntimeError

    Nagios::Contact fail: Cannot find command host_notify_by_email please define it first.

    Cookbook Trace:

    /var/chef/cache/cookbooks/nagios/libraries/base.rb:245:in block in notification_commands' /var/chef/cache/cookbooks/nagios/libraries/base.rb:241:ineach'
    /var/chef/cache/cookbooks/nagios/libraries/base.rb:241:in notification_commands' /var/chef/cache/cookbooks/nagios/libraries/contact.rb:76:inhost_notification_commands='
    /var/chef/cache/cookbooks/nagios/libraries/base.rb:276:in block in update_hash_options' /var/chef/cache/cookbooks/nagios/libraries/base.rb:274:inupdate_hash_options'
    /var/chef/cache/cookbooks/nagios/libraries/base.rb:269:in update_options' /var/chef/cache/cookbooks/nagios/libraries/contact.rb:88:inimport'
    /var/chef/cache/cookbooks/nagios/providers/resourcelist_items.rb:61:in update_object' /var/chef/cache/cookbooks/nagios/providers/resourcelist_items.rb:26:inblock (2 levels) in class_from_file'
    /var/chef/cache/cookbooks/nagios/providers/resourcelist_items.rb:21:in `block in class_from_file'

    Resource Declaration:

    In /var/chef/cache/cookbooks/nagios/recipes/default.rb

    169: nagios_resourcelist_items 'update'
    170:

    Compiled Resource:

    Declared in /var/chef/cache/cookbooks/nagios/recipes/default.rb:169:in `from_file'

    nagios_resourcelist_items("update") do
    action :update
    retries 0
    retry_delay 2
    default_guard_interpreter :default
    declared_type :nagios_resourcelist_items
    cookbook_name "nagios"
    recipe_name "default"
    end

from nagios.

blueharford avatar blueharford commented on August 16, 2024

@sbotman it works if i add pagerduty as a contact.. but then it doesnt configure it right as defined in pagerduty.rb . should default.rb be calling pagerduty.rb if so where?

from nagios.

sbotman avatar sbotman commented on August 16, 2024

Hi Joshua, did you also test the branch https://github.com/tas50/nagios/tree/fixing_353 ?

from nagios.

blueharford avatar blueharford commented on August 16, 2024

@sbotman i grabbed the last commit then made the change. but im not finding it clear on how to invoke pagerduty.

im seeing this in the contacts.cfg

Skipping pagerduty because missing email.

from nagios.

blueharford avatar blueharford commented on August 16, 2024

@sbotman ok so apparently it created a pagerduty.conf with the contact. so i had to add include_recipe "nagios::pagerduty" in default right before the update resource and all is happy.

from nagios.

sbotman avatar sbotman commented on August 16, 2024

Great!

To be very honest, I personally never used the data bag setup. And if we use it, we don't do very much with it. Yesterday GitBytes opened issue #354 which took me some time to fix. Think that these changes are also useful for your setup and it would be great if you can test that branch. The fix provided here above is also merged into that branch.

Please let me know the result :)

Cheers Sander

from nagios.

blueharford avatar blueharford commented on August 16, 2024

@sbotman yea it works. the only issue i have now. is that i dont want it to scan by environment. i'd likefor their to be an option where i can do default['nagios']['node']['hostname_match'] = 'b1p' would only auto add servers that node name starts with b1p. since we have mutltiple regions

from nagios.

sbotman avatar sbotman commented on August 16, 2024

@blueharford if you have setup your chef-environments per region, then you can use the following attributes:

default['nagios']['multi_environment_monitoring'] = false
default['nagios']['monitored_environments'] = []

Otherwise you will need to create some custom code like the example I gave here above.
The configuration is fully provider driven and you can put all your needs within recipes, please check the wiki https://github.com/tas50/nagios/wiki. If this still doesn't help you, you can contact me on skype under [email protected] and I will help you.

Cheers Sander

from nagios.

lock avatar lock commented on August 16, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from nagios.

Related Issues (20)

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.