Skip to content

Commit 6a775f6

Browse files
authored
New Script: Prometheus Paperless-NGX Exporter (#2153)
* New Script: Prometheus Paperless NGX Exporter * Temp: Change import URLs to test fork * Prometheus Paperless NGX Exporter: Fix double `=` in systemd unit file * Revert "Temp: Change import URLs to test fork" This reverts commit f78d295. * Fix script in `install_methods`
1 parent 0b3e63b commit 6a775f6

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Andy Grunwald (andygrunwald)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/hansmi/prometheus-paperless-exporter
7+
8+
# App Default Values
9+
APP="Prometheus-Paperless-NGX-Exporter"
10+
var_tags="monitoring;alerting"
11+
var_cpu="1"
12+
var_ram="256"
13+
var_disk="2"
14+
var_os="debian"
15+
var_version="12"
16+
var_unprivileged="1"
17+
18+
# App Output & Base Settings
19+
header_info "$APP"
20+
base_settings
21+
22+
# Core
23+
variables
24+
color
25+
catch_errors
26+
27+
function update_script() {
28+
header_info
29+
check_container_storage
30+
check_container_resources
31+
if [[ ! -f /etc/systemd/system/prometheus-paperless-ngx-exporter.service ]]; then
32+
msg_error "No ${APP} Installation Found!"
33+
exit
34+
fi
35+
RELEASE=$(curl -s https://api.github.com/repos/hansmi/prometheus-paperless-exporter/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
36+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
37+
msg_info "Stopping ${APP}"
38+
systemctl stop prometheus-paperless-ngx-exporter
39+
msg_ok "Stopped ${APP}"
40+
41+
msg_info "Updating ${APP} to v${RELEASE}"
42+
cd /opt
43+
wget -q https://github.com/hansmi/prometheus-paperless-exporter/releases/download/v${RELEASE}/prometheus-paperless-exporter_${RELEASE}_linux_amd64.tar.gz
44+
tar -xf prometheus-paperless-exporter_${RELEASE}_linux_amd64.tar.gz
45+
cp -rf prometheus-paperless-exporter_${RELEASE}_linux_amd64/prometheus-paperless-exporter /usr/local/bin/
46+
rm -rf prometheus-paperless-exporter_${RELEASE}_linux_amd64/ prometheus-paperless-exporter_${RELEASE}_linux_amd64.tar.gz
47+
echo "${RELEASE}" >/opt/${APP}_version.txt
48+
msg_ok "Updated ${APP} to v${RELEASE}"
49+
50+
msg_info "Starting ${APP}"
51+
systemctl start prometheus-paperless-ngx-exporter
52+
msg_ok "Started ${APP}"
53+
msg_ok "Updated Successfully"
54+
else
55+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
56+
fi
57+
exit
58+
}
59+
60+
start
61+
build_container
62+
description
63+
64+
msg_ok "Completed Successfully!\n"
65+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
66+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
67+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8081/metrics${CL}"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Andy Grunwald (andygrunwald)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/hansmi/prometheus-paperless-exporter
7+
8+
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies"
17+
$STD apt-get install -y \
18+
curl \
19+
sudo \
20+
mc
21+
msg_ok "Installed Dependencies"
22+
23+
msg_info "Installing Prometheus Paperless NGX Exporter"
24+
RELEASE=$(curl -s https://api.github.com/repos/hansmi/prometheus-paperless-exporter/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
25+
wget -q https://github.com/hansmi/prometheus-paperless-exporter/releases/download/v${RELEASE}/prometheus-paperless-exporter_${RELEASE}_linux_amd64.tar.gz
26+
tar -xf prometheus-paperless-exporter_${RELEASE}_linux_amd64.tar.gz
27+
mv prometheus-paperless-exporter_${RELEASE}_linux_amd64/prometheus-paperless-exporter /usr/local/bin/
28+
mkdir -p /etc/prometheus-paperless-ngx-exporter
29+
cat <<EOF > /etc/prometheus-paperless-ngx-exporter/paperless_auth_token_file
30+
SECRET_AUTH_TOKEN
31+
EOF
32+
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
33+
msg_ok "Installed Prometheus Paperless NGX Exporter"
34+
35+
msg_info "Creating Service"
36+
cat <<EOF >/etc/systemd/system/prometheus-paperless-ngx-exporter.service
37+
[Unit]
38+
Description=Prometheus Paperless NGX Exporter
39+
Wants=network-online.target
40+
After=network-online.target
41+
42+
[Service]
43+
User=root
44+
Restart=always
45+
Type=simple
46+
ExecStart=/usr/local/bin/prometheus-paperless-exporter \
47+
--paperless_url=http://paperless.example.org \
48+
--paperless_auth_token_file=/etc/prometheus-paperless-ngx-exporter/paperless_auth_token_file
49+
ExecReload=/bin/kill -HUP \$MAINPID
50+
51+
[Install]
52+
WantedBy=multi-user.target
53+
EOF
54+
systemctl enable -q --now prometheus-paperless-ngx-exporter
55+
msg_ok "Created Service"
56+
57+
motd_ssh
58+
customize
59+
60+
msg_info "Cleaning up"
61+
$STD apt-get -y autoremove
62+
$STD apt-get -y autoclean
63+
rm -rf prometheus-paperless-exporter_${RELEASE}_linux_amd64/ prometheus-paperless-exporter_${RELEASE}_linux_amd64.tar.gz
64+
msg_ok "Cleaned"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "Prometheus Paperless NGX Exporter",
3+
"slug": "prometheus-paperless-ngx-exporter",
4+
"categories": [
5+
9
6+
],
7+
"date_created": "2025-02-07",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 3000,
12+
"documentation": null,
13+
"website": "https://github.com/hansmi/prometheus-paperless-exporter",
14+
"logo": "https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/resources/logo/web/svg/square.svg",
15+
"description": "Prometheus metrics exporter for Paperless-NGX, a document management system transforming physical documents into a searchable online archive. The exporter relies on Paperless' REST API.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/prometheus-paperless-ngx-exporter.sh",
20+
"resources": {
21+
"cpu": 1,
22+
"ram": 256,
23+
"hdd": 2,
24+
"os": "debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": null,
31+
"password": null
32+
},
33+
"notes": [
34+
{
35+
"text": "Please adjust the Paperless URL in the systemd unit file: /etc/systemd/system/prometheus-paperless-ngx-exporter.service",
36+
"type": "info"
37+
},
38+
{
39+
"text": "Please adjust the Paperless authentication token in the configuration file: /etc/prometheus-paperless-ngx-exporter/paperless_auth_token_file",
40+
"type": "info"
41+
}
42+
]
43+
}

0 commit comments

Comments
 (0)