2008-06-06 11:13:16 +02:00
|
|
|
{config, pkgs}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2008-06-09 00:21:56 +02:00
|
|
|
cfg = config.services.zabbixAgent;
|
|
|
|
|
2008-06-06 11:13:16 +02:00
|
|
|
stateDir = "/var/run/zabbix";
|
|
|
|
|
|
|
|
logDir = "/var/log/zabbix";
|
|
|
|
|
|
|
|
pidFile = "${stateDir}/zabbix_agentd.pid";
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "zabbix_agentd.conf" ''
|
2008-06-09 00:21:56 +02:00
|
|
|
Server = ${cfg.server}
|
2008-06-06 11:13:16 +02:00
|
|
|
|
|
|
|
LogFile = ${logDir}/zabbix_agentd
|
|
|
|
|
|
|
|
PidFile = ${pidFile}
|
|
|
|
|
2008-06-06 14:38:40 +02:00
|
|
|
StartAgents = 5
|
2008-06-06 11:13:16 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "zabbix-agent";
|
|
|
|
|
|
|
|
users = [
|
|
|
|
{ name = "zabbix";
|
|
|
|
uid = (import ../system/ids.nix).uids.zabbix;
|
|
|
|
description = "Zabbix daemon user";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
job = ''
|
2008-09-12 18:31:39 +02:00
|
|
|
start on network-interfaces/started
|
|
|
|
stop on network-interfaces/stop
|
|
|
|
|
2008-06-06 11:13:16 +02:00
|
|
|
description "Zabbix agent daemon"
|
|
|
|
|
|
|
|
start script
|
|
|
|
mkdir -m 0755 -p ${stateDir} ${logDir}
|
|
|
|
chown zabbix ${stateDir} ${logDir}
|
|
|
|
|
|
|
|
export PATH=${pkgs.nettools}/bin:$PATH
|
|
|
|
${pkgs.zabbixAgent}/sbin/zabbix_agentd --config ${configFile}
|
|
|
|
end script
|
|
|
|
|
|
|
|
respawn sleep 100000
|
|
|
|
|
|
|
|
stop script
|
|
|
|
# !!! 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
|
|
|
|
end script
|
|
|
|
'';
|
|
|
|
|
|
|
|
}
|