icinga2监视器正在运行linux服务

时间:2017-09-28 05:25:36

标签: linux service centos7 monitor icinga2

我有一台运行Plex的服务器以及我希望用Icinga2监控的其他两项服​​务,对于我的生活,我无法弄清楚如何让它工作。如果我运行以下命令:

./check_procs -c 1:1 -a '/usr/lib/plexmediaserver/Plex Media Server'

当我手动杀死Plex时返回以下内容:

PROCS CRITICAL: 0 processes with args '/usr/lib/plexmediaserver/Plex Media Server' | procs=0;;1:1;0;

我无法弄清楚如何将此检查添加到服务器..我在哪里放?

我尝试在/etc/icinga2/conf.d/services.conf中添加另一个声明,如下所示:

apply Service "procs" 
    {
        import "generic-service"

        check_command = "procs"

        assign where host.name == NodeName

        arguments = 
        {
            "-a" = 
            {
              value = "/usr/lib/plexmediaserver/Plex Media Server"
              description = "service name"
              required = true
            }
        }
    }

但是代理人根本不会开始。

2 个答案:

答案 0 :(得分:0)

我正在运行一小群Raspberry Pi,我正在用Icinga2进行监控。在我的集群的主节点上,我运行了一个dhcp服务器。我按照以下方式检查它的状态。

首先我从Icinga Exchange下载了check service status plugin,使其可执行并将其移至/ usr / lib / nagios / plugins(您的路径可能不同)。

然后我为它定义了一个检查命令:

object CheckCommand "Check Service" {
import "plugin-check-command"
command = [ PluginDir + "/check_service.sh" ]
arguments += {
    "-o" = {
        required = true
        value = "$check_service_os$"
    }
    "-s" = {
        required = true
        value = "$check_service_name$"
    }
}
}

现在剩下的就是定义服务:

object Service "Check DHCP" {
host_name = "Localhost"
check_command = "Check Service"
enable_perfdata = true
event_command = "Restart DHCP"
vars.check_service_name = "isc-dhcp-server"
vars.check_service_os = "linux"
}

作为奖励,您甚至可以定义重启服务的事件命令:

object EventCommand "Restart DHCP" {
    import "plugin-event-command"
    command = [ "/usr/bin/sudo", "systemctl", "restart" ]
    arguments += {
        "(no key)" = {
            skip_key = true
            value = "$check_service_name$"
        }
    }
    vars.check_service_name = "isc-dhcp-server"
}

但要使其工作,您必须为您的nagios用户(或任何用户运行您的icinga服务)sudo权限重新启动服务。将此行添加到您的sudoers文件中:

nagios ALL = (ALL) NOPASSWD: /bin/systemctl restart *

我希望这可以帮助您解决问题: - )

答案 1 :(得分:0)

我通过定义服务解决了这个问题:

AttributeError: 'Ui_MainWindow' object has no attribute '_index'

然后在主机定义中,我只添加一个配置,例如apply Service for (service => config in host.vars.processes_linux) { import "generic-service" check_command = "nrpe" display_name = config.display_name vars.nrpe_command = "check_process" vars.nrpe_arguments = [ config.process, config.warn_range, config.crit_range ] }

mongodb

在远程主机上,我需要安装软件包vars.processes_linux["trench-srv-lin-process-mongodb"] = { display_name = "MongoDB processes" process = "mongod" warn_range = "1:" crit_range = "1:" }

然后在配置文件nagios-nrpe-server中添加以下行:

/etc/nagios/nrpe_local.cfg