FreeNAS Stat Monitor

Sure, there is a way to work around it. There always is a way, if there is a will.

You could use an automation to pass the data to a user defined sensor. If it’s empty, set it to OK or something. You could use a script to do something similar.

You might even be able to use a simple template with an if statement. {% if '{{ value_json[0].message }}' = '[]' %} 'All is well' {% else %} '{{ value_json[0].message }}' {% endif %} might work. Might need to play around with that to get the syntax right. If you can get that to work, then you could do something similar with the alert level. Play around with it, see if you can get it to work. :slightly_smiling_face:

hello all, I managed to configure freenas and its states through the bees and your advice, but I would like to be able to keep under control the temperature of the CPU (xeon 4 cores), 6x disks and have the ability to turn it off remotely, perhaps with a booleana so that it can check the status (if it is on then switch off, if it is off the switch will not give the possibility to turn off)
I’ve been trying for several hours, but even through ssh I can get a response from freenas, I get the entry (for example cpu temperature) but it is empty. I read the article on the forum freenas but it does not work with me, I’m definitely wrong.
I have freenas 11.
Thank you

Hi @abeone,

Sorry, I don’t know how to pull the CPU data from FN. Let me know if you figure this out though, because that would be great to have. Maybe SNMP would be helpful.

Good luck!

@abeone, looks like HA has a sensor for this protocol: https://www.home-assistant.io/components/sensor.snmp/

I found the fix for this. Basically you should have the value_template as following:

  - platform: rest
    name: FN Alert Level
    resource: http://hostname/api/v1.0/system/alert/?format=json
    value_template: "{{ value_json['objects'][0].level }}"

Notice the value_json as it return an array with two layers.

hope this will help someone out there.

1 Like

How did you customize the icons in the state card?

Sorry @madrose, I just saw this. I must have email notifications turned off for the forum.

You can customize the icons like anything else in HA: https://www.home-assistant.io/docs/configuration/customizing-devices/

You’ve probably figured this out by now. Sorry again for the delay.

I also saw your post above with the corrected value_template. Thank you. I just realized that mine was not behaving correctly. Not sure why it worked when I first set it up.

@gremblin Thank you for coming back. I did manage to sort out the icons.

Quick Question, I am facing an annoying issue when there is no messages/alerts on the FreeNAS box. the log is flooded with:

Error parsing value: list object has no element 0 (value: {"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 0}, "objects": []}, template: {{ value_json['objects'][0].message }})

Any idea how to disable/fix this? I do not want to disable the sensor, but it is annoying to see the error message repeated endlessly in the log.

which sensor is this for? You could probably do something with a template when there is no data.

This is for the alerts in the Freenas. in case there is any issue on the NAS there will be a message in the web console.

How to deal with an empty template? is there a way in HA? not aware of that.

Wouldnt it be better to use SNMP?

Possibly… Probably… I was unaware of SNMP when I went down this rabbit hole. It wasn’t until
this post that I realized that I could have gone that route.

Have you successfully set up SNMP sensors from FreeNAS? Is it pretty simple? Do you get access to the same information, warning messages etc?

To be fair, ive got no idea, it really depends how much data FreeNAS publishes through SNMP and how usable that data is. I havent played with FreeNAS and SNMP yet, but im using SNMP to monitor different servers and devices (like PDUs) and the results are mixed depending on how much information particular system or device exposes

FreeNAS exposes basic info over SNMP (such as 1/5/15 load - at OIDs from 1.3.6.1.4.1.2021.10.1.3.1 to _3).

However, it can be further extended by including “pass .1.3.6.1.2.1.25.1.8 /bin/sh /mnt/name_of_script.sh” in the SNMP service configuration.

I’ve only added temperature sensor (see below), however result of pretty much any command can be passed to SNMP and monitored over by HA.

#!/bin/sh
echo .1.3.6.1.2.1.25.1.8 # increment for additional sensors
echo gauge
sysctl -a | egrep -E "cpu\.0+\.temp" | awk '{print $2}'
exit 0

OK! Now I am intrigued! I assumed what SNMP gave you is what you got. But if you can pass anything, that would be awesome. Not only for notification, but I like having all my stat collection in one place and tracked in HA. Could probably accomplish the same thing or better in a FN jail with some type of logging server… Been thinking about looking into that to track network traffic from my pfSense router and such. Prioritizing time for these nice to haves is always the thing.

I originally thought it would be cool to have API integration because I could auto unlock my FreeNAS encrypted drives from HA and get stat data. I wasn’t able to get the unlock to work on my first crack and then found other things to do that were higher priority and never got back to it.

Can include result of custom scripts over SNMP on pfsense too.

As default SNMP daemon is limited, I installed net-snmp package, changed port from default 161, then in the advanced configuration added the location of the scripts:

extend .1.3.6.1.2.1.25.1.8 proctemp /bin/sh /home/user/custom/proctemp.sh

and the actual script for monitoring temperature on core 0:

#! /bin/bash 

sysctl -n dev.cpu.0.temperature |tr -d C

I installed a crazy custom API package to get stats from pfSense (link). SNMP may have been better?

My box is a fanless J1900 with pfblockerng, snort, ClamAV (comes with Squid) and net-snmp packages (I only added a few custom sensors over SNMP, was mostly looking to get processor temperature into HA).

Usually stays at 0.4-0.5 on 15 min load, sometimes going up to 0.7-0.8 (processor is quad core so this is quite low) and 70-72 degrees C.

1 Like

Got it all setup. Just a small glitch of missing the Alert level and message sensors

image

Also what other Stats can we get from the FreeNAS? I was hoping to read the status of my ups that is linked to my FreeNAS.