Skip to content

Commit

Permalink
nixos/glpi-agent: init
Browse files Browse the repository at this point in the history
  • Loading branch information
liberodark committed Jan 7, 2025
1 parent 61aa4ba commit 37e765f
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions nixos/modules/services/monitoring/glpi-agent.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
config,
lib,
pkgs,
...
}:

let
cfg = config.services.glpiAgent;

configFile = pkgs.writeText "agent.cfg" ''
# Server configuration
server = ${lib.concatStringsSep ", " cfg.servers}
# Configuration
${cfg.extraConfig}
'';

in
{
options = {
services.glpiAgent = {
enable = lib.mkEnableOption "GLPI Agent";

package = lib.mkPackageOption pkgs "glpi-agent" {
};

servers = lib.mkOption {
type = lib.types.listOf lib.types.str;
example = [ "https://glpi.example.com/inventory" ];
};

extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
example = ''
delaytime = 3600
timeout = 180
tag = mytag
logger = stderr
'';
};
};
};

config = lib.mkIf cfg.enable {
systemd.services.glpi-agent = {
description = "GLPI Agent";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];

serviceConfig = {
ExecStart = "${lib.getExe cfg.package} --conf-file ${configFile} --vardir /var/lib/glpi-agent --daemon --no-fork";
User = "root";
Restart = "on-failure";
StateDirectory = "glpi-agent";
RuntimeDirectory = "glpi-agent";
WorkingDirectory = "/var/lib/glpi-agent";
};
};
};
}

0 comments on commit 37e765f

Please sign in to comment.