summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/longview.nix
diff options
context:
space:
mode:
authorRodney Lorrimar <dev@rodney.id.au>2015-11-01 10:22:58 +0000
committerRodney Lorrimar <dev@rodney.id.au>2015-11-22 12:37:00 +0000
commitbc3fb7961976ce4d8c1df731f8cff1f97c14c27a (patch)
treee2b39edf03dd29c02897e4ba97d750ff598ab20a /nixos/modules/services/monitoring/longview.nix
parent96f81e3be57bb46858496edc07fd4bdcc6ce1704 (diff)
downloadnixpkgs-bc3fb7961976ce4d8c1df731f8cff1f97c14c27a.tar
nixpkgs-bc3fb7961976ce4d8c1df731f8cff1f97c14c27a.tar.gz
nixpkgs-bc3fb7961976ce4d8c1df731f8cff1f97c14c27a.tar.bz2
nixpkgs-bc3fb7961976ce4d8c1df731f8cff1f97c14c27a.tar.lz
nixpkgs-bc3fb7961976ce4d8c1df731f8cff1f97c14c27a.tar.xz
nixpkgs-bc3fb7961976ce4d8c1df731f8cff1f97c14c27a.tar.zst
nixpkgs-bc3fb7961976ce4d8c1df731f8cff1f97c14c27a.zip
longview nixos module: init
Diffstat (limited to 'nixos/modules/services/monitoring/longview.nix')
-rw-r--r--nixos/modules/services/monitoring/longview.nix77
1 files changed, 77 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/longview.nix b/nixos/modules/services/monitoring/longview.nix
new file mode 100644
index 00000000000..b55f43b437b
--- /dev/null
+++ b/nixos/modules/services/monitoring/longview.nix
@@ -0,0 +1,77 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.longview;
+
+  pidFile = "/run/longview.pid";
+
+  apacheConf =  ''
+    #location http://127.0.0.1/server-status?auto
+  '';
+  mysqlConf = ''
+    #username root
+    #password example_password
+  '';
+  nginxConf = ''
+    #location http://127.0.0.1/nginx_status
+  '';
+
+in
+
+{
+  options = {
+
+    services.longview = {
+
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          If enabled, system metrics will be sent to Linode LongView.
+        '';
+      };
+
+      apiKey = mkOption {
+        type = types.str;
+        description = ''
+          Longview API key. To get this, look in Longview settings which
+          are found at https://manager.linode.com/longview/.
+        '';
+      };
+
+    };
+
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.longview =
+      { description = "Longview Metrics Collection";
+        after = [ "network.target" ];
+        wantedBy = [ "multi-user.target" ];
+        serviceConfig.Type = "forking";
+        serviceConfig.ExecStop = "-${pkgs.coreutils}/bin/kill -TERM $MAINPID";
+        serviceConfig.ExecReload = "-${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+        serviceConfig.PIDFile = pidFile;
+        serviceConfig.ExecStart = "${pkgs.longview}/bin/longview";
+      };
+
+    environment.etc."linode/longview.key" = {
+      mode = "0400";
+      text = cfg.apiKey;
+    };
+    environment.etc."linode/longview.d/Apache.conf" = {
+      mode = "0400";
+      text = apacheConf;
+    };
+    environment.etc."linode/longview.d/MySQL.conf" = {
+      mode = "0400";
+      text = mysqlConf;
+    };
+    environment.etc."linode/longview.d/Nginx.conf" = {
+      mode = "0400";
+      text = nginxConf;
+    };
+  };
+}