Changeset 3242
- Timestamp:
- 08/06/13 10:40:14 (11 years ago)
- Location:
- monitoring/plugins/mpi
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
monitoring/plugins/mpi/check_clarin_discojuice_html.py
-
Property
svn:executable
set to
*
-
Property
svn:executable
set to
-
monitoring/plugins/mpi/check_clarin_discojuice_json.py
-
Property
svn:executable
set to
*
-
Property
svn:executable
set to
-
monitoring/plugins/mpi/check_lat_cql_endpoint.py
r3049 r3242 23 23 # Check status for all UP_URLs. 24 24 results = \ 25 map(lambda UP_URL : generic_tla_monitoring.check_condition(host = host,26 UP_URL = UP_URL,27 HTTP_method = 'GET',28 validator = generic_tla_monitoring.check_XML_validity,29 valid_root_element_tag = valid_root_element_tag,30 special_plugin_file_name = special_plugin_file_name),25 map(lambda UP_URL : generic_tla_monitoring.check_condition(host = host, 26 UP_URL = UP_URL, 27 HTTP_method = 'GET', 28 validator = generic_tla_monitoring.check_XML_validity, 29 valid_root_element_tag = valid_root_element_tag, 30 special_plugin_file_name = special_plugin_file_name), 31 31 UP_URLs) 32 32 -
monitoring/plugins/mpi/generic_tla_monitoring.py
r3051 r3242 33 33 sys.exit(max(suggested_exit_codes)) 34 34 35 def usage( ) :36 """ returns nagios status UNKNOWN with35 def usage(command_line_parameters_usage_string) : 36 """ returns Nagios status UNKNOWN with 37 37 a one line usage description 38 38 usage() calls nagios_return() 39 39 """ 40 40 nagios_return('UNKNOWN', 41 "usage: %s -h host" % (sys.argv[0]))41 "usage: " + sys.argv[0] + command_line_parameters_usage_string) 42 42 43 43 def generic_validator(data, … … 133 133 special_validator) 134 134 return (wellformedness) 135 136 137 def check_LDAP_validity(data, 138 descriptive_string, 139 **kwargs) : 140 141 def special_validator(data, 142 descriptive_string, 143 kwargs) : 144 try : 145 return True # X- 146 except : 147 return False 148 149 wellformedness = generic_validator(data, 150 descriptive_string, 151 kwargs, 152 special_validator) 153 return (wellformedness) 154 155 156 def check_ldap(host, 157 bindDN, 158 validator, 159 **validator_arguments) : 160 161 OpenDJ_directory_path = '/srv/LDAP/OpenDJ-2.5.0-Xpress1/' 162 163 command = [OpenDJ_directory_path + "/bin/ldapsearch", 164 '--port', '10389', 165 '--baseDN', 'dc=clarin,dc=eu', 166 '--useStartTLS', 167 '--trustAll', 168 '--hostname', "'" + host + "'", 169 '--bindDN', "'" + bindDN + "'", 170 "--bindPasswordFile", "'/root/LDAP_passwdfile'", 171 "'(objectClass=CLARINPerson)'", 172 'isMemberOf'] 173 174 # Run OpenDJ's "ldapsearch" command line utility 175 pdb.set_trace() 176 177 process = subprocess.Popen(command, 178 stdout = subprocess.PIPE, 179 stderr = subprocess.PIPE) 180 181 stdout, stderr = process.communicate() 182 183 print stdout 184 print stderr 185 186 pdb.set_trace() 187 188 if response : 189 return { 190 "code" : "OK", 191 "message" : 'Host %s is up and responds as expected.' % (host, UP_URL) 192 } 193 else : 194 return { 195 "code" : "CRITICAL", 196 "message" : 'Host %s is up but does not respond as expected.' % (host, UP_URL) 197 } 198 135 199 136 200 def check_condition(host, … … 227 291 } 228 292 229 def main(special_main_subroutine ) :230 """ example options processing231 here we're expecting 1 option "-h" 232 with a parameter233 """234 235 if len(sys.argv) < 2 :236 usage()237 238 try :239 opts , args = getopt.getopt(sys.argv[1:], "h:u:")293 def main(special_main_subroutine, 294 command_line_parameters = [("-h", "host",)]) : 295 296 ## Process plugin-specific command line parameters. 297 command_line_parameters_getopt_string = command_line_parameters_usage_string = "" 298 for (parameter, description) in command_line_parameters : 299 command_line_parameters_usage_string = command_line_parameters_usage_string + parameter + " " + description + "\n" 300 command_line_parameters_getopt_string = command_line_parameters_getopt_string + parameter.lstrip("-") + ":" 301 302 try : 303 opts = filter(None, getopt.getopt(sys.argv[1:], command_line_parameters_getopt_string))[0] # X- fix other plugins with -u option 240 304 except getopt.GetoptError, err : 241 usage() 242 243 url = None 244 for o, value in opts : 245 if o == "-h" : 246 host = value 247 elif o == "-u" : 248 url = value 249 305 usage(command_line_parameters_usage_string) 306 else : 307 if len(command_line_parameters) == len(opts) : 308 main_subroutine_argument_values = [parameter_value for parameter_name, parameter_value in opts] 309 # pdb.set_trace() 310 special_main_subroutine(*main_subroutine_argument_values) 250 311 else : 251 usage() 252 253 # this is necessary for all old probes (annex, etc). 254 # -u only works for cql/oai 255 if url: 256 special_main_subroutine(host, url) 257 else: 258 special_main_subroutine(host) 312 usage(command_line_parameters_usage_string) 313 259 314 260 315 if __name__ == "__main__" :
Note: See TracChangeset
for help on using the changeset viewer.