Merge pull request #21625 from mayflower/smokeping

smokeping: Allow customization of cgiurl and imgurl
This commit is contained in:
Franz Pletz 2017-01-04 21:56:12 +01:00 committed by GitHub
commit cdbffaa86e
1 changed files with 105 additions and 98 deletions

View File

@ -11,17 +11,17 @@ let
then then
'' ''
*** General *** *** General ***
owner = ${cfg.owner} cgiurl = ${cfg.cgiUrl}
contact = ${cfg.ownerEmail} contact = ${cfg.ownerEmail}
${lib.optionalString (cfg.mailHost != "") "mailhost = ${cfg.mailHost}"}
${lib.optionalString (cfg.sendmail != null) "sendmail = ${cfg.sendmail}"}
imgcache = ${smokepingHome}/cache
imgurl = http://${cfg.hostName}:${builtins.toString cfg.port}/cache
datadir = ${smokepingHome}/data datadir = ${smokepingHome}/data
imgcache = ${smokepingHome}/cache
imgurl = ${cfg.imgUrl}
linkstyle = ${cfg.linkStyle}
${lib.optionalString (cfg.mailHost != "") "mailhost = ${cfg.mailHost}"}
owner = ${cfg.owner}
pagedir = ${smokepingHome}/cache pagedir = ${smokepingHome}/cache
piddir = ${smokepingPidDir} piddir = ${smokepingPidDir}
cgiurl = http://${cfg.hostName}:${builtins.toString cfg.port}/smokeping.cgi ${lib.optionalString (cfg.sendmail != null) "sendmail = ${cfg.sendmail}"}
linkstyle = ${cfg.linkStyle}
smokemail = ${cfg.smokeMailTemplate} smokemail = ${cfg.smokeMailTemplate}
*** Presentation *** *** Presentation ***
template = ${cfg.presentationTemplate} template = ${cfg.presentationTemplate}
@ -54,72 +54,36 @@ in
default = false; default = false;
description = "Enable the smokeping service"; description = "Enable the smokeping service";
}; };
webService = mkOption { alertConfig = mkOption {
type = types.bool; type = types.string;
default = true; default = ''
description = "Enable a smokeping web interface"; to = root@localhost
}; from = smokeping@localhost
'';
example = literalExample ''
to = alertee@address.somewhere
from = smokealert@company.xy
user = mkOption { +someloss
type = types.string; type = loss
default = "smokeping"; # in percent
description = "User that runs smokeping and (optionally) thttpd"; pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row;
'';
description = "Configuration for alerts.";
}; };
mailHost = mkOption { cgiUrl = mkOption {
type = types.string; type = types.string;
default = ""; default = "http://${cfg.hostName}:${builtins.toString cfg.port}/smokeping.cgi";
example = "localhost"; example = "https://somewhere.example.com/smokeping.cgi";
description = "Use this SMTP server to send alerts"; description = "URL to the smokeping cgi.";
}; };
sendmail = mkOption { config = mkOption {
type = types.nullOr types.path; type = types.nullOr types.string;
default = null; default = null;
example = "/var/setuid-wrappers/sendmail"; description = "Full smokeping config supplied by the user. Overrides " +
description = "Use this sendmail compatible script to deliver alerts"; "and replaces any other configuration supplied.";
}; };
smokeMailTemplate = mkOption {
type = types.string;
default = "${cfg.package}/etc/smokemail.dist";
description = "Specify the smokemail template for alerts.";
};
package = mkOption {
type = types.package;
default = pkgs.smokeping;
defaultText = "pkgs.smokeping";
description = "Specify a custom smokeping package";
};
owner = mkOption {
type = types.string;
default = "nobody";
example = "Joe Admin";
description = "Real name of the owner of the instance";
};
hostName = mkOption {
type = types.string;
default = config.networking.hostName;
example = "somewhere.example.com";
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 {
type = types.int;
default = 8081;
example = 8081;
description = "TCP port to use for the web server.";
};
ownerEmail = mkOption {
type = types.string;
default = "no-reply@${cfg.hostName}";
example = "no-reply@yourdomain.com";
description = "Email contact for owner";
};
databaseConfig = mkOption { databaseConfig = mkOption {
type = types.string; type = types.string;
default = '' default = ''
@ -152,30 +116,59 @@ in
Once set, changing the interval will require deletion or migration of all Once set, changing the interval will require deletion or migration of all
the collected data.''; the collected data.'';
}; };
alertConfig = mkOption { extraConfig = mkOption {
type = types.string; type = types.lines;
default = '' default = "";
to = root@localhost description = "Any additional customization not already included.";
from = smokeping@localhost
'';
example = literalExample ''
to = alertee@address.somewhere
from = smokealert@company.xy
+someloss
type = loss
# in percent
pattern = >0%,*12*,>0%,*12*,>0%
comment = loss 3 times in a row;
'';
description = "Configuration for alerts.";
}; };
presentationTemplate = mkOption { hostName = mkOption {
type = types.string; type = types.string;
default = "${pkgs.smokeping}/etc/basepage.html.dist"; default = config.networking.hostName;
description = "Default page layout for the web UI."; example = "somewhere.example.com";
description = "DNS name for the urls generated in the cgi.";
};
imgUrl = mkOption {
type = types.string;
default = "http://${cfg.hostName}:${builtins.toString cfg.port}/cache";
example = "https://somewhere.example.com/cache";
description = "Base url for images 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.";
};
mailHost = mkOption {
type = types.string;
default = "";
example = "localhost";
description = "Use this SMTP server to send alerts";
};
owner = mkOption {
type = types.string;
default = "nobody";
example = "Joe Admin";
description = "Real name of the owner of the instance";
};
ownerEmail = mkOption {
type = types.string;
default = "no-reply@${cfg.hostName}";
example = "no-reply@yourdomain.com";
description = "Email contact for owner";
};
package = mkOption {
type = types.package;
default = pkgs.smokeping;
defaultText = "pkgs.smokeping";
description = "Specify a custom smokeping package";
};
port = mkOption {
type = types.int;
default = 8081;
example = 8081;
description = "TCP port to use for the web server.";
}; };
presentationConfig = mkOption { presentationConfig = mkOption {
type = types.string; type = types.string;
default = '' default = ''
@ -217,6 +210,11 @@ in
''; '';
description = "presentation graph style"; description = "presentation graph style";
}; };
presentationTemplate = mkOption {
type = types.string;
default = "${pkgs.smokeping}/etc/basepage.html.dist";
description = "Default page layout for the web UI.";
};
probeConfig = mkOption { probeConfig = mkOption {
type = types.string; type = types.string;
default = '' default = ''
@ -225,6 +223,17 @@ in
''; '';
description = "Probe configuration"; description = "Probe configuration";
}; };
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 {
type = types.string;
default = "${cfg.package}/etc/smokemail.dist";
description = "Specify the smokemail template for alerts.";
};
targetConfig = mkOption { targetConfig = mkOption {
type = types.string; type = types.string;
default = '' default = ''
@ -243,18 +252,16 @@ in
''; '';
description = "Target configuration"; description = "Target configuration";
}; };
extraConfig = mkOption { user = mkOption {
type = types.lines; type = types.string;
default = ""; default = "smokeping";
description = "Any additional customization not already included."; description = "User that runs smokeping and (optionally) thttpd";
}; };
config = mkOption { webService = mkOption {
type = types.nullOr types.string; type = types.bool;
default = null; default = true;
description = "Full smokeping config supplied by the user. Overrides " + description = "Enable a smokeping web interface";
"and replaces any other configuration supplied.";
}; };
}; };
}; };