Long Term Monitoring of TrueNAS Drives in particular

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
It works very nicely and because you write each record to influxdb seperately when it (the script) barfs (smartctl does not like /dev/da0) on /dev/da0 which is a "unknown USB Bridge" - cos its an M.2 in a case attached to a USB port as part of the boot pool the all the values I care about are written correctly.

Don't care if the boot pool overheats. Its a £10.00 16GB Optane in a case that cost twice as much as the drive - and I have several spares and daily config backups

@sretalla - Thank you for your time on this
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
You could play with lines 95 and 108 to filter out any disk that you don't like...

Like you could make line 95 go from:
next if (/SSD|Verbatim|Kingston|Elements|Enclosure|Virtual|KINGSTON/);

to

next if (/SSD|AMicro|Verbatim|Kingston|Elements|Enclosure|Virtual|KINGSTON/);

Adding AMicro also to line 108 for when you go to SCALE.
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
The actual error I get is
Code:
Use of uninitialized value $value in concatenation (.) or string at /mnt/Tank/SMB/QNAS-Scripts/sretella/influxtemps_SCALE.pl line 81.
smartctl 7.2 2021-09-14 r5236 [FreeBSD 13.1-RELEASE-p7 amd64] (local build)
Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

/dev/da0: Unknown USB bridge [0x1de1:0xe101 (0x2001)]
Please specify device type with the -d option.

Use smartctl -h to get a usage summary


I may be being thick, but what is "AMicro" meant to do / be? I am assuming the | is the equivalent of 'or' with maybe the leading / being not?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
From your post a few back in the list, da0 is showing in this line:

<AMicro AM8180 NVME 1.00> at scbus18 target 0 lun 0 (da0,pass8)

AMicro is from that line and the intent is just to have that device that you're not interested in simply not part of the HD list, which then won't generate the attempt to use smartctl on it.

It's actually probably the brand of the controller that is used inside the case to convert M.2 to USB
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
| is the equivalent of 'or'
yes, correct.

maybe the leading / being not?
actually no, it's the next if at the beginning of the line that effectively says skip this one if ...

The slash represents the start (and again at the end) of the regular expression used for matching.
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
From your post a few back in the list, da0 is showing in this line:

<AMicro AM8180 NVME 1.00> at scbus18 target 0 lun 0 (da0,pass8)

AMicro is from that line and the intent is just to have that device that you're not interested in simply not part of the HD list, which then won't generate the attempt to use smartctl on it.
Aha - told you I thought I was being thick
And adding JMicron for da1 sorted that issue completely

Thank you again
 
Last edited:

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
And this inspired me (now that I am an expert (NOT)) to install home assistant on my Synology and push those details into influxdb and measure the Synology disk temps as well. Might have a play with the rest of home assistant later, maybe

Which just works
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
1678216827244.png

Yay - now I just have to wait for Summer to watch my drives melt
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
except that, as it turns out the homeassistant doesn't seem to be entirely reliable when it comes to gathering temp stats. Hmmm, perl is installed on the synology - I wonder if a certain script that works on scale would work on Synology.......
[Edit] - Apparently not

I shall find out when I get back from my appointment at silly O'Clock this morning

Rebooting home assistant starts up the data gathering again - so this appears to be an HA issue
 
Last edited:

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
Turns out that HomeAssistant only posts data to influxdb on a change - not entirely what I was looking for. Apparently it might be possible to force a regular update - but its all gobledegook to me
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
And just to round this out - @sretalla 's script prompted me to write something (I would say similar - but mine is not nearly as complex or complete) for the synology.
Code:
#!/bin/sh
#V1.0
#This was written for a Synology DS1517+ with attached DX517
#The drives in the base unit are sda through sde whilst the DX517 drives are sdfa through sdfe.
#Discovered via sfisk -l and ignoring the md*, zram* and synoboot*. I may automate this at some point if I can be bothered
#This uses the v2 api for influxdb and will not work with version 1.8 as it uses the token system

#Set use_influx to 0 to not post anything to influxdb
#Set use_influx to 1 to post silently to influxdb (but will I think print errors, maybe.
#Use -i instead of "-S -s -o" in curl statement to see more messages about results)
PATH=/opt/bin:/opt/sbin:$PATH
use_influx=1
influx_token="This-is-a-token-with-write-access=="
influx_org="home"
influx_db="synology"
influx_host="192.168.38.189"
influx_port="8086"
influx_protocol="http"
influx_hostname="BackupNAS"
devices="sda sdb sdc sdd sde sdfa sdfb sdfc sdfd sdfe"

#echo "Now Scanning "$devices

for var in $devices
    do
      tempdata="$(smartctl -A -d ata /dev/$var | grep '194 Temperature_Celsius')"
      #echo $tempdata
      searchstring="-"
      remaining=${tempdata#*$searchstring}
      #Now need to remove a whole bunch of garbage characters
      remaining="${remaining// /_}"
      remaining=${remaining//_}
      #Now collect the disk temperature
      disk_temp=$(echo "${remaining}" | head -c2)
      timestamp=`date "+%s" -u -d "Dec 31 $Year 23:59:59"` #Unused (for purposes of next echo statement)
      #echo disk_temp of $var is $disk_temp at $timestamp
        if [ $use_influx == 1 ];
        then
            curl -S -s -o /dev/null -XPOST "$influx_protocol://$influx_host:$influx_port/api/v2/write?org=$influx_org&bucket=$influx_db" \
                --header "Authorization: Token $influx_token" \
                --data-binary "$influx_hostname,disk=$var value=$disk_temp"
        fi
    done
   
exit

Which works - although I can see at least one possible typo as I look at it
 
Top