mirror of
				https://github.com/Tafkas/fritzbox-munin.git
				synced 2023-10-10 11:36:55 +00:00 
			
		
		
		
	Fixes #14. Added localization for english
This commit is contained in:
		
							
								
								
									
										18
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								README.md
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
				
			|||||||
# fritzbox-munin
 | 
					# fritzbox-munin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a [FRITZ!Box 7362 SL](http://geni.us/fTyoY)(Amazon link) running FRITZ!OS 06.83. This script also only works if the language of the Fritz!Box is set to German (this holds only for the uptime and wifi devices check).
 | 
					A collection of munin plugins to monitor your AVM FRITZ!Box router. The scripts have been developed using a [FRITZ!Box 7362 SL](http://geni.us/fTyoY)(Amazon link) running FRITZ!OS 06.83.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
If you are using the scripts on a different Fritz!Box model please let me know by
 | 
					If you are using the scripts on a different Fritz!Box model please let me know by
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -54,12 +54,12 @@ If you are using the scripts on a different Fritz!Box model please let me know b
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## fritzbox\_uptime
 | 
					## fritzbox\_uptime
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  fritzbox\_uptime shows you the uptime in days (requires password)  
 | 
					  fritzbox\_uptime shows you the uptime in days (requires password) (language dependant, see below).
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## fritzbox\_wifi\_devices
 | 
					## fritzbox\_wifi\_devices
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  fritzbox\_wifi\_devices shows you the number of connected wifi clients (requires password)
 | 
					  fritzbox\_wifi\_devices shows you the number of connected wifi clients (requires password) (language dependant, see below).
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -83,6 +83,18 @@ If you are using the scripts on a different Fritz!Box model please let me know b
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
5. Done. You should now start to see the charts on the Munin pages.
 | 
					5. Done. You should now start to see the charts on the Munin pages.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Localization
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Two scripts depend on the language selected in your fritzbox: the uptime and wifi\_devices. Currently, two locales are
 | 
				
			||||||
 | 
					supported:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					1. German: `de` (default)
 | 
				
			||||||
 | 
					2. English: `en`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You can change the used locale by setting an environment variable in your plugin configuration:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    env.locale en
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Environment Settings
 | 
					## Environment Settings
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  Do not forget to restart the munin-node daemon as described in step 3 of the installation instructions above.
 | 
					  Do not forget to restart the munin-node daemon as described in step 3 of the installation instructions above.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,8 +21,15 @@ import re
 | 
				
			|||||||
import sys
 | 
					import sys
 | 
				
			||||||
import fritzbox_helper as fh
 | 
					import fritzbox_helper as fh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					locale = os.environ.get('locale', 'de')
 | 
				
			||||||
 | 
					patternLoc = {"de":"(\d+)\s(Tag|Stunden|Minuten)", \
 | 
				
			||||||
 | 
					              "en":"(\d+)\s(days|hours|minutes)"}
 | 
				
			||||||
 | 
					dayLoc = {"de":"Tag", "en":"days"}
 | 
				
			||||||
 | 
					hourLoc = {"de":"Stunden", "en":"hours"}
 | 
				
			||||||
 | 
					minutesLoc = {"de":"Minuten", "en":"minutes"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PAGE = '/system/energy.lua'
 | 
					PAGE = '/system/energy.lua'
 | 
				
			||||||
pattern = re.compile("(\d+)\s(Tag|Stunden|Minuten)")
 | 
					pattern = re.compile(patternLoc[locale])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_uptime():
 | 
					def get_uptime():
 | 
				
			||||||
@@ -37,11 +44,11 @@ def get_uptime():
 | 
				
			|||||||
    if matches:
 | 
					    if matches:
 | 
				
			||||||
        hours = 0.0
 | 
					        hours = 0.0
 | 
				
			||||||
        for m in matches:
 | 
					        for m in matches:
 | 
				
			||||||
            if m.group(2) == 'Tag':
 | 
					            if m.group(2) == dayLoc[locale]:
 | 
				
			||||||
                hours += 24 * int(m.group(1))
 | 
					                hours += 24 * int(m.group(1))
 | 
				
			||||||
            if m.group(2) == "Stunden":
 | 
					            if m.group(2) == hourLoc[locale]:
 | 
				
			||||||
                hours += int(m.group(1))
 | 
					                hours += int(m.group(1))
 | 
				
			||||||
            if m.group(2) == "Minuten":
 | 
					            if m.group(2) == minutesLoc[locale]:
 | 
				
			||||||
                hours += int(m.group(1)) / 60.0
 | 
					                hours += int(m.group(1)) / 60.0
 | 
				
			||||||
        uptime = hours / 24
 | 
					        uptime = hours / 24
 | 
				
			||||||
        print "uptime.value %.2f" % uptime
 | 
					        print "uptime.value %.2f" % uptime
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,8 +21,11 @@ import re
 | 
				
			|||||||
import sys
 | 
					import sys
 | 
				
			||||||
import fritzbox_helper as fh
 | 
					import fritzbox_helper as fh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					locale = os.environ.get('locale', 'de')
 | 
				
			||||||
 | 
					patternLoc = {"de":"(\d+) WLAN", "en":"(\d+) wireless LAN"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PAGE = '/system/energy.lua'
 | 
					PAGE = '/system/energy.lua'
 | 
				
			||||||
pattern = re.compile("(\d+) WLAN")
 | 
					pattern = re.compile(patternLoc[locale])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_connected_wifi_devices():
 | 
					def get_connected_wifi_devices():
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user