Sans
2013-Mar-14 23:35 UTC
[Puppet Users] How to iterate over a string to construct nagios_service check as exported resource?
Dear all, I wrote a custom fact, which returns a comma separated list of addr:port, like this:> sb_intl_conn => > sbcms-t:22,sbsql05-wvuk-inst5:1434,sborc07-uk-t:1533,..,..,.. >The number of elements in the string varies from node to node. I need to do a Nagios tcp-port-check on each of them. I think sb_intl_conn.split(",")will turn this string into an array and then how can I iterate over it to do something like this? @@nagios_service { "check_stat_${::fqdn}_${addr}_${port}":> use => ''generic-service'', > check_command => "remote-nrpe-tcp-check!${addr}!${port}", > service_description => "V2::CON: ${addr} [Palms]", > display_name => "Connection check: ${addr}:${port}", > servicegroups => ''batch-worker'', > hostgroup_name => ''batch-job'', > } >Any help would be greatly appreciated. Cheers!! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Peter Brown
2013-Mar-15 05:42 UTC
Re: [Puppet Users] How to iterate over a string to construct nagios_service check as exported resource?
It''s pretty tricky to "program" puppet like your usual programming language. Given the nature of how puppet does things you will have to write a define that accepts the array you have split and then split the $title variable on "," That looks like a very complex way of generating nagios services. I am going to hope that the services you are monitoring aren''t managed by puppet at all and that''s the only way to do it. On 15 March 2013 09:35, Sans <r.santanu.das@gmail.com> wrote:> Dear all, > > I wrote a custom fact, which returns a comma separated list of addr:port, > like this: > > >> sb_intl_conn => >> sbcms-t:22,sbsql05-wvuk-inst5:1434,sborc07-uk-t:1533,..,..,.. >> > > The number of elements in the string varies from node to node. I need to > do a Nagios tcp-port-check on each of them. I think > sb_intl_conn.split(",") will turn this string into an array and then how > can I iterate over it to do something like this? > > > @@nagios_service { "check_stat_${::fqdn}_${addr}_${port}": >> use => ''generic-service'', >> check_command => "remote-nrpe-tcp-check!${addr}!${port}", >> service_description => "V2::CON: ${addr} [Palms]", >> display_name => "Connection check: ${addr}:${port}", >> servicegroups => ''batch-worker'', >> hostgroup_name => ''batch-job'', >> } >> > > Any help would be greatly appreciated. Cheers!! > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Sans
2013-Mar-15 08:41 UTC
Re: [Puppet Users] How to iterate over a string to construct nagios_service check as exported resource?
Thanks Pete! Do you think you can possibly put together a lines of example code? Just wondering, if it''s possible/easier with Ruby DSL? I haven''t tried that yet. Cheers!! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.