6
0
Fork 0

Add type to monitor Odoo license expiration with Prometheus.

This commit is contained in:
Joachim Desroches 2021-09-16 15:41:40 +02:00
parent 195bd49d53
commit cba90c83e4
No known key found for this signature in database
GPG key ID: 6778C9C29C02D691
5 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,17 @@
#!/bin/sh
DBNAME=$(cat "${__object:?}/parameter/dbname")
cat << EOF
[Unit]
Description=e-Durable's Prometheus Odoo License Expiration exporter
After=network.target
[Service]
Type=simple
User=odoo
ExecStart=/opt/prometheus-odoo-license-exporter/venv/bin/python /opt/prometheus-odoo-license-exporter/prometheus-odoo-license-exporter ${DBNAME:?}
[Install]
WantedBy=multi-user.target
EOF

View file

@ -0,0 +1,20 @@
#!/bin/sh
VCS_TAG=$(cat "${__object:?}/parameter/version")
VCS_URL="https://code.recycled.cloud/RecycledCloud/prometheus-odoo-license-exporter/raw/tag/$VCS_TAG/prometheus-odoo-license-exporter"
cat << EOF
cd /opt/prometheus-odoo-license-exporter
# Fetch sources
curl "$VCS_URL" -o prometheus-odoo-license-exporter
# Install virtualenv and dependencies
virtualenv venv
. venv/bin/activate
pip3 install prometheus_client psycopg2 datetime
# Start service
systemctl restart prometheus-odoo-license-exporter
EOF

View file

@ -0,0 +1,24 @@
#!/bin/sh
os=$(cat "${__global:?}/explorer/os")
mkdir -p "${__object:?}/files"
case "$os" in
debian|ubuntu)
__package python3-virtualenv
__package curl
__package libpq-dev
"${__type:?}/files/prometheus-odoo-license-exporter.service.sh" \
> "${__object:?}/files/prometheus-odoo-license-exporter.service"
__systemd_unit prometheus-odoo-license-exporter.service \
--source "${__object:?}/files/prometheus-odoo-license-exporter.service" \
--enablement-state enabled
;;
*)
echo "$os is not supported by this type. Exiting" >&2
exit 1
;;
esac
__directory /opt/prometheus-odoo-license-exporter

View file

@ -0,0 +1,2 @@
dbname
version