/web/acc/phpsysinfo/includes/ups/class.apcupsd.inc.php |
---|
39,27 → 39,54 |
public function __construct() |
{ |
parent::__construct(); |
if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) { |
$upses = eval(PSI_UPS_APCUPSD_LIST); |
if (!defined('PSI_UPS_APCUPSD_ACCESS')) { |
define('PSI_UPS_APCUPSD_ACCESS', false); |
} |
switch (strtolower(PSI_UPS_APCUPSD_ACCESS)) { |
case 'data': |
if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) { |
$upss = eval(PSI_UPS_APCUPSD_LIST); |
} else { |
$upss = array(PSI_UPS_APCUPSD_LIST); |
} |
} else { |
$upses = array(PSI_UPS_APCUPSD_LIST); |
$upss = array('UPS'); |
} |
foreach ($upses as $ups) { |
CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp); |
$un = 0; |
foreach ($upss as $ups) { |
$temp = ""; |
CommonFunctions::rftsdata("upsapcupsd{$un}.tmp", $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
$un++; |
} |
} else { //use default if address and port not defined |
if (!defined('PSI_EMU_HOSTNAME')) { |
CommonFunctions::executeProgram('apcaccess', 'status', $temp); |
} else { |
CommonFunctions::executeProgram('apcaccess', 'status '.PSI_EMU_HOSTNAME, $temp); |
break; |
default: |
if (defined('PSI_UPS_APCUPSD_LIST') && is_string(PSI_UPS_APCUPSD_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_APCUPSD_LIST)) { |
$upses = eval(PSI_UPS_APCUPSD_LIST); |
} else { |
$upses = array(PSI_UPS_APCUPSD_LIST); |
} |
foreach ($upses as $ups) { |
$temp = ""; |
CommonFunctions::executeProgram('apcaccess', 'status '.trim($ups), $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
} |
} else { //use default if address and port not defined |
if (!defined('PSI_EMU_HOSTNAME')) { |
CommonFunctions::executeProgram('apcaccess', 'status', $temp); |
} else { |
CommonFunctions::executeProgram('apcaccess', 'status '.PSI_EMU_HOSTNAME, $temp); |
} |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
} |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
} |
} |
66,7 → 93,7 |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return Void |
* @return void |
*/ |
private function _info() |
{ |
143,7 → 170,7 |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
* @return void |
*/ |
public function build() |
{ |
/web/acc/phpsysinfo/includes/ups/class.nut.inc.php |
---|
40,35 → 40,64 |
public function __construct() |
{ |
parent::__construct(); |
if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) { |
$upses = eval(PSI_UPS_NUT_LIST); |
if (!defined('PSI_UPS_NUT_ACCESS')) { |
define('PSI_UPS_NUT_ACCESS', false); |
} |
switch (strtolower(PSI_UPS_NUT_ACCESS)) { |
case 'data': |
if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) { |
$upss = eval(PSI_UPS_NUT_LIST); |
} else { |
$upss = array(PSI_UPS_NUT_LIST); |
} |
} else { |
$upses = array(PSI_UPS_NUT_LIST); |
$upss = array('UPS'); |
} |
foreach ($upses as $ups) { |
CommonFunctions::executeProgram('upsc', '-l '.trim($ups), $output, PSI_DEBUG); |
$un = 0; |
foreach ($upss as $ups) { |
$temp = ""; |
CommonFunctions::rftsdata("upsnut{$un}.tmp", $temp); |
if (! empty($temp)) { |
$this->_output[$ups] = $temp; |
} |
$un++; |
} |
break; |
default: |
if (defined('PSI_UPS_NUT_LIST') && is_string(PSI_UPS_NUT_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_NUT_LIST)) { |
$upses = eval(PSI_UPS_NUT_LIST); |
} else { |
$upses = array(PSI_UPS_NUT_LIST); |
} |
foreach ($upses as $ups) { |
CommonFunctions::executeProgram('upsc', '-l '.trim($ups), $output, PSI_DEBUG); |
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($ups_names as $ups_name) { |
$upsname = trim($ups_name).'@'.trim($ups); |
$temp = ""; |
CommonFunctions::executeProgram('upsc', $upsname, $temp, PSI_DEBUG); |
if (! empty($temp)) { |
$this->_output[$upsname] = $temp; |
} |
} |
} |
} else { //use default if address and port not defined |
if (!defined('PSI_EMU_HOSTNAME')) { |
CommonFunctions::executeProgram('upsc', '-l', $output, PSI_DEBUG); |
} else { |
CommonFunctions::executeProgram('upsc', '-l '.PSI_EMU_HOSTNAME, $output, PSI_DEBUG); |
} |
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($ups_names as $ups_name) { |
CommonFunctions::executeProgram('upsc', trim($ups_name).'@'.trim($ups), $temp, PSI_DEBUG); |
$temp = ""; |
CommonFunctions::executeProgram('upsc', trim($ups_name), $temp, PSI_DEBUG); |
if (! empty($temp)) { |
$this->_output[trim($ups_name).'@'.trim($ups)] = $temp; |
$this->_output[trim($ups_name)] = $temp; |
} |
} |
} |
} else { //use default if address and port not defined |
if (!defined('PSI_EMU_HOSTNAME')) { |
CommonFunctions::executeProgram('upsc', '-l', $output, PSI_DEBUG); |
} else { |
CommonFunctions::executeProgram('upsc', '-l '.PSI_EMU_HOSTNAME, $output, PSI_DEBUG); |
} |
$ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY); |
foreach ($ups_names as $ups_name) { |
CommonFunctions::executeProgram('upsc', trim($ups_name), $temp, PSI_DEBUG); |
if (! empty($temp)) { |
$this->_output[trim($ups_name)] = $temp; |
} |
} |
} |
} |
99,6 → 128,9 |
if (isset($ups_data['ups.status'])) { |
$dev->setStatus($ups_data['ups.status']); |
} |
if (isset($ups_data['ups.beeper.status'])) { |
$dev->setBeeperStatus($ups_data['ups.beeper.status']); |
} |
//Line |
if (isset($ups_data['input.voltage'])) { |
137,7 → 169,7 |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
* @return void |
*/ |
public function build() |
{ |
/web/acc/phpsysinfo/includes/ups/class.pmset.inc.php |
---|
38,8 → 38,11 |
public function __construct() |
{ |
parent::__construct(); |
if (PSI_OS == 'Darwin') { |
$temp = ""; |
if (defined('PSI_UPS_PMSET_ACCESS') && (strtolower(trim(PSI_UPS_PMSET_ACCESS))==='data')) { |
if (CommonFunctions::rftsdata('upspmset.tmp', $temp)) { |
$this->_output[] = $temp; |
} |
} elseif (PSI_OS == 'Darwin') { |
if (CommonFunctions::executeProgram('pmset', '-g batt', $temp) && !empty($temp)) { |
$this->_output[] = $temp; |
} |
89,7 → 92,7 |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
* @return void |
*/ |
public function build() |
{ |
/web/acc/phpsysinfo/includes/ups/class.powersoftplus.inc.php |
---|
38,7 → 38,12 |
public function __construct() |
{ |
parent::__construct(); |
if (PSI_OS == 'Linux') { |
if (defined('PSI_UPS_POWERSOFTPLUS_ACCESS') && (strtolower(trim(PSI_UPS_POWERSOFTPLUS_ACCESS))==='data')) { |
CommonFunctions::rftsdata('upspowersoftplus.tmp', $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
} elseif (PSI_OS == 'Linux') { |
CommonFunctions::executeProgram('powersoftplus', '-p', $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
49,7 → 54,7 |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return Void |
* @return void |
*/ |
private function _info() |
{ |
71,11 → 76,11 |
if (preg_match('/^Current UPS state\s*:\s*(.*)$/m', $ups, $data)) { |
$dev->setStatus(trim($data[1])); |
} |
if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]$/m', $ups, $data)) { |
if (preg_match('/^Output load\s*:\s*(.*)\s\[\%\]\r?$/m', $ups, $data)) { |
$load = trim($data[1]); |
} |
//wrong Output load issue |
if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]$/m', $ups, $data)) { |
if (($load == 0) && ($maxpwr != 0) && preg_match('/^Effective power\s*:\s*(.*)\s\[W\]\r?$/m', $ups, $data)) { |
$load = 100.0*trim($data[1])/$maxpwr; |
} |
if ($load != null) { |
82,7 → 87,7 |
$dev->setLoad($load); |
} |
// Battery |
if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) { |
if (preg_match('/^Battery voltage\s*:\s*(.*)\s\[Volt\]\r?$/m', $ups, $data)) { |
$dev->setBatteryVoltage(trim($data[1])); |
} |
if (preg_match('/^Battery state\s*:\s*(.*)$/m', $ups, $data)) { |
93,10 → 98,10 |
} |
} |
// Line |
if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]$/m', $ups, $data)) { |
if (preg_match('/^Input voltage\s*:\s*(.*)\s\[Volt\]\r?$/m', $ups, $data)) { |
$dev->setLineVoltage(trim($data[1])); |
} |
if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]$/m', $ups, $data)) { |
if (preg_match('/^Input frequency\s*:\s*(.*)\s\[Hz\]\r?$/m', $ups, $data)) { |
$dev->setLineFrequency(trim($data[1])); |
} |
$this->upsinfo->setUpsDevices($dev); |
108,7 → 113,7 |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
* @return void |
*/ |
public function build() |
{ |
/web/acc/phpsysinfo/includes/ups/class.snmpups.inc.php |
---|
39,7 → 39,30 |
public function __construct() |
{ |
parent::__construct(); |
if (!defined('PSI_UPS_SNMPUPS_ACCESS')) { |
define('PSI_UPS_SNMPUPS_ACCESS', 'php-snmp'); |
} |
switch (strtolower(PSI_UPS_SNMPUPS_ACCESS)) { |
case 'data': |
if (defined('PSI_UPS_SNMPUPS_LIST') && is_string(PSI_UPS_SNMPUPS_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_SNMPUPS_LIST)) { |
$upss = eval(PSI_UPS_SNMPUPS_LIST); |
} else { |
$upss = array(PSI_UPS_SNMPUPS_LIST); |
} |
} else { |
$upss = array('UPS'); |
} |
$un = 0; |
foreach ($upss as $ups) { |
$temp = ""; |
CommonFunctions::rftsdata("upssnmpups{$un}.tmp", $temp); |
if (! empty($temp)) { |
$this->_output[] = $temp; |
} |
$un++; |
} |
break; |
case 'command': |
if (defined('PSI_UPS_SNMPUPS_LIST') && is_string(PSI_UPS_SNMPUPS_LIST)) { |
if (preg_match(ARRAY_EXP, PSI_UPS_SNMPUPS_LIST)) { |
48,6 → 71,7 |
$upss = array(PSI_UPS_SNMPUPS_LIST); |
} |
foreach ($upss as $ups) { |
$buffer = ""; |
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$ups." .1.3.6.1.4.1.318.1.1.1.1", $buffer, PSI_DEBUG); |
if (strlen($buffer) > 0) { |
$this->_output[$ups] = $buffer; |
116,11 → 140,12 |
foreach ($bufferarr2 as $id=>$string) { |
$buffer .= $id." = ".$string."\n"; |
} |
} |
if (! empty($bufferarr3)) { |
foreach ($bufferarr3 as $id=>$string) { |
$buffer .= $id." = ".$string."\n"; |
} |
} } |
} |
if (! empty($bufferarr4)) { |
foreach ($bufferarr4 as $id=>$string) { |
$buffer .= $id." = ".$string."\n"; |
135,7 → 160,6 |
break; |
default: |
$this->error->addError("switch(PSI_UPS_SNMPUPS_ACCESS)", "Bad SNMPups configuration in phpsysinfo.ini"); |
break; |
} |
} |
142,7 → 166,7 |
/** |
* parse the input and store data in resultset for xml generation |
* |
* @return Void |
* @return void |
*/ |
private function _info() |
{ |
163,44 → 187,28 |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.4\.1\.1\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
switch (trim($data[1])) { |
case 1: $status = "Unknown"; |
break; |
case 2: $status = "On Line"; |
break; |
case 3: $status = "On Battery"; |
break; |
case 4: $status = "On Smart Boost"; |
break; |
case 5: $status = "Timed Sleeping"; |
break; |
case 6: $status = "Software Bypass"; |
break; |
case 7: $status = "Off"; |
break; |
case 8: $status = "Rebooting"; |
break; |
case 9: $status = "Switched Bypass"; |
break; |
case 10:$status = "Hardware Failure Bypass"; |
break; |
case 11:$status = "Sleeping Until Power Returns"; |
break; |
case 12:$status = "On Smart Trim"; |
break; |
default: $status = "Unknown state (".trim($data[1]).")"; |
break; |
case 1: $status = "Unknown"; break; |
case 2: $status = "On Line"; break; |
case 3: $status = "On Battery"; break; |
case 4: $status = "On Smart Boost"; break; |
case 5: $status = "Timed Sleeping"; break; |
case 6: $status = "Software Bypass"; break; |
case 7: $status = "Off"; break; |
case 8: $status = "Rebooting"; break; |
case 9: $status = "Switched Bypass"; break; |
case 10:$status = "Hardware Failure Bypass"; break; |
case 11:$status = "Sleeping Until Power Returns"; break; |
case 12:$status = "On Smart Trim"; break; |
default: $status = "Unknown state (".trim($data[1]).")"; |
} |
} |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.1\.1\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
$batstat = ""; |
switch (trim($data[1])) { |
case 1: $batstat = "Battery Unknown"; |
break; |
case 2: break; |
case 3: $batstat = "Battery Low"; |
break; |
default: $batstat = "Battery Unknown (".trim($data[1]).")"; |
break; |
case 1: $batstat = "Battery Unknown"; break; |
case 2: break; |
case 3: $batstat = "Battery Low"; break; |
default: $batstat = "Battery Unknown (".trim($data[1]).")"; |
} |
if ($batstat !== "") { |
if ($status !== "") { |
213,11 → 221,9 |
if (preg_match('/^\.1\.3\.6\.1\.4\.1\.318\.1\.1\.1\.2\.2\.4\.0 = INTEGER:\s(.*)/m', $result, $data)) { |
$batstat = ""; |
switch (trim($data[1])) { |
case 1: break; |
case 2: $batstat = "Replace Battery"; |
break; |
default: $batstat = "Replace Battery (".trim($data[1]).")"; |
break; |
case 1: break; |
case 2: $batstat = "Replace Battery"; break; |
default: $batstat = "Replace Battery (".trim($data[1]).")"; |
} |
if ($batstat !== "") { |
if ($status !== "") { |
277,7 → 283,7 |
* |
* @see PSI_Interface_UPS::build() |
* |
* @return Void |
* @return void |
*/ |
public function build() |
{ |