Changeset 2033


Ignore:
Timestamp:
07/13/12 14:10:17 (12 years ago)
Author:
sanmai
Message:
  • FIX: A condition was missed, resulting in lack of proper Nagios exit code and ultimately a runtime exception.
  • FIX: A parameter to templib.NamedTemporaryFile? has been added with Python v2.6, therefore with Python versions < v2.5 reading of the temporary file by the external shell script failed silently,

ultima$
valid> by check_response_data_validity().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • monitoring/plugins/mpi/check_clarin_saml.py

    r2028 r2033  
    5757    check_saml_metadata_file_path       = os.path.join(CLARIN_server_root_directory_path, "aai/check-saml-metadata/check_saml_metadata.sh")
    5858   
    59     with tempfile.NamedTemporaryFile(mode   = 'wb',
    60                                      delete = False) as temporary_file :
    61         temporary_file.write(data)
    62         XML_response_metadata_file_path = temporary_file.name
     59    temporary_file                      = tempfile.NamedTemporaryFile(mode   = 'wb')                                   
     60    temporary_file.write(data)
     61    temporary_file.flush()
     62
     63    XML_response_metadata_file_path     = temporary_file.name
     64
    6365
    6466    command                             = [check_saml_metadata_file_path, XML_response_metadata_file_path]
     67
    6568       
    6669    process                             = subprocess.Popen(command,
     
    7073    stdout, stderr                      = process.communicate()
    7174
     75    temporary_file.close()
     76
    7277    interpretation_tuple                = (interpret_for_well_formedness(stdout), interpret_for_validity(stdout),)
    7378
    74     os.unlink(XML_response_metadata_file_path)
     79    #os.unlink(XML_response_metadata_file_path)
    7580
    7681    return(interpretation_tuple)
     
    7883
    7984def check_condition(host) :
     85
    8086    UP_URL  = '/aai/clarin-sp-metadata.xml'
    8187
     
    108114                        "message"   : 'Host %s, service %s is up and returns well-formed, but invalid XML data.' % (host, DESCRIPTION)
    109115                       }
     116        else :
     117            return {
     118                        "code"      : "CRITICAL",
     119                        "message"   : 'Host %s, service %s is up but returns non-well-formed XML data.' % (host, DESCRIPTION)
     120                    }
    110121    else :
    111122        return {
     
    115126
    116127def test_case(host) :
    117     with open(os.path.join(CLARIN_server_root_directory_path, "aai/clarin-sp-metadata.xml"),
     128    metadata_file = open(os.path.join(CLARIN_server_root_directory_path, "aai/clarin-sp-metadata.xml"),
    118129              mode      = "r+",
    119               buffering = 0) as metadata_file :
     130              buffering = 0)
    120131       
    121         data = metadata_file.read()
     132    data = metadata_file.read()
     133
     134    metadata_file.close()       
    122135
    123136    interpretation_tuple = check_response_data_validity(data)
Note: See TracChangeset for help on using the changeset viewer.