Use the new scheme for zabbix upstart-job.
svn path=/nixos/branches/fix-style/; revision=13329
This commit is contained in:
parent
3a25babf1b
commit
9c751d377d
@ -2322,35 +2322,6 @@ in
|
||||
};
|
||||
|
||||
|
||||
zabbixAgent = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to run the Zabbix monitoring agent on this machine.
|
||||
It will send monitoring data to a Zabbix server.
|
||||
";
|
||||
};
|
||||
|
||||
server = mkOption {
|
||||
default = "127.0.0.1";
|
||||
description = ''
|
||||
The IP address or hostname of the Zabbix server to connect to.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
zabbixServer = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to run the Zabbix server on this machine.
|
||||
";
|
||||
};
|
||||
};
|
||||
|
||||
postfix = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
@ -3111,6 +3082,8 @@ root ALL=(ALL) SETENV: ALL
|
||||
(import ../upstart-jobs/pcmcia.nix)
|
||||
|
||||
# services
|
||||
(import ../upstart-jobs/zabbix-agent.nix)
|
||||
(import ../upstart-jobs/zabbix-server.nix.nix)
|
||||
(import ../upstart-jobs/disnix.nix)
|
||||
(import ../upstart-jobs/cron.nix)
|
||||
(import ../upstart-jobs/cron/locate.nix)
|
||||
|
@ -418,18 +418,6 @@ let
|
||||
inherit config pkgs;
|
||||
})
|
||||
|
||||
# Zabbix agent daemon.
|
||||
++ optional config.services.zabbixAgent.enable
|
||||
(import ../upstart-jobs/zabbix-agent.nix {
|
||||
inherit config pkgs;
|
||||
})
|
||||
|
||||
# Zabbix server daemon.
|
||||
++ optional config.services.zabbixServer.enable
|
||||
(import ../upstart-jobs/zabbix-server.nix {
|
||||
inherit config pkgs;
|
||||
})
|
||||
|
||||
# Postfix mail server.
|
||||
++ optional config.services.postfix.enable
|
||||
(import ../upstart-jobs/postfix.nix {
|
||||
|
@ -1,5 +1,35 @@
|
||||
# Zabbix agent daemon.
|
||||
{config, pkgs}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
zabbixAgent = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to run the Zabbix monitoring agent on this machine.
|
||||
It will send monitoring data to a Zabbix server.
|
||||
";
|
||||
};
|
||||
|
||||
server = mkOption {
|
||||
default = "127.0.0.1";
|
||||
description = ''
|
||||
The IP address or hostname of the Zabbix server to connect to.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
let
|
||||
|
||||
cfg = config.services.zabbixAgent;
|
||||
@ -20,44 +50,59 @@ let
|
||||
StartAgents = 5
|
||||
'';
|
||||
|
||||
user = {
|
||||
name = "zabbix";
|
||||
uid = (import ../system/ids.nix).uids.zabbix;
|
||||
description = "Zabbix daemon user";
|
||||
};
|
||||
|
||||
job = {
|
||||
name = "zabbix-agent";
|
||||
|
||||
job = ''
|
||||
start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
ifEnable = pkgs.lib.ifEnable cfg.enable;
|
||||
in
|
||||
|
||||
{
|
||||
name = "zabbix-agent";
|
||||
|
||||
users = [
|
||||
{ name = "zabbix";
|
||||
uid = (import ../system/ids.nix).uids.zabbix;
|
||||
description = "Zabbix daemon user";
|
||||
}
|
||||
require = [
|
||||
(import ../upstart-jobs/default.nix)
|
||||
# (import ../system/user.nix) # users = { .. }
|
||||
options
|
||||
];
|
||||
|
||||
job = ''
|
||||
start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
|
||||
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
|
||||
'';
|
||||
services = {
|
||||
extraJobs = ifEnable [job];
|
||||
};
|
||||
|
||||
users = {
|
||||
extraUsers = ifEnable [user];
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,25 @@
|
||||
# Zabbix server daemon.
|
||||
{config, pkgs}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
zabbixServer = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to run the Zabbix server on this machine.
|
||||
";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
let
|
||||
|
||||
stateDir = "/var/run/zabbix";
|
||||
@ -20,46 +40,62 @@ let
|
||||
DBUser = zabbix
|
||||
'';
|
||||
|
||||
user = {
|
||||
name = "zabbix";
|
||||
uid = (import ../system/ids.nix).uids.zabbix;
|
||||
description = "Zabbix daemon user";
|
||||
};
|
||||
|
||||
job = {
|
||||
name = "zabbix-server";
|
||||
|
||||
job = ''
|
||||
description "Zabbix server daemon"
|
||||
|
||||
start on postgresql/started
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
mkdir -m 0755 -p ${stateDir} ${logDir} ${libDir}
|
||||
chown zabbix ${stateDir} ${logDir} ${libDir}
|
||||
|
||||
if ! test -e "${libDir}/db-created"; then
|
||||
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true
|
||||
${pkgs.postgresql}/bin/createdb --owner zabbix zabbix || true
|
||||
cat ${pkgs.zabbixServer}/share/zabbix/db/schema/postgresql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
||||
cat ${pkgs.zabbixServer}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
||||
cat ${pkgs.zabbixServer}/share/zabbix/db/data/images_pgsql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
||||
touch "${libDir}/db-created"
|
||||
fi
|
||||
|
||||
export PATH=${pkgs.nettools}/bin:$PATH
|
||||
${pkgs.zabbixServer}/sbin/zabbix_server --config ${configFile}
|
||||
end script
|
||||
|
||||
respawn sleep 100000
|
||||
|
||||
stop script
|
||||
while ${pkgs.procps}/bin/pkill -u zabbix zabbix_server; do true; done
|
||||
end script
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
ifEnable = pkgs.lib.ifEnable config.services.zabbixServer.enable
|
||||
in
|
||||
|
||||
{
|
||||
name = "zabbix-server";
|
||||
|
||||
users = [
|
||||
{ name = "zabbix";
|
||||
uid = (import ../system/ids.nix).uids.zabbix;
|
||||
description = "Zabbix daemon user";
|
||||
}
|
||||
require = [
|
||||
(import ../upstart-jobs/default.nix)
|
||||
# (import ../system/user.nix) # users = { .. }
|
||||
options
|
||||
];
|
||||
|
||||
job = ''
|
||||
description "Zabbix server daemon"
|
||||
|
||||
start on postgresql/started
|
||||
stop on shutdown
|
||||
|
||||
start script
|
||||
mkdir -m 0755 -p ${stateDir} ${logDir} ${libDir}
|
||||
chown zabbix ${stateDir} ${logDir} ${libDir}
|
||||
|
||||
if ! test -e "${libDir}/db-created"; then
|
||||
${pkgs.postgresql}/bin/createuser --no-superuser --no-createdb --no-createrole zabbix || true
|
||||
${pkgs.postgresql}/bin/createdb --owner zabbix zabbix || true
|
||||
cat ${pkgs.zabbixServer}/share/zabbix/db/schema/postgresql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
||||
cat ${pkgs.zabbixServer}/share/zabbix/db/data/data.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
||||
cat ${pkgs.zabbixServer}/share/zabbix/db/data/images_pgsql.sql | ${pkgs.su}/bin/su -s "$SHELL" zabbix -c 'psql zabbix'
|
||||
touch "${libDir}/db-created"
|
||||
fi
|
||||
|
||||
export PATH=${pkgs.nettools}/bin:$PATH
|
||||
${pkgs.zabbixServer}/sbin/zabbix_server --config ${configFile}
|
||||
end script
|
||||
|
||||
respawn sleep 100000
|
||||
|
||||
stop script
|
||||
while ${pkgs.procps}/bin/pkill -u zabbix zabbix_server; do true; done
|
||||
end script
|
||||
'';
|
||||
services = {
|
||||
extraJobs = ifEnable [job];
|
||||
};
|
||||
|
||||
users = {
|
||||
extraUsers = ifEnable [user];
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user