FreeNAS Stat Monitor

I think that OP used a command line sensor; however, you can get the values over SNMP too.

Have a look at my post 35 above. You can extend SNMP with the result of any script that you run on the FN.

For example: in order to get temperature of each drive use (replace x with 0 or any drive that you have)
smartctl -A /dev/adax it will give you something like below. Then, to extract temperature only, use

smartctl -A /dev/ada0 | grep -i airflow_temperature | awk '{print $10}' and save this as a script on FN.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
  1 Raw_Read_Error_Rate     0x000f   083   064   006    Pre-fail  Always       -       220084509
  3 Spin_Up_Time            0x0003   094   094   000    Pre-fail  Always       -       0
  4 Start_Stop_Count        0x0032   100   100   020    Old_age   Always       -       357
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x000f   080   060   045    Pre-fail  Always       -       103205523
  9 Power_On_Hours          0x0032   098   098   000    Old_age   Always       -       2297 (111 71 0)
 10 Spin_Retry_Count        0x0013   100   100   097    Pre-fail  Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   020    Old_age   Always       -       253
183 Runtime_Bad_Block       0x0032   100   100   000    Old_age   Always       -       0
184 End-to-End_Error        0x0032   100   100   099    Old_age   Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
188 Command_Timeout         0x0032   100   100   000    Old_age   Always       -       0 0 0
189 High_Fly_Writes         0x003a   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0022   063   052   040    Old_age   Always       -       37 (Min/Max 27/37)
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       141
193 Load_Cycle_Count        0x0032   100   100   000    Old_age   Always       -       465
194 Temperature_Celsius     0x0022   037   048   000    Old_age   Always       -       37 (0 19 0 0 0)
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0
240 Head_Flying_Hours       0x0000   100   253   000    Old_age   Offline      -       2294h+50m+51.870s
241 Total_LBAs_Written      0x0000   100   253   000    Old_age   Offline      -       4607016717
242 Total_LBAs_Read         0x0000   100   253   000    Old_age   Offline      -       49821273044
1 Like

Hey guys! Could you please share your config? I got HDD and CPU temperature sensors working, but I’m having trouble setting up other sensors, such as system load. I don’t know how to ‘ask’ that of my system over SSH. Thanks! :slight_smile:

Please see post 52.

Do you mind sharing your sensor.yaml?

You need a little more than my yaml files (such as setting up ssh). Believe me, follow the link in post 52 and you’ll see I’ve documented the approach and given code examples. Nothing was held back. I don’t want to duplicate that work, but will be happy to answer specific questions.

after a long time finally finished the FreeNAS monitor, the FreeNAS server is the back bone of my house internal services:)
here is how it looks:

and here are some of the sensor if it helps anyone:
** Just a warning: the trick is to have Hassio talk to Freenas with ssh key authentication **

t - platform: command_line
    name: 'fn CPU Temp'
    unit_of_measurement: '°C'
    scan_interval: 300
    command: ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] sysctl dev.cpu.0 | grep temperature | tr '.' ' ' | awk '{print $5"°"}'    
  - platform: command_line
    name: 'fn Ram'
    unit_of_measurement: 'MB'
    scan_interval: 300
    command: ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected]  top |grep -Em2 '^(Mem|Swap):' | awk '/Mem/{ print substr($8,1) }'

 - platform: command_line
    name: 'Archive Disk 0'
    scan_interval: 300
    command: ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] smartctl -A /dev/ada0 | grep -i Temperature_Celsius | awk '{print $10}'    
    unit_of_measurement: '°C'   

  - platform: command_line
    name: 'Plex Server status'
    scan_interval: 300
    command: ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] iocage get state plex

  - platform: command_line
    name: 'Resilio Sync status'
    scan_interval: 300
    command: ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no -q [email protected] iocage get state rslsync
  - platform: rest
    name: 'Home Server'
      - state
    value_template: '{{ value_json.state }}'
    username: root
    password: your own pasword
    authentication: basic
      Content-Type: application/json


I have some issues with the ssh commands that are send. If I try those in cmd, than I have to seperately fill-in my password and than I get the expected “up” answer. HA is failing to do this the way you mention above. Got a way to resolve this issue?


You can either use SSHPASS to send the password in plain text (not recommended) or add ssh keys from HA’s host to FreeNAS to be able to poll the data over ssh.

Downside of the above choices is that you still need at least one successful ssh login from HA to FreeNAS (and when doing upgrades or some other changes to HA host you need to redo the process). Or, you can skip this altogether and use Netdata sensor by enabling Netdata service on FreeNAS (just change bind to instead of in /etc/local/netdata/netdata.conf as is doesn’t publish the port by default - on FreeNAS that is :wink: ).

And, there’s more :smiley: if you rather like the Netdata graphs to show in HA, you can use the iframe panel.

1 Like

My current FreeNAS HA monitor:


And statistic pusher:

there is no need for password if you use SSHkey, the authentication is done in automatic by the public and privet keys between HA and the server

1 Like

Wow! You built your own addon! Is it possible to use that as-is? If so, how? Do you have a guide to follow? Thanks!

Yes, you can use pusher script as-is at any system (Unix, Linux, Windows, OSx…). Just copy it to host you want to monitor and add Cron job to periodically run pusher script with proper parameters. That’s all.

For parameters description just manual run script without parameters.

I’m run it every 1 minute at my NAS.

Thanks man! I’m running the code unmodified now on my NAS, and it gives a good output when running verbose mode. However, I don’t see the values showing up in the HA sensors I created. I see you’re reading the values via MQTT. I’m using Mosquitto. Do I need to point the script to the Mosquitto port, rather than the Hass main instance? Or is there something else I’m missing?

The script does not access the MQTT-server directly. It uses the Home Assistant API to send data to the current MQTT-server. So the script doesn’t care what your server is.

If the data does not pass, perhaps the reason is some kind of failure in accessing the API. For example, to access the API, you need to specify the correct token, which is created through the HA interface.

You can obtain a token (“Long-Lived Access Token”) by logging into the frontend using a web browser, and going to your profile http://IP_ADDRESS:8123/profile .

Thanks for the response. I have already created an access token and used that in the config. Can it have to do with the fact that I use duckdns, and I try to send the data to

I have not tested this variant, but I believe that there should be no difference.
In verbose mode, are there any errors from the server? If not, then, in theory, the API command work correctly …

Thanks for the quick response! :slight_smile:

The response I get from running your script is below. Note that I have redacted my duckdns alias and API keys.

BlokmeisterNAS# python /mnt/Storage2/Other/Scripts/ -c -v -s API_KEY_REDACTED
Base URL:
SSL certificate check: False
blokmeisternas_8_8_8_8_state: {"last_boot": "2019-10-07T16:11:29", "cpu_load_1m": "0.57", "cpu_load_5m": "0.45", "cpu_load_1                                                         5m": "0.40", "cpu_temperature": 34.0, "cpu_stat": {"user": 2.0, "nice": 0.0, "system": 3.3, "idle": 94.7, "irq": 0.0}, "memo                                                         ry_stat": {"total": 16804630528, "available": 5493555200, "percent": 67.3, "used": 10382729216, "free": 405114880, "active":                                                          457871360, "inactive": 5088440320, "buffers": 0, "cached": 0, "shared": 240570368, "wired": 9924857856}, "swap_stat": {"tot                                                         al": 1572768, "used": 0, "free": 1572768, "percent": 0.0, "sin": 0, "sout": 5914}, "disks_stat": {"/": {"total": 11944650803                                                         2, "used": 2804934656, "free": 116641573376, "percent": 2.3}, "/mnt/NewStorage": {"total": 27400687971840, "used": 193297414                                                         28736, "free": 8070946543104, "percent": 70.5}, "/mnt/Storage2": {"total": 3140122140672, "used": 2482703224832, "free": 657                                                         418915840, "percent": 79.1}, "/mnt/Storage2/Jails": {"total": 657419005952, "used": 90112, "free": 657418915840, "percent":                                                          0.0}, "/mnt/Storage2/iocage": {"total": 657423183872, "used": 4268032, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2                                                         /iocage/download": {"total": 657419005952, "used": 90112, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/downl                                                         oad/11.2-RELEASE": {"total": 657704017920, "used": 285102080, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/i                                                         mages": {"total": 657419005952, "used": 90112, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/jails": {"total"                                                         : 657419005952, "used": 90112, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/jails/asigra": {"total": 6574191                                                         77984, "used": 262144, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/jails/asigra/root": {"total": 6582881935                                                         36, "used": 869277696, "free": 657418915840, "percent": 0.1}, "/mnt/Storage2/iocage/jails/transmission": {"total": 657419104                                                         256, "used": 188416, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/jails/transmission/root": {"total": 658129                                                         502208, "used": 710586368, "free": 657418915840, "percent": 0.1}, "/mnt/Storage2/iocage/log": {"total": 657419014144, "used"                                                         : 98304, "free": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/releases": {"total": 657419005952, "used": 90112, "fre                                                         e": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/releases/11.2-RELEASE": {"total": 657419005952, "used": 90112, "fre                                                         e": 657418915840, "percent": 0.0}, "/mnt/Storage2/iocage/releases/11.2-RELEASE/root": {"total": 658305945600, "used": 887029                                                         760, "free": 657418915840, "percent": 0.1}, "/mnt/Storage2/iocage/templates": {"total": 657419005952, "used": 90112, "free":                                                          657418915840, "percent": 0.0}, "/var/db/system": {"total": 8070947020800, "used": 477696, "free": 8070946543104, "percent":                                                          0.0}, "/var/db/system/cores": {"total": 8070963302400, "used": 16759296, "free": 8070946543104, "percent": 0.0}, "/var/db/s                                                         ystem/samba4": {"total": 8070947341824, "used": 798720, "free": 8070946543104, "percent": 0.0}, "/var/db/system/syslog-3bc72                                                         4bbb18d493585697320a07060e7": {"total": 8070946686976, "used": 143872, "free": 8070946543104, "percent": 0.0}, "/var/db/syst                                                         em/rrd-3bc724bbb18d493585697320a07060e7": {"total": 8070946686976, "used": 143872, "free": 8070946543104, "percent": 0.0}, "                                                         /var/db/system/configs-3bc724bbb18d493585697320a07060e7": {"total": 8071023985152, "used": 77442048, "free": 8070946543104,                                                          "percent": 0.0}, "/var/db/system/webui": {"total": 8070946686976, "used": 143872, "free": 8070946543104, "percent": 0.0}, "/                                                         mnt/Storage2/iocage/jails/asigra/root/proc": {"total": 4096, "used": 4096, "free": 0, "percent": 100.0}}, "disks_temperature                                                         ": {"ada0": "31", "ada1": "31", "ada2": "30", "ada3": "30", "ada4": "30", "ada5": "30", "ada6": "32", "ada7": "31"}, "pools_                                                         stat": {"NewStorage": {"total": 35734127902720, "used": 24513953800192, "free": 11220174102528, "percent": 68.6, "health": "                                                         ONLINE"}, "Storage2": {"total": 3985729650688, "used": 2978206695424, "free": 1007522955264, "percent": 74.7, "health": "ONL                                                         INE"}}, "alerts": "[WARNING] New feature flags are available for volume NewStorage. Refer to the \"Upgrading a ZFS Pool\" su                                                         bsection in the User Guide \"Installing and Upgrading\" chapter and \"Upgrading\" section for more instructions.\n[WARNING]                                                          New feature flags are available for volume Storage2. Refer to the \"Upgrading a ZFS Pool\" subsection in the User Guide \"In                                                         stalling and Upgrading\" chapter and \"Upgrading\" section for more instructions.\n[CRITICAL] Pool jailusb state is UNKNOWN:                                                          "}

I do not see error messages. It turns out that the command is sent correctly.

Try manually through the developer panel to call the mqtt.publish service with parameters
‘topic’: ‘sensor/blokmeisternas_8_8_8_8_state’,
‘payload’: ‘some data’,
‘retain’: True,
and see if this value gets into the MQTT server.

Then try sending the POST request with similar test data through the REST client to
‘Authorization’: "Bearer " + your_token,
‘Content-Type’: ‘application/json’,

I feel like such an idiot. I just blindly copy-pasted your script, including the state topics. I corrected the state_topic to sensor/blokmeisternas_8_8_8_8_state and everything worked. Thank you so much for all your help man! :slight_smile:

1 Like

@Limych Thanks for the great add on for FreeNAS. I am using it and it work perfectly. I just wanted to ask regarding the templates.
as you can see the templates shows as a text for the entity and will not translate to color or anything else. How is this supposed to be used?

appreciate the help.