Page 1 of 3

Display the HDD temperature in the web portal [patch]

Posted: 06 Nov 2010, 14:02
by [vEX]
Hi,

I think it's nice to be able to see the HDD temperature in the web portal and started digging around. I found out that you already have the functionallity but it doesn't seem to be used anywhere (navigate to http://b3.local/admin/stat/info to get the JSON data). Hence I decided to hack it in myself.

I've attached the patch incase anyone else is interested in seeing it as well. Just make sure you have hddtemp installed (apt-get install hddtemp).

Transfer the patch to your bubba and ssh in, now as root:

Code: Select all

cd /usr/share/web-admin/
patch --verbose -p0 < /path/to/gui_hdd.patch
gui_hdd.patch (I'm not allow to upload it as an attachment, make sure there is no trailing empty line):

Code: Select all

--- admin/controllers/stat.php.orig	2010-11-06 18:50:38.000000000 +0100
+++ admin/controllers/stat.php	2010-11-06 18:51:36.000000000 +0100
@@ -79,6 +79,7 @@
 		$sdata['totalspace']=number_format($totalspace,0,' ',' ');
 		$sdata['percentused']=intval(100*(($totalspace-$freespace)/$totalspace));
 		$sdata['notifications'] = $this->notify->list_all();
+		$sdata['hddtemp'] = $this->_getdisk('/dev/sda');
 
 		if($strip){
 			$this->load->view(THEME.'/stat/stat_view',$sdata);
--- admin/views/default/stat/stat_view.php.orig	2010-11-06 18:51:02.000000000 +0100
+++ admin/views/default/stat/stat_view.php	2010-11-06 18:47:17.000000000 +0100
@@ -17,6 +17,7 @@
 			<table class="ui-table-outline" id="ui-stat-list">
 				<tr><td class="ui-stat-list-col1"><?=t('Disk capacity')?></td><td class="ui-stat-list-col2"><?=$totalspace?> MB</td><td /></tr>
 				<tr><td><?=t('Available')?></td><td><?=$freespace?> MB</td><td /></tr>
+				<tr><td><?=t('HDD temperature')?></td><td><?=$hddtemp['temp']?></td><td /></tr>
 				<tr><td><?=t('Uptime')?></td><td>
 						<? if($uptime[0]>0) print($uptime[0]." ".t('days')." "); ?>
 						<? printf("%02d",$uptime[1])?>:<? printf("%02d",$uptime[2])?>:<? printf("%02d",$uptime[3])?>
The result:
HDD temperature in the portal
HDD temperature in the portal
gui_patch.jpeg (12.13 KiB) Viewed 34297 times

- EDIT -
Just noticed that I posted this in the wrong forum, it belongs under Hacking/Howtos so if any moderator could kindly move it I'd be grateful.

Re: Display the HDD temperature in the web portal [patch]

Posted: 09 Nov 2010, 10:06
by johannes
Great, nice howto! Any chance of you adding this to our wiki? (wiki.excito.org)? Would be much appreciated!

(If not, perhaps you allow us to move it?)

Also, moved this topic to hacking/howtos as requested.

Re: Display the HDD temperature in the web portal [patch]

Posted: 09 Nov 2010, 13:38
by [vEX]
Feel free to add/move it to the wiki, I'm too lazy to sign up for (yet) another service.

Re: Display the HDD temperature in the web portal [patch]

Posted: 09 Nov 2010, 13:49
by DanielM
johannes wrote:Great, nice howto! Any chance of you adding this to our wiki? (wiki.excito.org)? Would be much appreciated!
Why not just simply include it in next official update?

/Daniel

Re: Display the HDD temperature in the web portal [patch]

Posted: 09 Nov 2010, 14:08
by johannes
We might do that, but until then... I,ll move it to the wiki soon then, thanks!

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Nov 2010, 03:11
by johannes
Ok, done.

http://wiki.excito.org/wiki/index.php/D ... _interface

[vEX], many thanks! Let me know if you wish to add something more such as your name, links etc. You deserve credit for good work! :)

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Nov 2010, 03:23
by stompertje
Hmm, my B3 complains about a malformed patch. I can't see anything strange myself, but I don't read patches too well. Note: I took the patch file from the Wiki: the version above gave me loads of other errors.

Any ideas?

root@homeserver:/usr/share/web-admin# patch --verbose -p0 < /home/patrick/private/gui_hdd.patch
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- admin/controllers/stat.php.orig 2010-11-06 18:50:38.000000000 +0100
|+++ admin/controllers/stat.php 2010-11-06 18:51:36.000000000 +0100
--------------------------
Patching file admin/controllers/stat.php using Plan A...
patch: **** malformed patch at line 4: $sdata['totalspace']=number_format($totalspace,0,' ',' ');

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Nov 2010, 04:00
by johannes
Yes, can confirm this. I tried modding the two files according to the patch manually and this worked, I can now se the HDD temp. BUt you are right, the patch file seems corrupt in some way. I'm not a Linux expert, perhaps someone can explain what's wrong?

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Nov 2010, 04:42
by stompertje
I investigated a little more, and the problem is that the whitespacing is not correct. TABs are converted into spaces in the original patch file (which makes it fail because it can't find the matching lines in the original file) and the leading whitespace is deleted alltogether in the Wiki-version of the patch.

The lines in the first part of the patch should start with two TABs, the lines in the second part should start with four TABS.

Also, perhaps the article should mention that one needs to

Code: Select all

apt-get install hddtemp
first...

For now, I've solved it by applying the changes manually.

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Nov 2010, 05:37
by johannes
Ok, update the wiki post with a new patch file that works.

http://wiki.excito.org/wiki/index.php/D ... _interface

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Nov 2010, 16:57
by philgaskin
It's worth mentioning that you may need to do apt-get install patch first. I had to do this to make it work. I have reloaded my B3, so it might be that patch is on the original shipped image but not on the image on the web site.
Phil.

Re: Display the HDD temperature in the web portal [patch]

Posted: 11 Nov 2010, 02:13
by johannes
Great thanks. Added to the wiki article.

Re: Display the HDD temperature in the web portal [patch]

Posted: 30 Dec 2010, 15:00
by rasmus
Thanks for the patch! Got it working second time around, after actually reading the lines of code :-)

You might want to change the last line of the wiki code to:

Code: Select all

patch --verbose -p0 < /usr/share/web-admin/gui_hdd.patch 
Instead of the current, with "/path/to/".

//Rasmus

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Jan 2011, 11:18
by johannes
Thanks again, done. :)

Re: Display the HDD temperature in the web portal [patch]

Posted: 10 Jan 2011, 22:54
by supermagnum
I discovered that issuing the following command ( according to the wiki ) results in:
patch --verbose -p0 < /usr/share/web-admin/
patch: **** read error : Is a directory


The CORRECT command is:
patch --verbose -p0 < /usr/share/web-admin/gui_hdd.patch

It is not possible to watch the hdd temperature unless you have logged in as admin.