nncp: remove #77

Closed
ehmry wants to merge 2 commits from nncp into master
6 changed files with 2 additions and 184 deletions
Showing only changes of commit f07bc144f7 - Show all commits

View File

@ -634,22 +634,6 @@
system = "aarch64-linux";
};
# nncp = nixosSystem' {
# modules = [
# self.nixosModules.microvm
# self.nixosModules.nncp
# syndicate.nixosModules.default
# ./hosts/nncp
# {
# nixpkgs.overlays = [
# syndicate.overlays.default
# eris.inputs.nimble.overlay
# eris.overlays.default
# ];
# }
# ];
# };
dacbert = nixosSystem' {
modules = [
nixos-hardware.nixosModules.raspberry-pi-4

View File

@ -1,47 +0,0 @@
import std/[os, strutils]
import posix
proc getFileSize(path: string): BiggestInt =
var rawInfo: Stat
if stat(path, rawInfo) < 0'i32:
raiseOSError(osLastError(), path)
rawInfo.st_size
let
hostname = getEnv("COLLECTD_HOSTNAME", "localhost")
interval = max(60, getEnv("COLLECTD_INTERVAL", "0").parseFloat.int)
args = commandLineParams()
doAssert(args.len == 1, "pass only the NNCP spool directry as an argument")
type DirStats = tuple[size: BiggestInt, packets: int]
proc sumDir(path: string): DirStats =
for kind, path in walkDir path:
if kind == pcFile:
result.size = result.size + getFileSize(path)
inc result.packets
while true:
var stats: tuple[rx: DirStats, tx: DirStats]
for kind, path in walkDir args[0]:
if kind == pcDir:
block:
var rx = sumDir(path / "rx")
stats.rx.size = stats.rx.size + rx.size
stats.rx.packets.inc rx.packets
block:
var tx = sumDir(path / "tx")
stats.tx.size = stats.tx.size + tx.size
stats.tx.packets.inc tx.packets
stdout.writeLine("""PUTVAL "$#/exec-nncp/bytes-rx" interval=$# N:$#""" %
[hostname, $interval, $stats.rx.size])
stdout.writeLine("""PUTVAL "$#/exec-nncp/pending_operations-rx" interval=$# N:$#""" %
[hostname, $interval, $stats.rx.packets])
stdout.writeLine("""PUTVAL "$#/exec-nncp/bytes-tx" interval=$# N:$#""" %
[hostname, $interval, $stats.tx.size])
stdout.writeLine("""PUTVAL "$#/exec-nncp/pending_operations-tx" interval=$# N:$#""" %
[hostname, $interval, $stats.tx.packets])
flushFile stdout
sleep interval*1000

View File

@ -1,72 +0,0 @@
{ config, lib, pkgs, ... }:
{
imports = [ ./eris.nix ./neighbours.nix ];
microvm.interfaces = [ {
type = "tap";
id = "c3d2-nncp";
mac = "de:ec:9a:6f:3f:63";
} ];
c3d2.mergeNncpSettings = false;
c3d2.hq.statistics.enable = true;
c3d2.deployment = {
server = "server10";
mounts = [ "etc" "home" "var"];
autoNetSetup = false;
};
system.stateVersion = "22.05";
networking = {
hostName = "nncp";
firewall.enable = false;
};
programs.nncp = {
enable = true;
secrets = [ "/etc/nncp.secrets" ];
settings = {
mcd-listen = [ "c3d2" ];
mcd-send.c3d2 = 60;
neigh = # use c3d2.nncp.neigh but remove this node
let
hourlyCall = {
cron = "0 42 * * * * *";
xx = "tx"; # transmit only
when-tx-exists = true;
};
in lib.mapAttrs (name: value:
value // {
via = lib.lists.remove "c3d2" value.via;
} // (lib.attrsets.optionalAttrs (value.addrs or { } != { }) {
calls = [ hourlyCall ];
})) (builtins.removeAttrs config.c3d2.nncp.neigh [ "c3d2" ]);
};
};
services.collectd.plugins.exec = let
util =
pkgs.runCommand "collectd_nncp" { nativeBuildInputs = [ pkgs.nim ]; } ''
cp ${./collectd_nncp.nim} ./collectd_nncp.nim
nim c --nimcache:. -o:$out ./collectd_nncp.nim
'';
in ''
Exec "${config.services.collectd.user}" "${util}" "${config.programs.nncp.settings.spool}"
'';
users.groups.uucp.members = [ config.services.collectd.user ];
services.nncp = {
caller = {
enable = true;
extraArgs = [ "-autotoss" ];
};
daemon = {
enable = true;
socketActivation.enable = false;
extraArgs = [ "-autotoss" ];
};
};
}

View File

@ -1,30 +0,0 @@
{ pkgs, ... }:
let home = "/var/spool/eris";
in {
services.syndicate.eris = {
enable = true;
user = "eris";
config = [
(pkgs.writeText "eris.pr" ''
<require-service <daemon eris-resolver>>
<daemon eris-resolver {
argv: [ "${pkgs.nimPackages.eris}/bin/eriscmd" "resolver" ]
protocol: text/syndicate
}>
? <service-object <daemon eris-resolver> ?cap> $cap [
<coap-server "::" 5683 #{Get Put}>
<tkrzw "${home}/eris.tkh" #{Get Put} >
]
'')
];
};
users.groups.eris = { };
users.users.eris = {
isSystemUser = true;
group = "eris";
inherit home;
};
}

View File

@ -1,19 +0,0 @@
{ config, lib, pkgs, ... }:
let
exec = {
# A command to asynchronously export store paths to a remote caller.
nix-store-export = with pkgs;
[
(writeScript "nncp-nix-store-export.sh" ''
#!${bash}/bin/bash
set -euo pipefail
${config.nix.package}/bin/nix-store --export $@ | \
${config.programs.nncp.package}/bin/nncp-exec -nice $NNCP_NICE $NNCP_SENDER nix-store-import
'')
];
# A command to import store paths from a remote caller.
nix-store-import = [ "${config.nix.package}/bin/nix-store" "--import" ];
};
in { programs.nncp.settings.neigh = { emery = { inherit exec; }; }; }

View File

@ -130,5 +130,7 @@ in
wantedBy = [ "sockets.target" ];
socketConfig.Accept = true;
};
} // {
warnings = [ "the C3D2 nncp module may go away" ];
};
}