mirror of
				https://github.com/Stunkymonkey/nixos.git
				synced 2025-10-31 17:52:10 +01:00 
			
		
		
		
	service/fritzbox: init
This commit is contained in:
		
							parent
							
								
									d23f5a0e40
								
							
						
					
					
						commit
						8827ca309e
					
				
					 6 changed files with 89 additions and 2 deletions
				
			
		
							
								
								
									
										70
									
								
								modules/services/fritzbox/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								modules/services/fritzbox/default.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,70 @@ | |||
| { | ||||
|   config, | ||||
|   lib, | ||||
|   pkgs, | ||||
|   ... | ||||
| }: | ||||
| let | ||||
|   cfg = config.my.services.fritzbox; | ||||
| in | ||||
| { | ||||
|   options.my.services.fritzbox = with lib; { | ||||
|     enable = mkEnableOption "Fritzbox-Monitoring"; | ||||
|     port = mkOption { | ||||
|       type = types.port; | ||||
|       default = 9787; | ||||
|       example = 8080; | ||||
|       description = "Internal port"; | ||||
|     }; | ||||
| 
 | ||||
|     username = mkOption { | ||||
|       type = types.str; | ||||
|       default = "prometheus"; | ||||
|       example = "admin"; | ||||
|       description = "Admin username"; | ||||
|     }; | ||||
| 
 | ||||
|     passwordFile = mkOption { | ||||
|       type = types.str; | ||||
|       example = "/var/lib/fritz/password.txt"; | ||||
|       description = "password stored in a file"; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = lib.mkIf cfg.enable { | ||||
|     services = { | ||||
|       prometheus.exporters.fritz = { | ||||
|         inherit (cfg) enable port; | ||||
|         settings.devices = [ | ||||
|           { | ||||
|             inherit (cfg) username; | ||||
|             password_file = cfg.passwordFile; | ||||
|             host_info = true; | ||||
|           } | ||||
|         ]; | ||||
|       }; | ||||
|       prometheus.scrapeConfigs = [ | ||||
|         { | ||||
|           job_name = "fritzbox"; | ||||
|           static_configs = [ | ||||
|             { | ||||
|               targets = [ "127.0.0.1:${toString cfg.port}" ]; | ||||
|               labels = { | ||||
|                 instance = config.networking.hostName; | ||||
|               }; | ||||
|             } | ||||
|           ]; | ||||
|         } | ||||
|       ]; | ||||
|       grafana.provision = { | ||||
|         dashboards.settings.providers = [ | ||||
|           { | ||||
|             name = "Fritzbox"; | ||||
|             options.path = pkgs.grafana-dashboards.fritzbox; | ||||
|             disableDeletion = true; | ||||
|           } | ||||
|         ]; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Felix Buehler
						Felix Buehler