Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-manzi committed Jun 25, 2024
1 parent be8f81f commit 4cc9c2b
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 100 deletions.
9 changes: 9 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Maintainers
-----------
Andrea Manzi <[email protected]>
Baptiste Grenier <[email protected]>

Contributors
------------
Andrea Manzi <[email protected]>
Baptiste Grenier <[email protected]>
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# These owners will be the default owners for everything in the repo.
# Unless a later match takes precedence, they will be requested for
# review when someone opens a pull request.
* @EGI-Federation/admins @EGI-Federation/sdis
* @EGI-Federation/admins @EGI-Federation/operations
66 changes: 36 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,49 @@
# Contributing

Thank you for taking the time to contribute to this project. The maintainers
greatly appreciate the interest of contributors and rely on continued engagement
with the community to ensure that this project remains useful. We would like to
take steps to put contributors in the best possible position to have their
contributions accepted. Please take a few moments to read this short guide on
how to contribute; bear in mind that contributions regarding how to best
contribute are also welcome.
Thank you for taking the time to contribute to this project.
The maintainers greatly appreciate the interest of contributors and rely on
continued engagement with the community to ensure that this project remains
useful.
We would like to take steps to put contributors in the best possible position
to have their contributions accepted.
Please take a few moments to read this short guide on how to contribute; bear
in mind that contributions regarding how to best contribute are also welcome.

## Feedback and Questions

If you wish to discuss anything related to the project, please open a
[GitHub issue](https://github.com/EGI-Federation/REPOSITORY/issues/new).
If you wish to discuss anything related to the project, please open an issue or
start a topic on the [EGI Community Forum](https://community.egi.eu).
The maintainers will sometimes move issues off of GitHub to the community forum
if it is thought that longer, more open-ended discussion would be beneficial,
including a wider community scope.

## Contribution Process

Before proposing a contribution via pull request (PR), ideally there is an open
issue describing the need for your contribution (refer to this issue number when
you submit the pull request). We have a 3 steps process for contributions.
Before proposing a contribution via pull request, ideally there is an open
issue describing the need for your contribution (refer to this issue number
when you submit the pull request). We have a 3 steps process for contributions.

1. Fork the project if you have not, and commit changes to a git branch
1. Create a GitHub Pull Request for your change, following the instructions in
the pull request template.
1. Create a GitHub Pull Request for your change, following the instructions
in the pull request template.
1. Perform a [Code Review](#code-review-process) with the maintainers on the
pull request.

### Pull Request Requirements

1. **Explain your contribution in plain language.** To assist the maintainers in
understanding and appreciating your pull request, please use the template to
explain _why_ you are making this contribution, rather than just _what_ the
contribution entails.
1. **Explain your contribution in plain language.** To assist the maintainers
in understanding and appreciating your pull request, please use the
template to explain _why_ you are making this contribution, rather than
just _what_ the contribution entails.

### Code Review Process

Code review takes place in GitHub pull requests. See
[this article](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)
if you're not familiar with GitHub Pull Requests.
Code review takes place in GitHub pull requests. See [this
article](https://help.github.com/articles/about-pull-requests/) if you're not
familiar with GitHub Pull Requests.

Once you open a pull request, maintainers will review your code using the
built-in code review process in GitHub PRs. The process at this point is as
built-in code review process in Github PRs. The process at this point is as
follows:

1. A maintainer will review your code and merge it if no changes are necessary.
Expand All @@ -51,14 +55,14 @@ follows:

For collaboration purposes, it is best if you create a GitHub account and fork
the repository to your own account. Once you do this you will be able to push
your changes to your GitHub repository for others to see and use, and it will be
easier to send pull requests.
your changes to your GitHub repository for others to see and use, and it will
be easier to send pull requests.

### Branches and Commits

You should submit your patch as a git branch named after the GitHub issue, such
as `#3`\. This is called a _topic branch_ and allows users to associate a branch
of code with the issue.
You should submit your patch as a git branch named after the Github issue, such
as `#3`\. This is called a _topic branch_ and allows users to associate a
branch of code with the issue.

It is a best practice to have your commit message have a _summary line_ that
includes the issue number, followed by an empty line and then a brief
Expand All @@ -78,15 +82,17 @@ purpose of changes to the code.

## Release cycle

Main branch is always available. Tagged versions may be created as needed
following [Semantic Versioning](https://semver.org/) as far as applicable.
Main branch is always available.
Tagged versions may be created as needed following [Semantic
Versioning](https://semver.org/) as far as applicable.

## Community

EGI benefits from a strong community of developers and system administrators,
and vice-versa. If you have any questions or if you would like to get involved
in the wider EGI community you can check out:

- [EGI site](https://www.egi.eu)
- [EGI Community Forum](https://community.egi.eu/)
- [EGI website](https://www.egi.eu)

**This file has been modified from the Chef Cookbook Contributing Guide**.
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
NAME= $(shell grep Name: *.spec | sed 's/^[^:]*:[^a-zA-Z]*//')
VERSION= $(shell grep Version: *.spec | sed 's/^[^:]*:[^0-9]*//')
RELEASE= $(shell grep Release: *.spec | cut -d"%" -f1 | sed 's/^[^:]*:[^0-9]*//')
build=$(shell pwd)/build
DATE=$(shell date "+%a, %d %b %Y %T %z")
dist=$(shell rpm --eval '%dist' | sed 's/%dist/.el5/')

default:
@echo "Nothing to do"

install:
@echo installing ...

dist:
@mkdir -p $(build)/$(NAME)-$(VERSION)/
rsync -HaS --exclude ".git" --exclude "$(build)" * $(build)/$(NAME)-$(VERSION)/
cd $(build); tar --gzip -cf $(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)/; cd -

sources: dist
cp $(build)/$(NAME)-$(VERSION).tar.gz .

prepare: dist
@mkdir -p $(build)/RPMS/noarch
@mkdir -p $(build)/SRPMS/
@mkdir -p $(build)/SPECS/
@mkdir -p $(build)/SOURCES/
@mkdir -p $(build)/BUILD/
cp $(build)/$(NAME)-$(VERSION).tar.gz $(build)/SOURCES
cp $(NAME).spec $(build)/SPECS

srpm: prepare
rpmbuild -bs --define="dist ${dist}" --define='_topdir ${build}' $(build)/SPECS/$(NAME).spec

rpm: srpm
rpmbuild --rebuild --define='_topdir ${build}' --define="dist ${dist}" $(build)/SRPMS/$(NAME)-$(VERSION)-$(RELEASE)${dist}.src.rpm

clean:
rm -f *~ $(NAME)-$(VERSION).tar.gz
rm -rf $(build)

.PHONY: dist srpm rpm sources clean
158 changes: 89 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,90 @@
# Template for EGI repositories
# Nagios-plugins-storage

This is Nagios probe to monitor Storage endpoints executing simple file operations via Xrootd or Webdav protocols

It's based on the gfal2 library for the storage operations and the python-nap library for execution and reporting.

A X509 valid proxy certificate is needed to execute the probe (configured via X509_USER_PROXY variable).

The probes runs the following passive checks in sequence:

* LsDir: list the folder
* Put: put a test file
* Ls: list the file previously copied
* Get: copy the file locally and check if content matches
* Del: delete the file

the active check VOAll just combines the passive checks outcomes.

## Usage

```shell
usage: storage_probe.py [-h] [--version] [-H HOSTNAME] [-w WARNING] [-c CRITICAL]
[-d] [--print-all] [-p PREFIX] [-s SUFFIX] [-t TIMEOUT]
[-C COMMAND] [--dry-run] [-o OUTPUT] [-E ENDPOINT] [-X X509]
[-to TOKEN] [--se-timeout SE_TIMEOUT] [-S] [-RO]

NAGIOS Storage probe

options:
-h, --help show this help message and exit
--version show program's version number and exit
-H HOSTNAME, --hostname HOSTNAME
Host name, IP Address, or unix socket (must be an absolute path)
-w WARNING, --warning WARNING
Offset to result in warning status
-c CRITICAL, --critical CRITICAL
Offset to result in critical status
-d, --debug Specify debugging mode
--print-all Print output from all metrics to stdout
-p PREFIX, --prefix PREFIX
Text to prepend to ever metric name
-s SUFFIX, --suffix SUFFIX
Text to append to every metric name
-t TIMEOUT, --timeout TIMEOUT
Global timeout for plugin execution
-C COMMAND, --command COMMAND
Nagios command pipe for submitting passive results
--dry-run Dry run, will not execute commands and submit passive results
-o OUTPUT, --output OUTPUT
Plugin output format; valid options are nagios, check_mk
or passive (via command pipe); defaults to nagios)
-E ENDPOINT, --endpoint ENDPOINT
base URL to test
-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
-RO, --read-only enable read-only tests
```
## Example
```shell
./plugins/storage_probe.py -E root://eospps.cern.ch:1094/eos/pps/opstest/ftstests/test_andrea -H eospps.cern.ch --dry-run -X /tmp/x509up_u0 -d
Dec 01 18:40:53 DEBUG core[1559]: Call sequence: [(<function metricLsDir at 0x7f761240bc80>, 'LsDir', True), (<function metricPut at 0x7f761240bd08>, 'Put', True), (<function metricLs at 0x7f761240bd90>, 'Ls', True), (<function metricGet at 0x7f761240be18>, 'Get', True), (<function metricDel at 0x7f761240bea0>, 'Del', True), (<function metricAlll at 0x7f761240bf28>, 'All', False)]
Dec 01 18:40:53 DEBUG core[1559]: Function call: metricLsDir
Dec 01 18:40:53 DEBUG core[1559]: b'OK - Storage Path[root://eospps.cern.ch:1094/eos/pps/opstest/ftstests/test_andrea] Directory successfully listed\\n'
Dec 01 18:40:53 DEBUG core[1559]: [1638384053] PROCESS_SERVICE_CHECK_RESULT;eospps.cern.ch;LsDir;0;OK - Storage Path[root://eospps.cern.ch:1094/eos/pps/opstest/ftstests/test_andrea] Directory successfully listed\n
Dec 01 18:40:53 DEBUG core[1559]: Function call: metricPut
Dec 01 18:40:54 DEBUG core[1559]: b'OK - File was copied to the Storage endpoint: Transfer time: 0:00:00.815718\\n'
Dec 01 18:40:54 DEBUG core[1559]: [1638384054] PROCESS_SERVICE_CHECK_RESULT;eospps.cern.ch;Put;0;OK - File was copied to the Storage endpoint: Transfer time: 0:00:00.815718\n
Dec 01 18:40:54 DEBUG core[1559]: Function call: metricLs
Dec 01 18:40:54 DEBUG core[1559]: b'OK - File successfully listed\\n'
Dec 01 18:40:54 DEBUG core[1559]: [1638384054] PROCESS_SERVICE_CHECK_RESULT;eospps.cern.ch;Ls;0;OK - File successfully listed\n
Dec 01 18:40:54 DEBUG core[1559]: Function call: metricGet
Dec 01 18:40:54 DEBUG core[1559]: b'OK - File was copied from Storage endpoint.: Diff successful. Transfer time: 0:00:00.127798\\n'
Dec 01 18:40:54 DEBUG core[1559]: [1638384054] PROCESS_SERVICE_CHECK_RESULT;eospps.cern.ch;Get;0;OK - File was copied from the Storage endpoint.: Diff successful. Transfer time: 0:00:00.127798\n
Dec 01 18:40:54 DEBUG core[1559]: Function call: metricDel
Dec 01 18:40:54 DEBUG core[1559]: b'OK - File was deleted from the Storage endpoint.\\n'
Dec 01 18:40:54 DEBUG core[1559]: [1638384054] PROCESS_SERVICE_CHECK_RESULT;eospps.cern.ch;Del;0;OK - File was deleted from the Storage endpoint.\n
Dec 01 18:40:54 DEBUG core[1559]: Function call: metricAlll
OK - All fine
mkdir build
cd build
make rpm -f ../Makefile
```
This repository is to be used as a repository template for creating a new EGI
repository, and is aiming at being a clean basis promoting currently accepted
good practices.

It includes:

- License information
- Copyright and author information
- Code of conduct and contribution guidelines
- Templates for PR and issues
- Code owners file for automatic assignment of PR reviewers
- [GitHub actions](https://github.com/features/actions) workflows for linting
and checking links

Content is based on:

- [Contributor Covenant](http://contributor-covenant.org)
- [Semantic Versioning](https://semver.org/)
- [Chef Cookbook Contributing Guide](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD)

## Asking for creation of a repository

It can be done by contacting the
[administrators](https://github.com/orgs/EGI-Federation/teams/admins).

The following information should be provided:

- repository name (lower case, usually not required to mention EGI in the name)
- repository description (oneliner is enough)
- optionally additional users that should be able to manage PR and issues
- optional additional requirements (like disabling Pull Requests for the initial
repository population)

If required a private repository can be created but public ones are the default,
but feel free to ask.

Once all info will have been agreed the repository will be created.

## GitHub repository management rules

All changes should go through Pull Requests.

### Merge management

- Only squash should be enforced in the repository settings.
- Update commit message for the squashed commits as needed.

### Protection on main branch

To be configured on the repository settings.

- Require pull request reviews before merging
- Dismiss stale pull request approvals when new commits are pushed
- Require review from Code Owners
- Require status checks to pass before merging
- GitHub actions if available
- Other checks as available and relevant
- Require branches to be up to date before merging
- Include administrators

## Access

All access should be managed via
[GitHub teams](https://github.com/orgs/EGI-Federation/teams).

- EGI-Federation/admins: administration right
- Others participants depending on the requirement: maintain, triage or write or
rights
8 changes: 8 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: nagios-plugins-storage
channels:
- conda-forge
dependencies:
- python-gfal2=1.12.2
- pip
- pip:
- https://github.com/marian-babik/python-nap/archive/refs/tags/v0.1.21.tar.gz
49 changes: 49 additions & 0 deletions nagios-plugins-s3.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Package needs to stay arch specific (due to nagios plugins location), but
# there's nothing to extract debuginfo from
%global debug_package %{nil}

%define nagios_plugins_dir %{_libdir}/nagios/plugins

Name: nagios-plugins-s3
Version: 0.0.1
Release: 1%{?dist}
Summary: Nagios probes to be run remotely against s3 endpoints
License: MIT
Group: Applications/Internet
URL: https://github.com/EGI-Federation/nagios-plugins-storage
# The source of this package was pulled from upstream's vcs. Use the
# following commands to generate the tarball:
Source0: %{name}-%{version}.tar.gz
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch

Requires: nagios%{?_isa}
Requires: python3
Requires: python3-nap
Requires: python3-botocore
Requires: python3-boto3

%description
This package provides the nagios probes for s3

%prep
%setup -q -n %{name}-%{version}

%build

%install
make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}%{_libdir}/nagios/plugins/s3
cp --preserve=timestamps plugins/*.py %{buildroot}%{_libdir}/nagios/plugins/s3

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%{nagios_plugins_dir}/s3
%doc LICENSE README.md

%changelog
* Wed Jun 26 2024 Andrea Manzi <[email protected]> - 0.0.1-0
- first version

0 comments on commit 4cc9c2b

Please sign in to comment.