Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/llaumgui/nextcloud2prom

Convert a Nextcloud monitoring in JSON to prom textfile
https://github.com/llaumgui/nextcloud2prom

Last synced: about 6 hours ago
JSON representation

Convert a Nextcloud monitoring in JSON to prom textfile

Awesome Lists containing this project

README

        

# Nextcloud to prom

Get Nextcloud server's info in JSON and convert to [node_exporter textfile format](https://github.com/prometheus/node_exporter?tab=readme-ov-file#textfile-collector).

![image](https://github.com/user-attachments/assets/ad11f6a0-9924-4cb8-9481-4a24d06fe803)

## Install

### On Nextcloud

* Make sur that application server info is enable:

```bash
https://domain.ltd/settings/admin/serverinfo
```

* Set a token:

```bash
occ config:app:set serverinfo token --value MY_TOKEN
```

### On your server

* Create folder /var/lib/prometheus/node-exporter

```bash
mkdir /var/lib/prometheus/node-exporter
chown prometheus:prometheus /var/lib/prometheus/node-exporter
```

* Allow collect textfiles from it:

```bash
cat /etc/default/node_exporter
NODE_EXPORTER_OPTS="--collector.textfile.directory=/var/lib/prometheus/node-exporter"
```

* Get scripts:

```bash
cd /tmp
git clone https://github.com/llaumgui/nextcloud2prom.git
cd nextcloud2prom
```

* Install requirements from `dnf`, `apt`, etc. Or use `pip`:

```bash
pip install -r requirements.txt
```

* Install scripts:

```bash
cp prom_nextcloud.py /usr/local/bin
chmod +x /usr/local/bin/prom_nextcloud.py
cp system.d/prom* /etc/systemd/system
```

* Edit /etc/systemd/system/prom-nextcloud.service with your `NC_URL` and `NC_TOKEN` informations.
* Check:

```bash
systemd-analyze verify /etc/systemd/system/prom-nextcloud*
systemctl start prom-nextcloud.service
```

* and start systemd:

```bash
systemctl start prom-nextcloud.timer
systemctl enable prom-nextcloud.timer
```

## Develop

```bash
python -m venv env
source env/bin/activate
pip install -r requirements.txt
```