-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_cache_auth
More file actions
executable file
·46 lines (38 loc) · 1020 Bytes
/
Copy pathcheck_cache_auth
File metadata and controls
executable file
·46 lines (38 loc) · 1020 Bytes
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
#!/usr/bin/env python3
import os
import sys
import traceback
#from XRootD import client
import requests
STATE_OK = 0
STATE_WARNING = 1
STATE_CRITICAL = 2
STATE_UNKNOWN = 3
def xrdreadhttp(cache, port, filet):
try:
path = "https://"+cache+":"+str(port)+filet
print(path)
x = requests.get(path, verify="/etc/pki/tls/certs/ca-bundle.crt")
print(x)
if(x.status_code == 403):
return STATE_OK;
else:
return STATE_CRITICAL;
except Exception as e:
print(e)
traceback.print_exc()
return STATE_CRITICAL;
try:
#test that reading private data without authentication (to fail)
cache = sys.argv[1]
status = []
path="/user/ligo/test_access/access_ligo"
status.append(xrdreadhttp(cache,8443,path))
for st in status:
if(st == STATE_CRITICAL):
sys.exit(STATE_CRITICAL);
sys.exit(STATE_OK);
except Exception as e:
print(e)
traceback.print_exc()
sys.exit(STATE_UNKNOWN)