Synology NAS temperature on website

Moderator: Mattk

Post Reply
User avatar
idociko
Junior Boarder
Junior Boarder
Posts: 39
Joined: Tue Jan 24, 2012 6:16 pm
Location: Cikó, Hungary
Contact:

Synology NAS temperature on website

Post by idociko » Wed Mar 28, 2012 9:54 am

If more Meteohub users also use a Synology NAS and want the operating temperature of their NAS to appear on their website, It is possible! I worked it out. If interested, leave a message and I will describe the method here.

urosh
Expert Boarder
Expert Boarder
Posts: 83
Joined: Wed Jul 30, 2008 10:12 am

Re: Synology NAS temperature on website

Post by urosh » Thu Mar 29, 2012 8:50 am

Interested :)

User avatar
idociko
Junior Boarder
Junior Boarder
Posts: 39
Joined: Tue Jan 24, 2012 6:16 pm
Location: Cikó, Hungary
Contact:

Re: Synology NAS temperature on website

Post by idociko » Thu Mar 29, 2012 1:46 pm

OK, here we go :)

First of all you have to get the temperature information from your NAS. In a telnet session you can give this command:
/usr/syno/bin/smartctl -d sat -T permissive -l scttempsts /dev/sda
That will give this information:
smartctl 5.42 2011-10-20 r3458 [armv5tel-linux-2.6.32.12] (local build) Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

Unable to get testing progress of /dev/sda
=== START OF READ SMART DATA SECTION ===
SCT Status Version: 3
SCT Version (vendor specific): 522 (0x020a)
SCT Support Level: 1
Device State: Active (0)
Current Temperature: 34 Celsius
Power Cycle Min/Max Temperature: 14/41 Celsius
Lifetime Min/Max Temperature: 14/41 Celsius
With a cronjob we can automate this and save the info in a file. To make and edit cronjobs 'WizJos' wrote a perfect script. To run this script in DSM first instal 'Init_3rd_party.spk' You can find that on his site: http://wizjos.endofinternet.net/synolog ... it3rdparty
After installing and running init_3rd_party you can instal the cronjobscript: http://wizjos.endofinternet.net/synolog ... s/cronjobs
Oddly since DSM 4.0 this script runs only through your external IP.

In Cronjobs create a new job with this command:
/usr/syno/bin/smartctl -d sat -T permissive -l scttempsts /dev/sda> /volume1/....../servertemp.txt
Make sure you complete the path to the directory of your choice.
Complete the job with a user, discription and a time interval for this job.

Now we have to put this information on a webpage. I use this simple php script:
<?php>
//Open file on the location where cronjob put it
$a = fopen("/...../servertemp.txt","r");
$b = file("/...../servertemp.txt");
$numbers = count($b);
//read the lines in the file

for ($i=0;$i<10;$i++)
{
//print("$b[$i]<br>");
//remove the slashes above for output of all info
}
//read temperature in line 9, 11the pos of the right, two digits
$temp = substr($b[9], -11, 2);
//print temperature on screen
echo "Temperature of MySynology NAS: $temp&#176 C.";
//close file
fclose($a);

?>
Have fun with it!

The same principle I use for WunderGround API requests, so you'll never have more then 500 (free) request a day. No mather how much visitors of your site visit a page with an API request, your cron makes the request by interval. Also a page with (now a internal) API request will load 25 times faster then a direct request from your page to WunderGround.

User avatar
ON1DQD
Expert Boarder
Expert Boarder
Posts: 93
Joined: Fri Dec 05, 2008 8:46 pm
Location: Belgium (Genk)
Contact:

Re: Synology NAS temperature on website

Post by ON1DQD » Sat Jan 31, 2015 8:14 pm

Thank you!!!! :D

Post Reply