lol

longview nixos module: init

+78
+1
nixos/modules/module-list.nix
··· 240 240 ./services/monitoring/grafana.nix 241 241 ./services/monitoring/graphite.nix 242 242 ./services/monitoring/heapster.nix 243 + ./services/monitoring/longview.nix 243 244 ./services/monitoring/monit.nix 244 245 ./services/monitoring/munin.nix 245 246 ./services/monitoring/nagios.nix
+77
nixos/modules/services/monitoring/longview.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.longview; 7 + 8 + pidFile = "/run/longview.pid"; 9 + 10 + apacheConf = '' 11 + #location http://127.0.0.1/server-status?auto 12 + ''; 13 + mysqlConf = '' 14 + #username root 15 + #password example_password 16 + ''; 17 + nginxConf = '' 18 + #location http://127.0.0.1/nginx_status 19 + ''; 20 + 21 + in 22 + 23 + { 24 + options = { 25 + 26 + services.longview = { 27 + 28 + enable = mkOption { 29 + type = types.bool; 30 + default = false; 31 + description = '' 32 + If enabled, system metrics will be sent to Linode LongView. 33 + ''; 34 + }; 35 + 36 + apiKey = mkOption { 37 + type = types.str; 38 + description = '' 39 + Longview API key. To get this, look in Longview settings which 40 + are found at https://manager.linode.com/longview/. 41 + ''; 42 + }; 43 + 44 + }; 45 + 46 + }; 47 + 48 + config = mkIf cfg.enable { 49 + systemd.services.longview = 50 + { description = "Longview Metrics Collection"; 51 + after = [ "network.target" ]; 52 + wantedBy = [ "multi-user.target" ]; 53 + serviceConfig.Type = "forking"; 54 + serviceConfig.ExecStop = "-${pkgs.coreutils}/bin/kill -TERM $MAINPID"; 55 + serviceConfig.ExecReload = "-${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 56 + serviceConfig.PIDFile = pidFile; 57 + serviceConfig.ExecStart = "${pkgs.longview}/bin/longview"; 58 + }; 59 + 60 + environment.etc."linode/longview.key" = { 61 + mode = "0400"; 62 + text = cfg.apiKey; 63 + }; 64 + environment.etc."linode/longview.d/Apache.conf" = { 65 + mode = "0400"; 66 + text = apacheConf; 67 + }; 68 + environment.etc."linode/longview.d/MySQL.conf" = { 69 + mode = "0400"; 70 + text = mysqlConf; 71 + }; 72 + environment.etc."linode/longview.d/Nginx.conf" = { 73 + mode = "0400"; 74 + text = nginxConf; 75 + }; 76 + }; 77 + }