Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e46d2ee4f827
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5dee9b5699d1
Choose a head ref
  • 3 commits
  • 4 files changed
  • 2 contributors

Commits on Nov 7, 2020

  1. Copy the full SHA
    2c99a20 View commit details
  2. Copy the full SHA
    921a66e View commit details

Commits on Nov 11, 2020

  1. Merge pull request #96679 from midchildan/add-mackerel

    mackerel-agent: init at 0.69.3
    kevincox authored Nov 11, 2020
    Copy the full SHA
    5dee9b5 View commit details
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
@@ -542,6 +542,7 @@
./services/monitoring/kapacitor.nix
./services/monitoring/loki.nix
./services/monitoring/longview.nix
./services/monitoring/mackerel-agent.nix
./services/monitoring/monit.nix
./services/monitoring/munin.nix
./services/monitoring/nagios.nix
111 changes: 111 additions & 0 deletions nixos/modules/services/monitoring/mackerel-agent.nix
Original file line number Diff line number Diff line change
@@ -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 changes: 42 additions & 0 deletions pkgs/servers/monitoring/mackerel-agent/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
@@ -16872,6 +16872,8 @@ in

labelImg = callPackage ../applications/science/machine-learning/labelimg { };

mackerel-agent = callPackage ../servers/monitoring/mackerel-agent { };

mailman = callPackage ../servers/mail/mailman/wrapped.nix { };

mailman-rss = callPackage ../development/python-modules/mailman-rss { };