PHP Classes

PHP Linux ACPI Monitor: Get Linux hardware status via ACPI

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 63%Total: 177 All time: 8,749 This week: 140Up
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: 274536 in Argentina Argentina
Week rank: 215 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 (1)  
  • screenshot
  Files folder image Files (3)  
File Role Description
Plain text file class.php Class class file
Accessible without login Plain text file index.php Example front end

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:177
This week:0
All time:8,749
This week:140Up
User Ratings User Comments (1)
 All time
Utility:90%StarStarStarStarStar
Consistency:90%StarStarStarStarStar
Documentation:-
Examples:90%StarStarStarStarStar
Tests:-
Videos:-
Overall:63%StarStarStarStar
Rank:866
 
Thats a very good class to show Linux hardware status :-)
8 years ago (José Filipe Lopes Santos)
70%StarStarStarStar