From 223331510bc12fb239a6374ec722c7e658e23c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gar=C3=B0ar=20=C3=9Eorsteinsson?= Date: Fri, 11 Sep 2020 16:01:05 +0000 Subject: [PATCH] check_xroad_token plugin created --- check_xroad_token/check_xroad_token.sh | 15 ++++++ .../nagios-okplugin-check_xroad_token.spec | 49 +++++++++++++++++++ .../nrpe.d/check_xroad_token.cfg | 2 + check_xroad_token/sudoers.d/check_xroad_token | 2 + 4 files changed, 68 insertions(+) create mode 100644 check_xroad_token/check_xroad_token.sh create mode 100644 check_xroad_token/nagios-okplugin-check_xroad_token.spec create mode 100644 check_xroad_token/nrpe.d/check_xroad_token.cfg create mode 100644 check_xroad_token/sudoers.d/check_xroad_token diff --git a/check_xroad_token/check_xroad_token.sh b/check_xroad_token/check_xroad_token.sh new file mode 100644 index 0000000..d003df1 --- /dev/null +++ b/check_xroad_token/check_xroad_token.sh @@ -0,0 +1,15 @@ +#!/bin/bash +xroad_list_tokens=$(signer-console list-tokens) + +if [[ $xroad_list_tokens == "Token: 0 (OK, writable, available, active)" ]] +then + echo "OK - $xroad_list_tokens" + exit 0 +elif [[ $xroad_list_tokens != "Token: 0 (OK, writable, available, active)" ]] +then + echo "Critical - $xroad_list_tokens" + exit 2 +else + echo "Unknown - $xroad_list_tokens" + exit 3 +fi \ No newline at end of file diff --git a/check_xroad_token/nagios-okplugin-check_xroad_token.spec b/check_xroad_token/nagios-okplugin-check_xroad_token.spec new file mode 100644 index 0000000..3edee3e --- /dev/null +++ b/check_xroad_token/nagios-okplugin-check_xroad_token.spec @@ -0,0 +1,49 @@ +%define debug_package %{nil} + +Summary: A Nagios plugin to check status of XROAD soft-token +Name: nagios-okplugin-check_xroad_token +Version: 1.0.1 +Release: 1%{?dist} +License: GPLv2+ +Group: Applications/System +URL: https://github.com/opinkerfi/nagios-plugins/issues +Source0: http://opensource.ok.is/trac/browser/nagios-plugins/check_xroad_token/releases/nagios-okplugin-check_xroad_token-%{version}.tar.gz +Requires: nagios-nrpe +Requires: xroad-signer +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +Packager: Gardar Thorsteinsson + + +%description +A Nagios plugin to check status of XROAD soft-token + + +%prep +%setup -q +#perl -pi -e "s|/usr/lib64|%{_libdir}|g" nrpe.d/check_xroad_token.cfg + +%build + + +%install +rm -rf %{buildroot} +install -D -p -m 0755 check_xroad_token.sh %{buildroot}%{_libdir}/nagios/plugins/check_xroad_token.sh +install -D -p -m 0755 nrpe.d/check_xroad_token.cfg %{buildroot}/etc/nrpe.d/check_xroad_token.cfg +install -D -p -m 0644 sudoers.d/check_xroad_token %{buildroot}/etc/sudoers.d/check_xroad_token + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root,-) +#%doc README LICENSE +%{_libdir}/nagios/plugins/* +/etc/nrpe.d/check_xroad_token.cfg +/etc/sudoers.d/check_xroad_token + +%post +restorecon -v %{_libdir}/nagios/plugins/check_xroad_token.sh /etc/nrpe.d/check_xroad_token.cfg /etc/sudoers.d/check_xroad_token + +%changelog +* Fri Sep 11 2020 Gardar Thorsteinsson 1.0.1-1 +- Initial packaging diff --git a/check_xroad_token/nrpe.d/check_xroad_token.cfg b/check_xroad_token/nrpe.d/check_xroad_token.cfg new file mode 100644 index 0000000..7f3391c --- /dev/null +++ b/check_xroad_token/nrpe.d/check_xroad_token.cfg @@ -0,0 +1,2 @@ +# xroad plugin to check for tokens +command[check_xroad_token]=sudo -u xroad /usr/lib64/nagios/plugins/check_xroad_token.sh \ No newline at end of file diff --git a/check_xroad_token/sudoers.d/check_xroad_token b/check_xroad_token/sudoers.d/check_xroad_token new file mode 100644 index 0000000..9f38b61 --- /dev/null +++ b/check_xroad_token/sudoers.d/check_xroad_token @@ -0,0 +1,2 @@ +Defaults:nrpe !requiretty +nrpe ALL = (xroad) NOPASSWD: /usr/bin/signer-console list-tokens, /usr/lib64/nagios/plugins/check_xroad_token.sh