eduardo
2013-Feb-23 17:33 UTC
[Puppet Users] How to check service status to write monit snippet.
Hi all. I''m working on monit module. I have an array of services to configure monit via ENC. I need a consistent module logic so services arriving as input parameter must running on node agent. I''m trying to find out if there is services running to configure monit snippets. So, The snippet will be only written into /etc/monit/conf.d when service is running. Let''s say an input parameter like : services => [''ntp'',''ssh''] But ntp service is not running. In that case I need the snippet for ''ntp'' service not be written on conf.d Is there simple way to do it ?. Thanks in advanced, eduardo. -- 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.
Felix Frank
2013-Feb-25 13:33 UTC
Re: [Puppet Users] How to check service status to write monit snippet.
Hi, I''m almost certain I don''t really understand your problem, but here''s the most simple answer, so we can work from there: Your ENC should set a variable value for each service on each node, e.g.: $ssh => true $ntp => false ... If a given value is true, include the snippet. If not, don''t. On 02/23/2013 06:33 PM, eduardo wrote:> Hi all. > I''m working on monit module. I have an array of services to configure > monit via ENC. > I need a consistent module logic so services arriving as input > parameter must running on node agent. > > I''m trying to find out if there is services running to configure monit > snippets. > So, The snippet will be only written into /etc/monit/conf.d when > service is running. > > Let''s say an input parameter like : > > services => [''ntp'',''ssh''] > > But ntp service is not running. In that case I need the snippet for > ''ntp'' service not be written on conf.d > > Is there simple way to do it ?. > > > Thanks in advanced, eduardo.-- 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.
eduardo
2013-Feb-25 14:52 UTC
[Puppet Users] Re: How to check service status to write monit snippet.
Thanks felix, I''m trying to do a validator for monit module. I''m pretending down services are not controlled by monit, avoiding false alarm from monit service. I was work around with something like : class monit($services) { include monit::checkservice, monit::snippet monit::checkservice::checksrv{ $::monit::services : } ------ class monit::checkservice { define checksrv { notify { "Checking service $name":} service { $name: noop => true, hasstatus => false, status => "/usr/local/bin/check_service.sh ${name}", } } } where $services is array of services from ENC. But it have been unsuccessfully. I can see notifies messages foreach element from array but status script is not executed like i expected foreach item. regards, eduardo. El sábado, 23 de febrero de 2013 12:33:51 UTC-5, eduardo escribió:> > Hi all. > I''m working on monit module. I have an array of services to configure > monit via ENC. > I need a consistent module logic so services arriving as input parameter > must running on node agent. > > I''m trying to find out if there is services running to configure monit > snippets. > So, The snippet will be only written into /etc/monit/conf.d when service > is running. > > Let''s say an input parameter like : > > services => [''ntp'',''ssh''] > > But ntp service is not running. In that case I need the snippet for ''ntp'' > service not be written on conf.d > > Is there simple way to do it ?. > > > Thanks in advanced, eduardo. > >-- 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.
Felix Frank
2013-Feb-25 14:56 UTC
Re: [Puppet Users] Re: How to check service status to write monit snippet.
Hi, that''s actually a sound implementation. Try this for debugging: $comma_separated_list = inline_template(" <%= scope.lookupvar("::monit::services") * '', '' %>") notify { "Services list: $comma_separated_list": } Inside a class, not inside the defined type. Cheers, Felix On 02/25/2013 03:52 PM, eduardo wrote:> Thanks felix, > I''m trying to do a validator for monit module. > I''m pretending down services are not controlled by monit, avoiding > false alarm from monit service. > > I was work around with something like : > > class monit($services) { > > include monit::checkservice, > monit::snippet > > monit::checkservice::checksrv{ $::monit::services : } > > ------ > > class monit::checkservice { > define checksrv { > notify { "Checking service $name":} > service { $name: > noop => true, > hasstatus => false, > status => "/usr/local/bin/check_service.sh ${name}", > } > } > } > > where $services is array of services from ENC. > But it have been unsuccessfully. I can see notifies messages foreach > element from array but status script is not executed like i expected > foreach item.-- 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.
Jakov Sosic
2013-Jul-22 12:51 UTC
Re: [Puppet Users] How to check service status to write monit snippet.
On 02/23/2013 06:33 PM, eduardo wrote:> Hi all. > I''m working on monit module. I have an array of services to configure > monit via ENC. > I need a consistent module logic so services arriving as input > parameter must running on node agent. > > I''m trying to find out if there is services running to configure monit > snippets. > So, The snippet will be only written into /etc/monit/conf.d when > service is running. > > Let''s say an input parameter like : > > services => [''ntp'',''ssh''] > > But ntp service is not running. In that case I need the snippet for > ''ntp'' service not be written on conf.d > > Is there simple way to do it ?.Either you write your own facts that state if the service is running, or use exported resources from modules that manage services. First method isn''t bullet proof, because if services are not running and they are supposed to, monit checks won''t be activated in the first place. Second method forces other modules to add support to your specific monit module implementation, so module won''t be reusable. But I would go the latter path. -- 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. For more options, visit https://groups.google.com/groups/opt_out.