/** * get all information from all configured ups and store output in internal array */ 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); } 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) { CommonFunctions::executeProgram('upsc', trim($ups_name) . '@' . trim($ups), $temp, PSI_DEBUG); if (!empty($temp)) { $this->_output[trim($ups_name) . '@' . trim($ups)] = $temp; } } } } else { //use default if address and port not defined CommonFunctions::executeProgram('upsc', '-l', $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; } } } }
/** * get all information from all configured ups and store output in internal array */ public function __construct() { parent::__construct(); CommonFunctions::executeProgram('pmset', '-g batt', $temp); if (!empty($temp)) { $this->_output[] = $temp; } }
/** * get all information from all configured ups in config.php and store output in internal array */ public function __construct() { parent::__construct(); CommonFunctions::executeProgram('powersoftplus', '-p', $temp); if (!empty($temp)) { $this->_output[] = $temp; } }
/** * get all information from all configured ups and store output in internal array */ public function __construct() { parent::__construct(); CommonFunctions::executeProgram('upsc', '-l', $output); $ups_names = preg_split("/\n/", $output, -1, PREG_SPLIT_NO_EMPTY); foreach ($ups_names as $value) { CommonFunctions::executeProgram('upsc', $value, $temp); $this->_output[$value] = $temp; } }
/** * 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; } } }
/** * get all information from all configured ups in config.php and store output in internal array */ 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); } else { $upses = array(PSI_UPS_APCUPSD_LIST); } foreach ($upses as $ups) { CommonFunctions::executeProgram('apcaccess', 'status ' . trim($ups), $temp); if (!empty($temp)) { $this->_output[] = $temp; } } } }
/** * get all information from all configured ups in phpsysinfo.ini and store output in internal array */ public function __construct() { parent::__construct(); switch (strtolower(PSI_UPS_SNMPUPS_ACCESS)) { case 'command': 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); } foreach ($upss as $ups) { CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -r 1 " . $ups . " .1.3.6.1.4.1.318.1.1.1.1", $buffer, PSI_DEBUG); if (strlen($buffer) > 0) { $this->_output[$ups] = $buffer; $buffer = ""; CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -r 1 " . $ups . " .1.3.6.1.4.1.318.1.1.1.2", $buffer, PSI_DEBUG); if (strlen($buffer) > 0) { $this->_output[$ups] .= "\n" . $buffer; } $buffer = ""; CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -r 1 " . $ups . " .1.3.6.1.4.1.318.1.1.1.3", $buffer, PSI_DEBUG); if (strlen($buffer) > 0) { $this->_output[$ups] .= "\n" . $buffer; } $buffer = ""; CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -r 1 " . $ups . " .1.3.6.1.4.1.318.1.1.1.4", $buffer, PSI_DEBUG); if (strlen($buffer) > 0) { $this->_output[$ups] .= "\n" . $buffer; } } } } break; case 'php-snmp': if (!extension_loaded("snmp")) { $this->error->addError("Requirements error", "SNMPups plugin requires the snmp extension to php in order to work properly"); break; } snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); snmp_set_oid_output_format(SNMP_OID_OUTPUT_NUMERIC); 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); } foreach ($upss as $ups) { if (!PSI_DEBUG) { restore_error_handler(); /* default error handler */ $old_err_rep = error_reporting(); error_reporting(E_ERROR); /* fatal errors only */ } $bufferarr = snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.1", 1000000, 1); if (!PSI_DEBUG) { error_reporting($old_err_rep); /* restore error level */ set_error_handler('errorHandlerPsi'); /* restore error handler */ } if (!empty($bufferarr)) { $buffer = ""; foreach ($bufferarr as $id => $string) { $buffer .= $id . " = " . $string . "\n"; } if (!PSI_DEBUG) { restore_error_handler(); /* default error handler */ $old_err_rep = error_reporting(); error_reporting(E_ERROR); /* fatal errors only */ } $bufferarr2 = snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.2", 1000000, 1); $bufferarr3 = snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.3", 1000000, 1); $bufferarr4 = snmprealwalk($ups, "public", ".1.3.6.1.4.1.318.1.1.1.4", 1000000, 1); if (!PSI_DEBUG) { error_reporting($old_err_rep); /* restore error level */ set_error_handler('errorHandlerPsi'); /* restore error handler */ } if (!empty($bufferarr2)) { 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"; } } if (strlen(trim($buffer)) > 0) { $this->_output[$ups] = $buffer; } } } } break; default: $this->error->addError("switch(PSI_UPS_SNMPUPS_ACCESS)", "Bad SNMPups configuration in phpsysinfo.ini"); break; } }