https://wiki.qnap.com/mediawiki/index.php?title=Category:HDD_Monitoring_with_rrdtool&feed=atom&action=history
Category:HDD Monitoring with rrdtool - Revision history
2024-03-29T08:20:34Z
Revision history for this page on the wiki
MediaWiki 1.39.3
https://wiki.qnap.com/mediawiki/index.php?title=Category:HDD_Monitoring_with_rrdtool&diff=916&oldid=prev
Glenn: catchg
2015-10-26T09:19:15Z
<p>catchg</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 17:19, 26 October 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l267">Line 267:</td>
<td colspan="2" class="diff-lineno">Line 267:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Enjoy</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Enjoy</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[Category:<del style="font-weight: bold; text-decoration: none;">Categories</del>]]</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Category:<ins style="font-weight: bold; text-decoration: none;">Adding new services</ins>]]</div></td></tr>
</table>
Glenn
https://wiki.qnap.com/mediawiki/index.php?title=Category:HDD_Monitoring_with_rrdtool&diff=900&oldid=prev
Glenn: +cat
2015-10-26T08:50:40Z
<p>+cat</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 16:50, 26 October 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l266">Line 266:</td>
<td colspan="2" class="diff-lineno">Line 266:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>https://&lt;QNAP&gt;:8081/smartrrd</pre> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>https://&lt;QNAP&gt;:8081/smartrrd</pre> </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Enjoy</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Enjoy</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:Categories]]</ins></div></td></tr>
</table>
Glenn
https://wiki.qnap.com/mediawiki/index.php?title=Category:HDD_Monitoring_with_rrdtool&diff=76&oldid=prev
Admin: Created page with "== Introduction == This HowTo explains how you can set up continuous monitoring of all your harddisks. It *uses smartmonctl *writes every 30 min the current status to a r..."
2015-06-16T09:35:55Z
<p>Created page with "== Introduction == This HowTo explains how you can set up continuous monitoring of all your harddisks. It *uses smartmonctl *writes every 30 min the current status to a r..."</p>
<p><b>New page</b></p><div>== Introduction ==<br />
<br />
This HowTo explains how you can set up continuous monitoring of all your harddisks. It <br />
<br />
*uses smartmonctl <br />
*writes every 30 min the current status to a round robin database using rrdtool <br />
*generates for each S.M.A.R.T parameter 3 charts showing the status of the last week / last month / last year<br />
<br />
[[Image:Smartrrd.jpg|400px|Smartrrd.jpg]] <br />
<br />
== Install Packages ==<br />
<br />
*if not yet done, install Optware IPGK via the QNAP Web Administration site (under "App Center")<br />
<br />
'''Alternative 1:''' <br />
<br />
*launch Optware via the App Center (will open "The ipkg web frontend") <br />
*to update the catalogue, select "Sync packages" -&gt; yes, then press Submit <br />
*filter to "smartmontools" and press Submit then click "install" <br />
*filter to "rrdtool" and press Submit then click "install"<br />
<br />
'''Alternative 2:''' <br />
<br />
Log into your QNAP with SSH. <br />
<pre># ipkg install smartmontools<br />
# ipkg install rrdtool</pre> <br />
== Prepare Directories ==<br />
<pre># mkdir /mnt/HDA_ROOT/smartrrd<br />
# mkdir /share/Web/smartrrd</pre> <br />
== Install and Adopt the Script ==<br />
<br />
Copy the following script to '''/mnt/HDA_ROOT/smartrrd/smartctl_all_drives.sh''' <br />
<pre>#!/bin/sh<br />
<br />
script_dir=$(dirname "${BASH_SOURCE[0]}")<br />
script_runtime=$(date '+%s')<br />
<br />
http_path="/share/Web/smartrrd"<br />
<br />
# 1 5 29 38 44 50 57 67 76 88<br />
# +4 +24 +9 +6 +6 +7 +10 +9 +12<br />
# ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE<br />
# 1 Raw_Read_Error_Rate 0x000f 114 099 006 Pre-fail Always - 72984072<br />
smart_regex="^(.{4})(.{24})(.{9})(.{6})(.{6})(.{7})(.{10})(.{9})(.{12})(.+)$"<br />
<br />
. $script_dir/smartctl_all_drives.conf<br />
<br />
declare -a ATTRIBUTES<br />
<br />
IFS='<br />
'<br />
<br />
# Get data for all drives from smartmontools and store it in an array ATTRIBUTES<br />
# Later on this will allow to write values from all drives at once to the *.rrd file<br />
<br />
for disk in /dev/sd[a-d]<br />
do<br />
for oneline in $(smartctl -d ata -A $disk | grep 'Always\|Offline')<br />
do<br />
[[ $oneline =~ $smart_regex ]]<br />
<br />
smart_DISK=${disk:(-3)}<br />
smart_ID=${BASH_REMATCH[1]// /}<br />
smart_ID3=$(printf "%03d" $smart_ID)<br />
<br />
smart_ATTRIBUTE_NAME=${BASH_REMATCH[2]// /}<br />
smart_FLAG=${BASH_REMATCH[3]// /}<br />
smart_VALUE=${BASH_REMATCH[4]// /}<br />
smart_WORST=${BASH_REMATCH[5]// /}<br />
smart_THRESH=${BASH_REMATCH[6]// /}<br />
smart_TYPE=${BASH_REMATCH[7]// /}<br />
smart_UPDATED=${BASH_REMATCH[8]// /}<br />
smart_WHEN_FAILED=${BASH_REMATCH[9]// /}<br />
smart_RAW_VALUE=${BASH_REMATCH[10]%(*} # remove trailing "(..." string manipulation<br />
smart_RAW_VALUE=${smart_RAW_VALUE// /}<br />
<br />
# populate attributes array<br />
ATTRIBUTES[$smart_ID]+="$smart_DISK#$smart_RAW_VALUE "<br />
<br />
done<br />
done<br />
<br />
IFS=' '<br />
<br />
# Scan array ATTRIBUTES&nbsp;for values and if existing, write all values to *.rrd<br />
# If necessary (e.g. when run for the first time), create the database<br />
<br />
for i in {1..256}<br />
do<br />
if [[ ${ATTRIBUTES[$i]} ]]; then<br />
smart_ID3=$(printf "%03d" $i)<br />
<br />
rrd_ds=""<br />
rrd_value=""<br />
<br />
for disk_rawvalue in ${ATTRIBUTES[$i]}<br />
do<br />
rrd_ds+=${disk_rawvalue%'#'*}:<br />
rrd_value+=${disk_rawvalue#*'#'}:<br />
done<br />
<br />
rrd_ds=${rrd_ds%:}<br />
rrd_value=${rrd_value%:}<br />
<br />
# create RRD if not yet exist<br />
if [[&nbsp;! -f $script_dir/rrd/$smart_ID3.rrd ]]; then<br />
rrdtool create "$script_dir/rrd/$smart_ID3.rrd" \<br />
--step 1800 \<br />
DS:sda:GAUGE:3600:0:U \<br />
DS:sdb:GAUGE:3600:0:U \<br />
DS:sdc:GAUGE:3600:0:U \<br />
DS:sdd:GAUGE:3600:0:U \<br />
RRA:MAX:0.5:1:336 \<br />
RRA:MAX:0.5:2:744 \<br />
RRA:MAX:0.5:48:365<br />
<br />
# RRA:MAX:0.5:1:336 -&gt; every 30min for 2x24x7 times (one week in 30min interval)<br />
# RRA:MAX:0.5:2:744 -&gt; every second 30min for 24x31 times (one month in 1h interval)<br />
# RRA:MAX:0.5:48:365 -&gt; every 48th 30min for 365 times (one year in 1day interval)<br />
fi<br />
<br />
rrdtool update "$script_dir/rrd/$smart_ID3.rrd" -t $rrd_ds $script_runtime:$rrd_value<br />
<br />
fi<br />
done<br />
<br />
# Create charts for all existing *.rrd file<br />
<br />
for filename in $script_dir/rrd/*.rrd<br />
do<br />
smart_ID3=${filename%'.'*}<br />
smart_ID3=${smart_ID3#*'/'rrd'/'}<br />
smart_ID=$(echo $smart_ID3 | sed 's/^0*//')<br />
<br />
rrdtool graph "$http_path/${smart_ID3}_week.png" -a PNG --title="${smart_attributes[$smart_ID]}" \<br />
--vertical-label "RAW_VALUE" --start end-1w --end $script_runtime \<br />
DEF:a=$filename:sda:MAX \<br />
DEF:b=$filename:sdb:MAX \<br />
DEF:c=$filename:sdc:MAX \<br />
DEF:d=$filename:sdd:MAX \<br />
LINE1:a#FF0000:"/dev/sda" GPRINT:a:LAST:"%6.lf&nbsp;%s" \<br />
LINE2:b#800000:"/dev/sdb" GPRINT:b:LAST:"%6.lf&nbsp;%s\n" \<br />
LINE3:c#00FF00:"/dev/sdc" GPRINT:c:LAST:"%6.lf&nbsp;%s" \<br />
LINE4:d#0000FF:"/dev/sdd" GPRINT:d:LAST:"%6.lf&nbsp;%s"<br />
<br />
rrdtool graph "$http_path/${smart_ID3}_month.png" -a PNG --title="${smart_attributes[$smart_ID]}" \<br />
--vertical-label "RAW_VALUE" --start end-1m --end $script_runtime \<br />
DEF:a=$filename:sda:MAX \<br />
DEF:b=$filename:sdb:MAX \<br />
DEF:c=$filename:sdc:MAX \<br />
DEF:d=$filename:sdd:MAX \<br />
LINE1:a#FF0000:"/dev/sda" GPRINT:a:LAST:"%6.lf&nbsp;%s" \<br />
LINE2:b#800000:"/dev/sdb" GPRINT:b:LAST:"%6.lf&nbsp;%s\n" \<br />
LINE3:c#00FF00:"/dev/sdc" GPRINT:c:LAST:"%6.lf&nbsp;%s" \<br />
LINE4:d#0000FF:"/dev/sdd" GPRINT:d:LAST:"%6.lf&nbsp;%s"<br />
<br />
rrdtool graph "$http_path/${smart_ID3}_year.png" -a PNG --title="${smart_attributes[$smart_ID]}" \<br />
--vertical-label "RAW_VALUE" --start end-1y --end $script_runtime \<br />
DEF:a=$filename:sda:MAX \<br />
DEF:b=$filename:sdb:MAX \<br />
DEF:c=$filename:sdc:MAX \<br />
DEF:d=$filename:sdd:MAX \<br />
LINE1:a#FF0000:"/dev/sda" GPRINT:a:LAST:"%6.lf&nbsp;%s" \<br />
LINE2:b#800000:"/dev/sdb" GPRINT:b:LAST:"%6.lf&nbsp;%s\n" \<br />
LINE3:c#00FF00:"/dev/sdc" GPRINT:c:LAST:"%6.lf&nbsp;%s" \<br />
LINE4:d#0000FF:"/dev/sdd" GPRINT:d:LAST:"%6.lf&nbsp;%s"<br />
<br />
done<br />
<br />
# Recreate index.html<br />
<br />
echo "" &gt; $http_path/index.html<br />
<br />
for i in {1..256}<br />
do<br />
if [[ ${ATTRIBUTES[$i]} ]]; then<br />
<br />
smart_ID3=$(printf "%03d" $i)<br />
echo "&lt;img src=\"${smart_ID3}_week.png\"&gt;&lt;img src=\"${smart_ID3}_month.png\"&gt;&lt;img src=\"${smart_ID3}_year.png\"&gt;&lt;br&gt;" \<br />
&gt;&gt; $http_path/index.html<br />
fi<br />
done</pre> <br />
The script is designed for the '''4 drives sda, sdb, sdc, sdd'''.&nbsp;<br> <br />
<br />
There are several positions in the script that have to be addapted accordingly if you have more or less drives or different identifiers (e.g. sda).<br>I posted this script here with the hope that somebody would make it more flexible later .-) <br />
<br />
*for disk in /dev/sd[a-d] &nbsp;-&gt; change according to what "fdisk -l" says about installed drives <br />
*DS:sda:GAUGE:3600:0:U -&gt; add/remove additional drives <br />
*DEF:a=$filename:sda:MAX \ -&gt; add/remove additional drives <br />
*LINE1:a#FF0000:"/dev/sda" GPRINT:a:LAST:"%6.lf&nbsp;%s" \&nbsp;-&gt; add/remove additional drives in all 3 charts (week/month/year), also '''change the color'''<br />
<br />
== Install Script Config File ==<br />
<br />
Save the following file to '''/mnt/HDA_ROOT/smartrrd/smartctl_all_drives.conf<br>'''The array is used to create meaningful chart titles. <br />
<pre>smart_attributes[1]='001 Raw_Read_Error_Rate'<br />
smart_attributes[2]='002 Throughput_Performance'<br />
smart_attributes[3]='003 Spin_Up_Time'<br />
smart_attributes[4]='004 Start_Stop_Count'<br />
smart_attributes[5]='005 Reallocated_Sector_Ct'<br />
smart_attributes[7]='007 Seek_Error_Rate'<br />
smart_attributes[8]='008 Seek_Time_Performance'<br />
smart_attributes[9]='009 Power_On_Hours'<br />
smart_attributes[10]='010 Spin_Retry_Count'<br />
smart_attributes[11]='011 Calibration_Retry_Count'<br />
smart_attributes[12]='012 Power_Cycle_Count'<br />
smart_attributes[181]='181 Program_Fail_Cnt_Total'<br />
smart_attributes[183]='183 Runtime_Bad_Block'<br />
smart_attributes[184]='184 End-to-End_Error'<br />
smart_attributes[187]='187 Reported_Uncorrect'<br />
smart_attributes[188]='188 Command_Timeout'<br />
smart_attributes[189]='189 High_Fly_Writes'<br />
smart_attributes[190]='190 Airflow_Temperature_Cel'<br />
#smart_attributes[190]='190&nbsp;??'<br />
smart_attributes[191]='191 G-Sense_Error_Rate'<br />
smart_attributes[192]='192 Power-Off_Retract_Count'<br />
smart_attributes[193]='193 Load_Cycle_Count'<br />
smart_attributes[194]='194 Temperature_Celsius'<br />
smart_attributes[195]='195 Hardware_ECC_Recovered'<br />
smart_attributes[196]='196 Reallocated_Event_Count'<br />
smart_attributes[197]='197 Current_Pending_Sector'<br />
smart_attributes[198]='198 Offline_Uncorrectable'<br />
smart_attributes[199]='199 UDMA_CRC_Error_Count'<br />
smart_attributes[200]='200 Multi_Zone_Error_Rate'<br />
#smart_attributes[200]='200&nbsp;???'<br />
smart_attributes[223]='223 Load_Retry_Count'<br />
smart_attributes[225]='225 Load_Cycle_Count'<br />
smart_attributes[240]='240 Head_Flying_Hours'<br />
#smart_attributes[240]='240&nbsp;???'<br />
smart_attributes[241]='241 Total_LBAs_Written'<br />
smart_attributes[242]='242 Total_LBAs_Read'</pre> <br />
In case you miss values here, please edit this wiki page and add them above. You should identify the attribute name using <br />
<pre>smartctl -d ata -A /dev/hda</pre> <br />
Unfortunately there are IDs that have multiple meanings like 190, 200, 230, 231, 232, 233, 240&nbsp;(see: http://en.wikipedia.org/wiki/S.M.A.R.T.)<br>In case your drives use the strings that are commented out, adapt the .conf file accordingly. <br />
<br />
== Setup crontab ==<br />
<pre># vi /etc/config/crontab<br />
<br />
add the following line:<br />
*/30 * * * * /mnt/HDA_ROOT/smartrrd/smartctl_all_drives.sh<br />
<br />
# crontab /etc/config/crontab<br />
# /etc/init.d/crond.sh restart</pre> <br />
After 30 minutes there should be files in the directory /mnt/HDA_ROOT/smartrrd/rrd as well as in /share/Web/smartrrd <br />
<br />
On my system, I tested the smartctl_all_drives.sh script at the command line and got an error apparently related to rrd directory creation. Also: chmod +x the smartctl_all_drives.sh and smartctl_all_drives.conf.<br> <br />
<br />
Manually creating the rrd directory seemed to make things work. <br />
<pre>[/mnt/HDA_ROOT/smartrrd] # ./smartctl_all_drives.sh<br />
ERROR: creating './rrd/001.rrd': No such file or directory<br />
ERROR: opening './rrd/001.rrd': No such file or directory<br />
..<br />
[/mnt/HDA_ROOT/smartrrd] # mkdir rrd<br />
[/mnt/HDA_ROOT/smartrrd] # ./smartctl_all_drives.sh<br />
497x207<br />
497x207<br />
...<br />
<br />
</pre> <br />
== Open Monitoring Website ==<br />
<br />
Make sure Web Server service is enabled (Control Panel, Applications, Web Server)&nbsp;. <br />
<br />
Now you can open the monitoring site which should be available somewhere under <br />
<pre>http://&lt;QNAP&gt;/smartrrd <br />
https://&lt;QNAP&gt;/smartrrd<br />
https://&lt;QNAP&gt;:8081/smartrrd</pre> <br />
Enjoy</div>
Admin