Convert "nagios" upstart-job to the fix-style.
svn path=/nixos/branches/fix-style/; revision=13375
This commit is contained in:
parent
a63ea50ee9
commit
afe160c6b2
@ -2150,53 +2150,6 @@ in
|
||||
};
|
||||
|
||||
|
||||
nagios = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to use <link
|
||||
xlink:href='http://www.nagios.org/'>Nagios</link> to monitor
|
||||
your system or network.
|
||||
";
|
||||
};
|
||||
|
||||
objectDefs = mkOption {
|
||||
description = "
|
||||
A list of Nagios object configuration files that must define
|
||||
the hosts, host groups, services and contacts for the
|
||||
network that you want Nagios to monitor.
|
||||
";
|
||||
};
|
||||
|
||||
plugins = mkOption {
|
||||
default = [pkgs.nagiosPluginsOfficial pkgs.ssmtp];
|
||||
description = "
|
||||
Packages to be added to the Nagios <envar>PATH</envar>.
|
||||
Typically used to add plugins, but can be anything.
|
||||
";
|
||||
};
|
||||
|
||||
enableWebInterface = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the Nagios web interface. You should also
|
||||
enable Apache (<option>services.httpd.enable</option>).
|
||||
";
|
||||
};
|
||||
|
||||
urlPath = mkOption {
|
||||
default = "/nagios";
|
||||
description = "
|
||||
The URL path under which the Nagios web interface appears.
|
||||
That is, you can access the Nagios web interface through
|
||||
<literal>http://<replaceable>server</replaceable>/<replaceable>urlPath</replaceable></literal>.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
mysql = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
@ -3082,6 +3035,7 @@ root ALL=(ALL) SETENV: ALL
|
||||
(import ../upstart-jobs/pcmcia.nix)
|
||||
|
||||
# services
|
||||
(import ../upstart-jobs/nagios/default.nix)
|
||||
(import ../upstart-jobs/zabbix-agent.nix)
|
||||
(import ../upstart-jobs/zabbix-server.nix)
|
||||
(import ../upstart-jobs/disnix.nix)
|
||||
|
@ -412,12 +412,6 @@ let
|
||||
gpmConfig = config.services.gpm;
|
||||
})
|
||||
|
||||
# Nagios system/network monitoring daemon.
|
||||
++ optional config.services.nagios.enable
|
||||
(import ../upstart-jobs/nagios {
|
||||
inherit config pkgs;
|
||||
})
|
||||
|
||||
# Postfix mail server.
|
||||
++ optional config.services.postfix.enable
|
||||
(import ../upstart-jobs/postfix.nix {
|
||||
|
@ -1,6 +1,64 @@
|
||||
# Nagios system/network monitoring daemon.
|
||||
{config, pkgs}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption;
|
||||
|
||||
options = {
|
||||
services = {
|
||||
nagios = {
|
||||
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to use <link
|
||||
xlink:href='http://www.nagios.org/'>Nagios</link> to monitor
|
||||
your system or network.
|
||||
";
|
||||
};
|
||||
|
||||
objectDefs = mkOption {
|
||||
description = "
|
||||
A list of Nagios object configuration files that must define
|
||||
the hosts, host groups, services and contacts for the
|
||||
network that you want Nagios to monitor.
|
||||
";
|
||||
};
|
||||
|
||||
plugins = mkOption {
|
||||
default = [pkgs.nagiosPluginsOfficial pkgs.ssmtp];
|
||||
description = "
|
||||
Packages to be added to the Nagios <envar>PATH</envar>.
|
||||
Typically used to add plugins, but can be anything.
|
||||
";
|
||||
};
|
||||
|
||||
enableWebInterface = mkOption {
|
||||
default = false;
|
||||
description = "
|
||||
Whether to enable the Nagios web interface. You should also
|
||||
enable Apache (<option>services.httpd.enable</option>).
|
||||
";
|
||||
};
|
||||
|
||||
urlPath = mkOption {
|
||||
default = "/nagios";
|
||||
description = "
|
||||
The URL path under which the Nagios web interface appears.
|
||||
That is, you can access the Nagios web interface through
|
||||
<literal>http://<replaceable>server</replaceable>/<replaceable>urlPath</replaceable></literal>.
|
||||
";
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
###### implementation
|
||||
let
|
||||
cfg = config.services.nagios;
|
||||
|
||||
nagiosUser = "nagios";
|
||||
nagiosGroup = "nogroup";
|
||||
@ -13,7 +71,7 @@ let
|
||||
./host-templates.cfg
|
||||
./service-templates.cfg
|
||||
./commands.cfg
|
||||
] ++ config.services.nagios.objectDefs;
|
||||
] ++ cfg.objectDefs;
|
||||
|
||||
nagiosObjectDefsDir = pkgs.runCommand "nagios-objects" {inherit nagiosObjectDefs;}
|
||||
"ensureDir $out; ln -s $nagiosObjectDefs $out/";
|
||||
@ -53,7 +111,7 @@ let
|
||||
url_html_path=/nagios
|
||||
";
|
||||
|
||||
urlPath = config.services.nagios.urlPath;
|
||||
urlPath = cfg.urlPath;
|
||||
|
||||
extraHttpdConfig = "
|
||||
ScriptAlias ${urlPath}/cgi-bin ${pkgs.nagios}/sbin
|
||||
@ -76,31 +134,15 @@ let
|
||||
</Directory>
|
||||
";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
name = "nagios";
|
||||
|
||||
users = [
|
||||
{ name = nagiosUser;
|
||||
user = {
|
||||
name = nagiosUser;
|
||||
uid = (import ../../system/ids.nix).uids.nagios;
|
||||
description = "Nagios monitoring daemon";
|
||||
home = nagiosState;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
extraPath = [pkgs.nagios];
|
||||
|
||||
# This isn't needed, it's just so that the user can type "nagiostats
|
||||
# -c /etc/nagios.cfg".
|
||||
extraEtc = [
|
||||
{ source = nagiosCfgFile;
|
||||
target = "nagios.cfg";
|
||||
}
|
||||
];
|
||||
|
||||
extraHttpdConfig =
|
||||
if config.services.nagios.enableWebInterface then extraHttpdConfig else "";
|
||||
job = {
|
||||
name = "nagios";
|
||||
|
||||
# Run `nagios -v' to check the validity of the configuration file so
|
||||
# that a nixos-rebuild fails *before* we kill the running Nagios
|
||||
@ -127,5 +169,45 @@ in
|
||||
exec ${pkgs.nagios}/bin/nagios ${nagiosCfgFile}
|
||||
end script
|
||||
";
|
||||
};
|
||||
|
||||
ifEnable = pkgs.lib.ifEnable cfg.enable;
|
||||
in
|
||||
|
||||
{
|
||||
require = [
|
||||
(import ../../upstart-jobs/default.nix) # config.services.extraJobs
|
||||
# (import ../../system/user.nix) # users = { .. }
|
||||
# (import ?) # config.environment.etc
|
||||
# (import ?) # config.environment.extraPackages
|
||||
# (import ../../upstart-jobs/httpd.nix) # config.services.httpd
|
||||
options
|
||||
];
|
||||
|
||||
environment = {
|
||||
# This isn't needed, it's just so that the user can type "nagiostats
|
||||
# -c /etc/nagios.cfg".
|
||||
etc = ifEnable [
|
||||
{ source = nagiosCfgFile;
|
||||
target = "nagios.cfg";
|
||||
}
|
||||
];
|
||||
|
||||
extraPackages = ifEnable [pkgs.nagios];
|
||||
};
|
||||
|
||||
users = {
|
||||
extraUsers = ifEnable [user];
|
||||
};
|
||||
|
||||
services = {
|
||||
extraJobs = ifEnable [job];
|
||||
|
||||
httpd = {
|
||||
extraConfig = # ifEnable does not handle strings yet.
|
||||
if cfg.enable && cfg.enableWebInterface
|
||||
then extraHttpdConfig
|
||||
else "";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user