ctucx.git: nixfiles

ctucx' nixfiles

commit e41d9da11c8fccf60759a1e660b027639226230e
parent 64f1c25000cd57a3b440f1c01b9035fec858950a
Author: Leah (ctucx) <git@ctu.cx>
Date: Fri, 15 Nov 2024 17:43:04 +0100

machines/briefkasten/smarthome/influxdb2: comment out `power-history` service
1 file changed, 91 insertions(+), 91 deletions(-)
M
machines/briefkasten/smarthome/influxdb2.nix
|
182
++++++++++++++++++++++++++++++++++++++++----------------------------------------
diff --git a/machines/briefkasten/smarthome/influxdb2.nix b/machines/briefkasten/smarthome/influxdb2.nix
@@ -34,96 +34,96 @@
     };
   };
 
-  systemd.services.power-history = {
-    startAt = "0/2:00:00";
-    path = with pkgs; [ curl jq mosquitto ];
-
-    serviceConfig = {
-      NoNewPrivileges         = true;
-      PrivateTmp              = true;
-
-      ProtectSystem           = "strict";
-      ProtectKernelLogs       = true;
-      ProtectKernelModules    = true;
-      ProtectKernelTunables   = true;
-      ProtectControlGroups    = true;
-      ProtectHome             = true;
-
-      RestrictNamespaces      = true;
-      RestrictRealtime        = true;
-
-      DevicePolicy            = "closed";
-      LockPersonality         = true;
-    };
-
-    script = ''
-      QUERY=$(cat <<-END
-      import "timezone"
-      import "date"
-      import "math"
-
-      option location = {zone: "Europe/Berlin", offset: 0h}
-      option header = false
-
-      date_start = date.truncate(t: date.sub(from: now(), d: 3y), unit: 1d)
-      date_stop = date.truncate(t: now(), unit: 1d)
-
-      data =
-          from(bucket: "mqttData")
-              |> range(start: date_start, stop: date_stop)
-              |> filter(fn: (r) => r.topic == "sdm2mqtt/leah" and r._field == "import")
-              |> drop(columns: ["_field", "_measurement", "topic", "host"])
-
-      //daily aggregation
-      data
-        // Windows and aggregates the data
-        |> range(start: -30d, stop: now())
-        |> aggregateWindow(every: duration(v: 1d), fn: max, createEmpty: false, timeSrc: "_start")
-        |> difference()
-        |> drop(columns: ["_start", "_stop"])
-        |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
-        |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))+"-"+string(v: date.month(t: r._time))+"-"+string(v: date.monthDay(t: r._time))}))
-        |> yield(name: "d")
-
-      //weekly aggregation
-      data
-        // Windows and aggregates the data
-        |> aggregateWindow(every: duration(v: 1w), fn: max, createEmpty: false, offset: -3d, timeSrc: "_start")
-        |> difference()
-        |> drop(columns: ["_start", "_stop"])
-        |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
-        |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))+"-"+string(v: date.week(t: r._time))}))
-        |> yield(name: "w")
-
-      //monthly aggregation
-      data
-        // Windows and aggregates the data
-        |> aggregateWindow(every: duration(v: 1mo), fn: max, createEmpty: false, timeSrc: "_start")
-        |> difference()
-        |> drop(columns: ["_start", "_stop"])
-        |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
-        |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))+"-"+string(v: date.month(t: r._time))}))
-        |> yield(name: "m")
-
-      //yearly aggregation
-      data
-        // Windows and aggregates the data
-        |> aggregateWindow(every: duration(v: 1y), fn: max, createEmpty: false, timeSrc: "_start")
-        |> difference()
-        |> drop(columns: ["_start", "_stop"])
-        |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
-        |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))}))
-        |> yield(name: "y")
-
-      END
-      )
-
-      REQUEST_BODY=`echo '{"dialect": { "header": false}}' | jq --arg q "''${QUERY}" '.query=$q'`
-      RESPONSE=`curl -X POST 'https://influx.home.ctu.cx/api/v2/query?org=leah' -sS -H 'Accept:application/csv' -H 'Authorization: Token ZrTCG9n8ow-KC_x_HhwJD3VwWS208051WczuIa-3i2M3qmZETdth_XIi5FUTEVKmMXlQ015ujWLRZLjBNbINxQ==' -H 'Content-type:application/json' -d "''${REQUEST_BODY}"`
-      MESSAGE=`echo "''${RESPONSE}" | tr -s '\r' '\n' | jq --slurp --raw-input -c 'split("\n") | map(select(length > 0)) | .[1:] | map(split(",")) | map([.[1],.[3],.[4]])'`
-
-      mosquitto_pub -h '::1' -r -t 'sdm2mqtt/leah/history' -m "''${MESSAGE}"
-    '';
-  };
+#   systemd.services.power-history = {
+#     startAt = "0/2:00:00";
+#     path = with pkgs; [ curl jq mosquitto ];
+# 
+#     serviceConfig = {
+#       NoNewPrivileges         = true;
+#       PrivateTmp              = true;
+# 
+#       ProtectSystem           = "strict";
+#       ProtectKernelLogs       = true;
+#       ProtectKernelModules    = true;
+#       ProtectKernelTunables   = true;
+#       ProtectControlGroups    = true;
+#       ProtectHome             = true;
+# 
+#       RestrictNamespaces      = true;
+#       RestrictRealtime        = true;
+# 
+#       DevicePolicy            = "closed";
+#       LockPersonality         = true;
+#     };
+# 
+#     script = ''
+#       QUERY=$(cat <<-END
+#       import "timezone"
+#       import "date"
+#       import "math"
+# 
+#       option location = {zone: "Europe/Berlin", offset: 0h}
+#       option header = false
+# 
+#       date_start = date.truncate(t: date.sub(from: now(), d: 3y), unit: 1d)
+#       date_stop = date.truncate(t: now(), unit: 1d)
+# 
+#       data =
+#           from(bucket: "mqttData")
+#               |> range(start: date_start, stop: date_stop)
+#               |> filter(fn: (r) => r.topic == "sdm2mqtt/leah" and r._field == "import")
+#               |> drop(columns: ["_field", "_measurement", "topic", "host"])
+# 
+#       //daily aggregation
+#       data
+#         // Windows and aggregates the data
+#         |> range(start: -30d, stop: now())
+#         |> aggregateWindow(every: duration(v: 1d), fn: max, createEmpty: false, timeSrc: "_start")
+#         |> difference()
+#         |> drop(columns: ["_start", "_stop"])
+#         |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
+#         |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))+"-"+string(v: date.month(t: r._time))+"-"+string(v: date.monthDay(t: r._time))}))
+#         |> yield(name: "d")
+# 
+#       //weekly aggregation
+#       data
+#         // Windows and aggregates the data
+#         |> aggregateWindow(every: duration(v: 1w), fn: max, createEmpty: false, offset: -3d, timeSrc: "_start")
+#         |> difference()
+#         |> drop(columns: ["_start", "_stop"])
+#         |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
+#         |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))+"-"+string(v: date.week(t: r._time))}))
+#         |> yield(name: "w")
+# 
+#       //monthly aggregation
+#       data
+#         // Windows and aggregates the data
+#         |> aggregateWindow(every: duration(v: 1mo), fn: max, createEmpty: false, timeSrc: "_start")
+#         |> difference()
+#         |> drop(columns: ["_start", "_stop"])
+#         |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
+#         |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))+"-"+string(v: date.month(t: r._time))}))
+#         |> yield(name: "m")
+# 
+#       //yearly aggregation
+#       data
+#         // Windows and aggregates the data
+#         |> aggregateWindow(every: duration(v: 1y), fn: max, createEmpty: false, timeSrc: "_start")
+#         |> difference()
+#         |> drop(columns: ["_start", "_stop"])
+#         |> map(fn: (r) => ({r with _value: (math.round(x: r._value * 100.0) / 100.0)}))
+#         |> map(fn: (r) => ({r with _time: string(v: date.year(t: r._time))}))
+#         |> yield(name: "y")
+# 
+#       END
+#       )
+# 
+#       REQUEST_BODY=`echo '{"dialect": { "header": false}}' | jq --arg q "''${QUERY}" '.query=$q'`
+#       RESPONSE=`curl -X POST 'https://influx.home.ctu.cx/api/v2/query?org=leah' -sS -H 'Accept:application/csv' -H 'Authorization: Token ZrTCG9n8ow-KC_x_HhwJD3VwWS208051WczuIa-3i2M3qmZETdth_XIi5FUTEVKmMXlQ015ujWLRZLjBNbINxQ==' -H 'Content-type:application/json' -d "''${REQUEST_BODY}"`
+#       MESSAGE=`echo "''${RESPONSE}" | tr -s '\r' '\n' | jq --slurp --raw-input -c 'split("\n") | map(select(length > 0)) | .[1:] | map(split(",")) | map([.[1],.[3],.[4]])'`
+# 
+#       mosquitto_pub -h '::1' -r -t 'sdm2mqtt/leah/history' -m "''${MESSAGE}"
+#     '';
+#   };
 
 }