Display the HDD temperature in the web portal [patch]

A collection of tips on howto tweak your Bubba.
[vEX]
Posts: 4
Joined: 06 Nov 2010, 13:49
Location: Sweden

Display the HDD temperature in the web portal [patch]

Post by [vEX] » 06 Nov 2010, 14:02

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:
gui_patch.jpeg
HDD temperature in the portal
gui_patch.jpeg (12.13 KiB) Viewed 12438 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.
Bubba B3 500GB

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

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

Post by johannes » 09 Nov 2010, 10:06

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.
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

[vEX]
Posts: 4
Joined: 06 Nov 2010, 13:49
Location: Sweden

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

Post by [vEX] » 09 Nov 2010, 13:38

Feel free to add/move it to the wiki, I'm too lazy to sign up for (yet) another service.
Bubba B3 500GB

DanielM
Posts: 637
Joined: 28 Mar 2008, 06:37
Location: Sweden

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

Post by DanielM » 09 Nov 2010, 13:49

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

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

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

Post by johannes » 09 Nov 2010, 14:08

We might do that, but until then... I,ll move it to the wiki soon then, thanks!
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

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

Post by johannes » 10 Nov 2010, 03:11

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! :)
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

stompertje
Posts: 15
Joined: 16 Jul 2008, 16:23

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

Post by stompertje » 10 Nov 2010, 03:23

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,' ',' ');

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

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

Post by johannes » 10 Nov 2010, 04:00

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?
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

stompertje
Posts: 15
Joined: 16 Jul 2008, 16:23

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

Post by stompertje » 10 Nov 2010, 04:42

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.

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

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

Post by johannes » 10 Nov 2010, 05:37

Ok, update the wiki post with a new patch file that works.

http://wiki.excito.org/wiki/index.php/D ... _interface
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

philgaskin
Posts: 51
Joined: 12 Oct 2010, 12:18
Location: United Kingdom

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

Post by philgaskin » 10 Nov 2010, 16:57

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.

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

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

Post by johannes » 11 Nov 2010, 02:13

Great thanks. Added to the wiki article.
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

rasmus
Posts: 5
Joined: 30 Dec 2010, 13:40

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

Post by rasmus » 30 Dec 2010, 15:00

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
B3 Wifi - 2 TB

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

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

Post by johannes » 10 Jan 2011, 11:18

Thanks again, done. :)
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

supermagnum
Posts: 57
Joined: 19 Oct 2010, 05:27

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

Post by supermagnum » 10 Jan 2011, 22:54

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.

Post Reply