[Puppet Users] How to iterate over a string to construct nagios_service check as exported resource?

2013-03-14 Thread Sans
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+unsubscr...@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.




Re: [Puppet Users] How to iterate over a string to construct nagios_service check as exported resource?

2013-03-14 Thread Peter Brown
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@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+unsubscr...@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+unsubscr...@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.