From 014ffaac5d48f64073994b8644f659ee98c3023f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 15 Feb 2010 17:13:43 +0000 Subject: [PATCH] * Update the Zabbix agent module. svn path=/nixos/trunk/; revision=20019 --- modules/services/monitoring/zabbix-agent.nix | 29 +++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/services/monitoring/zabbix-agent.nix b/modules/services/monitoring/zabbix-agent.nix index 3691405e1e2f..65bb2c3d4174 100644 --- a/modules/services/monitoring/zabbix-agent.nix +++ b/modules/services/monitoring/zabbix-agent.nix @@ -21,7 +21,7 @@ let PidFile = ${pidFile} - StartAgents = 5 + StartAgents = 1 ''; in @@ -65,7 +65,7 @@ in }; jobs.zabbix_agent = - { #name = "zabbix-agent"; !!! mkIf bug + { name = "zabbix-agent"; description = "Zabbix agent daemon"; @@ -76,24 +76,27 @@ in '' mkdir -m 0755 -p ${stateDir} ${logDir} chown zabbix ${stateDir} ${logDir} - + + # Grrr, zabbix_agentd cannot be properly monitored by + # Upstart. Upstart's "expect fork/daemon" feature doesn't + # work because zabbix_agentd runs some programs on + # startup, and zabbix_agentd doesn't have a flag to + # prevent daemonizing. export PATH=${pkgs.nettools}/bin:$PATH - ${pkgs.zabbixAgent}/sbin/zabbix_agentd --config ${configFile} + ${pkgs.zabbix.agent}/sbin/zabbix_agentd --config ${configFile} ''; postStop = - '' - # !!! this seems to leave processes behind. - #pid=$(cat ${pidFile}) - #if test -n "$pid"; then - # kill $pid - #fi - - # So instead kill the agent in a brutal fashion. - while ${pkgs.procps}/bin/pkill -u zabbix zabbix_agentd; do true; done + '' + pid=$(cat ${pidFile}) + test -n "$pid" && kill "$pid" + # Wait until they're really gone. + while ${pkgs.procps}/bin/pgrep -u zabbix zabbix_agentd > /dev/null; do sleep 1; done ''; }; + environment.systemPackages = [ pkgs.zabbix.agent ]; + }; }