Changeset 3304


Ignore:
Timestamp:
08/08/13 08:51:08 (11 years ago)
Author:
sanmai
Message:
  • Rework check_clarin_saml.py to use new command line arguments processing.
  • Fix test script.
  • Add command line argument used with check_clarin_saml.py.
Location:
monitoring/plugins/mpi
Files:
3 edited

Legend:

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

    r3243 r3304  
    1010
    1111DESCRIPTION = "SAML"
    12 CLARIN_server_root_directory_path = "/srv/www/infra.clarin.eu"
     12#CLARIN_server_root_directory_path = "/srv/www/infra.clarin.eu/"
     13command_line_parameters = [("-h", "host",),
     14                           ("-u", "URL"),
     15                           ("-d", "infra.clarin.eu root directory path",)]
    1316
    1417nagios_codes = {
     
    1922                'DEPENDENT' : 4
    2023                }
    21 
    22 def usage() :
    23     """ returns nagios status UNKNOWN with
    24         a one line usage description
    25         usage() calls nagios_return()
    26     """
    27     nagios_return('UNKNOWN',
    28                   "usage: %s -h host" % (sys.argv[0]))
    2924
    3025def nagios_return(code, response) :
     
    9085
    9186
    92 def check_condition(host) :
    93 
    94     UP_URL  = '/aai/clarin-sp-metadata.xml'
     87def check_condition(host, URL, CLARIN_server_root_directory_path) :
    9588
    9689    conn    = httplib.HTTPSConnection(host)
    9790   
    9891    # Use exception handling.
    99     conn.request("GET", UP_URL)
     92    conn.request("GET", URL)
    10093   
    10194    r1      = conn.getresponse()
     
    117110                return {
    118111                        "code"      : "OK",
    119                         "message"   : 'Host %s, service %s is up and returns well-formed and valid XML data.' % (host, DESCRIPTION)
     112                        "message"   : 'Host %s, service %s is up and returns well-formed and valid XML data at %s.' % (host, DESCRIPTION, URL)
    120113                       }
    121114            else :
    122115                return {
    123116                        "code"      : "CRITICAL",
    124                         "message"   : 'Host %s, service %s is up and returns well-formed, but invalid XML data.' % (host, DESCRIPTION)
     117                        "message"   : 'Host %s, service %s is up and returns well-formed, but invalid XML data at %s.' % (host, DESCRIPTION, URL)
    125118                       }
    126119        else :
    127120            return {
    128121                        "code"      : "CRITICAL",
    129                         "message"   : 'Host %s, service %s is up but returns non-well-formed XML data.' % (host, DESCRIPTION)
     122                        "message"   : 'Host %s, service %s is up but returns non-well-formed XML data %s.' % (host, DESCRIPTION, URL)
    130123                    }
    131124    else :
    132125        return {
    133126                "code"      : "CRITICAL",
    134                 "message"   : 'Host %s, service %s has a problem.' % (host, DESCRIPTION)
     127                "message"   : 'Host %s, service %s, location %s has a problem.' % (host, DESCRIPTION, URL)
    135128               }
    136129
    137 def test_case(host) :
     130def test_case(host, URL, CLARIN_server_root_directory_path) :
    138131    metadata_file       = open(os.path.join(CLARIN_server_root_directory_path, "aai/clarin-sp-metadata.xml"),
    139132              mode      = "r+",
     
    153146            return {
    154147                    "code"      : "OK",
    155                     "message"   : 'Host %s, service %s is up and returns well-formed and valid XML data.' % (host, DESCRIPTION)
     148                    "message"   : 'Host %s, service %s is up and returns well-formed and valid XML data at %s.' % (host, DESCRIPTION, URL)
    156149                   }
    157150        else :
    158151            return {
    159152                    "code"      : "CRITICAL",
    160                     "message"   : 'Host %s, service %s is up and returns well-formed, but invalid XML data.' % (host, DESCRIPTION)
     153                    "message"   : 'Host %s, service %s is up and returns well-formed, but invalid XML data at %s.' % (host, DESCRIPTION, URL)
    161154                   }
    162155    else :
    163156        return {
    164157                "code"      : "CRITICAL",
    165                 "message"   : 'Host %s, service %s is up, but returns non-well-formed XML data.' % (host, DESCRIPTION)
     158                "message"   : 'Host %s, service %s is up, but returns non-well-formed XML data at %s.' % (host, DESCRIPTION, URL)
    166159               }
    167160
    168161    Sys.exit(0)
    169162
    170 def main() :
    171     """ example options processing
    172         here we're expecting 1 option "-h"
    173         with a parameter
    174     """
    175163
    176     if len(sys.argv) < 2 :
    177         usage()
     164def special_main_subroutine(host,
     165                            URL,
     166                            CLARIN_server_root_directory_path) :
    178167
    179     try:
    180         opts, args  = getopt.getopt(sys.argv[1:], "h:")
    181     except getopt.GetoptError, err :
    182         usage()
    183 
    184     for o, value in opts :
    185         if o == "-h" :
    186             host = value
    187         elif o == "-d" :
    188             CLARIN_server_root_directory_path = value
    189         else :
    190             usage()
     168    result = check_condition(host = host,
     169                             URL = URL,
     170                             CLARIN_server_root_directory_path = CLARIN_server_root_directory_path)
    191171   
    192     #result = test_case(host);
    193     result = check_condition(host)
    194172    nagios_return(result['code'], result['message'])
    195173
    196174if __name__ == "__main__" :
    197     main()
    198 
     175    generic_tla_monitoring.main(special_main_subroutine,
     176                                command_line_parameters)
  • monitoring/plugins/mpi/integration_test.R

    r3302 r3304  
    88                       quote     = "",
    99                       row.names = NULL,
    10                        check.names = FALSE
     10                       check.names = FALSE,
    1111                       as.is     = TRUE);
    1212
  • monitoring/plugins/mpi/plugins_hosts_services.tab

    r3291 r3304  
    1010check_lat_annex.py      Annex   corpus1.mpi.nl  http    '/ds/annex/runLoader?nodeid=MPI600401%23'       
    1111check_lat_oai_endpoint.py       OAI-PMH corpus1.mpi.nl  http    '/ds/oaiprovider/oai2?verb=Identify'   
    12 check_clarin_saml.py    SAML    www.clarin.eu   https          
     12check_clarin_saml.py    SAML    www.clarin.eu   https   '/aai/clarin-sp-metadata.xml'   
    1313check_clarin_discojuice_html.py Discojuice HTML catalog.clarin.eu       http    '/mw1/sds/discojuice'   
    1414check_clarin_discojuice_html.py Discojuice HTML catalog.clarin.eu       http    '/mw2/sds/discojuice'   
Note: See TracChangeset for help on using the changeset viewer.