| Server IP : 118.27.122.120 / Your IP : 216.73.216.136 Web Server : Apache System : Linux web0216.sh.tyo1 4.18.0-553.141.2.lve.el7h.x86_64 #1 SMP Wed Jul 8 17:20:31 UTC 2026 x86_64 User : r4834334 ( 11094) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/proc/self/root/proc/thread-self/root/lib64/nagios/plugins/ |
Upload File : |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import re
import GeoIP
arguments = sys.argv
if(len(arguments) == 4 and os.path.exists(arguments[1]) and re.search("^[0-9a-z\.]+$" ,arguments[2]) and re.search("^[0-9A-Z\.]+$" ,arguments[3])):
fileName = arguments[1]
searchArg = arguments[2]
resultArg = arguments[3]
else:
print('UNKNOWN - invalid arguments.\nusage: '+arguments[0]+' geolite_database_file search_string expected_result')
sys.exit(3)
try:
gi = GeoIP.open(fileName, GeoIP.GEOIP_MEMORY_CACHE)
if re.search("^[A-Z]{2}$" ,resultArg):
response = gi.country_code_by_addr(searchArg)
elif re.search("^AS[0-9\.]+$" ,resultArg):
response = gi.org_by_addr(searchArg)
else:
print('UNKNOWN - invalid arguments.\nusage: '+arguments[0]+' geolite_database_file search_string expected_result')
sys.exit(3)
except:
print('CRITICAL - Error, database may be corrupted.')
sys.exit(2)
if(response == None):
print('UNKNOWN - response is none.')
sys.exit(3)
result = response.split()
if not re.search('^'+resultArg+'$', result[0]):
print('WARNING - wrong response. '+searchArg+' is '+response)
sys.exit(1)
print('OK')