Balance exporter for https://smsc.ru service
The smsc balance exporter for prometheus allows exporting balance for smsc gateway
Exporter querying balance every hour (by default) and store it value in memory. When prometheus make request, exporter retrieve balance value from memory for make response.
You must set environment variables:
SMSC_LOGIN- your loginSMSC_PASSWORD- your password
listen-address- the address to listen on for HTTP requests. (Default:0.0.0.0:9601)interval- the interval (in seconds) for querying balance. (Default:3600)retry-interval- the interval (in seconds) for load balance when errors. (Default:10)retry-limit- the count of tries when error. (Default:10)
docker run \
-e SMSC_LOGIN=<your-login> \
-e SMSC_PASSWORD=<your-password> \
-p 9601:9601 \
--restart=unless-stopped \
--name smsc-balance-exporter \
-d \
xxxcoltxxx/smsc-balance-exporterCreate configuration file. For example, file named docker-compose.yaml:
version: "3"
services:
smsc-balance-exporter:
image: xxxcoltxxx/smsc-balance-exporter
restart: unless-stopped
environment:
SMSC_LOGIN: <your-login>
SMSC_PASSWORD: <your-password>
ports:
- 9601:9601Run exporter:
docker-compose up -dShow service logs:
docker-compose logs -f smsc-balance-exporterSet variables you need:
SMSC_EXPORTER_VERSION=v0.1.3-beta.3
SMSC_EXPORTER_PLATFORM=linux
SMSC_EXPORTER_ARCH=amd64
SMSC_LOGIN=<your_login>
SMSC_PASSWORD=<your_password>Download release:
wget https://github.com/xxxcoltxxx/smsc-balance-exporter/releases/download/${SMSC_EXPORTER_VERSION}/smsc_balance_exporter_${SMSC_EXPORTER_VERSION}_${SMSC_EXPORTER_PLATFORM}_${SMSC_EXPORTER_ARCH}.tar.gz
tar xvzf smsc_balance_exporter_${SMSC_EXPORTER_VERSION}_${SMSC_EXPORTER_PLATFORM}_${SMSC_EXPORTER_ARCH}.tar.gz
mv ./smsc_balance_exporter_${SMSC_EXPORTER_VERSION}_${SMSC_EXPORTER_PLATFORM}_${SMSC_EXPORTER_ARCH} /usr/local/bin/smsc_balance_exporterAdd service to systemctl. For example, file named /etc/systemd/system/smsc_balance_exporter.service:
[Unit]
Description=Smsc Balance Exporter
Wants=network-online.target
After=network-online.target
[Service]
Environment="SMSC_LOGIN=${SMSC_LOGIN}"
Environment="SMSC_PASSWORD=${SMSC_PASSWORD}"
Type=simple
ExecStart=/usr/local/bin/smsc_balance_exporter
[Install]
WantedBy=multi-user.targetReload systemctl configuration and restart service
systemctl daemon-reload
systemctl restart smsc_balance_exporterShow service status:
systemctl status smsc_balance_exporterShow service logs:
journalctl -fu smsc_balance_exporterImport dashboard from https://grafana.com/dashboards/9752 or use examples/grafana.json

- job_name: 'smsc_balance'
scrape_interval: 1m
static_configs:
- targets:
- '10.10.0.10:9601'examples/prometheus-alert.rules
- name: balance
rules:
- alert: sms_balance
expr: sum(balance_smsc) <= 2000
for: 1s
labels:
severity: critical
annotations:
summary: "sms balance is {{ .Value }} RUB"
description: "Top up the balance: https://smsc.ru/payment/"