blob: 2ad6667abb93b6668ac1f6c13607521cae48d4f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
{ config, lib, pkgs, ... }:
let
relabelHosts = [
{ source_labels = ["__address__"];
target_label = "instance";
regex = "localhost(:[0-9]+)?";
replacement = "vidhar";
}
{ source_labels = ["__address__"];
target_label = "instance";
regex = "10.141.1.2(:[0-9]+)?";
replacement = "switch01";
}
];
in {
config = {
services.prometheus = {
enable = true;
exporters = {
node.enable = true;
smartctl = {
enable = true;
devices = [
"pci-0000:00:1f.2-ata-1"
"pci-0000:00:1f.2-ata-3"
"pci-0000:00:1f.2-ata-4"
"pci-0000:00:1f.2-ata-5"
"pci-0000:00:1f.2-ata-6"
"pci-0000:02:00.0-nvme-1"
"pci-0000:05:00.0-sas-phy0-lun-0"
"pci-0000:05:00.0-sas-phy1-lun-0"
"pci-0000:06:00.0-nvme-1"
];
};
snmp = {
enable = true;
configuration = {
default = { auth = { community = "public"; }; version = 2; };
};
};
unbound = {
enable = true;
controlInterface = "/run/unbound/unbound.ctl";
};
wireguard.enable = true;
};
scrapeConfigs = [
{ job_name = "node";
static_configs = [
{ targets = ["localhost:${toString config.services.prometheus.exporters.node.port}"]; }
];
relabel_configs = relabelHosts;
}
{ job_name = "smartctl";
static_configs = [
{ targets = ["localhost:${toString config.services.prometheus.exporters.smartctl.port}"]; }
];
relabel_configs = relabelHosts;
}
{ job_name = "snmp";
static_configs = [
{ targets = ["10.141.1.2"]; }
];
metrics_path = "/snmp";
params = {
module = ["if_mib"];
};
relabel_configs = [
{ source_labels = ["__address__"];
target_label = "__param_target";
}
{ source_labels = ["__param_target"];
target_label = "instance";
}
{ replacement = "localhost:${toString config.services.prometheus.exporters.snmp.port}";
target_label = "__address__";
}
] ++ relabelHosts;
}
{ job_name = "zte";
static_configs = [
{ targets = ["localhost:9900"]; }
];
relabel_configs = [
{ replacement = "telekom";
target_label = "instance";
}
];
}
{ job_name = "unbound";
static_configs = [
{ targets = ["localhost:${toString config.services.prometheus.exporters.unbound.port}"]; }
];
relabel_configs = relabelHosts;
}
{ job_name = "wireguard";
static_configs = [
{ targets = ["localhost:${toString config.services.prometheus.exporters.wireguard.port}"]; }
];
relabel_configs = relabelHosts;
}
{ job_name = "corerad";
static_configs = [
{ targets = ["localhost:9430"]; }
];
relabel_configs = relabelHosts;
}
];
};
users.users.${config.services.prometheus.exporters.unbound.user} = {
extraGroups = [ config.services.unbound.group ];
};
systemd.services."prometheus-zte-exporter@10.141.1.3" = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Restart = "always";
PrivateTmp = true;
WorkingDirectory = "/tmp";
DynamicUser = true;
CapabilityBoundingSet = [""];
DeviceAllow = [""];
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateDevices = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectSystem = "strict";
RemoveIPC = true;
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
UMask = "0077";
Type = "simple";
ExecStart = "${pkgs.zte-prometheus-exporter}/bin/zte-prometheus-exporter";
Environment = "ZTE_BASEURL=http://%I ZTE_HOSTNAME=localhost ZTE_PORT=9900";
EnvironmentFile = config.sops.secrets."zte_10.141.1.3".path;
};
};
sops.secrets."zte_10.141.1.3" = {
format = "binary";
sopsFile = ./zte_10.141.1.3;
};
};
}
|