File tree Expand file tree Collapse file tree 3 files changed +119
-0
lines changed Expand file tree Collapse file tree 3 files changed +119
-0
lines changed Original file line number Diff line number Diff line change 962962 ./services/monitoring/opentelemetry-collector.nix
963963 ./services/monitoring/osquery.nix
964964 ./services/monitoring/parsedmarc.nix
965+ ./services/monitoring/pgscv.nix
965966 ./services/monitoring/prometheus/alertmanager-gotify-bridge.nix
966967 ./services/monitoring/prometheus/alertmanager-irc-relay.nix
967968 ./services/monitoring/prometheus/alertmanager-webhook-logger.nix
Original file line number Diff line number Diff line change 1+ {
2+ config ,
3+ lib ,
4+ pkgs ,
5+ utils ,
6+ ...
7+ } :
8+
9+ let
10+ inherit ( lib )
11+ mkEnableOption
12+ mkIf
13+ mkOption
14+ mkPackageOption
15+ types
16+ ;
17+
18+ cfg = config . services . pgscv ;
19+
20+ settingsFormat = pkgs . formats . yaml { } ;
21+ configFile = settingsFormat . generate "config.yaml" cfg . settings ;
22+ in
23+ {
24+ options . services . pgscv = {
25+ enable = mkEnableOption "pgSCV, a PostgreSQL ecosystem metrics collector" ;
26+
27+ package = mkPackageOption pkgs "pgscv" { } ;
28+
29+ logLevel = mkOption {
30+ type = types . enum [
31+ "debug"
32+ "info"
33+ "warn"
34+ "error"
35+ ] ;
36+ default = "info" ;
37+ description = "Log level for pgSCV." ;
38+ } ;
39+
40+ settings = mkOption {
41+ type = settingsFormat . type ;
42+ default = { } ;
43+ description = ''
44+ Configuration for pgSCV, in YAML format.
45+
46+ See [configuration reference](https://github.com/cherts/pgscv/wiki/Configuration-settings-reference).
47+ '' ;
48+ } ;
49+ } ;
50+
51+ config = mkIf cfg . enable {
52+ systemd . services . pgscv = {
53+ description = "pgSCV - PostgreSQL ecosystem metrics collector" ;
54+ wantedBy = [ "multi-user.target" ] ;
55+ requires = [ "network-online.target" ] ;
56+ after = [ "network-online.target" ] ;
57+ path = [ pkgs . glibc ] ; # shells out to getconf
58+
59+ serviceConfig = {
60+ User = "postgres" ;
61+ Group = "postgres" ;
62+ ExecStart = utils . escapeSystemdExecArgs [
63+ ( lib . getExe cfg . package )
64+ "--log-level=${ cfg . logLevel } "
65+ "--config-file=${ configFile } "
66+ ] ;
67+ KillMode = "control-group" ;
68+ TimeoutSec = 5 ;
69+ Restart = "on-failure" ;
70+ RestartSec = 10 ;
71+ OOMScoreAdjust = 1000 ;
72+ } ;
73+ } ;
74+ } ;
75+ }
Original file line number Diff line number Diff line change 1+ {
2+ lib ,
3+ buildGoModule ,
4+ fetchFromGitHub ,
5+ } :
6+
7+ buildGoModule rec {
8+ pname = "pgscv" ;
9+ version = "0.13.0" ;
10+
11+ src = fetchFromGitHub {
12+ owner = "CHERTS" ;
13+ repo = "pgscv" ;
14+ tag = "v${ version } " ;
15+ hash = "sha256-6qhJZHyVtEI4+pqi0dgagDC2RaISV9g/ygrezJO57Sk=" ;
16+ } ;
17+
18+ vendorHash = "sha256-KahDpLwk+6KXaIfvjr7+nkFuEV4Dw3pyshkJ5XUEdUg=" ;
19+
20+ ldflags = [
21+ "-X=main.appName=pgscv"
22+ "-X=main.gitTag=${ src . tag } "
23+ "-X=main.gitCommit=${ src . tag } "
24+ "-X=main.gitBranch=${ src . tag } "
25+ ] ;
26+
27+ # tests rely on a pretty complex Postgres setup
28+ doCheck = false ;
29+
30+ postInstall = ''
31+ mv $out/bin/{cmd,pgscv}
32+ '' ;
33+
34+ meta = {
35+ description = "PgSCV is a PostgreSQL ecosystem metrics collector" ;
36+ homepage = "https://github.com/CHERTS/pgscv/" ;
37+ changelog = "https://github.com/CHERTS/pgscv/releases/${ version } " ;
38+ license = lib . licenses . bsd3 ;
39+ platforms = lib . platforms . linux ;
40+ maintainers = with lib . maintainers ; [ k900 ] ;
41+ mainProgram = "pgscv" ;
42+ } ;
43+ }
You can’t perform that action at this time.
0 commit comments