Jump to content
XPEnology Community

Getting smart data in ESXi and a crude way of viewing it


Recommended Posts

Hi all,


I will present a simple way to obtain smart data in ESXi and a very crude way of viewing it.


My configuration :

  • HP microserver N54L
    ESXi 5.5.0 Update 1
    Nanoboot- with XPenology 5.0-4482
    3 3TB WD Red configured manually as RDM drives
    VMware Paravirtual SCSI driver


Getting the smart data


To get the complet smart data, you need to run a short or long smart test.

To do that, you need to create a new User-defined script in the Task Scheduler of the Control Panel. For the new script, in the General tab, User must be root to have proper access, and you need to copy the following code in the Run command box :

for dev in `ls /sys/block/|grep sd`; do
       smartctl -d sat -t short /dev/$dev

Replace short by long if you want to do a long test.

In the Schedule tab, select so it is run once a day.


Then we need to actually get the smart data generated by the smart test.

You need to add another User-defined script with the following code :

for dev in `ls /sys/block/|grep sd`; do
       smartctl -d sat -a /dev/$dev > /volume1/web/smart/$dev.smartdata

Schedule it hourly, even if no new test is executed, some of the data are update (temperature, power On hours...)

This will make a file per hard drive, it needs to be placed where the Web Station can read it, if you want to used the Web Station to show the results.


The smart data for each drive are in a separate file, now it only needs to be parsed.

I did a small php parser, but it could be done much more nicely by someone who actually know php or any other language the Web Station can execute.


(very) Crude way of viewing the smart data


To view the smart data we obtained in /volume1/web/smart/sdX.smartdata, I did a small parser in php.

I don't know much in php/html so it is a very crude viewer.


I placed the following code in a file named index.php in a subfolder "smart" of the "web" folder. The "web" folder being the active folder for the Web Station of DSM.



// list of hdd
exec('ls /sys/block/|grep sd',$devs);

echo " Smart data ";

// process smartctl output for each hdd
// sdX.smartdata must have been generated in the same folder as this .php
foreach ($devs as $dev) {
   $filename = $dev .'.smartdata';
   if (file_exists($filename) && is_readable ($filename)) {
	echo "
 Device : $dev   Raw Smart results
	echo "</pre>
<table>$match[1]: $match[2]$match[1]: $match[2]$match[1]: $match[2]$match[1]: $match[2]$match[1]: $match[2]$match[1]: $match[2]$match[1]: $match[2]$match[1]: $match[2]</table>";<br>} else {<br>echo "<br>Device : $dev <br>";<br>echo "Missing smartctl output file $filename<br>";<br>}<br>}<br>?&gt


Then to view it, you just need to load the page http://YourNasIPaddress/smart/

Link to comment
Share on other sites

I only tested this method in ESXi, but it should work on any other virtual environment with 'Raw' device.


In the DSM/ESXi case, ESXi forwards correctly the SMART commands to the drives, but it's DSM that does not manage to identify correctly the type of the hard drives.

So instead of using 'smartctl -d sat', DSM uses 'smartctl -d ata' which is not the correct type for the drives, and it fails.



you can use it in your tutorials (I don't have enough posts yet to be authorized to answer your pm :oops: )

Link to comment
Share on other sites

Thx @Saoclyph for sharing his knowledge!


So instead of using 'smartctl -d sat', DSM uses 'smartctl -d ata' which is not the correct type for the drives, and it fails.


Unfortunately I don't know much about Linux, but I hope that one of these ideas could work (enabling Smart Data on DSM Desktop):

  • 1. rename 'smartctl' -> 'smartctl2', create a batch file named 'smartctl' which calls 'smartctl2' with all given parameters but fixed '-d sat'
    2. rename 'smartctl' -> 'smartctl2', create a bin file named 'smartctl' which does exactly the same as the batch of #1 (and compile it for x86)
    3. (if sourcecode of smartctl is available) alter the code of smartctl for only supporting '-d sat' no matter which '-d' parameter is used (and compile it for x86)


best regards,


Link to comment
Share on other sites

I already did use this method to launch the smart tests with the standard Test Scheduler of the Storage Manager in the web interface.

But it only launches the tests, it does not work to get the smart data in the web interface.


The method I presented in the 1st post is easier to implement (no need to ssh into the NAS), that's why I used it instead.


But if you still want to use the standard Test Scheduler, you need to move smartctl to smartctl1 using ssh.

Once your are log into your NAS with ssh, type:

cd /usr/syno/bin
mv smartctl smartctl1
touch smartctl
chmod +x smartctl
vi smartctl

And paste the following code after typing the letter "i" for Insert.

Then "ESC", ":wq", and enter.

# fixes the drive type for smartctl under ESXi
#echo `date` >> $log_file
#echo $* >> $log_file
if [ "$1" = "-d" ]; then
       shift 2
       smartctl1 -d sat $*
       smartctl1 $*


Even if the log of smartctl callings shows that it's called when we access the Storage Manager in the web interface, nothing shows up there.

So there surely has something else that the web interface is doing. And I don't know how to do something similar to this script with .cgi files.




Link to comment
Share on other sites

  • Create New...