0

I have a Nagios NRPE module in my Puppet environment.

In the nrpe.cfg template I've configured some if statements in order to set specific checks to specific hosts.

Example:

<% if @hostname =~ /rs\d+/ -%> 
command[check_smtp]=/usr/lib64/nagios/plugins/check_smtp -H rs01.company.com -p 25 -e rs01.company.com 
<% end -%> 

Meaning: If hostname starts with chars rs followed by a digit then apply the check commands in the if statement block.

I want change the check to something like this:

command[check_smtp]=/usr/lib64/nagios/plugins/check_smtp -H @hostname -p 25 -e @hostname

But the problem is that @hostname is a ruby variable and the check command is written in bash.

How can I achieve my goal?

1 Answer 1

1
<% if @hostname =~ /rs\d+/ -%> 
command[check_smtp]=/usr/lib64/nagios/plugins/check_smtp -H <%= @hostname -%> -p 25 -e <%= @hostname -%>
<% end -%> 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.