summary refs log tree commit diff
path: root/modules/services/monitoring/zabbix-agent.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2010-02-15 17:13:43 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2010-02-15 17:13:43 +0000
commit014ffaac5d48f64073994b8644f659ee98c3023f (patch)
tree0eeb7bca93b6fab0480c3d1dad0785430a22a548 /modules/services/monitoring/zabbix-agent.nix
parent4253490fd44c664a24a507f2fc8dea80eab9561d (diff)
downloadnixpkgs-014ffaac5d48f64073994b8644f659ee98c3023f.tar
nixpkgs-014ffaac5d48f64073994b8644f659ee98c3023f.tar.gz
nixpkgs-014ffaac5d48f64073994b8644f659ee98c3023f.tar.bz2
nixpkgs-014ffaac5d48f64073994b8644f659ee98c3023f.tar.lz
nixpkgs-014ffaac5d48f64073994b8644f659ee98c3023f.tar.xz
nixpkgs-014ffaac5d48f64073994b8644f659ee98c3023f.tar.zst
nixpkgs-014ffaac5d48f64073994b8644f659ee98c3023f.zip
* Update the Zabbix agent module.
svn path=/nixos/trunk/; revision=20019
Diffstat (limited to 'modules/services/monitoring/zabbix-agent.nix')
-rw-r--r--modules/services/monitoring/zabbix-agent.nix29
1 files changed, 16 insertions, 13 deletions
diff --git a/modules/services/monitoring/zabbix-agent.nix b/modules/services/monitoring/zabbix-agent.nix
index 3691405e1e2..65bb2c3d417 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 ];
+
   };
 
 }