View previous topic :: View next topic |
Author |
Message |
Philippe23 Tux's lil' helper
Joined: 20 Dec 2006 Posts: 130 Location: Central NY
|
Posted: Mon Oct 01, 2012 3:26 pm Post subject: Best way to allow PHP/Apache to access /usr/bin/sensors |
|
|
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 |
|
|
PeGa! Tux's lil' helper
Joined: 13 May 2005 Posts: 104 Location: Capital Federal, Buenos Aires, Argentina
|
Posted: Wed Oct 03, 2012 5:06 am Post subject: |
|
|
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 needs an ebuild.
Adopt an unanswered post. |
|
Back to top |
|
|
Philippe23 Tux's lil' helper
Joined: 20 Dec 2006 Posts: 130 Location: Central NY
|
Posted: Wed Oct 03, 2012 11:57 am Post subject: |
|
|
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 |
|
|
PeGa! Tux's lil' helper
Joined: 13 May 2005 Posts: 104 Location: Capital Federal, Buenos Aires, Argentina
|
Posted: Thu Oct 04, 2012 11:01 am Post subject: |
|
|
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 needs an ebuild.
Adopt an unanswered post. |
|
Back to top |
|
|
|