Skip to content

Commit

Permalink
Merge master into staging-next
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 7, 2023
2 parents 8e7d266 + 5103716 commit 7520bf4
Show file tree
Hide file tree
Showing 25 changed files with 338 additions and 88 deletions.
44 changes: 38 additions & 6 deletions nixos/modules/services/monitoring/prometheus/exporters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ let
"nut"
"openldap"
"openvpn"
"pgbouncer"
"php-fpm"
"pihole"
"postfix"
Expand Down Expand Up @@ -312,6 +313,25 @@ in
Please specify either 'services.prometheus.exporters.nextcloud.passwordFile' or
'services.prometheus.exporters.nextcloud.tokenFile'
'';
} {
assertion = cfg.pgbouncer.enable -> (
(cfg.pgbouncer.connectionStringFile != null || cfg.pgbouncer.connectionString != "")
);
message = ''
PgBouncer exporter needs either connectionStringFile or connectionString configured"
'';
} {
assertion = cfg.pgbouncer.enable -> (
config.services.pgbouncer.ignoreStartupParameters != null && builtins.match ".*extra_float_digits.*" config.services.pgbouncer.ignoreStartupParameters != null
);
message = ''
Prometheus PgBouncer exporter requires including `extra_float_digits` in services.pgbouncer.ignoreStartupParameters
Example:
services.pgbouncer.ignoreStartupParameters = extra_float_digits;
See https://github.com/prometheus-community/pgbouncer_exporter#pgbouncer-configuration
'';
} {
assertion = cfg.sql.enable -> (
(cfg.sql.configFile == null) != (cfg.sql.configuration == null)
Expand Down Expand Up @@ -350,12 +370,24 @@ in
`openFirewall' is set to `true'!
'';
})) ++ config.services.prometheus.exporters.assertions;
warnings = [(mkIf (config.services.prometheus.exporters.idrac.enable && config.services.prometheus.exporters.idrac.configurationPath != null) ''
Configuration file in `services.prometheus.exporters.idrac.configurationPath` may override
`services.prometheus.exporters.idrac.listenAddress` and/or `services.prometheus.exporters.idrac.port`.
Consider using `services.prometheus.exporters.idrac.configuration` instead.
''
)] ++ config.services.prometheus.exporters.warnings;
warnings = [
(mkIf (config.services.prometheus.exporters.idrac.enable && config.services.prometheus.exporters.idrac.configurationPath != null) ''
Configuration file in `services.prometheus.exporters.idrac.configurationPath` may override
`services.prometheus.exporters.idrac.listenAddress` and/or `services.prometheus.exporters.idrac.port`.
Consider using `services.prometheus.exporters.idrac.configuration` instead.
''
)
(mkIf
(cfg.pgbouncer.enable && cfg.pgbouncer.connectionString != "") ''
config.services.prometheus.exporters.pgbouncer.connectionString is insecure. Use connectionStringFile instead.
''
)
(mkIf
(cfg.pgbouncer.enable && config.services.pgbouncer.authType != "any") ''
Admin user (with password or passwordless) MUST exist in the services.pgbouncer.authFile if authType other than any is used.
''
)
] ++ config.services.prometheus.exporters.warnings;
}] ++ [(mkIf config.services.minio.enable {
services.prometheus.exporters.minio.minioAddress = mkDefault "http://localhost:9000";
services.prometheus.exporters.minio.minioAccessKey = mkDefault config.services.minio.accessKey;
Expand Down
145 changes: 145 additions & 0 deletions nixos/modules/services/monitoring/prometheus/exporters/pgbouncer.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{ config, lib, pkgs, options }:

with lib;

let
cfg = config.services.prometheus.exporters.pgbouncer;
in
{
port = 9127;
extraOpts = {

telemetryPath = mkOption {
type = types.str;
default = "/metrics";
description = lib.mdDoc ''
Path under which to expose metrics.
'';
};

connectionString = mkOption {
type = types.str;
default = "";
example = "postgres://admin:@localhost:6432/pgbouncer?sslmode=require";
description = lib.mdDoc ''
Connection string for accessing pgBouncer.
NOTE: You MUST keep pgbouncer as database name (special internal db)!!!
NOTE: Admin user (with password or passwordless) MUST exist
in the services.pgbouncer.authFile if authType other than any is used.
WARNING: this secret is stored in the world-readable Nix store!
Use {option}`connectionStringFile` instead.
'';
};

connectionStringFile = mkOption {
type = types.nullOr types.path;
default = null;
example = "/run/keys/pgBouncer-connection-string";
description = lib.mdDoc ''
File that contains pgBouncer connection string in format:
postgres://admin:@localhost:6432/pgbouncer?sslmode=require
NOTE: You MUST keep pgbouncer as database name (special internal db)!!!
NOTE: Admin user (with password or passwordless) MUST exist
in the services.pgbouncer.authFile if authType other than any is used.
{option}`connectionStringFile` takes precedence over {option}`connectionString`
'';
};

pidFile = mkOption {
type = types.nullOr types.str;
default = null;
description = lib.mdDoc ''
Path to PgBouncer pid file.
If provided, the standard process metrics get exported for the PgBouncer
process, prefixed with 'pgbouncer_process_...'. The pgbouncer_process exporter
needs to have read access to files owned by the PgBouncer process. Depends on
the availability of /proc.
https://prometheus.io/docs/instrumenting/writing_clientlibs/#process-metrics.
'';
};

webSystemdSocket = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc ''
Use systemd socket activation listeners instead of port listeners (Linux only).
'';
};

logLevel = mkOption {
type = types.enum ["debug" "info" "warn" "error" ];
default = "info";
description = lib.mdDoc ''
Only log messages with the given severity or above.
'';
};

logFormat = mkOption {
type = types.enum ["logfmt" "json"];
default = "logfmt";
description = lib.mdDoc ''
Output format of log messages. One of: [logfmt, json]
'';
};

webConfigFile = mkOption {
type = types.nullOr types.path;
default = null;
description = lib.mdDoc ''
Path to configuration file that can enable TLS or authentication.
'';
};

extraFlags = mkOption {
type = types.listOf types.str;
default = [ ];
description = lib.mdDoc ''
Extra commandline options when launching Prometheus.
'';
};

};

serviceOpts = {
after = [ "pgbouncer.service" ];
serviceConfig = let
startScript = pkgs.writeShellScriptBin "pgbouncer-start" "${concatStringsSep " " ([
"${pkgs.prometheus-pgbouncer-exporter}/bin/pgbouncer_exporter"
"--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
"--pgBouncer.connectionString ${if cfg.connectionStringFile != null then
"$(head -n1 ${cfg.connectionStringFile})" else "${escapeShellArg cfg.connectionString}"}"
]
++ optionals (cfg.telemetryPath != null) [
"--web.telemetry-path ${escapeShellArg cfg.telemetryPath}"
]
++ optionals (cfg.pidFile != null) [
"--pgBouncer.pid-file= ${escapeShellArg cfg.pidFile}"
]
++ optionals (cfg.logLevel != null) [
"--log.level ${escapeShellArg cfg.logLevel}"
]
++ optionals (cfg.logFormat != null) [
"--log.format ${escapeShellArg cfg.logFormat}"
]
++ optionals (cfg.webSystemdSocket != false) [
"--web.systemd-socket ${escapeShellArg cfg.webSystemdSocket}"
]
++ optionals (cfg.webConfigFile != null) [
"--web.config.file ${escapeShellArg cfg.webConfigFile}"
]
++ cfg.extraFlags)}";
in
{
ExecStart = "${startScript}/bin/pgbouncer-start";
};
};
}
3 changes: 0 additions & 3 deletions nixos/modules/tasks/network-interfaces-systemd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ let
# TODO: warn the user that any address configured on those interfaces will be useless
++ concatMap (i: attrNames (filterAttrs (_: config: config.type != "internal") i.interfaces)) (attrValues cfg.vswitches);

domains = cfg.search ++ (optional (cfg.domain != null) cfg.domain);
genericNetwork = override:
let gateway = optional (cfg.defaultGateway != null && (cfg.defaultGateway.address or "") != "") cfg.defaultGateway.address
++ optional (cfg.defaultGateway6 != null && (cfg.defaultGateway6.address or "") != "") cfg.defaultGateway6.address;
Expand All @@ -40,8 +39,6 @@ let
};
in optionalAttrs (gateway != [ ]) {
routes = override (map makeGateway gateway);
} // optionalAttrs (domains != [ ]) {
domains = override domains;
};

genericDhcpNetworks = initrd: mkIf cfg.useDHCP {
Expand Down
30 changes: 30 additions & 0 deletions nixos/tests/prometheus-exporters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,36 @@ let
'';
};

pgbouncer = {
exporterConfig = {
enable = true;
connectionString = "postgres://admin:@localhost:6432/pgbouncer?sslmode=disable";
};

metricProvider = {
services.postgresql.enable = true;
services.pgbouncer = {
# https://github.com/prometheus-community/pgbouncer_exporter#pgbouncer-configuration
ignoreStartupParameters = "extra_float_digits";
enable = true;
listenAddress = "*";
databases = { postgres = "host=/run/postgresql/ port=5432 auth_user=postgres dbname=postgres"; };
authType = "any";
maxClientConn = 99;
};
};
exporterTest = ''
wait_for_unit("postgresql.service")
wait_for_unit("pgbouncer.service")
wait_for_unit("prometheus-pgbouncer-exporter.service")
wait_for_open_port(9127)
succeed("curl -sSf http://localhost:9127/metrics | grep 'pgbouncer_up 1'")
succeed(
"curl -sSf http://localhost:9127/metrics | grep 'pgbouncer_config_max_client_connections 99'"
)
'';
};

php-fpm = {
nodeName = "php_fpm";
exporterConfig = {
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/blockchains/lnd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

buildGoModule rec {
pname = "lnd";
version = "0.16.3-beta";
version = "0.17.0-beta";

src = fetchFromGitHub {
owner = "lightningnetwork";
repo = "lnd";
rev = "v${version}";
hash = "sha256-/seSpWnlQmeU4vQtlHMOSedPXP9HJp1GyxcB1LqHayA=";
hash = "sha256-HndO7vp/sia352hs23xAgrpyJ/CfbRxYAAhLZ4q94Pc=";
};

vendorHash = "sha256-obrSVMqTwHe7231wa0OuoT6ANBqkQbkHIy93J2f68Zk=";
vendorHash = "sha256-4n81AZLKCTEV4+p4kRhZbzYsdRGIztzh6EKPin8W1Z0=";

subPackages = [ "cmd/lncli" "cmd/lnd" ];

Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/file-managers/doublecmd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

stdenv.mkDerivation (finalAttrs: {
pname = "doublecmd";
version = "1.1.1";
version = "1.1.2";

src = fetchFromGitHub {
owner = "doublecmd";
repo = "doublecmd";
rev = "v${finalAttrs.version}";
hash = "sha256-IccM7AwPiOtGHjAzvjQ99mrLFh8iZu8G7Rf71LJHB/g=";
hash = "sha256-hRBF0Xl1SSoW+vbp9c1iCuFBVIzLtueNJaqoFMF8lJ4=";
};

nativeBuildInputs = [
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/graphics/fig2dev/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

stdenv.mkDerivation rec {
pname = "fig2dev";
version = "3.2.8b";
version = "3.2.9";

src = fetchurl {
url = "mirror://sourceforge/mcj/fig2dev-${version}.tar.xz";
sha256 = "1jv8rg71dsy00lpg434r5zqs5qrg8mxqvv2gpcjjvmzsm551d2j1";
hash = "sha256-FeJGyNE8xy3iXggxQDitUM59Le+pzxr8Fy/X9ZMgkLE=";
};

nativeBuildInputs = [ makeWrapper ];
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/graphics/meme-image-generator/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

buildGoModule rec {
pname = "meme-image-generator";
version = "1.0.1";
version = "1.0.2";

src = fetchFromGitHub {
owner = "nomad-software";
repo = "meme";
rev = "v${version}";
hash = "sha256-MzSPJCszVEZkBvSbRzXR7AaDQOOjDQ2stKKJr8oGOSE=";
hash = "sha256-L+JpNg9X3RSNXTozv2H1n2JiQx75i9gFGaQmDFaMIf0=";
};

vendorHash = null;
Expand Down
7 changes: 5 additions & 2 deletions pkgs/applications/graphics/xfig/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
, libXp
, Xaw3d
, libXaw
, libXft
, fig2dev
}:

stdenv.mkDerivation rec {
pname = "xfig";
version = "3.2.8b";
version = "3.2.9";

src = fetchurl {
url = "mirror://sourceforge/mcj/xfig-${version}.tar.xz";
sha256 = "0fndgbm1mkqb1sn2v2kj3nx9mxj70jbp31y2bjvzcmmkry0q3k5j";
hash = "sha256-E+2dBNG7wt7AnafvSc7sJ4OC0pD2zZJkdMLy0Bb+wvc=";
};

nativeBuildInputs = [ imagemagick makeWrapper ];
Expand All @@ -30,6 +31,7 @@ stdenv.mkDerivation rec {
libXp
Xaw3d
libXaw
libXft
];

postPatch = ''
Expand Down Expand Up @@ -57,6 +59,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;

meta = with lib; {
changelog = "https://sourceforge.net/p/mcj/xfig/ci/${version}/tree/CHANGES";
description = "An interactive drawing tool for X11";
longDescription = ''
Note that you need to have the <literal>netpbm</literal> tools
Expand Down
Loading

0 comments on commit 7520bf4

Please sign in to comment.