1 { config, lib, pkgs, ... }:
6 cfg = config.services.bosun;
8 configFile = pkgs.writeText "bosun.conf" ''
9 ${optionalString (cfg.opentsdbHost !=null) "tsdbHost = ${cfg.opentsdbHost}"}
10 ${optionalString (cfg.influxHost !=null) "influxHost = ${cfg.influxHost}"}
11 httpListen = ${cfg.listenAddress}
12 stateFile = ${cfg.stateFile}
13 ledisDir = ${cfg.ledisDir}
14 checkFrequency = ${cfg.checkFrequency}
25 enable = mkEnableOption "bosun";
27 package = mkPackageOption pkgs "bosun" { };
33 User account under which bosun runs.
41 Group account under which bosun runs.
45 opentsdbHost = mkOption {
46 type = types.nullOr types.str;
47 default = "localhost:4242";
49 Host and port of the OpenTSDB database that stores bosun data.
50 To disable opentsdb you can pass null as parameter.
54 influxHost = mkOption {
55 type = types.nullOr types.str;
57 example = "localhost:8086";
59 Host and port of the influxdb database.
63 listenAddress = mkOption {
67 The host address and port that bosun's web interface will listen on.
71 stateFile = mkOption {
73 default = "/var/lib/bosun/bosun.state";
75 Path to bosun's state file.
81 default = "/var/lib/bosun/ledis_data";
83 Path to bosun's ledis data dir
87 checkFrequency = mkOption {
91 Bosun's check frequency
95 extraConfig = mkOption {
99 Extra configuration options for Bosun. You should describe your
100 desired templates, alerts, macros, etc through this configuration
103 A detailed description of the supported syntax can be found at-spi2-atk
104 https://bosun.org/configuration.html
112 config = mkIf cfg.enable {
114 systemd.services.bosun = {
115 description = "bosun metrics collector (part of Bosun)";
116 wantedBy = [ "multi-user.target" ];
119 mkdir -p "$(dirname "${cfg.stateFile}")";
120 touch "${cfg.stateFile}"
121 touch "${cfg.stateFile}.tmp"
123 mkdir -p "${cfg.ledisDir}";
125 if [ "$(id -u)" = 0 ]; then
126 chown ${cfg.user}:${cfg.group} "${cfg.stateFile}"
127 chown ${cfg.user}:${cfg.group} "${cfg.stateFile}.tmp"
128 chown ${cfg.user}:${cfg.group} "${cfg.ledisDir}"
133 PermissionsStartOnly = true;
137 ${cfg.package}/bin/bosun -c ${configFile}
142 users.users.bosun = {
143 description = "bosun user";
145 uid = config.ids.uids.bosun;
148 users.groups.bosun.gid = config.ids.gids.bosun;