summaryrefslogtreecommitdiffstats
path: root/lass/1systems/mors.nix
diff options
context:
space:
mode:
authorlassulus <lass@lassul.us>2016-12-27 22:59:22 +0100
committerlassulus <lass@lassul.us>2016-12-27 22:59:22 +0100
commit8777507336421ae45bcf3b7fdbdb5b1ab9bcabd2 (patch)
treeaa148b35c071df0f853f760b78c184abc720c75c /lass/1systems/mors.nix
parent3ecebca46f8924de9dd97bd79a1f0272f39d9ae6 (diff)
l 1 mors: add graphite_beacon testing code
Diffstat (limited to 'lass/1systems/mors.nix')
-rw-r--r--lass/1systems/mors.nix131
1 files changed, 131 insertions, 0 deletions
diff --git a/lass/1systems/mors.nix b/lass/1systems/mors.nix
index ddb269e9d..3498f662b 100644
--- a/lass/1systems/mors.nix
+++ b/lass/1systems/mors.nix
@@ -86,6 +86,137 @@ with import <stockholm/lib>;
{
virtualisation.libvirtd.enable = true;
}
+ {
+ services.nginx = {
+ enable = mkDefault true;
+ virtualHosts = {
+ "stats.mors" = {
+ locations = {
+ "/" = {
+ proxyPass = "http://localhost:3000/";
+ extraConfig = ''
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ '';
+ };
+ };
+ };
+ };
+ };
+
+ services.grafana = {
+ enable = true;
+ addr = "127.0.0.1";
+ users.allowSignUp = false;
+ users.allowOrgCreate = false;
+ users.autoAssignOrg = false;
+ auth.anonymous.enable = true;
+ security = import <secrets/grafana_security.nix>; # { AdminUser = ""; adminPassword = ""}
+ };
+
+ services.graphite = {
+ api = {
+ enable = true;
+ listenAddress = "127.0.0.1";
+ port = 18080;
+ };
+ carbon = {
+ enableCache = true;
+ # save disk usage by restricting to 1 bulk update per second
+ config = ''
+ [cache]
+ MAX_CACHE_SIZE = inf
+ MAX_UPDATES_PER_SECOND = 1
+ MAX_CREATES_PER_MINUTE = 500
+ '';
+ storageSchemas = ''
+ [carbon]
+ pattern = ^carbon\.
+ retentions = 60:90d
+
+ [elchos]
+ patterhn = ^elchos\.
+ retentions = 10s:30d,60s:3y
+
+ [default]
+ pattern = .*
+ retentions = 30s:30d,300s:1y
+ '';
+ };
+ };
+
+ services.collectd = {
+ enable = true;
+ include = [ (toString (pkgs.writeText "collectd-graphite-cfg" ''
+ LoadPlugin write_graphite
+ <Plugin "write_graphite">
+ <Carbon>
+ Host "localhost"
+ Port "2003"
+ EscapeCharacter "_"
+ StoreRates false
+ AlwaysAppendDS false
+ </Carbon>
+ </Plugin>
+ ''))
+ ];
+ extraConfig = ''
+ LoadPlugin interface
+ LoadPlugin battery
+ LoadPlugin load
+ LoadPlugin cpu
+ LoadPlugin entropy
+ LoadPlugin write_graphite
+ <Plugin "interface">
+ Interface "et0"
+ Interface "wl0"
+ Interface "retiolum"
+ </Plugin>
+ '';
+ };
+ services.graphite.beacon = {
+ enable = true;
+ config = {
+ graphite_url = "http://localhost:18080";
+ cli = {
+ command = ''${pkgs.irc-announce}/bin/irc-announce irc.freenode.org 6667 mors-beacon-alert \#krebs ' ''${level} ''${name} ''${value}' '';
+ };
+ smtp = {
+ from = "beacon@mors.r";
+ to = [
+ "lass@mors.r"
+ ];
+ };
+ normal_handlers = [
+ "smtp"
+ "cli"
+ ];
+ warning_handlers = [
+ "smtp"
+ "cli"
+ ];
+ critical_handlers = [
+ "smtp"
+ "cli"
+ ];
+ alerts = [
+ {
+ name = "testbattery";
+ query = "*.battery-0.capacity";
+ method = "last_value";
+ interval = "1minute";
+ logging = "info";
+ repeat_interval = "5minute";
+ rules = [
+ "warning: < 30.0"
+ "critical: < 10.0"
+ ];
+ }
+ ];
+ };
+ };
+ }
];
krebs.build.host = config.krebs.hosts.mors;