diff options
author | makefu <github@syntax-fehler.de> | 2023-07-28 22:24:15 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2023-07-28 22:24:15 +0200 |
commit | 060a8f28fa1fc648bdf66afb31a5d1efac868837 (patch) | |
tree | 2b354eacc7897365ee45244fe7a51720e0d0333f /makefu/2configs/stats | |
parent | cbfcc890e3b76d942b927809bf981a5fa7289e6a (diff) |
makefu: move out to own repo, add vacation-note
Diffstat (limited to 'makefu/2configs/stats')
-rw-r--r-- | makefu/2configs/stats/arafetch.nix | 66 | ||||
-rw-r--r-- | makefu/2configs/stats/client.nix | 7 | ||||
-rw-r--r-- | makefu/2configs/stats/collectd-client.nix | 61 | ||||
-rw-r--r-- | makefu/2configs/stats/external/aralast.nix | 37 | ||||
-rw-r--r-- | makefu/2configs/stats/external/weather2stats.nix | 38 | ||||
-rw-r--r-- | makefu/2configs/stats/netdata-server.nix | 17 | ||||
-rw-r--r-- | makefu/2configs/stats/nodisk-client.nix | 60 | ||||
-rw-r--r-- | makefu/2configs/stats/server.nix | 65 | ||||
-rw-r--r-- | makefu/2configs/stats/telegraf/airsensor.nix | 49 | ||||
-rw-r--r-- | makefu/2configs/stats/telegraf/bamstats.nix | 35 | ||||
-rw-r--r-- | makefu/2configs/stats/telegraf/default.nix | 30 | ||||
-rw-r--r-- | makefu/2configs/stats/telegraf/europastats.nix | 43 | ||||
-rw-r--r-- | makefu/2configs/stats/telegraf/hamstats.nix | 69 |
13 files changed, 0 insertions, 577 deletions
diff --git a/makefu/2configs/stats/arafetch.nix b/makefu/2configs/stats/arafetch.nix deleted file mode 100644 index 0ea05e779..000000000 --- a/makefu/2configs/stats/arafetch.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ pkgs, lib, ...}: -with import <stockholm/lib>; -let - pkg = with pkgs.python3Packages;buildPythonPackage rec { - rev = "56d41de8219adc"; - name = "arafetch-${rev}"; - propagatedBuildInputs = [ - requests - docopt - influxdb - beautifulsoup4 - paho-mqtt - ]; - src = pkgs.fetchgit { - url = "http://cgit.euer.krebsco.de/arafetch"; - inherit rev; - sha256 = "0hnwbmj0plynhv3h2idhrzf2zcqx3qnw6lq8zzyn9am74pmvza39"; - }; - }; - home = "/var/lib/arafetch"; -in { - users.users.arafetch = { - uid = genid "arafetch"; - inherit home; - createHome = true; - isSystemUser = true; - group = "arafetch"; - }; - users.groups.arafetch = {}; - - systemd.services.ara2mqtt = { - startAt = "05:00:00"; - after = [ "network-online.target" ]; - path = [ pkg ]; - serviceConfig = { - User = "arafetch"; - # Restart = "always"; - WorkingDirectory = home; - PrivateTmp = true; - ExecStart = pkgs.writeDash "daily-mqtt" '' - ara2mqtt db/thales-deutschland.json --cantine thales-deutschland --host localhost - ''; - }; - }; - systemd.services.arafetch = { - startAt = "Mon,Wed,Fri 09:15:00"; - wantedBy = [ "multi-user.target" ]; - after = [ "network-online.target" ]; - environment.OUTDIR = home; - path = [ pkg pkgs.git pkgs.wget ]; - serviceConfig = { - User = "arafetch"; - # Restart = "always"; - WorkingDirectory = home; - PrivateTmp = true; - ExecStart = pkgs.writeDash "start-weekrun" '' - weekrun || echo "weekrun failed!" - find $OUTDIR/db -name \*.json | while read path;do - file=''${path##*/} - cantine=''${file%%.json} - ara2influx $path --cantine $cantine --host wbob.r - done - ''; - }; - }; -} diff --git a/makefu/2configs/stats/client.nix b/makefu/2configs/stats/client.nix deleted file mode 100644 index b88515a35..000000000 --- a/makefu/2configs/stats/client.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ - makefu.netdata = { - enable = true; - stream.role = "slave"; - # stream.destination = "netdata.makefu.r"; - }; -} diff --git a/makefu/2configs/stats/collectd-client.nix b/makefu/2configs/stats/collectd-client.nix deleted file mode 100644 index cfb5e3fd2..000000000 --- a/makefu/2configs/stats/collectd-client.nix +++ /dev/null @@ -1,61 +0,0 @@ -{pkgs, config, ...}: -{ - services.collectd = { - enable = true; - autoLoadPlugin = true; - extraConfig = '' - Hostname ${config.krebs.build.host.name} - LoadPlugin load - LoadPlugin disk - LoadPlugin memory - LoadPlugin df - Interval 30.0 - - LoadPlugin interface - <Plugin "interface"> - Interface "*Link" - Interface "lo" - Interface "vboxnet*" - Interface "virbr*" - IgnoreSelected true - </Plugin> - - LoadPlugin df - <Plugin "df"> - MountPoint "/nix/store" - # MountPoint "/run*" - # MountPoint "/sys*" - # MountPoint "/dev" - # MountPoint "/dev/shm" - # MountPoint "/tmp" - FSType "tmpfs" - FSType "binfmt_misc" - FSType "debugfs" - FSType "tracefs" - FSType "mqueue" - FSType "hugetlbfs" - FSType "systemd-1" - FSType "cgroup" - FSType "securityfs" - FSType "ramfs" - FSType "proc" - FSType "devpts" - FSType "devtmpfs" - MountPoint "/var/lib/docker/devicemapper" - IgnoreSelected true - </Plugin> - - LoadPlugin cpu - <Plugin cpu> - ReportByCpu true - ReportByState true - ValuesPercentage true - </Plugin> - - LoadPlugin network - <Plugin "network"> - Server "${config.makefu.stats-server}" "25826" - </Plugin> - ''; - }; -} diff --git a/makefu/2configs/stats/external/aralast.nix b/makefu/2configs/stats/external/aralast.nix deleted file mode 100644 index 19c7327af..000000000 --- a/makefu/2configs/stats/external/aralast.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - pkg = pkgs.stdenv.mkDerivation { - name = "aralast-master"; - src = pkgs.fetchFromGitHub { - owner = "makefu"; - repo = "aralast"; - rev = "a0d3aeaa109e219fb6fc57170e59020c23413718"; - sha256 = "0bi0nc51z5wk72lnjhg1gfzr5yvvsshyzq924yjbbqpqw08v7i4p"; - }; - installPhase = '' - install -m755 -D aralast.sh $out/bin/aralast - ''; - }; -in { - systemd.services.aralast = { - description = "periodically fetch aramark"; - path = [ - pkgs.curl - pkgs.gnugrep - pkgs.gnused - ]; - wantedBy = [ "multi-user.target" ]; - environment = { - INFLUX_HOST = "localhost"; - INFLUX_PORT = "8086"; - }; - # every 10 seconds when the cantina is open - startAt = "Mon,Tue,Wed,Thu,Fri *-*-* 6,7,8,9,10,11,12,13,14,15:*:0,15,30,45"; - serviceConfig = { - User = "nobody"; - ExecStart = "${pkg}/bin/aralast"; - PrivateTmp = true; - }; - }; -} diff --git a/makefu/2configs/stats/external/weather2stats.nix b/makefu/2configs/stats/external/weather2stats.nix deleted file mode 100644 index 870db99a8..000000000 --- a/makefu/2configs/stats/external/weather2stats.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ config, lib, pkgs, ... }: - -with import <stockholm/lib>; -let - pkg = pkgs.stdenv.mkDerivation { - name = "aralast-master"; - src = pkgs.fetchFromGitHub { - owner = "makefu"; - repo = "aralast"; - rev = "7121598"; - sha256 = "0vw027c698h9b69ksid5p3pji9960hd7n9xi4arrax0vfkwryb4m"; - }; - installPhase = '' - install -m755 -D aralast.sh $out/bin/aralast - ''; - }; -in { - systemd.services.aralast = { - description = "periodically fetch aramark"; - path = [ - pkgs.curl - pkgs.gnugrep - pkgs.gnused - ]; - wantedBy = [ "multi-user.target" ]; - environment = { - INFLUX_HOST = "localhost"; - INFLUX_PORT = "8086"; - }; - # every 10 seconds when the cantina is open - startAt = "Mon,Tue,Wed,Thu,Fri *-*-* 6,7,8,9,10,11,12,13,14,15:*:0,15,30,45"; - serviceConfig = { - User = "nobody"; - ExecStart = "${pkg}/bin/aralast"; - PrivateTmp = true; - }; - }; -} diff --git a/makefu/2configs/stats/netdata-server.nix b/makefu/2configs/stats/netdata-server.nix deleted file mode 100644 index 5fec3583c..000000000 --- a/makefu/2configs/stats/netdata-server.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - makefu.netdata = { - enable = true; - stream.role = "master"; - }; - - services.nginx = { - virtualHosts."netdata.euer.krebsco.de" = { - addSSL = true; - enableACME = true; - locations."/".proxyPass = "http://localhost:19999"; - }; - virtualHosts."netdata.makefu.r" = { - locations."/".proxyPass = "http://localhost:19999"; - }; - }; -} diff --git a/makefu/2configs/stats/nodisk-client.nix b/makefu/2configs/stats/nodisk-client.nix deleted file mode 100644 index fc8a268ce..000000000 --- a/makefu/2configs/stats/nodisk-client.nix +++ /dev/null @@ -1,60 +0,0 @@ -{pkgs, config, ...}: -{ - # disk module wakes up parked disks - services.collectd = { - enable = true; - autoLoadPlugin = true; - extraConfig = '' - Hostname ${config.krebs.build.host.name} - LoadPlugin load - LoadPlugin disk - LoadPlugin memory - Interval 30.0 - - LoadPlugin interface - <Plugin "interface"> - Interface "*Link" - Interface "lo" - Interface "vboxnet*" - Interface "virbr*" - IgnoreSelected true - </Plugin> - - # LoadPlugin df - #<Plugin "df"> - # MountPoint "/nix/store" - # # MountPoint "/run*" - # # MountPoint "/sys*" - # # MountPoint "/dev" - # # MountPoint "/dev/shm" - # # MountPoint "/tmp" - # FSType "tmpfs" - # FSType "binfmt_misc" - # FSType "debugfs" - # FSType "mqueue" - # FSType "hugetlbfs" - # FSType "systemd-1" - # FSType "cgroup" - # FSType "securityfs" - # FSType "ramfs" - # FSType "proc" - # FSType "devpts" - # FSType "devtmpfs" - # MountPoint "/var/lib/docker/devicemapper" - # IgnoreSelected true - #</Plugin> - - LoadPlugin cpu - <Plugin cpu> - ReportByCpu true - ReportByState true - ValuesPercentage true - </Plugin> - - LoadPlugin network - <Plugin "network"> - Server "${config.makefu.stats-server}" "25826" - </Plugin> - ''; - }; -} diff --git a/makefu/2configs/stats/server.nix b/makefu/2configs/stats/server.nix deleted file mode 100644 index 82ce31a62..000000000 --- a/makefu/2configs/stats/server.nix +++ /dev/null @@ -1,65 +0,0 @@ -{pkgs, config, ...}: - -with import <stockholm/lib>; -let - irc-server = "irc.r"; - irc-nick = "m-alarm"; - collectd-port = 25826; - influx-port = 8086; - grafana-port = 3000; - db = "collectd_db"; - logging-interface = config.makefu.server.primary-itf; -in { - services.grafana.enable = true; - services.grafana.addr = "0.0.0.0"; - - services.influxdb.enable = true; - systemd.services.influxdb.serviceConfig.LimitNOFILE = 8192; - - # redirect grafana to stats.makefu.r - services.nginx.enable = true; - services.nginx.virtualHosts."stats.makefu.r".locations."/".proxyPass = "http://localhost:3000"; - # forward these via nginx - services.influxdb.extraConfig = { - meta.hostname = config.krebs.build.host.name; - # meta.logging-enabled = true; - logging.level = "info"; - http.log-enabled = true; - http.flux-enabled = true; - http.write-tracing = false; - http.suppress-write-log = true; - data.trace-logging-enabled = false; - data.query-log-enabled = false; - reporting-disabled = true; - - http.bind-address = ":${toString influx-port}"; - admin.bind-address = ":8083"; - monitoring = { - enabled = false; - # write-interval = "24h"; - }; - collectd = [{ - enabled = true; - typesdb = "${pkgs.collectd}/share/collectd/types.db"; - database = db; - bind-address = ":${toString collectd-port}"; - }]; - }; - - networking.firewall.extraCommands = '' - iptables -A INPUT -i retiolum -p udp --dport ${toString collectd-port} -j ACCEPT - iptables -A INPUT -i retiolum -p tcp --dport ${toString influx-port} -j ACCEPT - iptables -A INPUT -i retiolum -p tcp --dport ${toString grafana-port} -j ACCEPT - #iptables -A INPUT -i ${logging-interface} -p udp --dport ${toString collectd-port} -j ACCEPT - #iptables -A INPUT -i ${logging-interface} -p tcp --dport ${toString influx-port} -j ACCEPT - #iptables -A INPUT -i ${logging-interface} -p tcp --dport ${toString grafana-port} -j ACCEPT - - ip6tables -A INPUT -i retiolum -p udp --dport ${toString collectd-port} -j ACCEPT - ip6tables -A INPUT -i retiolum -p tcp --dport ${toString influx-port} -j ACCEPT - ip6tables -A INPUT -i retiolum -p tcp --dport ${toString grafana-port} -j ACCEPT - #ip6tables -A INPUT -i ${logging-interface} -p udp --dport ${toString collectd-port} -j ACCEPT - #ip6tables -A INPUT -i ${logging-interface} -p tcp --dport ${toString influx-port} -j ACCEPT - #ip6tables -A INPUT -i ${logging-interface} -p tcp --dport ${toString grafana-port} -j ACCEPT - ''; - state = [ "/var/lib/grafana/data/grafana.db" ]; -} diff --git a/makefu/2configs/stats/telegraf/airsensor.nix b/makefu/2configs/stats/telegraf/airsensor.nix deleted file mode 100644 index 9d481000f..000000000 --- a/makefu/2configs/stats/telegraf/airsensor.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ pkgs, ...}: -let - genTopic = name: topic: tags: { - servers = [ "tcp://localhost:1883" ]; - qos = 0; - connection_timeout = "30s"; - topics = [ topic ]; - tags = tags; - persistent_session = false; - name_override = name; - data_format = "value"; - data_type = "float"; - }; - bamStat = stat: # Temperature or Humidity - host: # easy{1-4} - sensor: # dht11, dht22, ds18 - (genTopic stat - "/bam/${host}/${sensor}/${stat}" - {"host" = host; - "scope" = "bam"; - "sensor" = sensor; - } ); - dht22 = host: [(bamStat "Temperature" host "dht22") - (bamStat "Humidity" host "dht22")]; - dht11 = host: [(bamStat "Temperature" host "dht11") - (bamStat "Humidity" host "dht11")]; - ds18 = host: [(bamStat "Temperature" host "ds18")]; -in { - services.udev.extraRules = '' - SUBSYSTEMS=="usb", ATTRS{product}=="iAQ Stick", GROUP="input" - ''; - users.users.telegraf.extraGroups = [ "input" ]; - services.telegraf.extraConfig.inputs.exec = [ - { - commands = [ "${pkgs.airsensor-py}/bin/airsensor-py"]; - timeout = "10s"; - data_format = "value"; - data_type = "integer"; - name_override = "airquality"; - interval = "10s"; - tags.unit="VOC"; - } - ]; - services.telegraf.extraConfig.inputs.mqtt_consumer = - (dht22 "easy1") - ++ (dht22 "easy2") - ++ (dht11 "easy3") - ++ (ds18 "easy3"); -} diff --git a/makefu/2configs/stats/telegraf/bamstats.nix b/makefu/2configs/stats/telegraf/bamstats.nix deleted file mode 100644 index ae5301204..000000000 --- a/makefu/2configs/stats/telegraf/bamstats.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ pkgs, ...}: - -let - genTopic = name: topic: tags: { - servers = [ "tcp://localhost:1883" ]; - qos = 0; - connection_timeout = "30s"; - topics = [ topic ]; - tags = tags; - persistent_session = false; - name_override = name; - data_format = "value"; - data_type = "float"; - }; - bamStat = stat: # Temperature or Humidity - host: # easy{1-4} - sensor: # dht11, dht22, ds18 - (genTopic stat - "/bam/${host}/${sensor}/${stat}" - {"host" = host; - "scope" = "bam"; - "sensor" = sensor; - } ); - dht22 = host: [(bamStat "Temperature" host "dht22") - (bamStat "Humidity" host "dht22")]; - dht11 = host: [(bamStat "Temperature" host "dht11") - (bamStat "Humidity" host "dht11")]; - ds18 = host: [(bamStat "Temperature" host "ds18")]; -in { - services.telegraf.extraConfig.inputs.mqtt_consumer = - (dht22 "easy1") - ++ (dht22 "easy2") - ++ (dht11 "easy3") - ++ (ds18 "easy3"); -} diff --git a/makefu/2configs/stats/telegraf/default.nix b/makefu/2configs/stats/telegraf/default.nix deleted file mode 100644 index 941685695..000000000 --- a/makefu/2configs/stats/telegraf/default.nix +++ /dev/null @@ -1,30 +0,0 @@ -{...}: -let - url = "http://localhost:8086"; - mqtt_server = "localhost:1883"; -in { - services.telegraf = { - enable = true; - extraConfig = { - agent.debug = false; - outputs = { - influxdb = [{ - urls = [ url ]; - database = "telegraf"; - }]; - #file = [{ # debugging - # files = [ "stdout" ]; - # data_format = "influx"; - #}]; - - mqtt = [{ - servers = [ mqtt_server ]; - topic_prefix = "/telegraf"; - data_format = "json"; - qos = 0; - batch = false; - }]; - }; - }; - }; -} diff --git a/makefu/2configs/stats/telegraf/europastats.nix b/makefu/2configs/stats/telegraf/europastats.nix deleted file mode 100644 index 2ab62766a..000000000 --- a/makefu/2configs/stats/telegraf/europastats.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ pkgs, ...}: -let - pkg = with pkgs.python3Packages;buildPythonPackage rec { - rev = "be31da7"; - name = "europastats-${rev}"; - propagatedBuildInputs = [ - requests - docopt - ]; - src = pkgs.fetchgit { - url = "http://cgit.euer.krebsco.de/europastats"; - inherit rev; - sha256 = "0qj18vgj9nm6aisyqhk3iz3rf8xp7mn5jc6sfylcaw588a9sjfvc"; - }; - }; -in { - services.telegraf.extraConfig.inputs.exec = [ - { - commands = [ "${pkg}/bin/europa-attractions"]; - timeout = "1m"; - data_format = "json"; - name_override = "europawaiting"; - interval = "1m"; - tag_keys = [ - "status" - "type" - "name" - ]; - } - { - commands = [ "${pkg}/bin/europa-weather"]; - timeout = "20s"; - data_format = "json"; - name_override = "europaweather"; - interval = "10m"; - tag_keys = [ - "type" - "name" - "offset" - ]; - } - ]; -} diff --git a/makefu/2configs/stats/telegraf/hamstats.nix b/makefu/2configs/stats/telegraf/hamstats.nix deleted file mode 100644 index 99cb0cd04..000000000 --- a/makefu/2configs/stats/telegraf/hamstats.nix +++ /dev/null @@ -1,69 +0,0 @@ -{ pkgs, lib, ...}: - -let - genTopic_zigbee = name: tags: { - servers = [ "tcp://localhost:1883" ]; - username = "stats"; - password = lib.removeSuffix "\n" (builtins.readFile <secrets/mqtt/stats>); - qos = 0; - connection_timeout = "30s"; - topics = [ "/ham/zigbee/${name}" ]; - inherit tags; - persistent_session = false; - name_override = "zigbee ${tags.room} ${name}"; - data_format = "json"; - json_string_fields = [ "linkquality" "temperature" "humidity" "pressure" "battery" "contact" ]; - # json_name_key = <filed which defines the name> - - }; - genTopic_plain = name: topic: tags: { - servers = [ "tcp://localhost:1883" ]; - username = "stats"; - password = lib.removeSuffix "\n" (builtins.readFile <secrets/mqtt/stats>); - qos = 0; - connection_timeout = "30s"; - topics = [ topic ]; - inherit tags; - persistent_session = false; - name_override = tags.sensor; - data_type = "float"; - data_format = "value"; - # json_query = tags.sensor; #TODO? - }; - flycounter = name: - (genTopic_plain name ''/ham/flycounter/${name}'' - { inherit name; - "sensor" = name; - "type" = "gauge"; - "scope" = "ham"; - } ); - esensor = room: name: sensor: - (genTopic_plain sensor ''/ham/${room}/${name}/sensor/${sensor}/state'' - { inherit room sensor name; - "scope" = "ham"; - } ); - zsensor = room: name: - (genTopic_zigbee name - { inherit room name; - "scope" = "ham"; - } ); - zigbee_temphum = room: name: [ - (zsensor room name) - ]; - esphome_temphum = room: name: [ - (esensor room name ''${room}_${name}_temperature'') - (esensor room name ''${room}_${name}_humidity'') - (esensor room name ''${room}_${name}_pressure'') - ]; -in { - services.telegraf.extraConfig.inputs.mqtt_consumer = - (zigbee_temphum "Wohnzimmer" "temp1") - ++ (zigbee_temphum "Badezimmer" "temp2") - ++ (zigbee_temphum "Kinderzimmer" "temp3") - ++ (esphome_temphum "arbeitszimmer" "box") - ++ (esphome_temphum "schlafzimmer" "plug") - ++ (esphome_temphum "wohnzimmer" "plug") - ++ (esphome_temphum "terrasse" "plug") - ++ [ (flycounter "misa_fliegen") (flycounter "felix_fliegen") ] - ; -} |