From a07a40b018390b5832da6cf201c26ecfd4d1b7b3 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 17 Aug 2020 00:46:25 +0200 Subject: ma pkgs.nsrenamer: init --- makefu/5pkgs/nsrenamer/default.nix | 3 ++ makefu/5pkgs/nsrenamer/nsrenamer.sh | 58 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 makefu/5pkgs/nsrenamer/default.nix create mode 100755 makefu/5pkgs/nsrenamer/nsrenamer.sh diff --git a/makefu/5pkgs/nsrenamer/default.nix b/makefu/5pkgs/nsrenamer/default.nix new file mode 100644 index 000000000..9dbd3ad4f --- /dev/null +++ b/makefu/5pkgs/nsrenamer/default.nix @@ -0,0 +1,3 @@ +{ pkgs,... }: +# TODO: dependencies: coreutils, nx_game_info, +pkgs.writeScriptBin "nsrenamer" ./nsrenamer.sh diff --git a/makefu/5pkgs/nsrenamer/nsrenamer.sh b/makefu/5pkgs/nsrenamer/nsrenamer.sh new file mode 100755 index 000000000..3d60d1ae9 --- /dev/null +++ b/makefu/5pkgs/nsrenamer/nsrenamer.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +set -euf +indir=$(dirname "$1") +inname=$(basename "$1") +out=$(nxgameinfo_cli "$1") +ext=${1##*.} +id=$(awk -F: '/├ Title ID:/{print $2}' <<<$out |xargs) +baseid=$(awk -F: '/Base Title ID:/{print $2}' <<<$out |xargs) +version=$(awk -F: '/├ Display Version:/{print $2}' <<<$out |xargs) +name=$(awk -F: '/Title Name/{print $2}' <<<$out |xargs) +type=$(awk -F: '/Type:/{print $2}' <<<$out | xargs) + +! test -n "$id" && echo "Title ID cannot be empty!" && exit 1 +! test -n "$type" && echo "type cannot be empty!" && exit 1 + +if test "$type" == Base;then + ! test -n "$name" && echo "Title Name cannot be empty!" && exit 1 + NAME="[$id] $name Base Game.$ext" +elif test "$type" == Update;then + ! test -n "$name" && echo "Title Name cannot be empty!" && exit 1 + ! test -n "$version" && echo "Version cannot be empty!" && exit 1 + NAME="[$id] $name Update $version.$ext" +elif test "$type" == DLC;then + dlcname=$(jq -r --arg id "$id" '.[$id].name' < ~/.switch/titles.US.en.json) + if test -n "$dlcname" ;then + NAME="[$id] $dlcname DLC.$ext" + else + ! test -n "$name" && echo "dlcname cannot be found in titles.US.en.json and $name is empty!" && exit 1 + NAME="[$id] $name DLC.$ext" + fi +else + echo "unknown type '$type'" + exit 1 +fi +newname=$indir/$NAME + +if test "$NAME" == "${inname}";then + echo "name didn't change,doing nothing" + exit 0 +fi +if test -e "$newname" ;then + echo "'$NAME' already exists, will not override" + exit 1 +fi + +if test -n "${FORCE:-}" ;then + CONFIRM=y +else + read -p "rename '$inname' to '$NAME' - [y/N]" CONFIRM +fi + +if test -n "${FORCE:-}" -o "$CONFIRM" == "y" -o "$CONFIRM" == "Y";then + mv -nv "$1" "$newname" +else + echo "bailing out" + exit 1 +fi + -- cgit v1.2.3 From 9b30bf0814bd142052c30d0184d589fede04e1cf Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 18 Aug 2020 23:26:51 +0200 Subject: ma pkgs.nsrenamer: new naming scheme --- makefu/5pkgs/nsrenamer/default.nix | 2 +- makefu/5pkgs/nsrenamer/nsrenamer.sh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/makefu/5pkgs/nsrenamer/default.nix b/makefu/5pkgs/nsrenamer/default.nix index 9dbd3ad4f..16b9a4f20 100644 --- a/makefu/5pkgs/nsrenamer/default.nix +++ b/makefu/5pkgs/nsrenamer/default.nix @@ -1,3 +1,3 @@ { pkgs,... }: # TODO: dependencies: coreutils, nx_game_info, -pkgs.writeScriptBin "nsrenamer" ./nsrenamer.sh +pkgs.writeScriptBin "nsrenamer" (builtins.readFile ./nsrenamer.sh) diff --git a/makefu/5pkgs/nsrenamer/nsrenamer.sh b/makefu/5pkgs/nsrenamer/nsrenamer.sh index 3d60d1ae9..16aec3113 100755 --- a/makefu/5pkgs/nsrenamer/nsrenamer.sh +++ b/makefu/5pkgs/nsrenamer/nsrenamer.sh @@ -4,29 +4,29 @@ indir=$(dirname "$1") inname=$(basename "$1") out=$(nxgameinfo_cli "$1") ext=${1##*.} -id=$(awk -F: '/├ Title ID:/{print $2}' <<<$out |xargs) -baseid=$(awk -F: '/Base Title ID:/{print $2}' <<<$out |xargs) -version=$(awk -F: '/├ Display Version:/{print $2}' <<<$out |xargs) -name=$(awk -F: '/Title Name/{print $2}' <<<$out |xargs) -type=$(awk -F: '/Type:/{print $2}' <<<$out | xargs) +id=$(awk -F: '/├ Title ID:/{print $2}' <<<"$out" |xargs) +baseid=$(awk -F: '/Base Title ID:/{print $2}' <<<"$out" |xargs) +version=$(awk -F: '/├ Version:/{print $2}' <<<"$out" |xargs) +name=$(awk -F: '/Title Name/{print $2}' <<<"$out" | sed "s/[:']//g" | xargs ) +type=$(awk -F: '/Type:/{print $2}' <<<"$out" | xargs) ! test -n "$id" && echo "Title ID cannot be empty!" && exit 1 ! test -n "$type" && echo "type cannot be empty!" && exit 1 if test "$type" == Base;then ! test -n "$name" && echo "Title Name cannot be empty!" && exit 1 - NAME="[$id] $name Base Game.$ext" + NAME="$name [$id][v$version].$ext" elif test "$type" == Update;then ! test -n "$name" && echo "Title Name cannot be empty!" && exit 1 ! test -n "$version" && echo "Version cannot be empty!" && exit 1 - NAME="[$id] $name Update $version.$ext" + NAME="$name [UPD][$id][v$version].$ext" elif test "$type" == DLC;then - dlcname=$(jq -r --arg id "$id" '.[$id].name' < ~/.switch/titles.US.en.json) + dlcname=$(jq -r --arg id "$id" '.[$id].name' < ~/.switch/titles.US.en.json | sed "s/[:']//g") if test -n "$dlcname" ;then - NAME="[$id] $dlcname DLC.$ext" + NAME="$dlcname [DLC][$id][v$version].$ext" else ! test -n "$name" && echo "dlcname cannot be found in titles.US.en.json and $name is empty!" && exit 1 - NAME="[$id] $name DLC.$ext" + NAME="$dlcname [DLC][$id][v$version].$ext" fi else echo "unknown type '$type'" -- cgit v1.2.3 From 726238d8717a03f6c80da31d4923632fed27e15a Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 1 Sep 2020 23:25:17 +0200 Subject: glados/wasser: giesszeit 10 -> 20 --- krebs/2configs/shack/glados/multi/wasser.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/2configs/shack/glados/multi/wasser.nix b/krebs/2configs/shack/glados/multi/wasser.nix index 6f3dc98ad..e3ba28384 100644 --- a/krebs/2configs/shack/glados/multi/wasser.nix +++ b/krebs/2configs/shack/glados/multi/wasser.nix @@ -2,7 +2,7 @@ # switch.crafting_giesskanne_relay let glados = import ../lib; - seconds = 10; + seconds = 20; wasser = "switch.crafting_giesskanne_relay"; in { -- cgit v1.2.3 From 865f527886722416c9a65a6b31ef7cff1f3e45ca Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 2 Sep 2020 00:19:59 +0200 Subject: ma pkgs.chapter-marker: bump to latest master --- makefu/5pkgs/chapter-marker/default.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/makefu/5pkgs/chapter-marker/default.nix b/makefu/5pkgs/chapter-marker/default.nix index fe3e48142..5ffb63ae9 100644 --- a/makefu/5pkgs/chapter-marker/default.nix +++ b/makefu/5pkgs/chapter-marker/default.nix @@ -1,4 +1,4 @@ -{ coreutils, fetchFromGitHub, makeWrapper, xdotool, stdenv, ... }: +{ coreutils, fetchFromGitHub, makeWrapper, xclip, libnotify, stdenv, ... }: stdenv.mkDerivation rec { name = "chapter-marker-${version}"; @@ -6,8 +6,8 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "makefu"; repo = "chapter-marker"; - rev = "7602b611fb3d67fdb8a86db23220074dfa9dfa1e"; - sha256 = "0cwh650c3qhdrcvrqfzgrwpsnj4lbq64fw2sfwvnbxz94b4q36av"; + rev = "71b9bb8bc4d6fa87de6bea8f42d5486d05cf5443"; + sha256 = "13cvk24pwwyv9i21h57690s5niwkcrcvn8l24zfxwbgq0wwzw38x"; }; buildInputs = [ makeWrapper ]; @@ -16,7 +16,8 @@ stdenv.mkDerivation rec { let path = stdenv.lib.makeBinPath [ coreutils - xdotool + libnotify + xclip ]; in '' -- cgit v1.2.3 From 8bec9d2662ba65e3c65c6e416618af24a4d6832f Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 2 Sep 2020 00:43:34 +0200 Subject: ma pkgs.awesomecfg: start chapter-marks with ctrl-u, create new entry with ctrl-j --- makefu/5pkgs/awesomecfg/full.cfg | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/makefu/5pkgs/awesomecfg/full.cfg b/makefu/5pkgs/awesomecfg/full.cfg index d96b61ad6..86b401cfa 100644 --- a/makefu/5pkgs/awesomecfg/full.cfg +++ b/makefu/5pkgs/awesomecfg/full.cfg @@ -376,6 +376,12 @@ globalkeys = awful.util.table.join( awful.key({ }, "XF86AudioMute", function () awful.util.spawn("@alsaUtils@/bin/amixer -q -D default sset Master toggle", false) end), + -- chapter-marker + awful.key({ "Control" }, "u", function () awful.spawn("@chaptermarker@/bin/chapter-start") end, + {description = "start the chapter marker",}), + awful.key({ "Control" }, "j", function () awful.spawn("@chaptermarker@/bin/chapter-mark") end, + {description = "create a chapter mark",}), + -- Prompt awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end, {description = "run prompt", group = "launcher"}), @@ -492,9 +498,16 @@ awful.rules.rules = { properties = { floating = true } }, --{ rule = { class = "gimp" }, -- properties = { floating = true } }, - -- Set Firefox to always map on tags number 2 of screen 1. - -- { rule = { class = "Firefox" }, - -- properties = { tag = tags[1][2] } }, + { rule = { class = "Firefox" }, + properties = { tag = tags[3] } }, + { rule = { class = "signal-desktop" }, + properties = { tag = tags[4] } }, + { rule = { class = "telegram-desktop" }, + properties = { tag = tags[4] } }, + { rule = { class = "mutt" }, + properties = { tag = tags[5] } }, + { rule = { class = "mosh" }, + properties = { tag = tags[2] } }, } -- }}} @@ -569,7 +582,7 @@ local os = { -- {{{ autostart do - awful.spawn("urxvt", { tag = tags[1] }) -- dev shell + -- awful.spawn("urxvt", { tag = tags[1] }) -- dev shell awful.spawn("urxvt -e mosh makefu@gum.i", { tag = tags[2] }) awful.spawn("firefox", { tag = tags[3] }) awful.spawn("telegram-desktop", { tag = tags[4] }) -- cgit v1.2.3 From 1cd926948feb5d049e5dd984d3fe2d6970522593 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 3 Sep 2020 19:21:45 +0200 Subject: ma wbob.r: disable logging server --- makefu/1systems/wbob/config.nix | 4 +++- makefu/2configs/deployment/docker/template.md | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/makefu/1systems/wbob/config.nix b/makefu/1systems/wbob/config.nix index 9d0c7af61..32dedbde2 100644 --- a/makefu/1systems/wbob/config.nix +++ b/makefu/1systems/wbob/config.nix @@ -26,7 +26,8 @@ in { # # # - + ## no need for dns logs anymore + # # Services # @@ -48,6 +49,7 @@ in { # new hass entry point + # # #mpd is only used for TTS, this is the web interface diff --git a/makefu/2configs/deployment/docker/template.md b/makefu/2configs/deployment/docker/template.md index a26b2f042..690ce236e 100644 --- a/makefu/2configs/deployment/docker/template.md +++ b/makefu/2configs/deployment/docker/template.md @@ -1,15 +1,20 @@ # BGT -1. studio-link aufnehmen drücken (wichtig) - - markus 6407eb63@studio-link.de - - Felix1 1f1021b2@studio-link.de - - L33tFelix 4d47a82a@studio-link.de - - Ingo 03b33b4a@studio-link.de +1. studio-link aufnehmen drücken, schauen ob file größer wird (wichtig) + - markus 6407eb63@studio-link.de + - Felix1 1f1021b2@studio-link.de + - L33tFelix 842f85eb@studio-link.de + - Ingo 03b33b4a@studio-link.de 2. audiocity starten, 48000Hz einstellen, Audio-Device checken und aufnehmen drücken (wichtig) + * alternativ: + `$ pacmd list-sources | grep -e device.string -e 'name:' # keins der "monitor" devices` + `$ parecord --channels=1 -d alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo bgt.wav` 3. obs starten und aufnehmen drücken (eher unwichtig) -4. darkice starten (wichtig) -4. klatschen -5. Hallo und herzlich Willkommen +5. darkice starten (wichtig) +6. klatschen +7. Hallihallo und Herzlich Willkommen +8. chapter-marker starten mit ctrl-u auf "H" von "Halli" (wichtig) +9. Blast markieren und ctrl-j drücken für neuen Eintrag ## Vorschläge ### Backlog von Picks und Lesefoo aus der letzten Woche @@ -31,3 +36,5 @@ ## Lesefoo ## Picks + +## Ende -- cgit v1.2.3 From 440d1cc6642a22f4155fa616c5647cbd2bfbfb77 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 9 Sep 2020 00:32:10 +0200 Subject: shack/glados: re-enable influxdb output --- krebs/2configs/shack/glados/default.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index 9bf90bca4..e4f032950 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -62,13 +62,14 @@ in { ]; }; # https://www.home-assistant.io/components/influxdb/ - #influxdb = { - # database = "hass"; - # tags = { - # instance = "wolf"; - # source = "hass"; - # }; - #}; + influxdb = { + database = "glados"; + host = "influx.shack"; + tags = { + instance = "wolf"; + source = "glados"; + }; + }; esphome = {}; api = {}; mqtt = { -- cgit v1.2.3 From 341d11575de0c8731e5ad474f95bd146a9c63267 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 13 Sep 2020 10:48:23 +0200 Subject: ma tools: add esphome, remove esptool --- makefu/2configs/tools/dev.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/makefu/2configs/tools/dev.nix b/makefu/2configs/tools/dev.nix index 276ed6cdc..2acdcf69c 100644 --- a/makefu/2configs/tools/dev.nix +++ b/makefu/2configs/tools/dev.nix @@ -13,8 +13,7 @@ gi flashrom mosquitto - nodemcu-uploader - esptool + esphome # nix related nix-index nix-review -- cgit v1.2.3 From 306653db954b41759fccfbd8b9d42ff712fe64f0 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 13 Sep 2020 13:56:58 +0200 Subject: wolf.r: more relevant nginx data --- krebs/1systems/wolf/config.nix | 16 ++++++++++++++++ krebs/2configs/shack/influx.nix | 5 +++++ krebs/2configs/shack/node-light.nix | 3 +++ 3 files changed, 24 insertions(+) diff --git a/krebs/1systems/wolf/config.nix b/krebs/1systems/wolf/config.nix index 029644ca6..a9e8aafee 100644 --- a/krebs/1systems/wolf/config.nix +++ b/krebs/1systems/wolf/config.nix @@ -34,6 +34,22 @@ in # powerraw usb serial to mqtt and raw socket + { # do not log to /var/spool/log + services.nginx.appendHttpConfig = '' + map $request_method $loggable { + default 1; + GET 0; + } + log_format vhost '$host $remote_addr - $remote_user ' + '[$time_local] "$request" $status ' + '$body_bytes_sent "$http_referer" ' + '"$http_user_agent"'; + error_log stderr; + access_log syslog:server=unix:/dev/log vhost; + ''; + services.journald.rateLimitBurst = 10000; + } + # create samba share for anonymous usage with the laser and 3d printer pc diff --git a/krebs/2configs/shack/influx.nix b/krebs/2configs/shack/influx.nix index 92cb24bf3..93d83a59b 100644 --- a/krebs/2configs/shack/influx.nix +++ b/krebs/2configs/shack/influx.nix @@ -8,6 +8,11 @@ in networking.firewall.allowedTCPPorts = [ port ]; # for legacy applications networking.firewall.allowedUDPPorts = [ collectd-port ]; services.nginx.virtualHosts."influx.shack" = { + # Disable constant GET request logging. + # $loggable map is defined in 1/wolf + extraConfig = '' + access_log syslog:server=unix:/dev/log combined if=$loggable; + ''; locations."/" = { proxyPass = "http://localhost:${toString port}/"; }; diff --git a/krebs/2configs/shack/node-light.nix b/krebs/2configs/shack/node-light.nix index b471f2af5..4a981ea87 100644 --- a/krebs/2configs/shack/node-light.nix +++ b/krebs/2configs/shack/node-light.nix @@ -28,6 +28,9 @@ in { }; services.nginx.virtualHosts."openhab.shack" = { + extraConfig = '' + access_log syslog:server=unix:/dev/log combined if=$loggable; + ''; serverAliases = [ "lightapi.shack" ]; locations."/power/".proxyPass = "http://localhost:${port}/power/"; locations."/lounge/".proxyPass = "http://localhost:${port}/lounge/"; -- cgit v1.2.3 From eaf4ed0b24dcc89191d018fa4ebd9331e22ea324 Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 13 Sep 2020 23:52:22 +0200 Subject: shack/prometheus: activate alerting to telegram --- .../2configs/shack/prometheus/alertmanager-telegram.nix | 17 +++++++++++++++++ krebs/2configs/shack/prometheus/server.nix | 11 +++-------- 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 krebs/2configs/shack/prometheus/alertmanager-telegram.nix diff --git a/krebs/2configs/shack/prometheus/alertmanager-telegram.nix b/krebs/2configs/shack/prometheus/alertmanager-telegram.nix new file mode 100644 index 000000000..9d0ef45e8 --- /dev/null +++ b/krebs/2configs/shack/prometheus/alertmanager-telegram.nix @@ -0,0 +1,17 @@ +{ pkgs, ...}: +{ + systemd.services.alertmanager-bot-telegram = { + wantedBy = [ "multi-user.target" ]; + after = [ "ip-up.target" ]; + serviceConfig = { + EnvironmentFile = toString ; + DynamicUser = true; + StateDirectory = "alertbot"; + ExecStart = ''${pkgs.alertmanager-bot-telegram}/bin/alertmanager-bot \ + --alertmanager.url=http://alert.prometheus.shack --log.level=info \ + --store=bolt --bolt.path=/var/lib/alertbot/bot.db \ + --listen.addr="0.0.0.0:16320" \ + --template.paths=${pkgs.alertmanager-bot-telegram}/templates/default.tmpl''; + }; + }; +} diff --git a/krebs/2configs/shack/prometheus/server.nix b/krebs/2configs/shack/prometheus/server.nix index c088a3b08..8f37f4478 100644 --- a/krebs/2configs/shack/prometheus/server.nix +++ b/krebs/2configs/shack/prometheus/server.nix @@ -118,7 +118,7 @@ ]; alertmanager = { enable = true; - listenAddress = "0.0.0.0"; + listenAddress = "127.0.0.1"; configuration = { "global" = { "smtp_smarthost" = "smtp.example.com:587"; @@ -134,15 +134,10 @@ "receivers" = [ { "name" = "team-admins"; - "email_configs" = [ - { - "to" = "devnull@example.com"; - "send_resolved" = true; - } - ]; + "email_configs" = [ ]; "webhook_configs" = [ { - "url" = "https://example.com/prometheus-alerts"; + "url" = "http://localhost:8080"; "send_resolved" = true; } ]; -- cgit v1.2.3 From 156339f63adcddcd8b1eb6d17bd4f76f72086920 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 14 Sep 2020 00:26:21 +0200 Subject: shack/prometheus: alertmanager-bot on a different port now --- krebs/2configs/shack/prometheus/alert-rules.nix | 5 ----- krebs/2configs/shack/prometheus/server.nix | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/krebs/2configs/shack/prometheus/alert-rules.nix b/krebs/2configs/shack/prometheus/alert-rules.nix index 096c551ba..afef5b8a4 100644 --- a/krebs/2configs/shack/prometheus/alert-rules.nix +++ b/krebs/2configs/shack/prometheus/alert-rules.nix @@ -71,11 +71,6 @@ in mapAttrsToList (name: opts: { summary = "{{$labels.alias}}: Using more than 30% of its swap."; description = "{{$labels.alias}} is using 30% of its swap space for at least 30 minutes."; }; - node_visible_confluence_space = { - condition = "node_visible_confluence_space != 0"; - summary = "crowd prometheus cann see the {{$labels.space_name}} confluence space!"; - description = "crowd user `prometheus` can see the `{{$labels.space_name}}` confluence space."; - }; node_hwmon_temp = { condition = "node_hwmon_temp_celsius > node_hwmon_temp_crit_celsius*0.9 OR node_hwmon_temp_celsius > node_hwmon_temp_max_celsius*0.95"; time = "5m"; diff --git a/krebs/2configs/shack/prometheus/server.nix b/krebs/2configs/shack/prometheus/server.nix index 8f37f4478..a10a43af7 100644 --- a/krebs/2configs/shack/prometheus/server.nix +++ b/krebs/2configs/shack/prometheus/server.nix @@ -119,6 +119,9 @@ alertmanager = { enable = true; listenAddress = "127.0.0.1"; + webExternalUrl = "http://alert.prometheus.shack"; + logLevel = "debug"; + configuration = { "global" = { "smtp_smarthost" = "smtp.example.com:587"; @@ -137,7 +140,7 @@ "email_configs" = [ ]; "webhook_configs" = [ { - "url" = "http://localhost:8080"; + "url" = "http://localhost:16320"; "send_resolved" = true; } ]; -- cgit v1.2.3 From fc836fc0cb2aa2a9e65b2314ab361788d8e73186 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 14 Sep 2020 11:11:58 +0200 Subject: shack/prometheus: strip down number of alerts to 3 --- krebs/2configs/shack/prometheus/alert-rules.nix | 135 +++++++----------------- krebs/2configs/shack/prometheus/server.nix | 9 +- 2 files changed, 43 insertions(+), 101 deletions(-) diff --git a/krebs/2configs/shack/prometheus/alert-rules.nix b/krebs/2configs/shack/prometheus/alert-rules.nix index afef5b8a4..730921bee 100644 --- a/krebs/2configs/shack/prometheus/alert-rules.nix +++ b/krebs/2configs/shack/prometheus/alert-rules.nix @@ -1,97 +1,42 @@ -{ lib }: -with lib; - +{ lib,... }: let - deviceFilter = ''device!="ramfs",device!="rpc_pipefs",device!="lxcfs",device!="nsfs",device!="borgfs"''; -in mapAttrsToList (name: opts: { - alert = name; - expr = opts.condition; - for = opts.time or "2m"; - labels = if (opts.page or true) then { severity = "page"; } else {}; - annotations = { - summary = opts.summary; - description = opts.description; - }; -}) { - node_down = { - condition = ''up{job="node"} == 0''; - summary = "{{$labels.alias}}: Node is down."; - description = "{{$labels.alias}} has been down for more than 2 minutes."; - }; - node_systemd_service_failed = { - condition = ''node_systemd_unit_state{state="failed"} == 1''; - summary = "{{$labels.alias}}: Service {{$labels.name}} failed to start."; - description = "{{$labels.alias}} failed to (re)start service {{$labels.name}}."; - }; - node_filesystem_full_80percent = { - condition = ''sort(node_filesystem_free_bytes{${deviceFilter}} < node_filesystem_size_bytes{${deviceFilter}} * 0.2) / 1024^3''; - time = "10m"; - summary = "{{$labels.alias}}: Filesystem is running out of space soon."; - description = "{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} got less than 20% space left on its filesystem."; - }; - node_filesystem_full_in_7d = { - condition = ''predict_linear(node_filesystem_free_bytes{${deviceFilter}}[2d], 7*24*3600) <= 0''; - time = "1h"; - summary = "{{$labels.alias}}: Filesystem is running out of space in 7 days."; - description = "{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} is running out of space of in approx. 7 days"; - }; - node_filesystem_full_in_30d = { - condition = ''predict_linear(node_filesystem_free_bytes{${deviceFilter}}[30d], 30*24*3600) <= 0''; - time = "1h"; - summary = "{{$labels.alias}}: Filesystem is running out of space in 30 days."; - description = "{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} is running out of space of in approx. 30 days"; - }; - node_filedescriptors_full_in_3h = { - condition = ''predict_linear(node_filefd_allocated[3h], 3*3600) >= node_filefd_maximum''; - time = "20m"; - summary = "{{$labels.alias}} is running out of available file descriptors in 3 hours."; - description = "{{$labels.alias}} is running out of available file descriptors in approx. 3 hours"; - }; - node_filedescriptors_full_in_7d = { - condition = ''predict_linear(node_filefd_allocated[7d], 7*24*3600) >= node_filefd_maximum''; - time = "1h"; - summary = "{{$labels.alias}} is running out of available file descriptors in 7 days."; - description = "{{$labels.alias}} is running out of available file descriptors in approx. 7 days"; - }; - node_load15 = { - condition = ''node_load15 / on(alias) count(node_cpu_seconds_total{mode="system"}) by (alias) >= 1.0''; - time = "10m"; - summary = "{{$labels.alias}}: Running on high load: {{$value}}"; - description = "{{$labels.alias}} is running with load15 > 1 for at least 5 minutes: {{$value}}"; - }; - node_ram_using_90percent = { - condition = "node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes < node_memory_MemTotal_bytes * 0.1"; - time = "1h"; - summary = "{{$labels.alias}}: Using lots of RAM."; - description = "{{$labels.alias}} is using at least 90% of its RAM for at least 1 hour."; - }; - node_swap_using_30percent = { - condition = "node_memory_SwapTotal_bytes - (node_memory_SwapFree_bytes + node_memory_SwapCached_bytes) > node_memory_SwapTotal_bytes * 0.3"; - time = "30m"; - summary = "{{$labels.alias}}: Using more than 30% of its swap."; - description = "{{$labels.alias}} is using 30% of its swap space for at least 30 minutes."; - }; - node_hwmon_temp = { - condition = "node_hwmon_temp_celsius > node_hwmon_temp_crit_celsius*0.9 OR node_hwmon_temp_celsius > node_hwmon_temp_max_celsius*0.95"; - time = "5m"; - summary = "{{$labels.alias}}: Sensor {{$labels.sensor}}/{{$labels.chip}} temp is high: {{$value}} "; - description = "{{$labels.alias}} reports hwmon sensor {{$labels.sensor}}/{{$labels.chip}} temperature value is nearly critical: {{$value}}"; - }; - node_conntrack_limit = { - condition = "node_nf_conntrack_entries_limit - node_nf_conntrack_entries < 1000"; - time = "5m"; - summary = "{{$labels.alias}}: Number of tracked connections high"; - description = "{{$labels.alias}} has only {{$value}} free slots for connection tracking available."; - }; - node_reboot = { - condition = "time() - node_boot_time_seconds < 300"; - summary = "{{$labels.alias}}: Reboot"; - description = "{{$labels.alias}} just rebooted."; - }; - node_uptime = { - condition = "time() - node_boot_time_seconds > 2592000"; - page = false; - summary = "{{$labels.alias}}: Uptime monster"; - description = "{{$labels.alias}} has been up for more than 30 days."; - }; + disk_free_threshold = "10"; # at least this much free disk percentage +in { + services.prometheus.rules = [(builtins.toJSON + { + groups = [ + { name = "shack-env"; + rules = [ + { + alert = "RootPartitionFull"; + for = "30m"; + expr = ''(node_filesystem_avail_bytes{alias="wolf",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="wolf",mountpoint="/"} < ${disk_free_threshold}''; + labels.severity = "warning"; + annotations.summary = "{{ $labels.alias }} root disk full"; + annotations.url = "http://grafana.shack/"; + annotations.description = ''The root disk of {{ $labels.alias }} has {{ $value | printf "%.2f" }}% free disk space (Threshold at ${disk_free_threshold}%).A vast number of shackspace services will stop working. CI for deploying new configuration will also seize working. Log in to the system and run `nix-collect-garbage -d` and clean up the shack share folder in `/home/share` .If this does not help you can check `du -hs /var/ | sort -h`, run `docker system prune` or if you are really desperate run `du -hs / | sort -h` and go through the folders recursively until you've found something to delete''; + } + { + alert = "RootPartitionFull"; + for = "30m"; + expr = ''(node_filesystem_avail_bytes{alias="puyak",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="puyak",mountpoint="/"} < ${disk_free_threshold}''; + labels.severity = "warning"; + annotations.summary = "{{ $labels.alias }} root disk full"; + annotations.url = "http://grafana.shack/"; + annotations.description = ''The root disk of {{ $labels.alias }} has {{ $value | printf "%.2f" }}% free disk space (Threshold at ${disk_free_threshold}%).Prometheus will not be able to create new alerts and CI for deploying new configuration will also seize working. Log in to the system and run `nix-collect-garbage -d` and if this does not help you can check `du -hs /var/ | sort -h`, run `docker system prune` or if you are really desperate run `du -hs / | sort -h` and go through the folders recursively until you've found something to delete''; + } + { + alert = "HostDown"; + expr = ''up{alias="wolf"} == 0''; + for = "5m"; + labels.severity = "page"; + annotations.summary = "Instance {{ $labels.alias }} down for 5 minutes"; + annotations.url = "http://grafana.shack/"; + annotations.description = ''Host {{ $labels.alias }} went down and has not been reconnected after 5 minutes. This is probably bad news, try to restart the host via naproxen ( http://naproxen.shack:8006 ). Wolf being down means that CI,glados automation, light management and a couple of other services will not work anymore.''; + } + ]; + } + ]; + } + )]; } diff --git a/krebs/2configs/shack/prometheus/server.nix b/krebs/2configs/shack/prometheus/server.nix index a10a43af7..9e4b4d1a7 100644 --- a/krebs/2configs/shack/prometheus/server.nix +++ b/krebs/2configs/shack/prometheus/server.nix @@ -1,6 +1,9 @@ { pkgs, lib, config, ... }: # from https://gist.github.com/globin/02496fd10a96a36f092a8e7ea0e6c7dd { + imports = [ + ./alert-rules.nix + ]; networking = { firewall.allowedTCPPorts = [ 9090 # prometheus @@ -18,12 +21,6 @@ }; prometheus = { enable = true; - ruleFiles = lib.singleton (pkgs.writeText "prometheus-rules.yml" (builtins.toJSON { - groups = lib.singleton { - name = "mf-alerting-rules"; - rules = import ./alert-rules.nix { inherit lib; }; - }; - })); scrapeConfigs = [ { job_name = "node"; -- cgit v1.2.3 From 57e6296ac4ca6b600f9e57b2c347f413096d09ed Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 14 Sep 2020 11:13:03 +0200 Subject: puyak.r: enable alertmanager-bot --- krebs/1systems/puyak/config.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/1systems/puyak/config.nix b/krebs/1systems/puyak/config.nix index a50d2eab4..8b30dfef9 100644 --- a/krebs/1systems/puyak/config.nix +++ b/krebs/1systems/puyak/config.nix @@ -18,6 +18,7 @@ + ## Collect local statistics via collectd and send to collectd -- cgit v1.2.3 From df4f3982b15bf107db1b2c5cad58167e30fb3dec Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 14 Sep 2020 11:42:32 +0200 Subject: shack/prometheus: use correct alias for rules --- krebs/2configs/shack/prometheus/alert-rules.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/2configs/shack/prometheus/alert-rules.nix b/krebs/2configs/shack/prometheus/alert-rules.nix index 730921bee..0da1128ab 100644 --- a/krebs/2configs/shack/prometheus/alert-rules.nix +++ b/krebs/2configs/shack/prometheus/alert-rules.nix @@ -10,7 +10,7 @@ in { { alert = "RootPartitionFull"; for = "30m"; - expr = ''(node_filesystem_avail_bytes{alias="wolf",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="wolf",mountpoint="/"} < ${disk_free_threshold}''; + expr = ''(node_filesystem_avail_bytes{alias="wolf.shack",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="wolf.shack",mountpoint="/"} < ${disk_free_threshold}''; labels.severity = "warning"; annotations.summary = "{{ $labels.alias }} root disk full"; annotations.url = "http://grafana.shack/"; @@ -19,7 +19,7 @@ in { { alert = "RootPartitionFull"; for = "30m"; - expr = ''(node_filesystem_avail_bytes{alias="puyak",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="puyak",mountpoint="/"} < ${disk_free_threshold}''; + expr = ''(node_filesystem_avail_bytes{alias="puyak.shack",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="puyak.shack",mountpoint="/"} < ${disk_free_threshold}''; labels.severity = "warning"; annotations.summary = "{{ $labels.alias }} root disk full"; annotations.url = "http://grafana.shack/"; @@ -27,7 +27,7 @@ in { } { alert = "HostDown"; - expr = ''up{alias="wolf"} == 0''; + expr = ''up{alias="wolf.shack"} == 0''; for = "5m"; labels.severity = "page"; annotations.summary = "Instance {{ $labels.alias }} down for 5 minutes"; -- cgit v1.2.3 From 88aee4087ebf00e32b39476ddbd82c7e69490280 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 14 Sep 2020 15:45:37 +0200 Subject: shack/prometheus: add urls to alerts --- krebs/2configs/shack/prometheus/alert-rules.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/2configs/shack/prometheus/alert-rules.nix b/krebs/2configs/shack/prometheus/alert-rules.nix index 0da1128ab..1c2d0b1ad 100644 --- a/krebs/2configs/shack/prometheus/alert-rules.nix +++ b/krebs/2configs/shack/prometheus/alert-rules.nix @@ -13,7 +13,7 @@ in { expr = ''(node_filesystem_avail_bytes{alias="wolf.shack",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="wolf.shack",mountpoint="/"} < ${disk_free_threshold}''; labels.severity = "warning"; annotations.summary = "{{ $labels.alias }} root disk full"; - annotations.url = "http://grafana.shack/"; + annotations.url = "http://grafana.shack/d/hb7fSE0Zz/shack-system-dashboard?orgId=1&var-job=node&var-hostname=All&var-node=wolf.shack:9100&var-device=All&var-maxmount=%2F&var-show_hostname=wolf"; annotations.description = ''The root disk of {{ $labels.alias }} has {{ $value | printf "%.2f" }}% free disk space (Threshold at ${disk_free_threshold}%).A vast number of shackspace services will stop working. CI for deploying new configuration will also seize working. Log in to the system and run `nix-collect-garbage -d` and clean up the shack share folder in `/home/share` .If this does not help you can check `du -hs /var/ | sort -h`, run `docker system prune` or if you are really desperate run `du -hs / | sort -h` and go through the folders recursively until you've found something to delete''; } { @@ -22,7 +22,7 @@ in { expr = ''(node_filesystem_avail_bytes{alias="puyak.shack",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="puyak.shack",mountpoint="/"} < ${disk_free_threshold}''; labels.severity = "warning"; annotations.summary = "{{ $labels.alias }} root disk full"; - annotations.url = "http://grafana.shack/"; + annotations.url = "http://grafana.shack/d/hb7fSE0Zz/shack-system-dashboard?orgId=1&var-job=node&var-hostname=All&var-node=wolf.shack:9100&var-device=All&var-maxmount=%2F&var-show_hostname=puyak"; annotations.description = ''The root disk of {{ $labels.alias }} has {{ $value | printf "%.2f" }}% free disk space (Threshold at ${disk_free_threshold}%).Prometheus will not be able to create new alerts and CI for deploying new configuration will also seize working. Log in to the system and run `nix-collect-garbage -d` and if this does not help you can check `du -hs /var/ | sort -h`, run `docker system prune` or if you are really desperate run `du -hs / | sort -h` and go through the folders recursively until you've found something to delete''; } { @@ -31,7 +31,7 @@ in { for = "5m"; labels.severity = "page"; annotations.summary = "Instance {{ $labels.alias }} down for 5 minutes"; - annotations.url = "http://grafana.shack/"; + annotations.url = "http://grafana.shack/d/hb7fSE0Zz/shack-system-dashboard?orgId=1&var-job=node&var-hostname=All&var-node=wolf.shack:9100&var-device=All&var-maxmount=%2F&var-show_hostname=wolf"; annotations.description = ''Host {{ $labels.alias }} went down and has not been reconnected after 5 minutes. This is probably bad news, try to restart the host via naproxen ( http://naproxen.shack:8006 ). Wolf being down means that CI,glados automation, light management and a couple of other services will not work anymore.''; } ]; -- cgit v1.2.3 From 1394ae1bd4bc3dcfb77b0daee996e75f8092fc5b Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 14 Sep 2020 16:56:30 +0200 Subject: shack/prometheus: add custom shack template --- .../shack/prometheus/alertmanager-telegram.nix | 4 ++-- .../2configs/shack/prometheus/templates/shack.tmpl | 25 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 krebs/2configs/shack/prometheus/templates/shack.tmpl diff --git a/krebs/2configs/shack/prometheus/alertmanager-telegram.nix b/krebs/2configs/shack/prometheus/alertmanager-telegram.nix index 9d0ef45e8..2df63e520 100644 --- a/krebs/2configs/shack/prometheus/alertmanager-telegram.nix +++ b/krebs/2configs/shack/prometheus/alertmanager-telegram.nix @@ -8,10 +8,10 @@ DynamicUser = true; StateDirectory = "alertbot"; ExecStart = ''${pkgs.alertmanager-bot-telegram}/bin/alertmanager-bot \ - --alertmanager.url=http://alert.prometheus.shack --log.level=info \ + --alertmanager.url=http://alert.prometheus.shack --log.level=debug \ --store=bolt --bolt.path=/var/lib/alertbot/bot.db \ --listen.addr="0.0.0.0:16320" \ - --template.paths=${pkgs.alertmanager-bot-telegram}/templates/default.tmpl''; + --template.paths=${./templates}/shack.tmpl''; }; }; } diff --git a/krebs/2configs/shack/prometheus/templates/shack.tmpl b/krebs/2configs/shack/prometheus/templates/shack.tmpl new file mode 100644 index 000000000..9295f019f --- /dev/null +++ b/krebs/2configs/shack/prometheus/templates/shack.tmpl @@ -0,0 +1,25 @@ +{{ define "telegram.default" }} +{{range .Alerts -}} +{{ $severity := index .Labels "severity" }} +{{ $desc := "No Description" }} +{{ if eq .Status "firing" }} + {{ $desc = index .Annotations "description" }} + {{- if eq $severity "critical" -}} + [CRITICAL] + {{- else if eq $severity "warning" -}} + [WARNING] + {{- else -}} + [{{ $severity }}] + {{- end -}} +{{ else -}} + {{ $desc = "The issue has been resolved" }} + [RESOLVED] +{{- end }} {{ index .Labels "alertname"}}: {{ index .Annotations "summary"}} + +{{ $desc }} + +Alert Links: +* Grafana +* Source +{{end -}} +{{end}} -- cgit v1.2.3 From 91b7a2a58490a59d6090870a9db9eca8d11d9ab4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 15 Sep 2020 20:16:10 +0200 Subject: go: return go.r for shortened urls --- krebs/2configs/go.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/2configs/go.nix b/krebs/2configs/go.nix index f4c1290c2..c39b08a8e 100644 --- a/krebs/2configs/go.nix +++ b/krebs/2configs/go.nix @@ -13,7 +13,7 @@ with import ; enable = true; virtualHosts.go = { locations."/".extraConfig = '' - proxy_set_header Host go; + proxy_set_header Host go.r; proxy_pass http://localhost:1337; ''; serverAliases = [ -- cgit v1.2.3 From 371a8ced90d4ef6bf0a26718dcf0ff506b9e4208 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 15 Sep 2020 20:38:17 +0200 Subject: l games: disable most games --- lass/2configs/games.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lass/2configs/games.nix b/lass/2configs/games.nix index 63bfa53e0..67f250ef3 100644 --- a/lass/2configs/games.nix +++ b/lass/2configs/games.nix @@ -66,14 +66,16 @@ in { useDefaultShell = true; packages = with pkgs; [ # minecraft - steam-run - scummvm - dolphinEmu - doom1 - doom2 - vdoom1 - vdoom2 - vdoomserver + # ftb + # steam-run + # scummvm + # dolphinEmu + # doom1 + # doom2 + # protontricks + # vdoom1 + # vdoom2 + # vdoomserver retroarchBare ]; }; -- cgit v1.2.3 From d8dbc950ab343c0b55697cb1737ff3572eea0893 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 15 Sep 2020 20:48:08 +0200 Subject: shack: add telegram_bot secret --- krebs/0tests/data/secrets/shack/telegram_bot.env | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 krebs/0tests/data/secrets/shack/telegram_bot.env diff --git a/krebs/0tests/data/secrets/shack/telegram_bot.env b/krebs/0tests/data/secrets/shack/telegram_bot.env new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3 From 9904ec050bfc8ff91a4d9bff43d3d21ac06e8772 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 15 Sep 2020 22:33:29 +0200 Subject: l yellow.r: add flix-index service --- lass/1systems/yellow/config.nix | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lass/1systems/yellow/config.nix b/lass/1systems/yellow/config.nix index 82fe3fac5..bc3b1f5d5 100644 --- a/lass/1systems/yellow/config.nix +++ b/lass/1systems/yellow/config.nix @@ -251,6 +251,27 @@ with import ; 3f8a56ddb2e64eb67adfc9b337157ff4 -----END OpenVPN Static key V1----- - ''; + + systemd.services.flix-index = { + wantedBy = [ "multi-user.target" ]; + path = [ + pkgs.coreutils + pkgs.findutils + pkgs.inotifyTools + ]; + serviceConfig = { + Restart = "always"; + ExecStart = pkgs.writers.writeDash "flix-index" '' + set -efu + + DIR=/var/download/finished + cd "$DIR" + while inotifywait -rq -e create -e move -e delete "$DIR"; do + find . -type f > "$DIR"/index.tmp + mv "$DIR"/index.tmp "$DIR"/index + done + ''; + }; + }; } -- cgit v1.2.3 From e6a8d378460827bab9a0fd45a50faa5eca7e8ae0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 15 Sep 2020 22:52:34 +0200 Subject: reaktor2: nicks can have special characters --- krebs/2configs/reaktor2.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix index 72eff176b..061dc9ab9 100644 --- a/krebs/2configs/reaktor2.nix +++ b/krebs/2configs/reaktor2.nix @@ -76,7 +76,7 @@ let }; } { - pattern = ''^([\w-]*):?\s+([+-][1-9][0-9]*)\s+(\S+)$''; + pattern = ''^([\H-]*):?\s+([+-][1-9][0-9]*)\s+(\S+)$''; activate = "match"; arguments = [1 2 3]; command = { -- cgit v1.2.3 From e87f9e002bfb458ea9ab6dcdab482df315b94d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 22 Aug 2020 09:07:03 +0100 Subject: mic92: add v4/v6 aliases to etc hosts this is convinient when you only want to speak a certain protocol --- krebs/3modules/hosts.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/krebs/3modules/hosts.nix b/krebs/3modules/hosts.nix index 159b54e34..ae0136303 100644 --- a/krebs/3modules/hosts.nix +++ b/krebs/3modules/hosts.nix @@ -48,7 +48,9 @@ in { hostNetAliases = host: mapAttrs (_: net: filter (x: x.name != null && x.value != []) [ { name = net.ip4.addr or null; value = net.aliases; } + { name = net.ip4.addr or null; value = (map (alias: "4.${alias}") net.aliases); } { name = net.ip6.addr or null; value = net.aliases; } + { name = net.ip6.addr or null; value = (map (alias: "6.${alias}") net.aliases); } ]) host.nets; # netAliases : { ${netname} : [addrAliases] } -- cgit v1.2.3 From ec33eacc22cf690ef68774042a1a11cf6d1f2a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 27 Aug 2020 21:29:04 +0100 Subject: add prometheus.r --- krebs/3modules/external/mic92.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/3modules/external/mic92.nix b/krebs/3modules/external/mic92.nix index 782f8ac04..384d813cc 100644 --- a/krebs/3modules/external/mic92.nix +++ b/krebs/3modules/external/mic92.nix @@ -463,6 +463,7 @@ in { ip4.addr = "10.243.29.185"; aliases = [ "eva.r" + "prometheus.r" ]; tinc.pubkey = '' -----BEGIN PUBLIC KEY----- -- cgit v1.2.3 From e97cf417fc05b382830d226ffaa04665ffb6e48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 13 Sep 2020 09:35:41 +0200 Subject: mic92: add rock publickey --- krebs/3modules/external/mic92.nix | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/krebs/3modules/external/mic92.nix b/krebs/3modules/external/mic92.nix index 384d813cc..5a766664f 100644 --- a/krebs/3modules/external/mic92.nix +++ b/krebs/3modules/external/mic92.nix @@ -349,19 +349,20 @@ in { ip4.addr = "10.243.29.171"; aliases = [ "rock.r" ]; tinc.pubkey = '' - -----BEGIN RSA PUBLIC KEY----- - MIICCgKCAgEAsMJbXDhkaLZcEzCIe8G+rHyLulWIqrUAmDT4Vbtv4r0QhPBsqwjM - DuvRtX5SNHdjfZWnUZoOlmXrmIo07exPFQvyrnppm6DNx+IZ5mNMNVIFUoojRhF7 - HS2jubcjTEib56XEYWKly0olrVMbsJk5THJqRQyOQuTPCFToxXVRcT5t/UK6Dzgh - mp+suJ7IcmmO80IwfZrQrQslkQ6TdOy1Vs908GacSQJyRxdRxLraU/98iMhFbAQf - Ap+qVSUU88iCi+tcoSYzKhqU2N0AhRGcsE073B3Px8CAgPK/juwTrFElKEc17X9M - Rh41DvUjrtG4ERPmbwKPtsLagmnZUlU8A5YC8wtV08RI5QBsbbOsKInareV1aLeD - 91ZVCBPFTz8IM6Mc6H435eMCMC2ynFCDyRGdcue3tBQoaTGe1dbduIZkPGn+7cg4 - fef1db6SQD4HCwDLv8CTFLACR/jmAapwZEgvJ3u3bpgMGzt+QNvL1cxUr3TBUWRv - 3f0R+Dj8DCUWTJUE7K5LO7bL4p9Ht0yIsVH+/DucyoMQqRwCwWSr7+H2MAsWviav - ZRRfH0RqZPEzCxyLDBtkVrx+GRAUZxy1xlqmN16O/sRHiqq3bv8Jk3dwuRZlFu6q - cOFu4g9XsamHkmCuVkvTGjnC2h21MjUUr3PGHzOMtiM/18LcfX730f8CAwEAAQ== - -----END RSA PUBLIC KEY----- + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0uhNk3XXVxQcIVhD1Ime + 9PY3QBIcXvwDlOrd3oUwyWTvZpUeO7yzIXdouAe4s0ohPIVq7Cmruj4ZrOGUCKyB + oJpOziYSbL/IiCpXyOzWMLEwu0AoeFfbxig+5oZfwQ9epM2j902CgsUipJBLIg48 + BC9oOD+/iYEwsFPqQ/S0kETyQK5Ad+qv0lbU6/Kmify8Qplvpv/8DRdjsdLki1fU + a6MAEw12OtHe6IWtlitPjFMBykTP6kkSp/eg0G2KZFVuEulwHGf9QT/eT4fZTMCC + 2V5Vp4rIr/hawmj+h4NIxniBSQcPAAIGNwZVC4uYYV1nd4iaI/T04rDJwte5WKHf + EVxtlYt9RU1I/XdNRSj9gYyneVcVlDVos8Z93oUv1hIGZYFtNmGVna6lggOBPf/t + BZ1MT6FKA4QX9JI8bQoNs18s8ffzyb07psNbH6YhpCygnhf9C7NR/CeI8BtpzJza + 1Qk731Z6bk6xRFKMuY2tRKlNCqPHULj44oTHB3Ki2B/bMlkguqSChfFzKIRASYO1 + SASSgddexjkjKLslxcLWhIqYrZhuhYlFyoeoMI3qQsey/4X5PUmQDxxhTT80+qvE + thBNPg46joyLTq9E9ddf7t/0C6oD2DXY88N9bkztuK5dtYHmjajUbePuaTJtrKhI + 7MnLboZCEiSyvkVTTx0Yjf0CAwEAAQ== + -----END PUBLIC KEY----- ''; }; }; -- cgit v1.2.3 From 8ed22f337c76df2ad592650ece7abe1a414c4182 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:21:53 +0200 Subject: shack/glados: implement rollo triggers --- krebs/2configs/shack/glados/default.nix | 10 ++++-- krebs/2configs/shack/glados/multi/rollos.nix | 53 +++++++++++++++++++++++++--- krebs/2configs/shack/glados/multi/wasser.nix | 10 ++++-- 3 files changed, 63 insertions(+), 10 deletions(-) diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix index e4f032950..f47bca2db 100644 --- a/krebs/2configs/shack/glados/default.nix +++ b/krebs/2configs/shack/glados/default.nix @@ -3,6 +3,7 @@ let shackopen = import ./multi/shackopen.nix; wasser = import ./multi/wasser.nix; badair = import ./multi/schlechte_luft.nix; + rollos = import ./multi/rollos.nix; in { services.nginx.virtualHosts."hass.shack" = { serverAliases = [ "glados.shack" ]; @@ -65,6 +66,10 @@ in { influxdb = { database = "glados"; host = "influx.shack"; + component_config_glob = { + "sensor.*particulate_matter_2_5um_concentration".override_measurement = "2_5um particles"; + "sensor.*particulate_matter_10_0um_concentration".override_measurement ="10um particles"; + }; tags = { instance = "wolf"; source = "glados"; @@ -94,8 +99,7 @@ in { }; }; switch = - wasser.switch - ++ (import ./switch/power.nix) + (import ./switch/power.nix) ; light = []; media_player = [ @@ -114,6 +118,7 @@ in { ++ (import ./sensors/mate.nix) ++ (import ./sensors/darksky.nix { inherit lib;}) ++ shackopen.sensor + ++ wasser.sensor ; air_quality = (import ./sensors/sensemap.nix ); @@ -148,6 +153,7 @@ in { automation = wasser.automation ++ badair.automation + ++ rollos.automation ++ (import ./automation/shack-startup.nix) ++ (import ./automation/party-time.nix) ++ (import ./automation/hass-restart.nix); diff --git a/krebs/2configs/shack/glados/multi/rollos.nix b/krebs/2configs/shack/glados/multi/rollos.nix index 1febad525..4e6494936 100644 --- a/krebs/2configs/shack/glados/multi/rollos.nix +++ b/krebs/2configs/shack/glados/multi/rollos.nix @@ -1,13 +1,56 @@ +# + let glados = import ../lib; + tempsensor = "sensor.dark_sky_temperature"; + all_covers = [ + "cover.crafting_rollo" + "cover.elab_rollo" + "cover.or2_rollo" + "cover.retroraum_rollo" + ]; in { - # LED - light = [ - ]; - sensor = [ - ]; automation = [ + { alias = "Rollos fahren Runter"; + trigger = [ + { + platform = "numeric_state"; + entity_id = tempsensor; + above = 25; + for = "00:30:00"; + } + ]; + condition = + [ + { + condition = "state"; + entity_id = "sun.sun"; + state = "above_horizon"; + } + ]; + action = + [ + { service = "cover.close_cover"; + entity_id = all_covers; + } + ]; + } + { alias = "Rollos fahren Hoch"; + trigger = [ + { + platform = "sun"; + event = "sunset"; + } + ]; + condition = [ ]; + action = + [ + { service = "cover.open_cover"; + entity_id = all_covers; + } + ]; + } ]; } diff --git a/krebs/2configs/shack/glados/multi/wasser.nix b/krebs/2configs/shack/glados/multi/wasser.nix index e3ba28384..74ce736a6 100644 --- a/krebs/2configs/shack/glados/multi/wasser.nix +++ b/krebs/2configs/shack/glados/multi/wasser.nix @@ -6,9 +6,13 @@ let wasser = "switch.crafting_giesskanne_relay"; in { - switch = [ - (glados.tasmota.plug { host = "Wasser"; topic = "plug";} ) - ]; + sensor = map ( entity_id: { + platform = "statistics"; + name = "Statistics for ${entity_id}"; + inherit entity_id; + max_age.minutes = "60"; + }) ["sensor.crafting_brotbox_soil_moisture"]; + automation = [ -- cgit v1.2.3 From 67425ef5016de845f66f0943594e5bf3fc58f8d9 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:23:16 +0200 Subject: ma bam/kalauerbot: init --- makefu/2configs/bureautomation/kalauerbot.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 makefu/2configs/bureautomation/kalauerbot.nix diff --git a/makefu/2configs/bureautomation/kalauerbot.nix b/makefu/2configs/bureautomation/kalauerbot.nix new file mode 100644 index 000000000..d61b8885e --- /dev/null +++ b/makefu/2configs/bureautomation/kalauerbot.nix @@ -0,0 +1,17 @@ +{ config, lib, pkgs, ... }: + +{ + systemd.services.kalauerbot = { + description = "Kalauerbot"; + after = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + environment = import ; + serviceConfig = { + DynamicUser = true; + StateDirectory = "kalauerbot"; + WorkingDirectory = "/var/lib/kalauerbot"; + ExecStart = "${pkgs.kalauerbot}/bin/kalauerbot"; + PrivateTmp = true; + }; + }; +} -- cgit v1.2.3 From 78a81a0b84ad0c3210bddf7675be4c1052291178 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:24:12 +0200 Subject: ma ham: add influxdb --- makefu/2configs/ham/default.nix | 13 ++++++++++++- makefu/2configs/ham/device_tracker/openwrt.nix | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 makefu/2configs/ham/device_tracker/openwrt.nix diff --git a/makefu/2configs/ham/default.nix b/makefu/2configs/ham/default.nix index c7e8733b7..8311a1a76 100644 --- a/makefu/2configs/ham/default.nix +++ b/makefu/2configs/ham/default.nix @@ -39,6 +39,15 @@ in { ]; }; config = { + influxdb = { + database = "ham"; + host = "localhost:8086"; + tags = { + instance = "omo"; + source = "hass"; + }; + }; + config = {}; input_select = zigbee.input_select; # dict timer = zigbee.timer // kurzzeitwecker.timer; # dict @@ -91,6 +100,7 @@ in { ]; sun.elevation = 247; recorder = {}; + device_tracker = (import ./device_tracker/openwrt.nix); media_player = [ { platform = "FireTV Stick kodi"; host = firetv_stick; @@ -128,7 +138,7 @@ in { }; luftdaten = { show_on_map = true; - sensor_id = 679; + sensor_id = 10529; sensors.monitored_conditions = [ "P1" "P2" ]; }; #binary_sensor = @@ -162,4 +172,5 @@ in { configDir = hassdir; }; + state = [ "/var/lib/hass/known_devices.yaml" ]; } diff --git a/makefu/2configs/ham/device_tracker/openwrt.nix b/makefu/2configs/ham/device_tracker/openwrt.nix new file mode 100644 index 000000000..8173fcfcb --- /dev/null +++ b/makefu/2configs/ham/device_tracker/openwrt.nix @@ -0,0 +1,10 @@ +[ + { platform = "luci"; + host = "192.168.1.5"; + username = "root"; + password = import ; + interval_seconds = 30; # instead of 12seconds + consider_home = 300; # 5 minutes timeout + new_device_defaults.track_new_devices = true; + } +] -- cgit v1.2.3 From ce41b987239abbac0f817a9ae1f7019ad9f4035a Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:25:40 +0200 Subject: ma awesomecfg: add chapter-marker --- makefu/5pkgs/awesomecfg/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/makefu/5pkgs/awesomecfg/default.nix b/makefu/5pkgs/awesomecfg/default.nix index 1ae2f50d9..acbe61f3f 100644 --- a/makefu/5pkgs/awesomecfg/default.nix +++ b/makefu/5pkgs/awesomecfg/default.nix @@ -6,15 +6,17 @@ , blueman , clipit , flameshot +, chapter-marker , modkey ? "Mod4" , locker? "${pkgs.xlock}/bin/xlock -mode blank" , ... }: { - # replace: @alsaUtils@ @xlockmore@ @xbacklight@ @modkey@ + # replace: @alsaUtils@ @xlockmore@ @xbacklight@ @modkey@ @chapter-marker@ full = lib.makeOverridable pkgs.substituteAll { name = "awesome_full_config"; inherit alsaUtils locker xbacklight modkey networkmanagerapplet blueman clipit flameshot ; + chaptermarker = chapter-marker; isExecutable = false; src = ./full.cfg; }; -- cgit v1.2.3 From 3a93c400a3f8e58a4d10ae743fbdbada216d8641 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:28:13 +0200 Subject: ma pkgs.kalauerbot: init --- makefu/5pkgs/kalauerbot/default.nix | 18 ++++++++++++++++ makefu/5pkgs/kalauerbot/matrixbot.patch | 12 +++++++++++ makefu/5pkgs/kalauerbot/python-matrixbot.nix | 31 ++++++++++++++++++++++++++++ makefu/5pkgs/kalauerbot/translate.patch | 17 +++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 makefu/5pkgs/kalauerbot/default.nix create mode 100644 makefu/5pkgs/kalauerbot/matrixbot.patch create mode 100644 makefu/5pkgs/kalauerbot/python-matrixbot.nix create mode 100644 makefu/5pkgs/kalauerbot/translate.patch diff --git a/makefu/5pkgs/kalauerbot/default.nix b/makefu/5pkgs/kalauerbot/default.nix new file mode 100644 index 000000000..2cecbc3f2 --- /dev/null +++ b/makefu/5pkgs/kalauerbot/default.nix @@ -0,0 +1,18 @@ +{ stdenv, python3, fetchgit }: +python3.pkgs.buildPythonPackage rec { +name = "kalauerbot"; +rev = "08d98aa"; + src = fetchgit { + url = "http://cgit.euer.krebsco.de/kalauerbot"; + inherit rev; + sha256 = "017hh61smgq4zsxd10brgwmykwgwabgllxjs31xayvs1hnqmkv2v"; + }; + propagatedBuildInputs = with python3.pkgs;[ + (callPackage ./python-matrixbot.nix {}) + (stdenv.lib.overrideDerivation googletrans (self: { + patches = [ ./translate.patch ]; + })) + ]; + checkInputs = [ python3.pkgs.black ]; +} + diff --git a/makefu/5pkgs/kalauerbot/matrixbot.patch b/makefu/5pkgs/kalauerbot/matrixbot.patch new file mode 100644 index 000000000..2b9bbbea1 --- /dev/null +++ b/makefu/5pkgs/kalauerbot/matrixbot.patch @@ -0,0 +1,12 @@ +diff --git a/matrixbot/matrixbot.py b/matrixbot/matrixbot.py +index 8e5598c..d8c23d2 100644 +--- a/matrixbot/matrixbot.py ++++ b/matrixbot/matrixbot.py +@@ -51,7 +51,6 @@ class MatrixBot: + self.user = None + if self.token is not None and self.user_id is not None: + self.user = self.client.get_user(self.user_id) +- self.user.set_display_name(self.display_name) + self.init_rooms(self.client.rooms) + self.invite_listener = self.client.add_invite_listener(self.handle_invite) + self.cache = Cache(dbfile=cache_db) diff --git a/makefu/5pkgs/kalauerbot/python-matrixbot.nix b/makefu/5pkgs/kalauerbot/python-matrixbot.nix new file mode 100644 index 000000000..7bc5aa7f3 --- /dev/null +++ b/makefu/5pkgs/kalauerbot/python-matrixbot.nix @@ -0,0 +1,31 @@ +{ lib +, buildPythonPackage +, fetchPypi +, markdown +, matrix-client +}: + +buildPythonPackage rec { + pname = "python-matrixbot"; + version = "0.0.7"; + CI_COMMIT_TAG = version; + + #src = ./python-matrixbot; + src = fetchPypi { + inherit pname version; + sha256 = "9412981b14ff3ab7ffbb1bfc1691758113ab8d71f731b3093d8808c286b69c71"; + }; + patches = [ ./matrixbot.patch ]; + + propagatedBuildInputs = [ + markdown + matrix-client + ]; + + meta = with lib; { + description = "A basic bot for Matrix"; + homepage = https://gitlab.com/gibberfish/python-matrixbot; + license = licenses.mit; + # maintainers = [ maintainers. ]; + }; +} diff --git a/makefu/5pkgs/kalauerbot/translate.patch b/makefu/5pkgs/kalauerbot/translate.patch new file mode 100644 index 000000000..6ff820726 --- /dev/null +++ b/makefu/5pkgs/kalauerbot/translate.patch @@ -0,0 +1,17 @@ +diff --git a/googletrans/client.py b/googletrans/client.py +index 89c2237..c203b44 100644 +--- a/googletrans/client.py ++++ b/googletrans/client.py +@@ -190,6 +190,13 @@ class Translator(object): + pass + if not PY3 and isinstance(pron, unicode) and isinstance(origin, str): # pragma: nocover + origin = origin.decode('utf-8') ++ ++ if pron is None: ++ try: ++ pron = data[0][2][2] ++ except: # pragma: nocover ++ pass ++ + if dest in EXCLUDES and pron == origin: + pron = translated -- cgit v1.2.3 From 1af471af1eec077bc21ff0c96679362f055beaaa Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:28:58 +0200 Subject: ma home-manager/direnv: remove custom use_nix --- makefu/2configs/home-manager/cli.nix | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/makefu/2configs/home-manager/cli.nix b/makefu/2configs/home-manager/cli.nix index 5d5673b81..38d02424c 100644 --- a/makefu/2configs/home-manager/cli.nix +++ b/makefu/2configs/home-manager/cli.nix @@ -2,31 +2,6 @@ imports = [ ./zsh.nix ]; home-manager.users.makefu = { programs.direnv = { - stdlib = '' -use_nix() { - local cache=".direnv.$(nixos-version --hash)" - - if [[ ! -e "$cache" ]] || \ - [[ "$HOME/.direnvrc" -nt "$cache" ]] || \ - [[ ".envrc" -nt "$cache" ]] || \ - [[ "default.nix" -nt "$cache" ]] || \ - [[ "shell.nix" -nt "$cache" ]]; - then - local tmp="$(mktemp "$${cache}.tmp-XXXXXXXX")" - trap "rm -rf '$tmp' >/dev/null" EXIT - nix-shell --show-trace "$@" --run 'direnv dump' > "$tmp" && \ - mv "$tmp" "$cache" - fi - - direnv_load cat "$cache" - - if [[ $# = 0 ]]; then - watch_file default.nix - watch_file shell.nix - rm direnv.* 2>/dev/null - fi -} -''; enableZshIntegration = true; }; }; -- cgit v1.2.3 From ab0c5651a638a897d6623d32900126b5b5cfdd4a Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:29:55 +0200 Subject: ma hw/switch: add more options for connecting to switch --- makefu/2configs/hw/switch.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/makefu/2configs/hw/switch.nix b/makefu/2configs/hw/switch.nix index d46e8cf3f..79de7ffb1 100644 --- a/makefu/2configs/hw/switch.nix +++ b/makefu/2configs/hw/switch.nix @@ -2,9 +2,11 @@ { - users.extraUsers.${config.krebs.build.user.name}.extraGroups = [ "plugdev" ]; - + users.users.makefu.extraGroups = [ "plugdev" ]; + users.groups.plugdev = {}; services.udev.extraRules = '' SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0664", GROUP="plugdev" + SUBSYSTEM=="usb", ATTR{idVendor}=="16c0", ATTR{idProduct}=="27e2", SYMLINK+="switch-%k", MODE="0664", GROUP="plugdev" + SUBSYSTEM=="usb", ATTR{idVendor}=="057e", ATTR{idProduct}=="3000", SYMLINK+="switch-%k", MODE="0664", GROUP="plugdev" ''; } -- cgit v1.2.3 From 15c3030a915f001b9f0e6e8424780213e6a3faf7 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:30:12 +0200 Subject: ma tools/consoles: add nsrenamer --- makefu/2configs/tools/consoles.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/makefu/2configs/tools/consoles.nix b/makefu/2configs/tools/consoles.nix index e54ff4ff5..a4c474c5b 100644 --- a/makefu/2configs/tools/consoles.nix +++ b/makefu/2configs/tools/consoles.nix @@ -7,5 +7,6 @@ cue2pops nx_game_info hactool + nsrenamer ]; } -- cgit v1.2.3 From a24fec6855977969f96a1d50cea4f68c6540f6d5 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Sep 2020 22:37:08 +0200 Subject: pkgs.alertmanager-bot-telegram: init --- ..