Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2775 → Rev 2780

/web/acc/phpsysinfo/plugins/raid/raid_bootstrap.html
0,0 → 1,15
<div class="col-lg-12" id="block_raid" style="display:none;">
<div class="card" id="panel_raid" style="display:none;">
<div class="card-header"><span class="lang_plugin_raid_001">RAID Status</span>
<div id="reload_raid" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="raid" class="table borderless table-sm">
<tbody id="raid-data">
</tbody>
</table>
</div>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/smart/class.smart.inc.php
0,0 → 1,365
<?php
/**
* SMART plugin, which displays all SMART informations available
*
* @category PHP
* @package PSI_Plugin_SMART
* @author Antoine Bertin <diaoulael@users.sourceforge.net>
* @copyright 2009 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version Release: 3.0
* @link http://phpsysinfo.sourceforge.net
*/
class SMART extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
*/
private $_filecontent = array();
 
/**
* variable, which holds the result before the xml is generated out of this array
* @var array
*/
private $_result = array();
 
/**
* variable, which holds PSI_PLUGIN_SMART_IDS well formated datas
* @var array
*/
private $_ids = array();
 
/**
* read the data into an internal array and also call the parent constructor
*
* @param String $enc target encoding
*/
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_SMART_ACCESS)) {
case 'wmi':
case 'command':
case 'data':
if (defined('PSI_PLUGIN_SMART_DEVICES') && is_string(PSI_PLUGIN_SMART_DEVICES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_SMART_DEVICES)) {
$disks = eval(PSI_PLUGIN_SMART_DEVICES);
} else {
$disks = array(PSI_PLUGIN_SMART_DEVICES);
}
if (defined('PSI_PLUGIN_SMART_IDS') && is_string(PSI_PLUGIN_SMART_IDS)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_SMART_IDS)) {
$fullIds = eval(PSI_PLUGIN_SMART_IDS);
} else {
$fullIds = array(PSI_PLUGIN_SMART_IDS);
}
foreach ($fullIds as $fullId) {
$arrFullId = preg_split('/-/', $fullId);
$this->_ids[intval($arrFullId[0])] = strtolower($arrFullId[1]);
if (!empty($arrFullId[2]))
$this->_ids[intval($arrFullId[2])] = "#replace-".intval($arrFullId[0]);
}
}
}
break;
default:
$this->global_error->addConfigError("__construct()", "[smart] ACCESS");
break;
}
 
switch (strtolower(PSI_PLUGIN_SMART_ACCESS)) {
case 'wmi':
if (PSI_OS == 'WINNT') {
$asd_wmi = null;
try {
$objLocator = new COM('WbemScripting.SWbemLocator');
$wmi = $objLocator->ConnectServer('', 'root\wmi');
$asd_wmi = CommonFunctions::getWMI($wmi, 'MSStorageDriver_ATAPISmartData', array('VendorSpecific'));
} catch (Exception $e) {
}
foreach ($asd_wmi as $_nr=>$asd) {
$_name = "/dev/sd".chr(97+$_nr);
if (array_search($_name, $disks) !== false) {
$this->_filecontent[$_name] = "\nVendor Specific SMART Attributes with Thresholds\n";
$this->_filecontent[$_name] .= "ID# _ATTRIBUTE_NAME_ FLAG VALUE WORST RAW_VALUE\n";
$asdvs = $asd['VendorSpecific'];
for ($c = 2; $c < count($asdvs); $c += 12) {
//Attribute values 0x00, 0xff are invalid
$id = $asdvs[$c];
if (($id != 0) && ($id != 255)) {
switch ($id) {
case 3:
//raw16(avg16)
$this->_filecontent[$_name] .= $id." ID".$id." 0x".substr("0".dechex($asdvs[$c+2]),-2).substr("0".dechex($asdvs[$c+1]),-2)." ".substr("00".$asdvs[$c+3],-3)." ".substr("00".$asdvs[$c+4],-3)." ".($asdvs[$c+5]+256*$asdvs[$c+6])."\n";
break;
case 5:
case 196:
//raw16(raw16)
$this->_filecontent[$_name] .= $id." ID".$id." 0x".substr("0".dechex($asdvs[$c+2]),-2).substr("0".dechex($asdvs[$c+1]),-2)." ".substr("00".$asdvs[$c+3],-3)." ".substr("00".$asdvs[$c+4],-3)." ".($asdvs[$c+5]+256*$asdvs[$c+6])."\n";
break;
case 9:
case 240:
//raw24(raw8)
$this->_filecontent[$_name] .= $id." ID".$id." 0x".substr("0".dechex($asdvs[$c+2]),-2).substr("0".dechex($asdvs[$c+1]),-2)." ".substr("00".$asdvs[$c+3],-3)." ".substr("00".$asdvs[$c+4],-3)." ".($asdvs[$c+5]+256*$asdvs[$c+6]+65536*$asdvs[$c+7])."\n";
break;
case 190:
case 194:
//tempminmax
$this->_filecontent[$_name] .= $id." ID".$id." 0x".substr("0".dechex($asdvs[$c+2]),-2).substr("0".dechex($asdvs[$c+1]),-2)." ".substr("00".$asdvs[$c+3],-3)." ".substr("00".$asdvs[$c+4],-3)." ".($asdvs[$c+5]+256*$asdvs[$c+6])."\n";
break;
default:
//raw48
$this->_filecontent[$_name] .= $id." ID".$id." 0x".substr("0".dechex($asdvs[$c+2]),-2).substr("0".dechex($asdvs[$c+1]),-2)." ".substr("00".$asdvs[$c+3],-3)." ".substr("00".$asdvs[$c+4],-3)." ".($asdvs[$c+5]+256*$asdvs[$c+6]+65536*$asdvs[$c+7]+16777216*$asdvs[$c+8])."\n";
break;
}
}
}
$this->_filecontent[$_name] .= "SMART Error Log Version";
}
}
}
break;
case 'command':
foreach ($disks as $disk) {
if (trim($disk) != "") {
$diskdev = "";
if (preg_match("/\s*\(([^\(\(]*)\)\s*(.*)/", $disk, $devdisk)) {
$diskname = trim($devdisk[2]);
if (trim($devdisk[1]) != "") {
$diskdev = "--device ".preg_replace('/\./', ',', trim($devdisk[1]));
}
} else {
$diskname = trim($disk);
}
$buffer = "";
if (trim($diskname != "") && (CommonFunctions::executeProgram('smartctl', '--all'.' '.$diskdev.' '.$diskname, $buffer, PSI_DEBUG))) {
$this->_filecontent[trim($disk)] = $buffer;
}
}
}
break;
case 'data':
$dn=0;
foreach ($disks as $disk) {
$buffer="";
if (CommonFunctions::rfts(PSI_APP_ROOT."/data/smart{$dn}.txt", $buffer) && !empty($buffer)) {
$this->_filecontent[$disk] = $buffer;
}
$dn++;
}
break;
}
}
 
/**
* doing all tasks to get the required informations that the plugin needs
* result is stored in an internal array
*
* @return void
*/
public function execute()
{
if (empty($this->_filecontent) || empty($this->_ids)) {
return;
}
foreach ($this->_filecontent as $disk=>$result) {
// set the start and end offset in the result string at the beginning and end respectively
// just in case we don't find the two strings, so that it still works as expected.
$startIndex = 0;
$endIndex = 0;
$vendorInfos = "";
 
// locate the beginning string offset for the attributes
if (preg_match('/(Vendor Specific SMART Attributes with Thresholds)/', $result, $matches, PREG_OFFSET_CAPTURE))
$startIndex = $matches[0][1];
 
// locate the end string offset for the attributes, this is usually right before string "SMART Error Log Version" or "SMART Error Log not supported" or "Error SMART Error Log Read failed" (hopefully every output has it!)
if (preg_match('/(SMART Error Log Version)|(SMART Error Log not supported)|(Error SMART Error Log Read failed)/', $result, $matches, PREG_OFFSET_CAPTURE))
$endIndex = $matches[0][1];
 
if ($startIndex && $endIndex && ($endIndex>$startIndex))
$vendorInfos = preg_split("/\n/", substr($result, $startIndex, $endIndex - $startIndex));
 
if (!empty($vendorInfos)) {
$labels = preg_split('/\s+/', $vendorInfos[1]);
foreach ($labels as $k=>$v) {
$labels[$k] = str_replace('#', '', strtolower($v));
}
$i = 0; // Line number
foreach ($vendorInfos as $line) {
$line = preg_replace('/^\s+/', '', $line);
$values = preg_split('/\s+/', $line);
if (count($values) > count($labels)) {
$values = array_slice($values, 0, count($labels), true);
}
$j = 0;
$found = false;
foreach ($values as $value) {
if ((in_array($value, array_keys($this->_ids)) && $labels[$j] == 'id')) {
$arrFullVa = preg_split('/-/', $this->_ids[$value]);
if (($arrFullVa[0]=="#replace") && !empty($arrFullVa[1]))
$value=$arrFullVa[1];
}
if (((in_array($value, array_keys($this->_ids)) && $labels[$j] == 'id') || ($found && (in_array($labels[$j], array_values($this->_ids)))) || ($found && $labels[$j] == 'attribute_name'))) {
$this->_result[$disk][$i][$labels[$j]] = $value;
$found = true;
}
$j++;
}
$i++;
}
} else {
//SCSI and MVMe devices
if (!empty($this->_ids[1]) && ($this->_ids[1]=="raw_value")) {
if (preg_match('/\nread\: (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[7]!=null)) {
$this->_result[$disk][0]['id'] = 1;
$this->_result[$disk][0]['attribute_name'] = "Raw_Read_Error_Rate";
$this->_result[$disk][0]['raw_value'] = trim($values[7]);
}
} elseif (preg_match('/\Media and Data Integrity Errors\: (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[5]!=null)) {
$vals=preg_replace('/,/', '', trim($values[5]));
$this->_result[$disk][0]['id'] = 1;
$this->_result[$disk][0]['attribute_name'] = "Raw_Read_Error_Rate";
$this->_result[$disk][0]['raw_value'] = $vals;
}
}
}
if (!empty($this->_ids[5]) && ($this->_ids[5]=="raw_value")) {
if (preg_match('/\nElements in grown defect list\: (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[5]!=null)) {
$this->_result[$disk][1]['id'] = 5;
$this->_result[$disk][1]['attribute_name'] = "Reallocated_Sector_Ct";
$this->_result[$disk][1]['raw_value'] = trim($values[5]);
}
}
}
if (!empty($this->_ids[9]) && ($this->_ids[9]=="raw_value")) {
if (preg_match('/\n +number of hours powered up = (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[7]!=null)) {
$vals=preg_split('/[,\.]/', trim($values[7]));
$this->_result[$disk][2]['id'] = 9;
$this->_result[$disk][2]['attribute_name'] = "Power_On_Hours";
$this->_result[$disk][2]['raw_value'] = $vals[0];
}
} elseif (preg_match('/\nPower On Hours\: (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[3]!=null)) {
$vals=preg_replace('/,/', '', trim($values[3]));
$this->_result[$disk][2]['id'] = 9;
$this->_result[$disk][2]['attribute_name'] = "Power_On_Hours";
$this->_result[$disk][2]['raw_value'] = $vals;
}
}
}
if (!empty($this->_ids[194]) && ($this->_ids[194]=="raw_value")) {
if (preg_match('/\nCurrent Drive Temperature\: (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[3]!=null)) {
$this->_result[$disk][3]['id'] = 194;
$this->_result[$disk][3]['attribute_name'] = "Temperature_Celsius";
$this->_result[$disk][3]['raw_value'] = trim($values[3]);
}
} elseif (preg_match('/\nTemperature\: (.*) Celsius/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[1]!=null)) {
$this->_result[$disk][3]['id'] = 194;
$this->_result[$disk][3]['attribute_name'] = "Temperature_Celsius";
$this->_result[$disk][3]['raw_value'] = trim($values[1]);
}
}
}
if (!empty($this->_ids[12]) && ($this->_ids[12]=="raw_value")) {
if (preg_match('/\nPower Cycles\: (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[2]!=null)) {
$vals=preg_replace('/,/', '', trim($values[2]));
$this->_result[$disk][4]['id'] = 12;
$this->_result[$disk][4]['attribute_name'] = "Power_Cycle_Count";
$this->_result[$disk][4]['raw_value'] = $vals;
}
}
}
if (!empty($this->_ids[192]) && ($this->_ids[192]=="raw_value")) {
if (preg_match('/\nUnsafe Shutdowns\: (.*)\n/', $result, $lines)) {
$values=preg_split('/ +/', $lines[0]);
if (!empty($values) && ($values[2]!=null)) {
$vals=preg_replace('/,/', '', trim($values[2]));
$this->_result[$disk][5]['id'] = 192;
$this->_result[$disk][5]['attribute_name'] = "Unsafe_Shutdown_Count";
$this->_result[$disk][5]['raw_value'] = $vals;
}
}
}
}
}
//Usage test
$newIds = array();
foreach ($this->_ids as $id=>$column_name) {
$found = 0;
foreach ($this->_result as $diskName=>$diskInfos) {
if ($found!=2) foreach ($diskInfos as $lineInfos) {
if ($found!=2) {
$found = 0;
foreach ($lineInfos as $label=>$value) {
if (($found==0) && ($label=="id") && ($value==$id))
$found = 1;
if (($found==1) && ($label==$column_name))
$found = 2;
}
}
}
}
if ($found==2) $newIds[$id] = $this->_ids[$id];
}
$this->_ids = $newIds;
}
 
/**
* generates the XML content for the plugin
*
* @return SimpleXMLElement entire XML content for the plugin
*/
public function xml()
{
if (empty($this->_result) || empty($this->_ids)) {
return $this->xml->getSimpleXmlElement();
}
 
$columnsChild = $this->xml->addChild('columns');
// Fill the xml with preferences
foreach ($this->_ids as $id=>$column_name) {
$columnChild = $columnsChild->addChild('column');
$columnChild->addAttribute('id', $id);
$columnChild->addAttribute('name', $column_name);
}
 
$disksChild = $this->xml->addChild('disks');
// Now fill the xml with S.M.A.R.T datas
foreach ($this->_result as $diskName=>$diskInfos) {
$diskChild = $disksChild->addChild('disk');
$diskChild->addAttribute('name', $diskName);
foreach ($diskInfos as $lineInfos) {
$lineChild = $diskChild->addChild('attribute');
 
if (($lineInfos['id'] == 9) && isset($lineInfos['attribute_name']) && ($lineInfos['attribute_name'] !== "Power_On_Hours")) { //Power_On_Hours_and_Msec and Power_On_Seconds
$lineInfos['attribute_name'] = "Power_On_Hours";
$raw_value = preg_split("/h/", $lineInfos['raw_value'], -1, PREG_SPLIT_NO_EMPTY);
$lineInfos['raw_value'] = $raw_value[0];
}
 
foreach ($lineInfos as $label=>$value) {
$lineChild->addAttribute($label, $value);
}
}
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/smart/smart_bootstrap.html
0,0 → 1,12
<div class="col-lg-12" id="block_smart" style="display:none;">
<div class="card" id="panel_smart" style="display:none;">
<div class="card-header"><span class="lang_plugin_smart_001">S.M.A.R.T Informations</span>
<div id="reload_smart" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="smart" class="table table-hover table-sm"></table>
</div>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/snmppinfo/class.snmppinfo.inc.php
0,0 → 1,279
<?php
/**
* SNMPPInfo Plugin, which displays printers info via SNMP
*
* @category PHP
* @package PSI_Plugin_SNMPPInfo
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
* @copyright 2011 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version $Id: class.snmppinfo.inc.php 661 2012-08-27 11:26:39Z namiltd $
* @link http://phpsysinfo.sourceforge.net
*/
class SNMPPInfo extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
*/
private $_filecontent = array();
 
/**
* variable, which holds the result before the xml is generated out of this array
* @var array
*/
private $_result = array();
 
/**
* read the data into an internal array and also call the parent constructor
*
* @param String $enc encoding
*/
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_SNMPPINFO_ACCESS)) {
case 'command':
if (defined('PSI_PLUGIN_SNMPPINFO_DEVICES') && is_string(PSI_PLUGIN_SNMPPINFO_DEVICES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_SNMPPINFO_DEVICES)) {
$printers = eval(PSI_PLUGIN_SNMPPINFO_DEVICES);
} else {
$printers = array(PSI_PLUGIN_SNMPPINFO_DEVICES);
}
foreach ($printers as $printer) {
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$printer." .1.3.6.1.2.1.1.5", $buffer, PSI_DEBUG);
if (strlen($buffer) > 0) {
$this->_filecontent[$printer] = $buffer;
 
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$printer." .1.3.6.1.4.1.367.3.2.1.2.24.1.1", $buffer1, false);
if (strlen($buffer1) > 0) {
$this->_filecontent[$printer] .= "\n".$buffer1;
}
 
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$printer." .1.3.6.1.2.1.43.11.1.1", $buffer2, PSI_DEBUG);
if (strlen($buffer2) > 0) {
$this->_filecontent[$printer] .= "\n".$buffer2;
}
CommonFunctions::executeProgram("snmpwalk", "-Ona -c public -v 1 -t ".PSI_SNMP_TIMEOUT_INT." -r ".PSI_SNMP_RETRY_INT." ".$printer." .1.3.6.1.2.1.43.18.1.1", $buffer3, PSI_DEBUG);
if (strlen($buffer3) > 0) {
$this->_filecontent[$printer] .= "\n".$buffer3;
}
}
}
}
break;
case 'php-snmp':
if (!extension_loaded("snmp")) {
$this->global_error->addError("Requirements error", "SNMPPInfo 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_PLUGIN_SNMPPINFO_DEVICES') && is_string(PSI_PLUGIN_SNMPPINFO_DEVICES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_SNMPPINFO_DEVICES)) {
$printers = eval(PSI_PLUGIN_SNMPPINFO_DEVICES);
} else {
$printers = array(PSI_PLUGIN_SNMPPINFO_DEVICES);
}
foreach ($printers as $printer) {
if (! PSI_DEBUG) {
restore_error_handler(); /* default error handler */
$old_err_rep = error_reporting();
error_reporting(E_ERROR); /* fatal errors only */
}
$bufferarr=snmprealwalk($printer, "public", ".1.3.6.1.2.1.1.5", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT);
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";
}
 
restore_error_handler(); /* default error handler */
$old_err_rep = error_reporting();
error_reporting(E_ERROR); /* fatal errors only */
 
$bufferarr1=snmprealwalk($printer, "public", ".1.3.6.1.4.1.367.3.2.1.2.24.1.1", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT);
 
error_reporting($old_err_rep); /* restore error level */
set_error_handler('errorHandlerPsi'); /* restore error handler */
if (! empty($bufferarr1)) {
foreach ($bufferarr1 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($printer, "public", ".1.3.6.1.2.1.43.11.1.1", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT);
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 (! PSI_DEBUG) {
restore_error_handler(); /* default error handler */
$old_err_rep = error_reporting();
error_reporting(E_ERROR); /* fatal errors only */
}
$bufferarr3=snmprealwalk($printer, "public", ".1.3.6.1.2.1.43.18.1.1", 1000000 * PSI_SNMP_TIMEOUT_INT, PSI_SNMP_RETRY_INT);
if (! PSI_DEBUG) {
error_reporting($old_err_rep); /* restore error level */
set_error_handler('errorHandlerPsi'); /* restore error handler */
}
if (! empty($bufferarr3)) {
foreach ($bufferarr3 as $id=>$string) {
$buffer .= $id." = ".$string."\n";
}
}
 
if (strlen(trim($buffer)) > 0) {
$this->_filecontent[$printer] = $buffer;
}
}
}
}
break;
case 'data':
if (defined('PSI_PLUGIN_SNMPPINFO_DEVICES') && is_string(PSI_PLUGIN_SNMPPINFO_DEVICES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_SNMPPINFO_DEVICES)) {
$printers = eval(PSI_PLUGIN_SNMPPINFO_DEVICES);
} else {
$printers = array(PSI_PLUGIN_SNMPPINFO_DEVICES);
}
$pn=0;
foreach ($printers as $printer) {
$buffer="";
if (CommonFunctions::rfts(PSI_APP_ROOT."/data/snmppinfo{$pn}.txt", $buffer) && !empty($buffer)) {
$this->_filecontent[$printer] = $buffer;
}
$pn++;
}
}
break;
default:
$this->global_error->addConfigError("__construct()", "[snmppinfo] ACCESS");
break;
}
}
 
/**
* doing all tasks to get the required informations that the plugin needs
* result is stored in an internal array
*
* @return void
*/
public function execute()
{
if (empty($this->_filecontent)) {
return;
}
foreach ($this->_filecontent as $printer=>$result) {
$result = preg_replace('/End of MIB\r?\n/', '', $result);
$result = preg_replace('/\s\r?\n([^\.])/', ' $1', $result);
$lines = preg_split('/\r?\n/', $result);
foreach ($lines as $line) {
if (preg_match('/^(.+) = Hex-STRING:\s(.+)/', $line, $linetmp)) {
$hexchars = explode(" ", trim($linetmp[2]));
$newstring = "";
foreach ($hexchars as $hexchar) {
$hexint = hexdec($hexchar);
if (($hexint<32) || ($hexint>126)) {
$newstring .= ".";
} else {
$newstring .= chr($hexint);
}
}
if ($newstring!=="") {
$line = $linetmp[1]." = STRING: ".$newstring;
}
}
if (preg_match('/^\.1\.3\.6\.1\.2\.1\.43\.11\.1\.1\.6\.1\.(.*) = STRING:\s(.*)/', $line, $data)) {
$this->_result[$printer][$data[1]]['prtMarkerSuppliesDescription']=trim($data[2], "\"");
} elseif (preg_match('/^\.1\.3\.6\.1\.2\.1\.43\.11\.1\.1\.7\.1\.(.*) = INTEGER:\s(.*)/', $line, $data)) {
$this->_result[$printer][$data[1]]['prtMarkerSuppliesSupplyUnit']=$data[2];
} elseif (preg_match('/^\.1\.3\.6\.1\.2\.1\.43\.11\.1\.1\.8\.1\.(.*) = INTEGER:\s(.*)/', $line, $data)) {
$this->_result[$printer][$data[1]]['prtMarkerSuppliesMaxCapacity']=$data[2];
} elseif (preg_match('/^\.1\.3\.6\.1\.2\.1\.43\.11\.1\.1\.9\.1\.(.*) = INTEGER:\s(.*)/', $line, $data)) {
$this->_result[$printer][$data[1]]['prtMarkerSuppliesLevel']=$data[2];
} elseif (preg_match('/^\.1\.3\.6\.1\.2\.1\.1\.5\.0 = STRING:\s(.*)/', $line, $data)) {
$this->_result[$printer][0]['prtMarkerSuppliesDescription']=trim($data[1], "\"");
} elseif (preg_match('/^\.1\.3\.6\.1\.2\.1\.43\.18\.1\.1\.8\.1\.(.*) = STRING:\s(.*)/', $line, $data)) {
$this->_result[$printer][99][$data[1]]["message"]=trim($data[2], "\"");
} elseif (preg_match('/^\.1\.3\.6\.1\.2\.1\.43\.18\.1\.1\.2\.1\.(.*) = INTEGER:\s(.*)/', $line, $data)) {
$this->_result[$printer][99][$data[1]]["severity"]=$data[2];
 
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.367\.3\.2\.1\.2\.24\.1\.1\.2\.(.*) = STRING:\s(.*)/', $line, $data)) {
$this->_result[$printer][$data[1]]['prtMarkerSuppliesDescriptionRicoh']=trim($data[2], "\"");
} elseif (preg_match('/^\.1\.3\.6\.1\.4\.1\.367\.3\.2\.1\.2\.24\.1\.1\.5\.(.*) = INTEGER:\s(.*)/', $line, $data)) {
$this->_result[$printer][$data[1]]['prtMarkerSuppliesLevelRicoh']=$data[2];
}
}
}
}
 
/**
* generates the XML content for the plugin
*
* @return SimpleXMLElement entire XML content for the plugin
*/
public function xml()
{
foreach ($this->_result as $printer=>$markersupplies_item) {
$xmlsnmppinfo_printer = $this->xml->addChild("Printer");
$xmlsnmppinfo_printer->addAttribute("Device", $printer);
if (isset($markersupplies_item[1]) &&
isset($markersupplies_item[1]['prtMarkerSuppliesDescriptionRicoh']) &&
isset($markersupplies_item[1]['prtMarkerSuppliesLevelRicoh'])) {
$ricoh = true;
} else {
$ricoh = false;
}
 
foreach ($markersupplies_item as $marker=>$snmppinfo_item) {
if ($marker==0) {
$xmlsnmppinfo_printer->addAttribute("Name", $snmppinfo_item['prtMarkerSuppliesDescription']);
} elseif ($marker==99) {
foreach ($snmppinfo_item as $item=>$iarr) {
if (isset($iarr["message"]) && $iarr["message"] != "") {
$xmlsnmppinfo_errors = $xmlsnmppinfo_printer->addChild("PrinterMessage");
$xmlsnmppinfo_errors->addAttribute("Message", $iarr["message"]);
$xmlsnmppinfo_errors->addAttribute("Severity", $iarr["severity"]);
}
}
} else {
if ($ricoh) {
if (isset($snmppinfo_item['prtMarkerSuppliesDescriptionRicoh'])) {
$xmlsnmppinfo = $xmlsnmppinfo_printer->addChild("MarkerSupplies");
 
$xmlsnmppinfo->addAttribute("Description", $snmppinfo_item['prtMarkerSuppliesDescriptionRicoh']);
$xmlsnmppinfo->addAttribute("SupplyUnit", "19");
$xmlsnmppinfo->addAttribute("MaxCapacity", "100");
$xmlsnmppinfo->addAttribute("Level", isset($snmppinfo_item['prtMarkerSuppliesLevelRicoh']) ? $snmppinfo_item['prtMarkerSuppliesLevelRicoh'] : "");
}
} else {
$xmlsnmppinfo = $xmlsnmppinfo_printer->addChild("MarkerSupplies");
 
$xmlsnmppinfo->addAttribute("Description", isset($snmppinfo_item['prtMarkerSuppliesDescription']) ? $snmppinfo_item['prtMarkerSuppliesDescription'] : "");
$xmlsnmppinfo->addAttribute("SupplyUnit", isset($snmppinfo_item['prtMarkerSuppliesSupplyUnit']) ? $snmppinfo_item['prtMarkerSuppliesSupplyUnit'] : "");
$xmlsnmppinfo->addAttribute("MaxCapacity", isset($snmppinfo_item['prtMarkerSuppliesMaxCapacity']) ? $snmppinfo_item['prtMarkerSuppliesMaxCapacity'] : "");
$xmlsnmppinfo->addAttribute("Level", isset($snmppinfo_item['prtMarkerSuppliesLevel']) ? $snmppinfo_item['prtMarkerSuppliesLevel'] : "");
}
}
}
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/snmppinfo/snmppinfo_bootstrap.html
0,0 → 1,22
<div class="col-lg-6" id="block_snmppinfo" style="display:none;">
<div class="card" id="panel_snmppinfo" style="display:none;">
<div class="card-header"><span class="lang_plugin_snmppinfo_001">Printer Information</span>
<div id="reload_snmppinfo" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="snmppinfo" class="table table-hover table-sm">
<thead>
<tr>
<th><span class="lang_plugin_snmppinfo_002">Printer</span></th>
<th><span class="lang_plugin_snmppinfo_003">Percent</span></th>
<th class="rightCell"><span class="lang_plugin_snmppinfo_004">Units</span></th>
</tr>
</thead>
<tbody id="snmppinfo-data">
</tbody>
</table>
</div>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/stablebit/class.stablebit.inc.php
0,0 → 1,74
<?php
/**
* StableBit Plugin, which displays disks state
*
* @category PHP
* @package PSI_Plugin_StableBit
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
* @copyright 2017 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version $Id: class.stablebit.inc.php 661 2012-08-27 11:26:39Z namiltd $
* @link http://phpsysinfo.sourceforge.net
*/
class StableBit extends PSI_Plugin
{
/**
* variable, which holds the result before the xml is generated out of this array
* @var array
*/
private $_result;
 
/**
* read the data into an internal array and also call the parent constructor
*
* @param String $enc encoding
*/
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
 
$this->_result = array();
}
 
private $stablebit_items = array('Name', 'Firmware', 'Size', 'TemperatureC', 'PowerState', 'IsHot', 'IsSmartWarning', 'IsSmartPastThresholds', 'IsSmartPastAdvisoryThresholds', 'IsSmartFailurePredicted', 'IsDamaged', 'SerialNumber');
 
/**
* doing all tasks to get the required informations that the plugin needs
* result is stored in an internal array
*
* @return void
*/
public function execute()
{
if (PSI_OS == 'WINNT') {
try {
$objLocator = new COM('WbemScripting.SWbemLocator');
$wmi = $objLocator->ConnectServer('', 'root\StableBit\Scanner');
$this->_result = CommonFunctions::getWMI($wmi, 'Disks', $this->stablebit_items);
} catch (Exception $e) {
}
}
}
 
/**
* generates the XML content for the plugin
*
* @return SimpleXMLElement entire XML content for the plugin
*/
public function xml()
{
foreach ($this->_result as $disk_items) {
if (isset($disk_items['Name']) && (trim($disk_items['Name']) !== '')) {
$xmlstablebit_disk = $this->xml->addChild("Disk");
foreach ($this->stablebit_items as $item) {
if (isset($disk_items[$item]) && (($itemvalue=$disk_items[$item]) !== '') &&
(($item !== 'SerialNumber') || (defined('PSI_PLUGIN_STABLEBIT_SHOW_SERIAL') && (PSI_PLUGIN_STABLEBIT_SHOW_SERIAL === true)))) {
$xmlstablebit_disk ->addAttribute($item, $itemvalue);
}
}
}
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/stablebit/stablebit_bootstrap.html
0,0 → 1,21
<div class="col-lg-6" id="block_stablebit" style="display:none;">
<div class="card" id="panel_stablebit" style="display:none;">
<div class="card-header"><span class="lang_plugin_stablebit_001">StableBit Scanner Information</span>
<div id="reload_stablebit" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="stablebit" class="table table-hover table-sm">
<thead>
<tr>
<th><span class="lang_plugin_stablebit_002">Disk</span></th>
<th class="rightCell"><span class="lang_plugin_stablebit_003">Value</span></th>
</tr>
</thead>
<tbody id="stablebit-data">
</tbody>
</table>
</div>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/updatenotifier/class.updatenotifier.inc.php
0,0 → 1,114
<?php
/**
* UpdateNotifier Plugin, which displays update notification from Ubuntu Landscape system
*
* @category PHP
* @package PSI_Plugin_UpdateNotifier
* @author Damien ROTH <iysaak@users.sourceforge.net>
* @copyright 2009 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version $Id: class.updatenotifier.inc.php 661 2012-08-27 11:26:39Z namiltd $
* @link http://phpsysinfo.sourceforge.net
*/
class UpdateNotifier extends PSI_Plugin
{
/**
* variable, which holds the content of the command
* @var array
*/
private $_filecontent = array();
 
/**
* variable, which holds the result before the xml is generated out of this array
* @var array
*/
private $_result = array();
 
/**
* read the data into an internal array and also call the parent constructor
*
* @param String $enc encoding
*/
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_UPDATENOTIFIER_ACCESS)) {
case 'command':
if (defined('PSI_PLUGIN_UPDATENOTIFIER_UBUNTU_LANDSCAPE_FORMAT') && (PSI_PLUGIN_UPDATENOTIFIER_UBUNTU_LANDSCAPE_FORMAT === true)) {
CommonFunctions::executeProgram("/usr/lib/update-notifier/apt-check", "--human-readable", $buffer_info);
} else {
CommonFunctions::executeProgram("/usr/lib/update-notifier/apt-check", "2>&1", $buffer_info);
}
break;
case 'data':
if (defined('PSI_PLUGIN_UPDATENOTIFIER_FILE') && is_string(PSI_PLUGIN_UPDATENOTIFIER_FILE)) {
CommonFunctions::rfts(PSI_PLUGIN_UPDATENOTIFIER_FILE, $buffer_info);
} else {
CommonFunctions::rfts("/var/lib/update-notifier/updates-available", $buffer_info);
}
break;
default:
$this->global_error->addConfigError("__construct()", "[updatenotifier] ACCESS");
break;
}
 
// Remove blank lines
$this->_filecontent = preg_split("/\r?\n/", $buffer_info, -1, PREG_SPLIT_NO_EMPTY);
}
 
/**
* doing all tasks to get the required informations that the plugin needs
* result is stored in an internal array
*
* @return void
*/
public function execute()
{
if (empty($this->_filecontent)) {
return;
}
 
if (defined('PSI_PLUGIN_UPDATENOTIFIER_UBUNTU_LANDSCAPE_FORMAT') && (PSI_PLUGIN_UPDATENOTIFIER_UBUNTU_LANDSCAPE_FORMAT === true)) {
/*
Ubuntu Landscape format:
- line 1: packages to update
- line 2: security packages to update
*/
if (count($this->_filecontent) == 2) {
foreach ($this->_filecontent as $line) {
list($num, $text) = explode(" ", $line, 2);
$this->_result[] = $num;
}
} else {
$this->global_error->addWarning("Unable to parse UpdateNotifier file");
}
} else {
/*
Universal format: A;B
- A: packages to update
- B: security packages to update
*/
if (count($this->_filecontent) == 1 && strpos($this->_filecontent[0], ";") !== false) {
$this->_result = explode(";", $this->_filecontent[0]);
} else {
$this->global_error->addWarning("Unable to parse UpdateNotifier file");
}
}
}
 
/**
* generates the XML content for the plugin
*
* @return SimpleXMLElement entire XML content for the plugin
*/
public function xml()
{
if (!empty($this->_result)) {
$xmluu = $this->xml->addChild("UpdateNotifier");
$xmluu->addChild("packages", $this->_result[0]);
$xmluu->addChild("security", $this->_result[1]);
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/updatenotifier/updatenotifier_bootstrap.html
0,0 → 1,14
<div class="col-lg-6" id="block_updatenotifier" style="display:none;">
<div class="card" id="panel_updatenotifier" style="display:none;">
<div class="card-header"><span class="lang_plugin_updatenotifier_001">Updates Notifier</span>
<div id="reload_updatenotifier" class="reload" title="reload"></div>
</div>
<div class="card-body">
<p id="updatenotifier-info"><strong><span class="lang_plugin_updatenotifier_002">Updates available</span></strong></p>
<ul class="list-group" id="updatenotifier">
<li class="list-group-item"><span class="badge badge-secondary" data-bind="updateNotifierNbPackages"></span><span class="lang_plugin_updatenotifier_006">Number of packages</span></li>
<li class="list-group-item"><span class="badge badge-secondary" data-bind="updateNotifierNbSecPackages"></span><span class="lang_plugin_updatenotifier_007">Number of security packages</span></li>
</ul>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/uprecords/class.uprecords.inc.php
0,0 → 1,116
<?php
/**
* Uprecords plugin, which displays all uprecords informations available
*
* @category PHP
* @package PSI_Plugin_Uprecords
* @author Ambrus Sandor Olah <aolah76@freemail.hu>
* @copyright 2014 phpSysInfo
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License version 2, or (at your option) any later version
* @version Release: 1.0
* @link http://phpsysinfo.sourceforge.net
*/
 
class uprecords extends PSI_Plugin
{
private $_lines;
 
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
 
$this->_lines = array();
}
 
/**
* get uprecords information
*
* @return array uprecords in array with label
*/
 
private function getUprecords()
{
$result = array();
$i = 0;
 
foreach ($this->_lines as $line) {
if (($i > 1) and (strpos($line, '---') === false)) {
$buffer = preg_split("/\s*[ |]\s+/", ltrim(ltrim($line, '->'), ' '));
if (defined('PSI_PLUGIN_UPRECORDS_SHORT_MODE') &&
(PSI_PLUGIN_UPRECORDS_SHORT_MODE === true) &&
!is_numeric($buffer[0])) {
break;
}
 
if (strpos($line, '->') !== false) {
if (defined('PSI_PLUGIN_UPRECORDS_DENOTE_BY_ASTERISK') && (PSI_PLUGIN_UPRECORDS_DENOTE_BY_ASTERISK === true)) {
$buffer[0] .= ' *';
} else {
$buffer[0] = '-> '.$buffer[0];
}
}
 
if (count($buffer) > 4) {
$buffer[3] = $buffer[3].' '.$buffer[4];
}
 
$result[$i]['hash'] = $buffer[0];
$result[$i]['Uptime'] = $buffer[1];
$result[$i]['System'] = $buffer[2];
//Date formating
$result[$i]['Bootup'] = preg_replace("/^(\S+)(\s+)/", "$1,$2", preg_replace("/^(\S+\s+\S+\s+)(\d)(\s+)/", "$1 0$2$3", trim($buffer[3])." GMT"));
}
$i++;
}
 
return $result;
}
 
public function execute()
{
$this->_lines = array();
switch (strtolower(PSI_PLUGIN_UPRECORDS_ACCESS)) {
case 'command':
$lines = "";
$options = "";
if (defined('PSI_PLUGIN_UPRECORDS_MAX_ENTRIES')) {
if (($ment = max(intval(PSI_PLUGIN_UPRECORDS_MAX_ENTRIES), 0)) != 10) {
$options=" -m ".$ment;
}
}
if (defined('PSI_PLUGIN_UPRECORDS_SHORT_MODE') && (PSI_PLUGIN_UPRECORDS_SHORT_MODE === true)) {
$options .= " -s";
}
if (CommonFunctions::executeProgram('TZ=GMT uprecords', '-a -w'.$options, $lines) && !empty($lines))
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT."/data/uprecords.txt", $lines) && !empty($lines))
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
default:
$this->global_error->addConfigError("execute()", "[uprecords] ACCESS");
break;
}
}
 
public function xml()
{
if (empty($this->_lines))
return $this->xml->getSimpleXmlElement();
 
$arrBuff = $this->getUprecords();
if (sizeof($arrBuff) > 0) {
$uprecords = $this->xml->addChild("Uprecords");
foreach ($arrBuff as $arrValue) {
$item = $uprecords->addChild('Item');
$item->addAttribute('hash', $arrValue['hash']);
$item->addAttribute('Uptime', $arrValue['Uptime']);
$item->addAttribute('System', $arrValue['System']);
$item->addAttribute('Bootup', $arrValue['Bootup']);
}
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/uprecords/uprecords_bootstrap.html
0,0 → 1,29
<div class="col-lg-12" id="block_uprecords" style="display:none;">
<div class="card" id="panel_uprecords" style="display:none;">
<div class="card-header"><span class="lang_plugin_uprecords_001">Uprecords</span>
<div id="reload_uprecords" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="uprecords" class="table table-hover table-sm">
<thead>
<tr>
<th><span class="lang_plugin_uprecords_101">#</span></th>
<th><span class="lang_plugin_uprecords_102">Uptime</span></th>
<th><span class="lang_plugin_uprecords_103">System</span></th>
<th><span class="lang_plugin_uprecords_104">Boot up</span></th>
</tr>
</thead>
<tbody id="uprecords-data">
<tr>
<th><span data-bind="hash"></span></th>
<td><span data-bind="Uptime"></span></td>
<td><span data-bind="System"></span></td>
<td><span data-bind="Bootup"></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>