| 
									
										
										
										
											2015-06-30 17:16:51 -04:00
										 |  |  | { config, pkgs, lib, ... }: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | with pkgs; | 
					
						
							|  |  |  | with lib; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   cfg = config.services.riemann-tools; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   riemannHost = "${cfg.riemannHost}"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   healthLauncher = writeScriptBin "riemann-health" ''
 | 
					
						
							|  |  |  |     #!/bin/sh | 
					
						
							|  |  |  |     exec ${pkgs.riemann-tools}/bin/riemann-health --host ${riemannHost} | 
					
						
							|  |  |  |   '';
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | in { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   options = { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     services.riemann-tools = { | 
					
						
							|  |  |  |       enableHealth = mkOption { | 
					
						
							|  |  |  |         type = types.bool; | 
					
						
							|  |  |  |         default = false; | 
					
						
							|  |  |  |         description = ''
 | 
					
						
							|  |  |  |           Enable the riemann-health daemon. | 
					
						
							|  |  |  |         '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |       riemannHost = mkOption { | 
					
						
							|  |  |  |         type = types.str; | 
					
						
							|  |  |  |         default = "127.0.0.1"; | 
					
						
							|  |  |  |         description = ''
 | 
					
						
							|  |  |  |           Address of the host riemann node. Defaults to localhost. | 
					
						
							|  |  |  |         '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config = mkIf cfg.enableHealth { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     users.extraGroups.riemanntools.gid = config.ids.gids.riemanntools; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     users.extraUsers.riemanntools = { | 
					
						
							|  |  |  |       description = "riemann-tools daemon user"; | 
					
						
							|  |  |  |       uid = config.ids.uids.riemanntools; | 
					
						
							|  |  |  |       group = "riemanntools"; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     systemd.services.riemann-health = { | 
					
						
							|  |  |  |       wantedBy = [ "multi-user.target" ]; | 
					
						
							| 
									
										
										
										
											2016-10-05 10:50:29 -04:00
										 |  |  |       path = [ procps ]; | 
					
						
							| 
									
										
										
										
											2015-06-30 17:16:51 -04:00
										 |  |  |       serviceConfig = { | 
					
						
							|  |  |  |         User = "riemanntools"; | 
					
						
							|  |  |  |         ExecStart = "${healthLauncher}/bin/riemann-health"; | 
					
						
							|  |  |  |         PermissionsStartOnly = true; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |