Nerd For Tech
Published in

Nerd For Tech

TrueNAS Bespoke Alerts

TrueNAS has several built in alerting mechanisms, however I wanted the ability to have NAS alerts pushed to my phone via PushOver. To accommodate this, I needed to abuse one of the existing alerting methods to send alerts to my custom script.

Of the existing alerting mechanisms, the SNMP Trap method seemed like it would be the easiest to bend to my will. I created a jail called “Monitoring” (using Basejail) which will contain all my various monitoring and utility scripts. Make sure you configure this jail to automatically start. Inside of this jail, I installed python, pip, and the python library pysnmp:

# pkg update
# pkg install python3 py37-pip
# pip install pysnmp requests

For a starting script, I used this great example: https://bytesofgigabytes.com/snmp-protocol/python-snmp-trap-receiver/

By modifying the above script, I was quickly able to publish SNMP Trap message to any service I wanted. You can figure out what MIB’s mean what via this document (notifications section): https://mibs.observium.org/mib/FREENAS-MIB/

Since I use PushOver, here’s what my script ultimately looked like:

I configured the JAIL with “NAT” networking, and noted down the NAT IP.

Inside of the Monitoring jail I created a new file called /etc/rc.d/snmpmonitor which will start the monitoring script above (update paths appropriately):

Now add the following line to /etc/rc:

snmpmonitor_enable=YES

The final step is go to the TrueNAS application -> System -> Alert Services, then click “Edit” on “SNMP Trap”.

Now make sure “Enabled” is checked, and that the “Hostname” points to the net address for your monitoring jail. Also update the “Port” to be accurate:

Now click “Save”. You should now get alerts via your customized script. I recommend using the “Sent Test Alert” to make sure everything is configured correctly.

--

--

--

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Recommended from Medium

Monitoring Kubernetes Clusters

Aggregated Allure report using Copy Artifact Jenkins plugin

Substack Newsletter — OpenLampTech issue #32

Arc Finance Quiz Event

AI Workbench with GKE

Speaking Machine and Human in the Second Machine Age

Swift.gitignore by Github Explained

A Day in the Life: Greg Ryzhov (CTO, Urban Sports Club)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
shellster

shellster

More from Medium

What Users Want: High-Confidence Consumer Features at Ethos

Amex Launches Consumer Checking; Congress Holds Stablecoin Hearing; What’s a “Junk Fee”?

[Book Review] Secrets of Sand Hill Road

Rethinking a Staging Environment