Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Best way to allow PHP/Apache to access /usr/bin/sensors
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Philippe23
Tux's lil' helper
Tux's lil' helper


Joined: 20 Dec 2006
Posts: 88
Location: Rome, NY

PostPosted: Mon Oct 01, 2012 3:26 pm    Post subject: Best way to allow PHP/Apache to access /usr/bin/sensors Reply with quote

I've got a PHP script that runs /usr/bin/sensors show the temperature of the CPU on a webpage live. I've upgraded to a Hardened kernel that doesn't allow this anymore.

What's the best way to allow this access? sudo? Is there a way to do it with ACLs? Something else?
Back to top
View user's profile Send private message
PeGa!
n00b
n00b


Joined: 13 May 2005
Posts: 62
Location: Capital Federal, Buenos Aires, Argentina

PostPosted: Wed Oct 03, 2012 5:06 am    Post subject: Reply with quote

Hi,

If you don't want to install a fully-fledged system monitor like Nagios or Cacti or something like that (IMHO they are flexible and robust but also a bit complex), you may simply read the data that sensors see.

This is an example in my home box.

Code:
box sys # cat devices/pci0000:00/0000:00:18.3/temp1_input
56500
box sys # sensors
k10temp-pci-00c3
Adapter: PCI adapter
temp1:        +56.5°C  (high = +70.0°C)
                       (crit = +99.5°C, hyst = +97.5°C)


You see, i've got a k10temp-pci-00c3 heat sensor, and I read the content of /sys/devices/pci0000:00/0000:00:18.3/temp1_input, and it gave me the same information (well, "unformatted") that sensors. I think that if you _ONLY_ want CPU heat data, that's the cleanest way you've got.


Best regards,

Paul.
_________________
If it moves, it has an ebuild.

Adopt an unanswered post.
Back to top
View user's profile Send private message
Philippe23
Tux's lil' helper
Tux's lil' helper


Joined: 20 Dec 2006
Posts: 88
Location: Rome, NY

PostPosted: Wed Oct 03, 2012 11:57 am    Post subject: Reply with quote

Hey Paul,

Thanks for your answer. (I actually do have Munin installed, but it only updates every minute or so: this is a more real-time reading.)

So that morphs the question to: What's the best way to allow PHP/Apache to access that file?
Back to top
View user's profile Send private message
PeGa!
n00b
n00b


Joined: 13 May 2005
Posts: 62
Location: Capital Federal, Buenos Aires, Argentina

PostPosted: Thu Oct 04, 2012 11:01 am    Post subject: Reply with quote

Hi!

According to some tests I did, apache user can access that file without any issue. This means that PHP also can access it, so everything is reduced to a fopen instruction ;)

Hth,

Paul.
_________________
If it moves, it has an ebuild.

Adopt an unanswered post.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum