Sensu

使用 sensu-install 是否有意義,因為它不會在 /etc/sensu/plugins 目錄中部署檢查?

  • May 9, 2020
[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 外掛似乎沒有安裝在 plugins 目錄中。

[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

簡潔的

是的,使用 是有意義的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 外掛命令的“相對路徑”;

例如:“命令”:“檢查-http.rb -u https://sensuapp.org

sensu-install命令修改了,$PATH以便 Sensu 可以通過定義檢查來找到檢查,例如,check-http.rb而不是完整路徑,例如/opt/sensu/embedded/bin/check-http.rb

引用自:https://serverfault.com/questions/797613