NRPE 和 $USER1$ 变量

Tim*_*ham 5 nagios puppet nrpe

我的所有远程 Linux 机器上都运行着 NRPE 守护进程。我有几个配置,我正在尝试标准化我的 nrpe.cfg 中的路径。这些更改是通过 Puppet 部署的。

我想使用以下语法:

command[mycommand]=$USER1$/check_tcp .. etc.
Run Code Online (Sandbox Code Playgroud)

$USER1$ 变量在我的 NRPE 设置中不可用。我可以为所有变体编写 Puppet 模板,但我更愿意通过本机方法来管理它。有什么办法可以这样做吗?如果没有,是否有人拥有可以解决此问题的示例 Puppet 配置?

qua*_*nta 9

我可以为所有变体编写 Puppet 模板,但我更愿意通过本机方法来管理它。

$USERn$是 Nagios 的标准宏。它们在resource.cfg文件中定义:

# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/local/nagios/libexec

# Sets $USER2$ to be the path to event handlers
#$USER2$=/usr/local/nagios/libexec/eventhandlers
Run Code Online (Sandbox Code Playgroud)

这个文件包含在主配置中:

# This is an optional resource file that contains $USERx$ macro
# definitions. Multiple resource files can be specified by using
# multiple resource_file definitions.  The CGIs will not attempt to
# read the contents of resource files, so information that is
resource_file=/usr/local/nagios/etc/resource.cfg
Run Code Online (Sandbox Code Playgroud)

AFAIK,你不能在远程主机上使用它, NRPE


Tim*_*ham 1

我整理了一个满足我的需求的自定义事实。我还尝试了一个可以应用拱门的小开关,但它不是跨平台的。

lib/facter/nrpe.rb

file = File.open("/etc/nagios/resource.cfg" , "r" )
while ( line = file.gets )
  if  /^\$USER1\$=(.*)/ =~ line
    matched="#{$1}"
  end
end
file.close
Facter.add("nrpe") do
  setcode do
    matched
  end
end
Run Code Online (Sandbox Code Playgroud)