curl check_http nagios插件

curlnagios的Python项目详细描述


标题1

检查URL如果发现问题,则发出警报。 使用curl及其所有功能,因此您可以使用所有curl选项扩展检查范围。

VERSION

安装

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}。 添加您的客户机密

这来自使用标记的文档:https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-access-token

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

待办事项

  • 使用哈希密码
  • 添加单元测试?

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有x86javapath的x64机器上x86java上的java JNI未满足链接错误   java将Pixmap的一部分上传到GPU   图像Java位图RLE8格式   java Android studio谷歌广告崩溃应用程序   java如何创建包含未知数量对象的变量?   Java计算给定int数组的所有可能组合   java JDBC classnotfound异常   httpclient中的java将HttpEntity转换为字符串的最优雅/正确的方法是什么?   如何从Java程序运行nano?   java在安卓中调用自定义类/方法   调用方法和JOptionPane后,允许代码继续执行所需的java计时器或其他想法   关于侦听器的向量Java并发问题   线程池执行器Java线程池   java配置DTO上的Swagger javax验证约束   Java中用于按钮功能的swing操作命令   ServletOutputStream中的java设置状态代码   java打印输入数组的平均值