mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 23:22:37 +00:00
Merge pull request #19367 from cransom/smokeping-fix
smokeping module: fix missing js, broken alerts
This commit is contained in:
commit
1997761725
@ -6,23 +6,28 @@ let
|
|||||||
cfg = config.services.smokeping;
|
cfg = config.services.smokeping;
|
||||||
smokepingHome = "/var/lib/smokeping";
|
smokepingHome = "/var/lib/smokeping";
|
||||||
smokepingPidDir = "/run";
|
smokepingPidDir = "/run";
|
||||||
configFile = ''
|
configFile =
|
||||||
|
if cfg.config == null
|
||||||
|
then
|
||||||
|
''
|
||||||
*** General ***
|
*** General ***
|
||||||
owner = ${cfg.owner}
|
owner = ${cfg.owner}
|
||||||
contact = ${cfg.ownerEmail}
|
contact = ${cfg.ownerEmail}
|
||||||
mailhost = ${cfg.mailHost}
|
${lib.optionalString (cfg.mailHost != "") "mailhost = ${cfg.mailHost}"}
|
||||||
#sendmail = /var/setuid-wrappers/sendmail
|
${lib.optionalString (cfg.sendmail != null) "sendmail = ${cfg.sendmail}"}
|
||||||
imgcache = ${smokepingHome}/cache
|
imgcache = ${smokepingHome}/cache
|
||||||
imgurl = http://${cfg.hostName}:${builtins.toString cfg.port}/cache
|
imgurl = http://${cfg.hostName}:${builtins.toString cfg.port}/cache
|
||||||
datadir = ${smokepingHome}/data
|
datadir = ${smokepingHome}/data
|
||||||
|
pagedir = ${smokepingHome}/cache
|
||||||
piddir = ${smokepingPidDir}
|
piddir = ${smokepingPidDir}
|
||||||
cgiurl = http://${cfg.hostName}:${builtins.toString cfg.port}/smokeping.cgi
|
cgiurl = http://${cfg.hostName}:${builtins.toString cfg.port}/smokeping.cgi
|
||||||
|
linkstyle = ${cfg.linkStyle}
|
||||||
smokemail = ${cfg.smokeMailTemplate}
|
smokemail = ${cfg.smokeMailTemplate}
|
||||||
*** Presentation ***
|
*** Presentation ***
|
||||||
template = ${cfg.presentationTemplate}
|
template = ${cfg.presentationTemplate}
|
||||||
${cfg.presentationConfig}
|
${cfg.presentationConfig}
|
||||||
#*** Alerts ***
|
*** Alerts ***
|
||||||
#${cfg.alertConfig}
|
${cfg.alertConfig}
|
||||||
*** Database ***
|
*** Database ***
|
||||||
${cfg.databaseConfig}
|
${cfg.databaseConfig}
|
||||||
*** Probes ***
|
*** Probes ***
|
||||||
@ -30,7 +35,10 @@ let
|
|||||||
*** Targets ***
|
*** Targets ***
|
||||||
${cfg.targetConfig}
|
${cfg.targetConfig}
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
'';
|
''
|
||||||
|
else
|
||||||
|
cfg.config;
|
||||||
|
|
||||||
configPath = pkgs.writeText "smokeping.conf" configFile;
|
configPath = pkgs.writeText "smokeping.conf" configFile;
|
||||||
cgiHome = pkgs.writeScript "smokeping.fcgi" ''
|
cgiHome = pkgs.writeScript "smokeping.fcgi" ''
|
||||||
#!${pkgs.bash}/bin/bash
|
#!${pkgs.bash}/bin/bash
|
||||||
@ -59,8 +67,15 @@ in
|
|||||||
};
|
};
|
||||||
mailHost = mkOption {
|
mailHost = mkOption {
|
||||||
type = types.string;
|
type = types.string;
|
||||||
default = "127.0.0.1";
|
default = "";
|
||||||
description = "Use this SMTP server rather than localhost";
|
example = "localhost";
|
||||||
|
description = "Use this SMTP server to send alerts";
|
||||||
|
};
|
||||||
|
sendmail = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
default = null;
|
||||||
|
example = "/var/setuid-wrappers/sendmail";
|
||||||
|
description = "Use this sendmail compatible script to deliver alerts";
|
||||||
};
|
};
|
||||||
smokeMailTemplate = mkOption {
|
smokeMailTemplate = mkOption {
|
||||||
type = types.string;
|
type = types.string;
|
||||||
@ -71,6 +86,7 @@ in
|
|||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
default = pkgs.smokeping;
|
default = pkgs.smokeping;
|
||||||
|
defaultText = "pkgs.smokeping";
|
||||||
description = "Specify a custom smokeping package";
|
description = "Specify a custom smokeping package";
|
||||||
};
|
};
|
||||||
owner = mkOption {
|
owner = mkOption {
|
||||||
@ -85,6 +101,12 @@ in
|
|||||||
example = "somewhere.example.com";
|
example = "somewhere.example.com";
|
||||||
description = "DNS name for the urls generated in the cgi.";
|
description = "DNS name for the urls generated in the cgi.";
|
||||||
};
|
};
|
||||||
|
linkStyle = mkOption {
|
||||||
|
type = types.enum ["original" "absolute" "relative"];
|
||||||
|
default = "relative";
|
||||||
|
example = "absolute";
|
||||||
|
description = "DNS name for the urls generated in the cgi.";
|
||||||
|
};
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 8081;
|
default = 8081;
|
||||||
@ -132,7 +154,10 @@ in
|
|||||||
};
|
};
|
||||||
alertConfig = mkOption {
|
alertConfig = mkOption {
|
||||||
type = types.string;
|
type = types.string;
|
||||||
default = "";
|
default = ''
|
||||||
|
to = root@localhost
|
||||||
|
from = smokeping@localhost
|
||||||
|
'';
|
||||||
example = literalExample ''
|
example = literalExample ''
|
||||||
to = alertee@address.somewhere
|
to = alertee@address.somewhere
|
||||||
from = smokealert@company.xy
|
from = smokealert@company.xy
|
||||||
@ -223,12 +248,26 @@ in
|
|||||||
default = "";
|
default = "";
|
||||||
description = "Any additional customization not already included.";
|
description = "Any additional customization not already included.";
|
||||||
};
|
};
|
||||||
|
config = mkOption {
|
||||||
|
type = types.nullOr types.string;
|
||||||
|
default = null;
|
||||||
|
description = "Full smokeping config supplied by the user. Overrides " +
|
||||||
|
"and replaces any other configuration supplied.";
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = !(cfg.sendmail != null && cfg.mailHost != "");
|
||||||
|
message = "services.smokeping: sendmail and Mailhost cannot both be enabled.";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
security.setuidPrograms = [ "fping" ];
|
||||||
|
environment.systemPackages = [ pkgs.fping ];
|
||||||
users.extraUsers = singleton {
|
users.extraUsers = singleton {
|
||||||
name = cfg.user;
|
name = cfg.user;
|
||||||
isNormalUser = false;
|
isNormalUser = false;
|
||||||
@ -243,9 +282,12 @@ in
|
|||||||
serviceConfig.PermissionsStartOnly = true;
|
serviceConfig.PermissionsStartOnly = true;
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -m 0755 -p ${smokepingHome}/cache ${smokepingHome}/data
|
mkdir -m 0755 -p ${smokepingHome}/cache ${smokepingHome}/data
|
||||||
|
rm -f ${smokepingHome}/cropper
|
||||||
|
ln -s ${cfg.package}/htdocs/cropper ${smokepingHome}/cropper
|
||||||
chown -R ${cfg.user} ${smokepingHome}
|
chown -R ${cfg.user} ${smokepingHome}
|
||||||
cp ${cgiHome} ${smokepingHome}/smokeping.fcgi
|
cp ${cgiHome} ${smokepingHome}/smokeping.fcgi
|
||||||
${cfg.package}/bin/smokeping --check --config=${configPath}
|
${cfg.package}/bin/smokeping --check --config=${configPath}
|
||||||
|
${cfg.package}/bin/smokeping --static --config=${configPath}
|
||||||
'';
|
'';
|
||||||
script = ''${cfg.package}/bin/smokeping --config=${configPath} --nodaemon'';
|
script = ''${cfg.package}/bin/smokeping --config=${configPath} --nodaemon'';
|
||||||
};
|
};
|
||||||
@ -253,8 +295,9 @@ in
|
|||||||
wantedBy = [ "multi-user.target"];
|
wantedBy = [ "multi-user.target"];
|
||||||
requires = [ "smokeping.service"];
|
requires = [ "smokeping.service"];
|
||||||
partOf = [ "smokeping.service"];
|
partOf = [ "smokeping.service"];
|
||||||
path = with pkgs; [ bash rrdtool smokeping ];
|
path = with pkgs; [ bash rrdtool smokeping thttpd ];
|
||||||
script = ''${pkgs.thttpd}/bin/thttpd -u ${cfg.user} -c "**.fcgi" -d ${smokepingHome} -p ${builtins.toString cfg.port} -D'';
|
script = ''thttpd -u ${cfg.user} -c "**.fcgi" -d ${smokepingHome} -p ${builtins.toString cfg.port} -D -nos'';
|
||||||
|
serviceConfig.Restart = "always";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,10 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
services.smokeping = {
|
services.smokeping = {
|
||||||
enable = true;
|
enable = true;
|
||||||
port = 8081;
|
port = 8081;
|
||||||
|
mailHost = "127.0.0.2";
|
||||||
probeConfig = ''
|
probeConfig = ''
|
||||||
+ FPing
|
+ FPing
|
||||||
binary = ${pkgs.fping}/bin/fping
|
binary = /var/setuid-wrappers/fping
|
||||||
offset = 0%
|
offset = 0%
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@ -27,5 +28,6 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
$sm->waitForFile("/var/lib/smokeping/data/Local/LocalMachine.rrd");
|
$sm->waitForFile("/var/lib/smokeping/data/Local/LocalMachine.rrd");
|
||||||
$sm->succeed("curl -s -f localhost:8081/smokeping.fcgi?target=Local");
|
$sm->succeed("curl -s -f localhost:8081/smokeping.fcgi?target=Local");
|
||||||
$sm->succeed("ls /var/lib/smokeping/cache/Local/LocalMachine_mini.png");
|
$sm->succeed("ls /var/lib/smokeping/cache/Local/LocalMachine_mini.png");
|
||||||
|
$sm->succeed("ls /var/lib/smokeping/cache/index.html");
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user