Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 在Nagios中将主机可用性提取到外部网页_Linux_Api_Monitoring_Nagios - Fatal编程技术网

Linux 在Nagios中将主机可用性提取到外部网页

Linux 在Nagios中将主机可用性提取到外部网页,linux,api,monitoring,nagios,Linux,Api,Monitoring,Nagios,是否有任何可能的方法从Nagios监控工具(已配置主机/主机组)获取主机/主机组的实时可用性,该工具可以重定向/捕获到外部网页。 是否有任何公开的API可以做到这一点,但找不到方法。 Nagios在Linux主机上。 欢迎提供任何帮助或信息 编辑1: 我有一个主机组,例如'All_prod',在这个主机组中,我将拥有大约20台linux主机,所有主机都将定义一些度量/检查(例如可用性、cpu负载、可用内存等)。在这里,我只想报告所有主机的可用性指标(例如:假设在24小时内,如果可用性下降10分钟

是否有任何可能的方法从Nagios监控工具(已配置主机/主机组)获取主机/主机组的实时可用性,该工具可以重定向/捕获到外部网页。 是否有任何公开的API可以做到这一点,但找不到方法。 Nagios在Linux主机上。 欢迎提供任何帮助或信息

编辑1:

我有一个主机组,例如'All_prod',在这个主机组中,我将拥有大约20台linux主机,所有主机都将定义一些度量/检查(例如可用性、cpu负载、可用内存等)。在这里,我只想报告所有主机的可用性指标(例如:假设在24小时内,如果可用性下降10分钟,那么它应该向我提供报告,因为它在24小时内下降了10分钟,或者只给我任何相关信息,我可以使用数据评估进行评估)。
如果有任何API来获取这些信息,将以json/xml的形式返回数据,那就太好了。

您可以使用Nagios json API。您可以在此处使用查询生成器

但是,为了回答您的特定问题,对主机的查询如下所示:

将输出类似于以下内容的内容:

{
    "format_version": 0,
    "result": {
        "query_time": 1497384499000,
        "cgi": "statusjson.cgi",
        "user": "nagiosadmin",
        "query": "host",
        "query_status": "released",
        "program_start": 1497368240000,
        "last_data_update": 1497384489000,
        "type_code": 0,
        "type_text": "Success",
        "message": ""
    },
    "data": {
        "host": {
            "name": "localhost",
            "plugin_output": "egsdda",
            "long_plugin_output": "",
            "perf_data": "",
            "status": 8,
            "last_update": 1497384489000,
            "has_been_checked": true,
            "should_be_scheduled": false,
            "current_attempt": 10,
            "max_attempts": 10,
            "last_check": 1496158536000,
            "next_check": 0,
            "check_options": 0,
            "check_type": 1,
            "last_state_change": 1496158536000,
            "last_hard_state_change": 1496158536000,
            "last_hard_state": 1,
            "last_time_up": 1496158009000,
            "last_time_down": 1496158536000,
            "last_time_unreachable": 1480459504000,
            "state_type": 1,
            "last_notification": 1496158536000,
            "next_notification": 1496165736000,
            "no_more_notifications": false,
            "notifications_enabled": true,
            "problem_has_been_acknowledged": false,
            "acknowledgement_type": 0,
            "current_notification_number": 2,
            "accept_passive_checks": true,
            "event_handler_enabled": true,
            "checks_enabled": false,
            "flap_detection_enabled": true,
            "is_flapping": false,
            "percent_state_change": 0,
            "latency": 0.49,
            "execution_time": 0,
            "scheduled_downtime_depth": 0,
            "process_performance_data": true,
            "obsess": true
        }
    }
}
{
  "format_version": 0,
  "result": {
    "query_time": 1497384613000,
    "cgi": "statusjson.cgi",
    "user": "nagiosadmin",
    "query": "hostlist",
    "query_status": "released",
    "program_start": 1497368240000,
    "last_data_update": 1497384609000,
    "type_code": 0,
    "type_text": "Success",
    "message": ""
  },
  "data": {
    "selectors": {
      "hostgroup": "linux-servers"
    },
    "hostlist": {
      "localhost": 8
    }
  }
}
对于主机组:

将输出类似于以下内容的内容:

{
    "format_version": 0,
    "result": {
        "query_time": 1497384499000,
        "cgi": "statusjson.cgi",
        "user": "nagiosadmin",
        "query": "host",
        "query_status": "released",
        "program_start": 1497368240000,
        "last_data_update": 1497384489000,
        "type_code": 0,
        "type_text": "Success",
        "message": ""
    },
    "data": {
        "host": {
            "name": "localhost",
            "plugin_output": "egsdda",
            "long_plugin_output": "",
            "perf_data": "",
            "status": 8,
            "last_update": 1497384489000,
            "has_been_checked": true,
            "should_be_scheduled": false,
            "current_attempt": 10,
            "max_attempts": 10,
            "last_check": 1496158536000,
            "next_check": 0,
            "check_options": 0,
            "check_type": 1,
            "last_state_change": 1496158536000,
            "last_hard_state_change": 1496158536000,
            "last_hard_state": 1,
            "last_time_up": 1496158009000,
            "last_time_down": 1496158536000,
            "last_time_unreachable": 1480459504000,
            "state_type": 1,
            "last_notification": 1496158536000,
            "next_notification": 1496165736000,
            "no_more_notifications": false,
            "notifications_enabled": true,
            "problem_has_been_acknowledged": false,
            "acknowledgement_type": 0,
            "current_notification_number": 2,
            "accept_passive_checks": true,
            "event_handler_enabled": true,
            "checks_enabled": false,
            "flap_detection_enabled": true,
            "is_flapping": false,
            "percent_state_change": 0,
            "latency": 0.49,
            "execution_time": 0,
            "scheduled_downtime_depth": 0,
            "process_performance_data": true,
            "obsess": true
        }
    }
}
{
  "format_version": 0,
  "result": {
    "query_time": 1497384613000,
    "cgi": "statusjson.cgi",
    "user": "nagiosadmin",
    "query": "hostlist",
    "query_status": "released",
    "program_start": 1497368240000,
    "last_data_update": 1497384609000,
    "type_code": 0,
    "type_text": "Success",
    "message": ""
  },
  "data": {
    "selectors": {
      "hostgroup": "linux-servers"
    },
    "hostlist": {
      "localhost": 8
    }
  }
}
希望这有帮助

编辑1(与问题的编辑1相对应):

默认情况下,您所要求的不是内置的。您可以使用上面的方法获取每个主机的数据(但听起来好像每个服务都需要数据),因此我们将再次使用位于的JSON API获取服务数据

我们将获得以下输出(无论如何,类似的输出):

您要做的最重要的一行(据我所知)是perfdata行:

"perf_data": "load1=0.000;5.000;10.000;0; load5=0.000;4.000;6.000;0; load15=0.000;3.000;4.000;0;",
这是您用来生成任何您试图生成的自定义度量报告的数据

请记住,这是一种内置于NigiOS席的东西(不是像你所要求的可导出格式),但是度量组件允许你轻松地钻取并查看一些度量特定的数据。
希望这有帮助

谢谢你的回答,但我的问题是关于主机的可用性。例如,如果主机组“ubuntu12.04”中有一台linux主机,那么我会通过任何查询获得同一主机的可用性状态吗?您是否询问该主机的状态?比如,它是向上还是向下?如果没有,你能说得更具体一点吗?好的,这是我编辑问题(编辑1)并提供示例案例的场景。编辑1应该反映出一个适当的答案。感谢详细的解释,它提供了一个很好的见解,但问题是我们需要服务状态为“关闭/打开”时的timelog数据