Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore all dotfiles #
#######################
.*
!/.gitignore
!/.git-blame-ignore-revs
!/.editorconfig
!/.php_cs
!/.github/
!/.mention-bot
!/.env.example

# Others #
##########
__pycache__
47 changes: 47 additions & 0 deletions snmp/common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# LibreNMS SNMP Extension Common Units

This directory contains shared systemd units for LibreNMS SNMP extensions that refresh cached output on a schedule.

## Files

- `librenms-snmp-extension@.service`: common oneshot service template.
- `librenms-snmp-extension@.timer`: common timer template that runs an extension every five minutes.

## Defaults

The common service runs extension instances by name:

```ini
ExecStart=/usr/local/lib/snmpd/%i --config /etc/snmp/extension/%i.yaml --output /run/snmp/extension/%i.json
```

For an extension named `example`, this resolves to:

- Script: `/usr/local/lib/snmpd/example`
- Config: `/etc/snmp/extension/example.yaml`
- Output: `/run/snmp/extension/example.json`

Extensions that need different arguments should install a systemd drop-in override for their specific instance.

The units include `Documentation=` metadata for the shared common units and the extension-specific directory. The service also sets `SyslogIdentifier=librenms-snmp-extension-%i` so logs can be filtered per extension instance.

## Enable An Extension

Install the shared units to `/etc/systemd/system/`, then enable the timer for the extension instance:

```bash
sudo systemctl daemon-reload
sudo systemctl enable --now librenms-snmp-extension@example.timer
```

Check timer status:

```bash
systemctl status librenms-snmp-extension@example.timer
```

Run a refresh manually:

```bash
sudo systemctl start librenms-snmp-extension@example.service
```
17 changes: 17 additions & 0 deletions snmp/common/librenms-snmp-extension@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SNMP common extension cache.
[Unit]
Description=LibreNMS SNMP extension cache: %i
Documentation=https://github.com/librenms/librenms-agent/tree/master/snmp/common
Documentation=https://github.com/librenms/librenms-agent/tree/master/snmp/%i

[Service]
Type=oneshot
SyslogIdentifier=librenms-snmp-extension-%i
RuntimeDirectory=snmp/extension
RuntimeDirectoryMode=0755
ExecStart=/usr/local/lib/snmpd/%i --config /etc/snmp/extension/%i.yaml --output /run/snmp/extension/%i.json
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=full
ReadWritePaths=/run/snmp/extension
14 changes: 14 additions & 0 deletions snmp/common/librenms-snmp-extension@.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SNMP common extension cache.
[Unit]
Description=Run LibreNMS SNMP extension cache refresh: %i
Documentation=https://github.com/librenms/librenms-agent/tree/master/snmp/common
Documentation=https://github.com/librenms/librenms-agent/tree/master/snmp/%i

[Timer]
OnBootSec=2min
OnUnitActiveSec=5min
AccuracySec=30s
Persistent=true

[Install]
WantedBy=timers.target
101 changes: 0 additions & 101 deletions snmp/mdadm

This file was deleted.

Loading
Loading