forked from mirrors/nixpkgs
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
166 lines
3.9 KiB
Nix
166 lines
3.9 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.bosun;
|
|
|
|
configFile = pkgs.writeText "bosun.conf" ''
|
|
${optionalString (cfg.opentsdbHost !=null) "tsdbHost = ${cfg.opentsdbHost}"}
|
|
${optionalString (cfg.influxHost !=null) "influxHost = ${cfg.influxHost}"}
|
|
httpListen = ${cfg.listenAddress}
|
|
stateFile = ${cfg.stateFile}
|
|
ledisDir = ${cfg.ledisDir}
|
|
checkFrequency = ${cfg.checkFrequency}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.bosun = {
|
|
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether to run bosun.
|
|
'';
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.bosun;
|
|
defaultText = literalExpression "pkgs.bosun";
|
|
description = lib.mdDoc ''
|
|
bosun binary to use.
|
|
'';
|
|
};
|
|
|
|
user = mkOption {
|
|
type = types.str;
|
|
default = "bosun";
|
|
description = lib.mdDoc ''
|
|
User account under which bosun runs.
|
|
'';
|
|
};
|
|
|
|
group = mkOption {
|
|
type = types.str;
|
|
default = "bosun";
|
|
description = lib.mdDoc ''
|
|
Group account under which bosun runs.
|
|
'';
|
|
};
|
|
|
|
opentsdbHost = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = "localhost:4242";
|
|
description = lib.mdDoc ''
|
|
Host and port of the OpenTSDB database that stores bosun data.
|
|
To disable opentsdb you can pass null as parameter.
|
|
'';
|
|
};
|
|
|
|
influxHost = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
example = "localhost:8086";
|
|
description = lib.mdDoc ''
|
|
Host and port of the influxdb database.
|
|
'';
|
|
};
|
|
|
|
listenAddress = mkOption {
|
|
type = types.str;
|
|
default = ":8070";
|
|
description = lib.mdDoc ''
|
|
The host address and port that bosun's web interface will listen on.
|
|
'';
|
|
};
|
|
|
|
stateFile = mkOption {
|
|
type = types.path;
|
|
default = "/var/lib/bosun/bosun.state";
|
|
description = lib.mdDoc ''
|
|
Path to bosun's state file.
|
|
'';
|
|
};
|
|
|
|
ledisDir = mkOption {
|
|
type = types.path;
|
|
default = "/var/lib/bosun/ledis_data";
|
|
description = lib.mdDoc ''
|
|
Path to bosun's ledis data dir
|
|
'';
|
|
};
|
|
|
|
checkFrequency = mkOption {
|
|
type = types.str;
|
|
default = "5m";
|
|
description = lib.mdDoc ''
|
|
Bosun's check frequency
|
|
'';
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = lib.mdDoc ''
|
|
Extra configuration options for Bosun. You should describe your
|
|
desired templates, alerts, macros, etc through this configuration
|
|
option.
|
|
|
|
A detailed description of the supported syntax can be found at-spi2-atk
|
|
http://bosun.org/configuration.html
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.bosun = {
|
|
description = "bosun metrics collector (part of Bosun)";
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
preStart = ''
|
|
mkdir -p "$(dirname "${cfg.stateFile}")";
|
|
touch "${cfg.stateFile}"
|
|
touch "${cfg.stateFile}.tmp"
|
|
|
|
mkdir -p "${cfg.ledisDir}";
|
|
|
|
if [ "$(id -u)" = 0 ]; then
|
|
chown ${cfg.user}:${cfg.group} "${cfg.stateFile}"
|
|
chown ${cfg.user}:${cfg.group} "${cfg.stateFile}.tmp"
|
|
chown ${cfg.user}:${cfg.group} "${cfg.ledisDir}"
|
|
fi
|
|
'';
|
|
|
|
serviceConfig = {
|
|
PermissionsStartOnly = true;
|
|
User = cfg.user;
|
|
Group = cfg.group;
|
|
ExecStart = ''
|
|
${cfg.package}/bin/bosun -c ${configFile}
|
|
'';
|
|
};
|
|
};
|
|
|
|
users.users.bosun = {
|
|
description = "bosun user";
|
|
group = "bosun";
|
|
uid = config.ids.uids.bosun;
|
|
};
|
|
|
|
users.groups.bosun.gid = config.ids.gids.bosun;
|
|
|
|
};
|
|
|
|
}
|