curl check_http nagios插件
curlnagios的Python项目详细描述
安装
Linux:
sudo pip3 install curlnagios --upgrade
也可以使用:
sudo python3 -m pip install curlnagios --upgrade
在带有python3.5的Windows上:
pip install curlnagios --upgrade
代理添加:
--proxy='http://user:passw@server:port'
用法
使用命令行:
> curlnagios --help usage: curlnagios [-h] [-u [URL]] [-e [EXTRA_ARGS]] optional arguments: -h, --help show this help message and exit -u [URL], --url [URL] url to check -e [EXTRA_ARGS], --extra_args [EXTRA_ARGS] extra args to add to curl, see `curl manpage <https://curl.haxx.se/docs/manpage.html>`_.
示例用法
与代理一起使用的示例:
> curlnagios --url='http://xx/dd' --extra_args='--proxy http://user:pass@host:8080'
使用代理和NTlm验证网站的示例:
> curlnagios –url=’http://xx/dd’ –extra_args=’–proxy http://user:pass@host:8080 –user user:pass –ntlm’
所有额外的参数都是从curl手册页直接提交的选项,您几乎可以使用任何 除了-s,-o,-w这些 隐式添加在curl命令行参数上以格式化此插件的输出。
使用azuread oauth2的示例
使用azure ad oauth2创建身份验证时,需要创建客户端应用程序和azure只读应用程序:
https://apps.dev.microsoft.com/#/appList
然后使用:
> curlnagios –url ‘https://{yoururltotest}/api/path’ –client_id ‘unique-client-id’ –scope ‘https://{tenant}/unique-id-here-for-the-app/.default’ –client_secret ‘theclientoken’ –grant_type ‘client_credentials’ –auth_url ‘https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token’ –oauth2
用您的标识符和客户机和应用程序的唯一id更改{tenant}。 添加您的客户机密
Nagios配置
命令示例:
define command{ command_name check_http_curl command_line /usr/local/bin/curlnagios --url='$ARG1$' --extra_args='$ARG2$' } define command{ command_name check_http_curl_azuread command_line /usr/local/bin/curlnagios --url='$ARG1$' --client_id '$ARG2$' --scope '$ARG3$' --client_secret '$ARG4$' --auth_url 'https://login.microsoftonline.com/$ARG5$/oauth2/v2.0/token' --oauth2 --extra_args='$ARG6$' }
示例服务:
define service { host_name SERVERX service_description service_name check_command check_http_curl!http://url/path!--proxy http://user:name@host:8080 --user user:name --ntlm use generic-service notes some useful notes }
绕过反向代理、DNS和代理服务器的示例服务:
define service { host_name SERVERY service_description fqdn.backend1 check_command check_http_curl!http://192.168.10.10:80!--noproxy "192.168.10.10" -H "Host: fqdn.site.name" use generic-service notes Monitoring backend1 de of site fqdn.site.name } ## In this way you can connect to some backend and pass with -H the host header to get and also ensure no proxy used to connect to url.
使用azuread oauth2的示例:
define service { host_name SERVERY service_description fqdn.backend1 check_command check_http_curl_azuread!http://fqdn.site.name/api/xx!client-unique-id!https://{tenant}/unique-id-here-for-the-app/.default!client-secret-unique!tenant!some extra args if desired use generic-service notes Monitoring backend1 de of site fqdn.site.name }
您可以使用已经有安装和命令的ansible角色:https://github.com/CoffeeITWorks/ansible_nagios4_server_plugins
待办事项
- 使用哈希密码
- 添加单元测试?