????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.217 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/phpsysinfo/includes/ups/ |
Upload File : |
<?php
/**
* Apcupsd class
*
* PHP version 5
*
* @category PHP
* @package PSI_UPS
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
* @copyright 2009 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @version SVN: $Id: class.Apcupsd.inc.php 417 2011-01-14 12:57:16Z jacky672 $
* @link http://phpsysinfo.sourceforge.net
*/
/**
* getting ups information from apcupsd program
*
* @category PHP
* @package PSI_UPS
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
* @author Artem Volk <artvolk@mail.ru>
* @copyright 2009 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class Apcupsd extends UPS
{
/**
* internal storage for all gathered data
*
* @var Array
*/
private $_output = array();
/**
* get all information from all configured ups in config.php and store output in internal array
*/
public function __construct()
{
parent::__construct();
$upses = preg_split('/,/', PSI_UPS_APCUPSD_LIST, -1, PREG_SPLIT_NO_EMPTY);
foreach ($upses as $ups) {
CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp);
if (! empty($temp)) {
$this->_output[] = $temp;
}
}
}
/**
* parse the input and store data in resultset for xml generation
*
* @return Void
*/
private function _info()
{
foreach ($this->_output as $ups) {
$dev = new UPSDevice();
// General info
if (preg_match('/^UPSNAME\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setName(trim($data[1]));
}
if (preg_match('/^MODEL\s*:\s*(.*)$/m', $ups, $data)) {
$model=trim($data[1]);
if (preg_match('/^APCMODEL\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setModel($model.' ('.trim($data[1]).')');
} else {
$dev->setModel($model);
}
}
if (preg_match('/^UPSMODE\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setMode(trim($data[1]));
}
if (preg_match('/^STARTTIME\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setStartTime(trim($data[1]));
}
if (preg_match('/^STATUS\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setStatus(trim($data[1]));
}
if (preg_match('/^ITEMP\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setTemperatur(trim($data[1]));
}
// Outages
if (preg_match('/^NUMXFERS\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setOutages(trim($data[1]));
}
if (preg_match('/^LASTXFER\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setLastOutage(trim($data[1]));
}
if (preg_match('/^XOFFBATT\s*:\s*(.*)$/m', $ups, $data)) {
$dev->setLastOutageFinish(trim($data[1]));
}
// Line
if (preg_match('/^LINEV\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) {
$dev->setLineVoltage(trim($data[1]));
}
if (preg_match('/^LOADPCT\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) {
$dev->setLoad(trim($data[1]));
}
// Battery
if (preg_match('/^BATTV\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) {
$dev->setBatteryVoltage(trim($data[1]));
}
if (preg_match('/^BCHARGE\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) {
$dev->setBatterCharge(trim($data[1]));
}
if (preg_match('/^TIMELEFT\s*:\s*(\d*\.\d*)(.*)$/m', $ups, $data)) {
$dev->setTimeLeft(trim($data[1]));
}
$this->upsinfo->setUpsDevices($dev);
}
}
/**
* get the information
*
* @see PSI_Interface_UPS::build()
*
* @return Void
*/
function build()
{
$this->_info();
}
}
?>