| 
									
										
										
										
											2014-12-30 13:09:33 +02:00
										 |  |  | #!/usr/bin/python | 
					
						
							|  |  |  | # -*- encoding: utf-8; py-indent-offset: 4 -*- | 
					
						
							|  |  |  | # Author: Marius Pana <mp@sphs.ro> | 
					
						
							|  |  |  | # EXAMPLE DATA FROM: | 
					
						
							|  |  |  | # format: datbase size_in_MB free_MB_available | 
					
						
							|  |  |  | #<<<exchange_db_size>>> | 
					
						
							| 
									
										
										
										
											2015-01-24 14:41:21 +02:00
										 |  |  | #RomaniaEXC 177 | 
					
						
							|  |  |  | #ExchangeDB_Size 81 | 
					
						
							| 
									
										
										
										
											2014-12-30 13:09:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | factory_settings["exchange_db_size_default_values"] = { | 
					
						
							|  |  |  |         "levels" : (20000, 25000), | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | exchange_db_size_default_values = (20000, 25000) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def inventory_exchange_db_size(info): | 
					
						
							|  |  |  |     inventory = [] | 
					
						
							|  |  |  |     for line in info: | 
					
						
							|  |  |  |         database = line[0] | 
					
						
							|  |  |  |         inventory.append((database, "exchange_db_size_default_values")) | 
					
						
							|  |  |  |     return inventory | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def check_exchange_db_size(item, params, info): | 
					
						
							| 
									
										
										
										
											2015-01-24 14:41:21 +02:00
										 |  |  |     if type(params) != dict: | 
					
						
							|  |  |  |         params = { "levels" : params } | 
					
						
							| 
									
										
										
										
											2014-12-30 13:09:33 +02:00
										 |  |  |     #unpack check params | 
					
						
							| 
									
										
										
										
											2015-01-24 14:41:21 +02:00
										 |  |  |     warn, crit = params["levels"] | 
					
						
							| 
									
										
										
										
											2014-12-30 13:09:33 +02:00
										 |  |  |     for line in info: | 
					
						
							|  |  |  |         if line[0] == item: | 
					
						
							|  |  |  |             dbsize = int(line[1]) | 
					
						
							|  |  |  |             #dbavail = int(line[2]) | 
					
						
							|  |  |  |             perfdata = [ | 
					
						
							|  |  |  |                 ( "size", str(dbsize), warn, crit  ), | 
					
						
							|  |  |  |                 #( "avail", str(dbavail), warn, crit  ), | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |             if dbsize > crit: | 
					
						
							|  |  |  |                 return (2, "Database size is %dMB" % dbsize, perfdata) | 
					
						
							|  |  |  |             elif dbsize > warn: | 
					
						
							|  |  |  |                 return (1, "Database size is %dMB" % dbsize, perfdata) | 
					
						
							|  |  |  |             else: | 
					
						
							|  |  |  |                 return (0, "Database size is %dMB" % dbsize, perfdata) | 
					
						
							|  |  |  |     return(3, "Database %s not found in agent output" % item) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | check_info["exchange_db_size"] = { | 
					
						
							|  |  |  |     'check_function':        check_exchange_db_size, | 
					
						
							|  |  |  |     'inventory_function':    inventory_exchange_db_size, | 
					
						
							|  |  |  |     'service_description':   '%s Database size', | 
					
						
							| 
									
										
										
										
											2015-01-24 14:41:21 +02:00
										 |  |  |     'default_levels_variable': 'exchange_user_mbx_size_default_values', | 
					
						
							| 
									
										
										
										
											2014-12-30 13:09:33 +02:00
										 |  |  |     'has_perfdata':          True, | 
					
						
							|  |  |  |     'group':                 'exchange_db_size', | 
					
						
							|  |  |  | } |