This file is indexed.

/usr/lib/nagios/plugins/check_arcservice is in nordugrid-arc-nagios-plugins 1.9.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/python
#
# Contributed by Nagy Zsombor.
# Support for GLUE 2.0r1 by Gabor Roczei.
# Released under the Apache License with permission from Gabor Roczei.
# See also http://bugzilla.nordugrid.org/show_bug.cgi?id=1983.

import httplib
import urlparse
import sys
try:
    import xml.etree.ElementTree as ET
except ImportError:
    import elementtree.ElementTree as ET
import getopt
import signal
import traceback

glue_schemas = [
    'http://schemas.ogf.org/glue/2008/05/spec_2.0_d41_r01',
    'http://schemas.ogf.org/glue/2009/03/spec_2.0_r1',
]

timeout = 10

def handler(signum, frame):
    print "ARCSERVICE UNKNOWN:", "Check has timed out (after %s seconds)" % timeout
    sys.exit(3)
    
signal.signal(signal.SIGALRM, handler)
signal.alarm(timeout)

def usage():
    print """Usage: check_arcservice -u <URL> -k <key_file> -c <cert_file> -t <timeout> --debug
    
    -u <URL>        the URL of the service to check (mandatory)
    -t <timeout>    after this amount of seconds the check will return UNKNOWN (default: 10)
    -k <key_file>   path of the key file (default: /etc/grid-security/hostkey.pem)
    -c <cert_file>  path of the cert file (default: /etc/grid-security/hostcert.pem)
    --debug         print some debugging information
    """
    sys.exit(3)

try:
    options, args = getopt.getopt(sys.argv[1:],"u:k:c:t:",["debug"])
except getopt.GetoptError:
    usage()
    
key_file = '/etc/grid-security/hostkey.pem'
cert_file = '/etc/grid-security/hostcert.pem'
url = ''
debug = False

for name, value in options:
    if name in ['-k']:
        key_file = value
    if name in ['-c']:
        cert_file = value
    if name in ['-u']:
        url = value
    if name in ['--debug']:
        debug = True
    if name in ['-t']:
        timeout = int(value)
        signal.alarm(timeout)
        
if not key_file or not cert_file or not url:
    usage()

try:
    parsed = urlparse.urlparse(url)
    https = (parsed[0] == 'https')
    hostport = parsed[1]
    path = parsed[2]
except:
    print "ARCSERVICE UNKNOWN: Error parsing URL", url


get_resource_property_document_request = '''<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2" xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <SOAP-ENV:Header>
        <wsa:Action>http://docs.oasis-open.org/wsrf/rpw-2/GetResourcePropertyDocument/GetResourcePropertyDocumentRequest</wsa:Action>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <wsrf-rp:GetResourcePropertyDocument/>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>'''

if https:
    connection = httplib.HTTPSConnection(host = hostport, key_file = key_file, cert_file = cert_file)
else:
    connection = httplib.HTTPConnection(host = hostport)
try:
    connection.request('POST', path, get_resource_property_document_request)
except Exception, e:
    print "ARCSERVICE CRITICAL:", "Connecting to", url, "failed (%s)" % e 
    if debug:
        traceback.print_exc()
    sys.exit(2)
response = connection.getresponse()
if response.status == 200:
    data = response.read()
    try:
        et = ET.fromstring(data)
	health_state = None
	for glue_schema in glue_schemas:
	    health_state = et.findtext(".//{%s}HealthState"%glue_schema)
	    if health_state:
		break

        if health_state is None:
            print "ARCSERVICE UNKNOWN:", "Service's health state is unknown"
            if debug:
                print data
            sys.exit(3)

	if health_state == 'ok':
            print "ARCSERVICE OK:", "Service's health state is", health_state
            if debug:
                print data
            sys.exit(0)
        else:
            print "ARCSERVICE CRITICAL:", "Service's health state is", health_state
            if debug:
                print data
            sys.exit(2)
    except StandardError, e:
        print "ARCSERVICE UNKNOWN:", "Unable to parse respone (%s)" % e
        if debug:
            print data
        sys.exit(3)
else:
    print "ARCSERVICE CRITICAL:", "Invalid response from server (%s, %s)" % (response.status, response.reason)
    if debug:
        print response.read()
    sys.exit(2)