PHP Classes

PHP Linux ACPI Monitor: Get Linux hardware status via ACPI

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 70%Total: 175 All time: 8,750 This week: 190Up
Version License PHP version Categories
lacpim 1GNU Free Document...5PHP 5, Unix, Hardware
Description 

Author

This is a simple class that can get Linux hardware status via ACPI.

It uses the acpi command to query the status of different hardware aspects using ACPI.

Currently it can query the battery charge status, if the computer is connected to AC power, temperature and cooling level, and other details.

Innovation Award
PHP Programming Innovation award nominee
January 2016
Number 10


Prize: One subscription to the PDF edition of the PHP Architect magazine
The standard way to determine the status of hardware on a Linux machine is using ACPI.

This class can retrieve the query the battery charge status, if the computer is connected to AC power, temperature and cooling level, and other details using ACPI.

Manuel Lemos
Picture of Christian Petersen
  Performance   Level  
Name: Christian Petersen <contact>
Classes: 3 packages by
Country: Argentina Argentina
Age: 43
All time rank: 274136 in Argentina Argentina
Week rank: 387 Up4 in Argentina Argentina Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
require_once("class.php");
$monitor = new energyMonitor();
$op = $_POST['option'];
?>

<html>
<title>Linux ACPI Monitor</title>
<head>
<style type="text/css">
body{background-color: black; color: white; text-align: center;}
</style>

</head>

<body>

<div style="width: 100%; float: left; text-align: center;">LINUX ACPI MONITOR</div>

<div style="width: 100%; margin-top: 20px; float: left; text-align: center;">

<div style="margin: auto; width: 35%;">

<div style="float: left; margin-left: 10px;">
<form name="battery" action="index.php" method="post">
<button>BATTERY</button>
<input type="hidden" name="option" value="battery">
</form>
</div>


<div style="float: left; margin-left: 10px;">
<form name="acAdapter" action="index.php" method="post">
<button>AC ADAPTER</button>
<input type="hidden" name="option" value="acAdapter">
</form>
</div>


<div style="float: left; margin-left: 10px;">
<form name="cooling" action="index.php" method="post">
<button>COOLING</button>
<input type="hidden" name="option" value="cooling">
</form>
</div>


<div style="float: left; margin-left: 10px;">
<form name="details" action="index.php" method="post">
<button>DETAILS</button>
<input type="hidden" name="option" value="details">
</form>
</div>


<div style="float: left; margin-left: 10px;">
<form name="all" action="index.php" method="post">
<button>ALL</button>
<input type="hidden" name="option" value="all">
</form>
</div>
</div>

</div>

<div style="width: 100%; float:left; text-align: center; margin-top: 20px;">
<?php
if($op == "" || $op == "all"){
$monitor -> battery();
print
'<br />';
$monitor -> acAdapter();
print
'<br />';
$monitor -> thermal();
print
'<br />';
$monitor -> cooling();
print
'<br />';
$monitor -> details();
}
else if(
$op == "battery"){
$monitor -> battery();
print
'<br />';
}
else if(
$op == "acAdapter"){
$monitor -> acAdapter();
print
'<br />';
}
else if(
$op == "cooling"){
$monitor -> cooling();
print
'<br />';
}
else if(
$op == "details"){
$monitor -> details();
print
'<br />';
}
else{
$monitor -> battery();
print
'<br />';
$monitor -> acAdapter();
print
'<br />';
$monitor -> thermal();
print
'<br />';
$monitor -> cooling();
print
'<br />';
$monitor -> details();
   
}
?>
</div>

</body>
</html>


Screenshots  
  • screenshot
  Files folder image Files  
File Role Description
Plain text file class.php Class class file
Accessible without login Plain text file index.php Example front end

 Version Control Unique User Downloads Download Rankings  
 0%
Total:175
This week:0
All time:8,750
This week:190Up
User Ratings User Comments (1)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:-
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:70%StarStarStarStar
Rank:387
 
Thats a very good class to show Linux hardware status :-)
7 years ago (José Filipe Lopes Santos)
70%StarStarStarStar