mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
[exodus_] Add plugin to monitore number of applications, reports and trackers (#1286)
Add monitoring of count for applications, reports and trackers of an exodus instance.
This commit is contained in:
parent
38f3a4297e
commit
3c20ac15f4
1 changed files with 109 additions and 0 deletions
109
plugins/exodus/exodus_
Normal file
109
plugins/exodus/exodus_
Normal file
|
@ -0,0 +1,109 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
=head1 NAME
|
||||
|
||||
exodus_ - Exodus wildcard-plugin to monitor an L<Exodus|https://github.com/Exodus-Privacy/exodus/>
|
||||
instance.
|
||||
|
||||
This wildcard plugin provides the suffixes C<applications>, C<reports> and C<trackers>.
|
||||
|
||||
=head1 INSTALLATION
|
||||
|
||||
- Copy this plugin in your munin plugins directory
|
||||
|
||||
=over 2
|
||||
|
||||
ln -s /usr/share/munin/plugins/exodus_ /etc/munin/plugins/exodus_applications
|
||||
ln -s /usr/share/munin/plugins/exodus_ /etc/munin/plugins/exodus_reports
|
||||
ln -s /usr/share/munin/plugins/exodus_ /etc/munin/plugins/exodus_trackers
|
||||
|
||||
=back
|
||||
|
||||
After the installation you need to restart your munin-node service.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
|
||||
You need to create a file named exodus placed in the directory
|
||||
/etc/munin/plugin-conf.d/ with the following config:
|
||||
|
||||
=over 2
|
||||
|
||||
[exodus_*]
|
||||
env.exodus_url https://reports.exodus-privacy.eu.org
|
||||
env.exodus_token your-api-token
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Codimp <contact@lithio.fr>
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
GPLv3
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
|
||||
#%# family=manual
|
||||
#%# capabilities=suggest
|
||||
|
||||
=cut
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import urllib.request
|
||||
|
||||
|
||||
def print_count(element):
|
||||
endpoint = os.getenv("exodus_url") + "/api/" + element + "/count"
|
||||
headers = {"Authorization": "Token " + os.getenv("exodus_token")}
|
||||
request = urllib.request.Request(endpoint, method="POST", headers=headers)
|
||||
with urllib.request.urlopen(request) as connection:
|
||||
if connection.getcode() == 200:
|
||||
count = json.loads(connection.read())["count"]
|
||||
print(element + ".value", count)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
mode = sys.argv[1]
|
||||
except IndexError:
|
||||
mode = ""
|
||||
wildcard = sys.argv[0].split("exodus_")[1]
|
||||
|
||||
if mode == "suggest":
|
||||
print("applications")
|
||||
print("reports")
|
||||
print("trackers")
|
||||
exit(0)
|
||||
|
||||
if wildcard == "applications":
|
||||
if mode == "config":
|
||||
print("graph_title Exodus applications")
|
||||
print("graph_vlabel applications")
|
||||
print("graph_category exodus")
|
||||
print("applications.label Applications")
|
||||
else:
|
||||
print_count("applications")
|
||||
elif wildcard == "reports":
|
||||
if mode == "config":
|
||||
print("graph_title Exodus reports")
|
||||
print("graph_vlabel reports")
|
||||
print("graph_category exodus")
|
||||
print("reports.label Reports")
|
||||
else:
|
||||
print_count("reports")
|
||||
elif wildcard == "trackers":
|
||||
if mode == "config":
|
||||
print("graph_title Exodus trackers")
|
||||
print("graph_vlabel trackers")
|
||||
print("graph_category exodus")
|
||||
print("trackers.label Trackers")
|
||||
else:
|
||||
print_count("trackers")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue