···
} "mkdir -p $out; ln -s $nagiosObjectDefs $out/";
20
-
nagiosCfgFile = pkgs.writeText "nagios.cfg"
22
-
# Paths for state and logs.
23
-
log_file=${nagiosLogDir}/current
24
-
log_archive_path=${nagiosLogDir}/archive
25
-
status_file=${nagiosState}/status.dat
26
-
object_cache_file=${nagiosState}/objects.cache
27
-
temp_file=${nagiosState}/nagios.tmp
28
-
lock_file=/run/nagios.lock # Not used I think.
29
-
state_retention_file=${nagiosState}/retention.dat
30
-
query_socket=${nagiosState}/nagios.qh
31
-
check_result_path=${nagiosState}
32
-
command_file=${nagiosState}/nagios.cmd
34
-
# Configuration files.
35
-
#resource_file=resource.cfg
36
-
cfg_dir=${nagiosObjectDefsDir}
38
-
# Uid/gid that the daemon runs under.
43
-
illegal_macro_output_chars=`~$&|'"<>
44
-
retain_state_information=1
22
+
log_file="${nagiosLogDir}/current";
23
+
log_archive_path="${nagiosLogDir}/archive";
24
+
status_file="${nagiosState}/status.dat";
25
+
object_cache_file="${nagiosState}/objects.cache";
26
+
temp_file="${nagiosState}/nagios.tmp";
27
+
lock_file="/run/nagios.lock";
28
+
state_retention_file="${nagiosState}/retention.dat";
29
+
query_socket="${nagiosState}/nagios.qh";
30
+
check_result_path="${nagiosState}";
31
+
command_file="${nagiosState}/nagios.cmd";
32
+
cfg_dir="${nagiosObjectDefsDir}";
33
+
nagios_user="nagios";
34
+
nagios_group="nagios";
35
+
illegal_macro_output_chars="`~$&|'\"<>";
36
+
retain_state_information="1";
38
+
lines = mapAttrsToList (key: value: "${key}=${value}") (default // cfg.extraConfig);
39
+
content = concatStringsSep "\n" lines;
40
+
file = pkgs.writeText "nagios.cfg" content;
41
+
validated = pkgs.runCommand "nagios-checked.cfg" {preferLocalBuild=true;} ''
42
+
cp ${file} nagios.cfg
43
+
# nagios checks the existence of /var/lib/nagios, but
44
+
# it does not exists in the build sandbox, so we fake it
46
+
lib=$(readlink -f lib)
47
+
sed -i s@=${nagiosState}@=$lib@ nagios.cfg
48
+
${pkgs.nagios}/bin/nagios -v nagios.cfg && cp ${file} $out
50
+
defaultCfgFile = if cfg.validateConfig then validated else file;
52
+
if cfg.mainConfigFile == null then defaultCfgFile else cfg.mainConfigFile;
# Plain configuration for the Nagios web-interface with no
···
(mkRemovedOptionModule [ "services" "nagios" "urlPath" ] "The urlPath option has been removed as it is hard coded to /nagios in the nagios package.")
87
+
meta.maintainers = with lib.maintainers; [ symphorien ];
85
-
Whether to use <link
86
-
xlink:href='http://www.nagios.org/'>Nagios</link> to monitor
87
-
your system or network.
91
+
enable = mkEnableOption "<link xlink:href='http://www.nagios.org/'>Nagios</link> to monitor your system or network.";
···
the hosts, host groups, services and contacts for the
network that you want Nagios to monitor.
99
+
type = types.listOf types.path;
100
+
example = literalExample "[ ./objects.cfg ]";
type = types.listOf types.package;
101
-
default = [pkgs.nagiosPluginsOfficial pkgs.ssmtp];
102
-
defaultText = "[pkgs.nagiosPluginsOfficial pkgs.ssmtp]";
105
+
default = with pkgs; [ nagiosPluginsOfficial ssmtp mailutils ];
106
+
defaultText = "[pkgs.nagiosPluginsOfficial pkgs.ssmtp pkgs.mailutils]";
Packages to be added to the Nagios <envar>PATH</envar>.
Typically used to add plugins, but can be anything.
···
mainConfigFile = mkOption {
110
-
type = types.package;
111
-
default = nagiosCfgFile;
112
-
defaultText = "nagiosCfgFile";
114
+
type = types.nullOr types.package;
114
-
Derivation for the main configuration file of Nagios.
117
+
If non-null, overrides the main configuration file of Nagios.
121
+
extraConfig = mkOption {
122
+
type = types.attrsOf types.str;
124
+
debug_level = "-1";
125
+
debug_file = "/var/log/nagios/debug.log";
128
+
description = "Configuration to add to /etc/nagios.cfg";
131
+
validateConfig = mkOption {
133
+
default = pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform;
134
+
description = "if true, the syntax of the nagios configuration file is checked at build time";
cgiConfigFile = mkOption {
default = nagiosCGICfgFile;
···
enableWebInterface = mkOption {
Whether to enable the Nagios web interface. You should also
···
# This isn't needed, it's just so that the user can type "nagiostats
168
-
{ source = cfg.mainConfigFile;
188
+
{ source = nagiosCfgFile;
···
environment.systemPackages = [ pkgs.nagios ];
systemd.services.nagios = {
description = "Nagios monitoring daemon";
176
-
path = [ pkgs.nagios ];
196
+
path = [ pkgs.nagios ] ++ cfg.plugins;
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
···
LogsDirectory = "nagios";
StateDirectory = "nagios";
207
+
ExecStart = "${pkgs.nagios}/bin/nagios /etc/nagios.cfg";
208
+
X-ReloadIfChanged = nagiosCfgFile;
190
-
for i in ${toString cfg.plugins}; do
191
-
export PATH=$i/bin:$i/sbin:$i/libexec:$PATH
193
-
exec ${pkgs.nagios}/bin/nagios ${cfg.mainConfigFile}
services.httpd.virtualHosts = optionalAttrs cfg.enableWebInterface {