This repository has no description
6.7 kB
223 lines
1{ config, lib, pkgs, ... }:
2
3{
4 imports = [
5 ../../.
6
7 ../../2configs/mouse.nix
8 ../../2configs/retiolum.nix
9 ../../2configs/git.nix
10 ../../2configs/exim-retiolum.nix
11 ../../2configs/baseX.nix
12 ../../2configs/pipewire.nix
13 ../../2configs/browsers.nix
14 ../../2configs/programs.nix
15 ../../2configs/fetchWallpaper.nix
16 ../../2configs/games.nix
17 ../../2configs/bitcoin.nix
18 ../../2configs/wine.nix
19 ../../2configs/network-manager.nix
20 ../../2configs/red-host.nix
21 ../../2configs/ipfs.nix
22 ../../2configs/snapclient.nix
23 ../../2configs/consul.nix
24 { # === logging playground ===
25 # --- client ---
26
27 # services.fluentd = {
28 # enable = true;
29 # config = ''
30 # '';
31 # };
32
33 # services.netdata = {
34 # enable = true;
35 # config = {
36 # global = {
37 # "debug log" = "syslog";
38 # "error log" = "syslog";
39 # };
40
41 # backend = {
42 # enabled = "yes";
43 # type = "opentsdb";
44 # destination = "tcp:localhost:4242";
45 # prefix = "netdata";
46 # hostname = config.networking.hostName;
47 # };
48 # # "exporting:global" = {
49 # # enabled = "yes";
50 # # "update every" = "60";
51 # # };
52 # # "graphite:icarus" = {
53 # # enabled = "yes";
54 # # destination = "localhost:8086";
55 # # "data source" = "average";
56 # # prefix = "netdata";
57 # # hostname = config.networking.hostName;
58 # # "send charts matching" = "*";
59 # # "send hosts matching" = "localhost *";
60 # # "send names instead of ids" = "yes";
61 # # };
62 # };
63 # };
64
65 # - metrics
66 services.telegraf = {
67 enable = true;
68 extraConfig = {
69 inputs = {
70 cpu = {};
71 mem = {};
72 net = {
73 ignore_protocol_stats = true;
74 };
75 exec = {
76 command = pkgs.writers.writePython3 "get_bat_stats" {} /* python */ ''
77 import json
78 import os
79
80
81 values_to_fetch = [
82 "capacity",
83 "energy_now",
84 "energy_full",
85 "energy_full_design",
86 "charge_now",
87 "charge_full",
88 "charge_full_design",
89 ]
90
91 result = {}
92 for sup in os.listdir('/sys/class/power_supply'):
93 with open('/sys/class/power_supply/{}/type'.format(sup)) as f:
94 if f.read().strip() != "Battery":
95 continue
96 for val in values_to_fetch:
97 try:
98 with open('/sys/class/power_supply/{}/{}'.format(sup, val)) as f:
99 key = '{}_{}'.format(sup, val)
100 try:
101 result[key] = int(f.read().strip())
102 except ValueError:
103 result[key] = f.read().strip()
104 except: # noqa
105 pass
106
107 print(json.dumps(result))
108 '';
109 data_format = "json";
110 name_suffix = "_bat";
111 interval = "10s";
112 };
113 };
114 outputs = {
115 influxdb = { database = "telegraf"; urls = [ "http://localhost:8086" ]; };
116 };
117 };
118 };
119
120 # --- server ---
121
122 # - metrics
123 services.influxdb = {
124 enable = true;
125 extraConfig = {
126 opentsdb = [{
127 enabled = true;
128 bind-address = ":4242";
129 database = "opentsdb";
130 retention-policy = "";
131
132 batch-size = 1000;
133 batch-pending = 5;
134 batch-timeout = "1s";
135 }];
136 };
137 };
138
139 # - logs
140 services.graylog = {
141 enable = true;
142 passwordSecret = "AmjUYosI6hXKyI1MLEusupZy7srxQxZOowpHSmvF0ekMoi19go5qmnqd3po4VcQahdR1AKZ3Yk9tP6nLUbgmzLwQFodIc5g8";
143 rootPasswordSha2 = "cf80cd8aed482d5d1527d7dc72fceff84e6326592848447d2dc0b0e87dfc9a90"; # testing
144 elasticsearchHosts = [ "http://localhost:9200" ];
145 };
146
147 services.elasticsearch = {
148 enable = true;
149 };
150 # services.loki = {
151 # enable = true;
152 # configuration = {
153 # auth_enabled = false;
154 # server.http_listen_port = 3100;
155 # ingester = {
156 # lifecycler = {
157 # address = "127.0.0.1";
158 # ring = {
159 # kvstore.store = "inmemory";
160 # replication_factor = 1;
161 # };
162 # final_sleep = "0s";
163 # };
164 # };
165 # schema_config = {
166 # configs = [
167 # {
168 # from = "2018-04-15";
169 # store = "inmemory";
170 # object_store = "filesystem";
171 # schema = "v9";
172 # }
173 # ];
174 # };
175 # storage_config = {
176 # filesystem.directory = "/tmp/loki/chunks";
177 # };
178 # #table_manager = {
179 # # chunk_tables_provisioning = {
180 # # inactive_read_throughput = 0;
181 # # inactive_write_throughput = 0;
182 # # provisioned_read_throughput = 0;
183 # # provisioned_write_throughput = 0;
184 # # };
185 # # index_tables_provisioning = {
186 # # inactive_read_throughput = 0;
187 # # inactive_write_throughput = 0;
188 # # provisioned_read_throughput = 0;
189 # # provisioned_write_throughput = 0;
190 # # };
191 # # retention_deletes_enabled = false;
192 # # retention_period = 0;
193 # #};
194 # };
195 # };
196
197 services.grafana = {
198 enable = true;
199 addr = "0.0.0.0";
200 auth.anonymous.enable = true;
201 auth.anonymous.org_role = "Admin";
202 };
203 krebs.iptables.tables.filter.INPUT.rules = [
204 { predicate = "-p tcp --dport 3000"; target = "ACCEPT"; } # grafana
205 ];
206 }
207 ];
208
209 krebs.build.host = config.krebs.hosts.icarus;
210
211 # services.xrdp = {
212 # enable = true;
213 # defaultWindowManager = "xmonad";
214 # };
215 # krebs.iptables.tables.filter.INPUT.rules = [
216 # { predicate = "-p tcp --dport 3389"; target = "ACCEPT"; } # xrdp
217 # ];
218
219 environment.systemPackages = [ pkgs.chromium ];
220
221 # users.users.lass.openssh.authorizedKeys = [ config.krebs.users.mic92.pubkey ];
222 system.stateVersion = "22.05";
223}