Merge pull request #71058 from WilliButz/add-nextcloud-exporter
prometheus-nextcloud-exporter: init at 2019-10-12, with module and test
This commit is contained in:
commit
87178a2e6e
|
@ -30,6 +30,7 @@ let
|
|||
"json"
|
||||
"mail"
|
||||
"minio"
|
||||
"nextcloud"
|
||||
"nginx"
|
||||
"node"
|
||||
"postfix"
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
{ config, lib, pkgs, options }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.prometheus.exporters.nextcloud;
|
||||
in
|
||||
{
|
||||
port = 9205;
|
||||
extraOpts = {
|
||||
url = mkOption {
|
||||
type = types.str;
|
||||
example = "https://domain.tld";
|
||||
description = ''
|
||||
URL to the Nextcloud serverinfo page.
|
||||
Adding the path to the serverinfo API is optional, it defaults
|
||||
to <literal>/ocs/v2.php/apps/serverinfo/api/v1/info</literal>.
|
||||
'';
|
||||
};
|
||||
username = mkOption {
|
||||
type = types.str;
|
||||
default = "nextcloud-exporter";
|
||||
description = ''
|
||||
Username for connecting to Nextcloud.
|
||||
Note that this account needs to have admin privileges in Nextcloud.
|
||||
'';
|
||||
};
|
||||
passwordFile = mkOption {
|
||||
type = types.path;
|
||||
example = "/path/to/password-file";
|
||||
description = ''
|
||||
File containing the password for connecting to Nextcloud.
|
||||
Make sure that this file is readable by the exporter user.
|
||||
'';
|
||||
};
|
||||
timeout = mkOption {
|
||||
type = types.str;
|
||||
default = "5s";
|
||||
description = ''
|
||||
Timeout for getting server info document.
|
||||
'';
|
||||
};
|
||||
};
|
||||
serviceOpts = {
|
||||
serviceConfig = {
|
||||
DynamicUser = false;
|
||||
ExecStart = ''
|
||||
${pkgs.prometheus-nextcloud-exporter}/bin/nextcloud-exporter \
|
||||
-a ${cfg.listenAddress}:${toString cfg.port} \
|
||||
-u ${cfg.username} \
|
||||
-t ${cfg.timeout} \
|
||||
-l ${cfg.url} \
|
||||
-p @${cfg.passwordFile} \
|
||||
${concatStringsSep " \\\n " cfg.extraFlags}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -229,6 +229,40 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
nextcloud = {
|
||||
exporterConfig = {
|
||||
enable = true;
|
||||
passwordFile = "/var/nextcloud-pwfile";
|
||||
url = "http://localhost/negative-space.xml";
|
||||
};
|
||||
metricProvider = {
|
||||
systemd.services.nc-pwfile = let
|
||||
passfile = (pkgs.writeText "pwfile" "snakeoilpw");
|
||||
in {
|
||||
requiredBy = [ "prometheus-nextcloud-exporter.service" ];
|
||||
before = [ "prometheus-nextcloud-exporter.service" ];
|
||||
serviceConfig.ExecStart = ''
|
||||
${pkgs.coreutils}/bin/install -o nextcloud-exporter -m 0400 ${passfile} /var/nextcloud-pwfile
|
||||
'';
|
||||
};
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts."localhost" = {
|
||||
basicAuth.nextcloud-exporter = "snakeoilpw";
|
||||
locations."/" = {
|
||||
root = "${pkgs.prometheus-nextcloud-exporter.src}/serverinfo/testdata";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
exporterTest = ''
|
||||
waitForUnit("nginx.service")
|
||||
waitForUnit("prometheus-nextcloud-exporter.service")
|
||||
waitForOpenPort(9205)
|
||||
succeed("curl -sSf http://localhost:9205/metrics | grep -q 'nextcloud_up 1'")
|
||||
'';
|
||||
};
|
||||
|
||||
nginx = {
|
||||
exporterConfig = {
|
||||
enable = true;
|
||||
|
|
|
@ -0,0 +1,300 @@
|
|||
# file generated from go.mod using vgo2nix (https://github.com/adisbladis/vgo2nix)
|
||||
[
|
||||
{
|
||||
goPackagePath = "github.com/beorn7/perks";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/beorn7/perks";
|
||||
rev = "v1.0.1";
|
||||
sha256 = "17n4yygjxa6p499dj3yaqzfww2g7528165cl13haj97hlx94dgl7";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/davecgh/go-spew";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/davecgh/go-spew";
|
||||
rev = "v1.1.1";
|
||||
sha256 = "0hka6hmyvp701adzag2g26cxdj47g21x6jz4sc6jjz1mn59d474y";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/go-kit/kit";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/go-kit/kit";
|
||||
rev = "v0.8.0";
|
||||
sha256 = "1rcywbc2pvab06qyf8pc2rdfjv7r6kxdv2v4wnpqnjhz225wqvc0";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/go-logfmt/logfmt";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/go-logfmt/logfmt";
|
||||
rev = "v0.4.0";
|
||||
sha256 = "06smxc112xmixz78nyvk3b2hmc7wasf2sl5vxj1xz62kqcq9lzm9";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/golang/protobuf";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/golang/protobuf";
|
||||
rev = "v1.3.2";
|
||||
sha256 = "1k1wb4zr0qbwgpvz9q5ws9zhlal8hq7dmq62pwxxriksayl6hzym";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/google/go-cmp";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/google/go-cmp";
|
||||
rev = "v0.3.0";
|
||||
sha256 = "1hyxx3434zshl2m9ja78gwlkg1rx9yl6diqa7dnjb31xz5x4gbjj";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/google/gofuzz";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/google/gofuzz";
|
||||
rev = "v1.0.0";
|
||||
sha256 = "0qz439qvccm91w0mmjz4fqgx48clxdwagkvvx89cr43q1d4iry36";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/json-iterator/go";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/json-iterator/go";
|
||||
rev = "v1.1.7";
|
||||
sha256 = "0n79p4s67zl5zprxv7diayw3vavnmmfqkmd6snz0i9bxp825dsyz";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/julienschmidt/httprouter";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/julienschmidt/httprouter";
|
||||
rev = "v1.2.0";
|
||||
sha256 = "1k8bylc9s4vpvf5xhqh9h246dl1snxrzzz0614zz88cdh8yzs666";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/konsorten/go-windows-terminal-sequences";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/konsorten/go-windows-terminal-sequences";
|
||||
rev = "v1.0.1";
|
||||
sha256 = "1lchgf27n276vma6iyxa0v1xds68n2g8lih5lavqnx5x6q5pw2ip";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/kr/logfmt";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/kr/logfmt";
|
||||
rev = "b84e30acd515";
|
||||
sha256 = "02ldzxgznrfdzvghfraslhgp19la1fczcbzh7wm2zdc6lmpd1qq9";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/matttproud/golang_protobuf_extensions";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/matttproud/golang_protobuf_extensions";
|
||||
rev = "v1.0.1";
|
||||
sha256 = "1d0c1isd2lk9pnfq2nk0aih356j30k3h1gi2w0ixsivi5csl7jya";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/modern-go/concurrent";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/modern-go/concurrent";
|
||||
rev = "bacd9c7ef1dd";
|
||||
sha256 = "0s0fxccsyb8icjmiym5k7prcqx36hvgdwl588y0491gi18k5i4zs";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/modern-go/reflect2";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/modern-go/reflect2";
|
||||
rev = "v1.0.1";
|
||||
sha256 = "06a3sablw53n1dqqbr2f53jyksbxdmmk8axaas4yvnhyfi55k4lf";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/mwitkow/go-conntrack";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/mwitkow/go-conntrack";
|
||||
rev = "cc309e4a2223";
|
||||
sha256 = "0nbrnpk7bkmqg9mzwsxlm0y8m7s9qd9phr1q30qlx2qmdmz7c1mf";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/pkg/errors";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/pkg/errors";
|
||||
rev = "v0.8.0";
|
||||
sha256 = "001i6n71ghp2l6kdl3qq1v2vmghcz3kicv9a5wgcihrzigm75pp5";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/pmezard/go-difflib";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/pmezard/go-difflib";
|
||||
rev = "v1.0.0";
|
||||
sha256 = "0c1cn55m4rypmscgf0rrb88pn58j3ysvc2d0432dp3c6fqg6cnzw";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/prometheus/client_golang";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/prometheus/client_golang";
|
||||
rev = "v1.1.0";
|
||||
sha256 = "1r0irxkmfnj6ininb06w6ybknini5lz02idawrbkk2i5lq1qcvvf";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/prometheus/client_model";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/prometheus/client_model";
|
||||
rev = "14fe0d1b01d4";
|
||||
sha256 = "0zdmk6rbbx39cvfz0r59v2jg5sg9yd02b4pds5n5llgvivi99550";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/prometheus/common";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/prometheus/common";
|
||||
rev = "v0.6.0";
|
||||
sha256 = "1q16br348117ffycxdwsldb0i39p34miclfa8z93k6vjwnrqbh2l";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/prometheus/procfs";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/prometheus/procfs";
|
||||
rev = "v0.0.3";
|
||||
sha256 = "18c4m795fwng8f8qa395f3crvamlbk5y5afk8b5rzyisnmjq774y";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/sirupsen/logrus";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/sirupsen/logrus";
|
||||
rev = "v1.2.0";
|
||||
sha256 = "0r6334x2bls8ddznvzaldx4g88msjjns4mlks95rqrrg7h0ijigg";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/spf13/pflag";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/spf13/pflag";
|
||||
rev = "v1.0.3";
|
||||
sha256 = "1cj3cjm7d3zk0mf1xdybh0jywkbbw7a6yr3y22x9sis31scprswd";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/stretchr/objx";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/stretchr/objx";
|
||||
rev = "v0.1.1";
|
||||
sha256 = "0iph0qmpyqg4kwv8jsx6a56a7hhqq8swrazv40ycxk9rzr0s8yls";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "github.com/stretchr/testify";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://github.com/stretchr/testify";
|
||||
rev = "v1.3.0";
|
||||
sha256 = "0wjchp2c8xbgcbbq32w3kvblk6q6yn533g78nxl6iskq6y95lxsy";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/crypto";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/crypto";
|
||||
rev = "c2843e01d9a2";
|
||||
sha256 = "01xgxbj5r79nmisdvpq48zfy8pzaaj90bn6ngd4nf33j9ar1dp8r";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/net";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/net";
|
||||
rev = "d28f0bde5980";
|
||||
sha256 = "18xj31h70m7xxb7gc86n9i21w6d7djbjz67zfaljm4jqskz6hxkf";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/sync";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/sync";
|
||||
rev = "37e7f081c4d4";
|
||||
sha256 = "1bb0mw6ckb1k7z8v3iil2qlqwfj408fvvp8m1cik2b46p7snyjhm";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/sys";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/sys";
|
||||
rev = "4e8604ab3aff";
|
||||
sha256 = "1y4nvb8xqk3gzmkk3pc0bdphxbnphz71cld9i6f75js01pggaspc";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "golang.org/x/text";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://go.googlesource.com/text";
|
||||
rev = "v0.3.0";
|
||||
sha256 = "0r6x6zjzhr8ksqlpiwm5gdd7s209kwk5p4lw54xjvz10cs3qlq19";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "gopkg.in/alecthomas/kingpin.v2";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://gopkg.in/alecthomas/kingpin.v2";
|
||||
rev = "v2.2.6";
|
||||
sha256 = "0mndnv3hdngr3bxp7yxfd47cas4prv98sqw534mx7vp38gd88n5r";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "gopkg.in/check.v1";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://gopkg.in/check.v1";
|
||||
rev = "20d25e280405";
|
||||
sha256 = "0k1m83ji9l1a7ng8a7v40psbymxasmssbrrhpdv2wl4rhs0nc3np";
|
||||
};
|
||||
}
|
||||
{
|
||||
goPackagePath = "gopkg.in/yaml.v2";
|
||||
fetch = {
|
||||
type = "git";
|
||||
url = "https://gopkg.in/yaml.v2";
|
||||
rev = "v2.2.1";
|
||||
sha256 = "0dwjrs2lp2gdlscs7bsrmyc5yf6mm4fvgw71bzr9mv2qrd2q73s1";
|
||||
};
|
||||
}
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
{ lib, fetchFromGitHub, buildGoPackage }:
|
||||
|
||||
buildGoPackage {
|
||||
pname = "prometheus-nextcloud-exporter";
|
||||
version = "unstable-2019-10-12";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "xperimental";
|
||||
repo = "nextcloud-exporter";
|
||||
rev = "215c8b6b2daa3125798d883fe222bc419240e7ab";
|
||||
sha256 = "1xpc6q6zp92ckkyd24cfl65vyzjv60qwh44ys6mza4k6yrxhacv4";
|
||||
};
|
||||
|
||||
goPackagePath = "github.com/xperimental/nextcloud-exporter";
|
||||
|
||||
goDeps = ./nextcloud-exporter-deps.nix;
|
||||
|
||||
doCheck = true;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Prometheus exporter for Nextcloud servers.";
|
||||
homepage = "https://github.com/xperimental/nextcloud-exporter";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ willibutz ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
|
@ -15175,6 +15175,7 @@ in
|
|||
prometheus-mesos-exporter = callPackage ../servers/monitoring/prometheus/mesos-exporter.nix { };
|
||||
prometheus-minio-exporter = callPackage ../servers/monitoring/prometheus/minio-exporter { };
|
||||
prometheus-mysqld-exporter = callPackage ../servers/monitoring/prometheus/mysqld-exporter.nix { };
|
||||
prometheus-nextcloud-exporter = callPackage ../servers/monitoring/prometheus/nextcloud-exporter.nix { };
|
||||
prometheus-nginx-exporter = callPackage ../servers/monitoring/prometheus/nginx-exporter.nix { };
|
||||
prometheus-node-exporter = callPackage ../servers/monitoring/prometheus/node-exporter.nix { };
|
||||
prometheus-openvpn-exporter = callPackage ../servers/monitoring/prometheus/openvpn-exporter.nix { };
|
||||
|
|
Loading…
Reference in New Issue