Skip to content

Commit

Permalink
Merge pull request #7 from EGI-Federation/token
Browse files Browse the repository at this point in the history
add support for bearer tokens
  • Loading branch information
andrea-manzi authored Jun 19, 2024
2 parents 2fa48c4 + ebee053 commit 6ee1777
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ optional arguments:
-E ENDPOINT, --endpoint ENDPOINT
Storage URL to test (Mandatory)
-X X509, --x509 X509 location of x509 certificate proxy file
-to TOKEN, --token TOKEN
BEARER TOKEN to be used
--se-timeout SE_TIMEOUT
storage operations timeout
-S, --skip-ls-dir skip LSDir tests, needed for Object storage backend
Expand Down
6 changes: 4 additions & 2 deletions nagios-plugins-storage.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
%define nagios_plugins_dir %{_libdir}/nagios/plugins

Name: nagios-plugins-storage
Version: 0.1.1
Version: 0.1.2
Release: 1%{?dist}
Summary: Nagios probes to be run remotely against EGI Online endpoints
License: MIT
Expand All @@ -25,7 +25,6 @@ Requires: gfal2-plugin-file
Requires: gfal2-plugin-xrootd
Requires: gfal2-plugin-http


%description
This package provides the nagios probes for XRootD

Expand All @@ -48,6 +47,9 @@ rm -rf %{buildroot}
%doc LICENSE README.md

%changelog
* Wed Jun 19 2024 Andrea Manzi <[email protected]> - 0.1.2-1
- Add support for bearer tokens

* Tue Jun 18 2024 Andrea Manzi <[email protected]> - 0.1.1-1
- Add read-only option

Expand Down
9 changes: 8 additions & 1 deletion plugins/storage_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
app = nap.core.Plugin(description="NAGIOS Storage probe", version=PROBE_VERSION)
app.add_argument("-E", "--endpoint", help="base URL to test")
app.add_argument("-X", "--x509", help="location of x509 certificate proxy file")
app.add_argument("-to", "--token", help="BEARER TOKEN to be used")

app.add_argument(
"--se-timeout",
dest="se_timeout",
Expand Down Expand Up @@ -67,7 +69,12 @@ def parse_args(args, io):
gfal2.cred_set(ctx, "davs://", cred)
gfal2.cred_set(ctx, "root://", cred)
gfal2.cred_set(ctx, "xroot://", cred)

if args.token:
cred = gfal2.cred_new("BEARER", args.token)
gfal2.cred_set(ctx, "https://", cred)
gfal2.cred_set(ctx, "davs://", cred)
gfal2.cred_set(ctx, "root://", cred)
gfal2.cred_set(ctx, "xroot://", cred)

@app.metric(seq=1, metric_name="LsDir", passive=True)
def metricLsDir(args, io):
Expand Down

0 comments on commit 6ee1777

Please sign in to comment.