Skip to content

Commit

Permalink
add icecast metrics exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerx committed Nov 17, 2020
1 parent 09081da commit 0769d4e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
27 changes: 27 additions & 0 deletions packages/icecast-exporter/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ pkgs ? import <nixpkgs> {} }:

with pkgs;

let
metadata = import ./metadata.nix;
in buildGoModule rec {
pname = "icecast_exporter";
version = metadata.rev;

src = fetchFromGitHub {
owner = "markuslindenberg";
repo = pname;
rev = metadata.rev;
sha256 = metadata.sha256;
};

vendorSha256 = metadata.vendorSha256;

meta = with stdenv.lib; {
homepage = "https://github.com/markuslindenberg/icecast_exporter";
description = "Icecast exporter for Prometheus";
platforms = platforms.unix;
maintainers = with maintainers; [ markuslindenberg ];
license = licenses.apache2;
};
}
5 changes: 5 additions & 0 deletions packages/icecast-exporter/metadata.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
vendorSha256 = "0000000000000000000000000000000000000000000000000000";
rev = "ce5cb4055d987ab0f8b95061ef7bf75dc547c787";
sha256 = "0000000000000000000000000000000000000000000000000000";
}
19 changes: 17 additions & 2 deletions services/icecast.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{ config, lib, pkgs, ... }:
with lib;
let
metrics-pkg = import ../../../packages/icecast-exporter { inherit pkgs; };
port = 8002;
tld = config.redbrick.tld;
admin-secret = "/var/secrets/icecast-admin.secret";
source-secret = "/var/secrets/icecast-source.secret";
Expand Down Expand Up @@ -29,7 +31,7 @@ in {
password = "${lib.fileContents admin-secret}";
};
listen = {
port = 8002;
inherit port;
address = listenAddress;
};
logDir = "/var/log/icecast/";
Expand Down Expand Up @@ -64,5 +66,18 @@ in {
<fileserve>1</fileserve>
'';
};
networking.firewall.allowedTCPPorts = [ 8002 ];

systemd.services.icecast-exporter = {
description = "Icecast Metrics exporter";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${metrics-pkg}/bin/icecast_exporter -log.format='logger:stdout?json=true' -icecast.scrape-uri='http://${listenAddress}:${port}/status-json.xsl'";
User = "icecast";
Restart = "always";
RestartSec = "10s";
};
};

networking.firewall.allowedTCPPorts = [ 8002 9146 ];
}
4 changes: 4 additions & 0 deletions services/prometheus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ in {
job_name = "bind";
static_configs = [{ targets = ["m1cr0man.internal:9119"]; }];
}
{
job_name = "icecast";
static_configs = [{ targets = ["localhost:9146"]; }];
}
{
job_name = "collectd";
static_configs = [{ targets = ["zeus.internal:9103"]; }];
Expand Down

0 comments on commit 0769d4e

Please sign in to comment.