Hi Ken,
Thank you so much for your reply
I did like you said BUT i was still getting the error
err: Must pass a parameter or all necessary values at /etc/puppet/
modules/nagios/manifests/server.pp:19 on node mon1a.internal
Then I started to insert notice statement in the ruby DSL class - it
turns out I a logical erro in the code.
Arghhh - I have been so fooled by the totally misguiding error
message.
Shouldn't puppet err indicate that there is problem in /etc/puppet/
modules/nagios/manifests/ssa_nagios_checks.rb and not in /etc/puppet/
modules/nagios/manifests/server.pp?
Anyway now that the ruby error is fixed I get new error
err: undefined method `Puppet' for #<Puppet::DSL::ResourceAPI:
0xb73f50e0> at /etc/puppet/modules/nagios/manifests/server.pp:15 on
node mon1a.internal
What does this error means?
Here is the real ruby dsl class code - in case it's again a problem
with the class :)
----------------
require 'json'
require 'open-uri'
hostclass :'nagios::ssa_nagios_checks' do
nagios_confdir = scope.lookupvar('nagios::params::nrpe_confdir')
url = "http://localhost:5984/nagios_alerts/_all_docs?
include_docs=true"
result = JSON.parse(open(URI.parse(url)).read)
result['rows'].each do |x|
type = x['doc']['type']
args = x['doc']['args']
warning_threshold = x['doc']['warning_threshold']
critical_threshold = x['doc']['critical_threshold']
contacts = x['doc']['contacts']
contact_groups = x['doc']['contact_groups']
notification_period = x['doc']['notifications_period']
case type
when "mysql"
mysql_user = 'nagios'
mysql_password = 'xxxx'
check_command = "check_mysql_health_sql_tresholds!#{mysql_user}!
#{mysql_password}!'#{args}'!#{warning_threshold}!
#{critical_threshold}"
when "api"
check_command = "blah-blah"
else
raise Puppet:Error, "Unsupported ssa nagios check type $type"
end
nagios_service( "ssa_#{x['doc']['_id']}",
:target => "${nagios_confdir}/app_alerts/ssa/
services/${name}.cfg",
:host_name => x['doc']['hosts'],
:service_description => x['doc']['desc'],
:use => 'generic-service',
:check_command => check_command,
:require => "File[#{nagios_confdir}/app_alerts/ssa/
services]" )
end
end
----------------
Thanks
Alex
On Aug 11, 9:13 pm, Ken Barber <[email protected]> wrote:
> If you look at this example:
>
> >> I have a Ruby class in "nagios" module - it's located in nagios/
> >> manifests/ssa_nagios_checks.rb
> >> and looks like this
>
> >> hostclass :ssa_nagios_checks do
> >> ...
> >> end
>
> >> In nagios/manifests/init.pp I have
>
> >> class nagios::server {
> >> ...
> >> include ssa_nagios_checks
> >> ...
> >> }
>
> The autoloader/module layout recommendations/rules haven't been followed.
>
> You actually want something more like:
>
> nagios/manifests/server.pp:
>
> class nagios::server {
> include nagios::ssa_nagios_checks
> }
>
> nagios/manifests/ssa_nagios_checks.rb:
>
> hostclass :'nagios::ssa_nagios_checks' do
> notice(["should work"])
> end
>
> This should work. Can you test it?
>
> Remember that sub-classes belong in their own file ... and only the
> class with the same name as the module belongs in init.pp. Also - you
> have to fully qualify class names when declaring them in their rb/pp
> file.
>
> ken.
>
> --
> "Join us for PuppetConf, September 22nd and 23rd in Portland,
> OR:http://bit.ly/puppetconfsig"
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.