使用“sensu-install”是否有意义,因为它不会在“/etc/sensu/plugins”目录中部署检查?

使用“sensu-install”是否有意义,因为它不会在“/etc/sensu/plugins”目录中部署检查?
[user@host ~]$ sudo sensu-install -p ansible
[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] determining if Sensu plugin gem 'sensu-plugins-ansible' is already installed ...
false
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-ansible"]
[SENSU-INSTALL] installing Sensu plugin gem 'sensu-plugins-ansible'
Fetching: sensu-plugins-ansible-0.0.4.gem (100%)
You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu
Successfully installed sensu-plugins-ansible-0.0.4
1 gem installed
[SENSU-INSTALL] successfully installed Sensu plugins: ["ansible"]

ansible 插件似乎没有安装在插件目录中。

[user@host ~]$ ls /etc/sensu/plugins
check-apache.rb

尝试解决问题

尝试一

[user@host ~]$ sudo -u sensu sensu-install -p ssl
[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] determining if Sensu plugin gem 'sensu-plugins-ssl' is already installed ...
false
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-ssl"]
[SENSU-INSTALL] installing Sensu plugin gem 'sensu-plugins-ssl'
Fetching: unf_ext-0.0.7.2.gem (100%)
ERROR:  While executing gem ... (Errno::ENOENT)
    No such file or directory @ rb_sysopen - /opt/sensu/.gem/ruby/2.3.0/cache/unf_ext-0.0.7.2.gem
[SENSU-INSTALL] failed to install Sensu plugin gem 'sensu-plugins-ssl'
[SENSU-INSTALL] you can run the sensu-install command again with --verbose for more info
[SENSU-INSTALL] please take note of any failure messages above
[SENSU-INSTALL] make sure you have build tools installed (e.g. gcc)
[SENSU-INSTALL] trying to determine the Sensu plugin homepage for sensu-plugins-ssl ...
homepage: https://github.com/sensu-plugins/sensu-plugins-ssl

第二次尝试

you can run the sensu-install command again with --verbose for more info按照上次尝试的建议,结果如下:

[user@host ~]$ sudo sensu-install -p http --verbose
[SENSU-INSTALL] installing Sensu plugins ...
[SENSU-INSTALL] provided Sensu plugins: ["http"]
[SENSU-INSTALL] compiled Sensu plugin gems: ["sensu-plugins-http"]
[SENSU-INSTALL] determining if Sensu plugin gem 'sensu-plugins-http' is already installed ...
[SENSU-INSTALL] gem list -i sensu-plugins-http
false
[SENSU-INSTALL] Sensu plugin gem 'sensu-plugins-http' has not been installed
[SENSU-INSTALL] Sensu plugin gems to be installed: ["sensu-plugins-http"]
[SENSU-INSTALL] installing Sensu plugin gem 'sensu-plugins-http'
[SENSU-INSTALL] gem install sensu-plugins-http --no-ri --no-rdoc --verbose
HEAD https://api.rubygems.org/api/v1/dependencies
200 OK
...
/opt/sensu/embedded/bin/metrics-http-json-deep.rb
/opt/sensu/embedded/bin/check-http-json.rb
/opt/sensu/embedded/bin/metrics-curl.rb
/opt/sensu/embedded/bin/check-last-modified.rb
/opt/sensu/embedded/bin/check-https-cert.rb
/opt/sensu/embedded/bin/check-http-cors.rb
/opt/sensu/embedded/bin/check-head-redirect.rb
/opt/sensu/embedded/bin/metrics-http-json.rb
/opt/sensu/embedded/bin/check-http.rb
You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu
Successfully installed sensu-plugins-http-1.0.0
13 gems installed
[SENSU-INSTALL] successfully installed Sensu plugins: ["http"]

插件已安装并且可以执行检查:

[user@host ~]$ /opt/sensu/embedded/bin/check-http.rb
CheckHttp UNKNOWN: No URL specified

答案1

简洁的

是的,使用是有意义的sensu-install,因为:

  1. 无需 git clone 和 copy 语句即可在/etc/sensu/plugins
  2. sensu-install命令修改路径,以便 sensu 可以找到插件

详细

尽管该sensu-install命令将检查安装在不同的目录中,但/etc/sensu/plugins对于运行插件来说,这并不是必需的。由于Sensu 插件文档表示:

注意:默认情况下,Sensu 安装程序包将修改 Sensu 进程的系统 $PATH 以包含 /etc/sensu/plugins。因此,位于 /etc/sensu/plugins 中的可执行脚本(例如插件)将是有效命令。这允许命令属性对 Sensu 插件命令使用“相对路径”;

例如:“命令”:“check-http.rb -uhttps://sensuapp.org

sensu-install命令进行了修改,$PATH以便 Sensu 可以通过定义检查来找到该检查,例如check-http.rb而不是完整路径,例如/opt/sensu/embedded/bin/check-http.rb

相关内容