Merge pull request #96679 from midchildan/add-mackerel
mackerel-agent: init at 0.69.3
This commit is contained in:
commit
5dee9b5699
@ -542,6 +542,7 @@
|
|||||||
./services/monitoring/kapacitor.nix
|
./services/monitoring/kapacitor.nix
|
||||||
./services/monitoring/loki.nix
|
./services/monitoring/loki.nix
|
||||||
./services/monitoring/longview.nix
|
./services/monitoring/longview.nix
|
||||||
|
./services/monitoring/mackerel-agent.nix
|
||||||
./services/monitoring/monit.nix
|
./services/monitoring/monit.nix
|
||||||
./services/monitoring/munin.nix
|
./services/monitoring/munin.nix
|
||||||
./services/monitoring/nagios.nix
|
./services/monitoring/nagios.nix
|
||||||
|
111
nixos/modules/services/monitoring/mackerel-agent.nix
Normal file
111
nixos/modules/services/monitoring/mackerel-agent.nix
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.services.mackerel-agent;
|
||||||
|
settingsFmt = pkgs.formats.toml {};
|
||||||
|
in {
|
||||||
|
options.services.mackerel-agent = {
|
||||||
|
enable = mkEnableOption "mackerel.io agent";
|
||||||
|
|
||||||
|
# the upstream package runs as root, but doesn't seem to be strictly
|
||||||
|
# necessary for basic functionality
|
||||||
|
runAsRoot = mkEnableOption "Whether to run as root.";
|
||||||
|
|
||||||
|
autoRetirement = mkEnableOption ''
|
||||||
|
Whether to automatically retire the host upon OS shutdown.
|
||||||
|
'';
|
||||||
|
|
||||||
|
apiKeyFile = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
default = "";
|
||||||
|
example = "/run/keys/mackerel-api-key";
|
||||||
|
description = ''
|
||||||
|
Path to file containing the Mackerel API key. The file should contain a
|
||||||
|
single line of the following form:
|
||||||
|
|
||||||
|
<literallayout>apikey = "EXAMPLE_API_KEY"</literallayout>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
description = ''
|
||||||
|
Options for mackerel-agent.conf.
|
||||||
|
|
||||||
|
Documentation:
|
||||||
|
<link xlink:href="https://mackerel.io/docs/entry/spec/agent"/>
|
||||||
|
'';
|
||||||
|
|
||||||
|
default = {};
|
||||||
|
example = {
|
||||||
|
verbose = false;
|
||||||
|
silent = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
type = types.submodule {
|
||||||
|
freeformType = settingsFmt.type;
|
||||||
|
|
||||||
|
options.host_status = {
|
||||||
|
on_start = mkOption {
|
||||||
|
type = types.enum [ "working" "standby" "maintenance" "poweroff" ];
|
||||||
|
description = "Host status after agent startup.";
|
||||||
|
default = "working";
|
||||||
|
};
|
||||||
|
on_stop = mkOption {
|
||||||
|
type = types.enum [ "working" "standby" "maintenance" "poweroff" ];
|
||||||
|
description = "Host status after agent shutdown.";
|
||||||
|
default = "poweroff";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
options.diagnostic =
|
||||||
|
mkEnableOption "Collect memory usage for the agent itself";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
environment.systemPackages = with pkgs; [ mackerel-agent ];
|
||||||
|
|
||||||
|
environment.etc = {
|
||||||
|
"mackerel-agent/mackerel-agent.conf".source =
|
||||||
|
settingsFmt.generate "mackerel-agent.conf" cfg.settings;
|
||||||
|
"mackerel-agent/conf.d/api-key.conf".source = cfg.apiKeyFile;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.mackerel-agent.settings = {
|
||||||
|
root = mkDefault "/var/lib/mackerel-agent";
|
||||||
|
pidfile = mkDefault "/run/mackerel-agent/mackerel-agent.pid";
|
||||||
|
|
||||||
|
# conf.d stores the symlink to cfg.apiKeyFile
|
||||||
|
include = mkDefault "/etc/mackerel-agent/conf.d/*.conf";
|
||||||
|
};
|
||||||
|
|
||||||
|
# upstream service file in https://git.io/JUt4Q
|
||||||
|
systemd.services.mackerel-agent = {
|
||||||
|
description = "mackerel.io agent";
|
||||||
|
after = [ "network-online.target" "nss-lookup.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
environment = {
|
||||||
|
MACKEREL_PLUGIN_WORKDIR = mkDefault "%C/mackerel-agent";
|
||||||
|
};
|
||||||
|
serviceConfig = {
|
||||||
|
DynamicUser = !cfg.runAsRoot;
|
||||||
|
PrivateTmp = mkDefault true;
|
||||||
|
CacheDirectory = "mackerel-agent";
|
||||||
|
ConfigurationDirectory = "mackerel-agent";
|
||||||
|
RuntimeDirectory = "mackerel-agent";
|
||||||
|
StateDirectory = "mackerel-agent";
|
||||||
|
ExecStart = "${pkgs.mackerel-agent}/bin/mackerel-agent supervise";
|
||||||
|
ExecStopPost = mkIf cfg.autoRetirement "${pkg.mackerel-agent}/bin/mackerel-agent retire -force";
|
||||||
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||||
|
LimitNOFILE = mkDefault 65536;
|
||||||
|
LimitNPROC = mkDefault 65536;
|
||||||
|
};
|
||||||
|
restartTriggers = [
|
||||||
|
config.environment.etc."mackerel-agent/mackerel-agent.conf".source
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
42
pkgs/servers/monitoring/mackerel-agent/default.nix
Normal file
42
pkgs/servers/monitoring/mackerel-agent/default.nix
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{ stdenv, lib, buildGoModule, fetchFromGitHub, makeWrapper, iproute, nettools }:
|
||||||
|
|
||||||
|
buildGoModule rec {
|
||||||
|
pname = "mackerel-agent";
|
||||||
|
version = "0.69.3";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "mackerelio";
|
||||||
|
repo = pname;
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "0jkvqqzk6wyjsdsmn2l2cdw8pjqzswlqb9p492czhgrfy065lrqp";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
checkInputs = lib.optionals (!stdenv.isDarwin) [ nettools ];
|
||||||
|
buildInputs = lib.optionals (!stdenv.isDarwin) [ iproute ];
|
||||||
|
|
||||||
|
vendorSha256 = "0kjky2mhs6dapnr4xpjpnbibp6y8r320igddplynsfsp8vwrfp7m";
|
||||||
|
|
||||||
|
subPackages = [ "." ];
|
||||||
|
|
||||||
|
buildFlagsArray = ''
|
||||||
|
-ldflags=
|
||||||
|
-X=main.version=${version}
|
||||||
|
-X=main.gitcommit=v${version}
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
wrapProgram $out/bin/mackerel-agent \
|
||||||
|
--prefix PATH : "${lib.makeBinPath buildInputs}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "System monitoring service for mackerel.io";
|
||||||
|
homepage = "https://github.com/mackerelio/mackerel-agent";
|
||||||
|
license = licenses.asl20;
|
||||||
|
maintainers = with maintainers; [ midchildan ];
|
||||||
|
platforms = platforms.all;
|
||||||
|
};
|
||||||
|
}
|
@ -16872,6 +16872,8 @@ in
|
|||||||
|
|
||||||
labelImg = callPackage ../applications/science/machine-learning/labelimg { };
|
labelImg = callPackage ../applications/science/machine-learning/labelimg { };
|
||||||
|
|
||||||
|
mackerel-agent = callPackage ../servers/monitoring/mackerel-agent { };
|
||||||
|
|
||||||
mailman = callPackage ../servers/mail/mailman/wrapped.nix { };
|
mailman = callPackage ../servers/mail/mailman/wrapped.nix { };
|
||||||
|
|
||||||
mailman-rss = callPackage ../development/python-modules/mailman-rss { };
|
mailman-rss = callPackage ../development/python-modules/mailman-rss { };
|
||||||
|
Loading…
Reference in New Issue
Block a user