mirror of
https://seed.radicle.dev/rad:z254T5p17bdFPmzfDojsdjo4HjpoZ.git
synced 2026-10-18 19:10:32 +08:00
os/mixin/radicle-stats: Collect rad stats
A systemd timer unit that will just take the output of `rad stats` and timestamp it.
This commit is contained in:
@@ -8,6 +8,7 @@ in {
|
||||
imports = [
|
||||
../../mixin/radicle.nix
|
||||
../../mixin/radicle-permissive.nix
|
||||
../../mixin/radicle-stats.nix
|
||||
];
|
||||
|
||||
fileSystems."/var/lib/radicle" = {
|
||||
|
||||
@@ -8,6 +8,7 @@ in {
|
||||
imports = [
|
||||
../../mixin/radicle.nix
|
||||
../../mixin/radicle-permissive.nix
|
||||
../../mixin/radicle-stats.nix
|
||||
];
|
||||
|
||||
fileSystems."/var/lib/radicle" = {
|
||||
|
||||
@@ -3,7 +3,10 @@
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [../../mixin/radicle.nix];
|
||||
imports = [
|
||||
../../mixin/radicle.nix
|
||||
../../mixin/radicle-stats.nix
|
||||
];
|
||||
|
||||
fileSystems."/var/lib/radicle" = {
|
||||
device = "/dev/disk/by-id/scsi-0HC_Volume_30473554";
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
name = "radicle-stats";
|
||||
in {
|
||||
systemd = {
|
||||
timers.${name} = {
|
||||
wantedBy = ["timers.target"];
|
||||
timerConfig = {
|
||||
OnBootSec = "1m";
|
||||
OnUnitActiveSec = "6h";
|
||||
Unit = "${name}.service";
|
||||
};
|
||||
};
|
||||
services = {
|
||||
${name} = let
|
||||
cmd = "rad-system";
|
||||
rad =
|
||||
lib.findFirst (x: x.name == cmd) (throw "could not find `${cmd}`") config.environment.systemPackages;
|
||||
in {
|
||||
script = ''
|
||||
set -xeu
|
||||
mkdir -p /tmp/radicle
|
||||
${lib.getExe rad} stats | ${lib.getExe pkgs.jq} --compact-output '. * { timestamp: now | strftime("%s") }' >> /tmp/radicle/stats.jsonl
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
};
|
||||
};
|
||||
nginx.serviceConfig.BindReadOnlyPaths = [
|
||||
"/tmp/radicle/stats.jsonl:/tmp/radicle/stats.jsonl"
|
||||
];
|
||||
};
|
||||
};
|
||||
services.nginx.virtualHosts.${config.networking.fqdn}.locations."/tmp/".alias = "/tmp/radicle/";
|
||||
}
|
||||
Reference in New Issue
Block a user