Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2784 → Rev 2785

/web/acc/phpsysinfo/plugins/docker/class.docker.inc.php
0,0 → 1,135
<?php
/**
* Docker plugin, which displays docker informations
*
* @category PHP
* @package PSI_Plugin_Docker
* @author Mieczyslaw Nalewaj <namiltd@users.sourceforge.net>
* @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 Docker extends PSI_Plugin
{
private $_lines;
 
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
 
$this->_lines = array();
}
 
/**
* get docker information
*
* @return array docker in array with label
*/
 
private function getDocker()
{
$result = array();
$i = 0;
 
foreach ($this->_lines as $line) {
if ($i > 0) {
$buffer = preg_split("/\s\s+/", $line);
$result[$i]['Name'] = $buffer[0];
$result[$i]['CPUUsage'] = str_replace(',', '.',trim($buffer[1],'%'));
preg_match('/([\d\.]+)(B|KiB|MiB|GiB|TiB|PiB)\s+\/\s+([\d\.]+)(B|KiB|MiB|GiB|TiB|PiB)/', str_replace(',', '.',trim($buffer[2])), $tmpbuf);
switch ($tmpbuf[2]) {
case 'B':
$result[$i]['MemoryUsed'] = $tmpbuf[1];
break;
case 'KiB':
$result[$i]['MemoryUsed'] = 1024*$tmpbuf[1];
break;
case 'MiB':
$result[$i]['MemoryUsed'] = 1024*1024*$tmpbuf[1];
break;
case 'GiB':
$result[$i]['MemoryUsed'] = 1024*1024*1024*$tmpbuf[1];
break;
case 'TiB':
$result[$i]['MemoryUsed'] = 1024*1024*1024*1024*$tmpbuf[1];
break;
case 'PiB':
$result[$i]['MemoryUsed'] = 1024*1024*1024*1024*1025*$tmpbuf[1];
break;
}
switch ($tmpbuf[4]) {
case 'B':
$result[$i]['MemoryLimit'] = $tmpbuf[3];
break;
case 'KiB':
$result[$i]['MemoryLimit'] = 1024*$tmpbuf[3];
break;
case 'MiB':
$result[$i]['MemoryLimit'] = 1024*1024*$tmpbuf[3];
break;
case 'GiB':
$result[$i]['MemoryLimit'] = 1024*1024*1024*$tmpbuf[3];
break;
case 'TiB':
$result[$i]['MemoryLimit'] = 1024*1024*1024*1024*$tmpbuf[3];
break;
case 'PiB':
$result[$i]['MemoryLimit'] = 1024*1024*1024*1024*1025*$tmpbuf[3];
break;
}
$result[$i]['MemoryUsage'] = str_replace(',', '.',trim($buffer[3],'%'));
$result[$i]['NetIO'] = trim($buffer[4]);
$result[$i]['BlockIO'] = trim($buffer[5]);
$result[$i]['PIDs'] = trim($buffer[6]);
}
$i++;
}
 
return $result;
}
 
public function execute()
{
$this->_lines = array();
switch (strtolower(PSI_PLUGIN_DOCKER_ACCESS)) {
case 'command':
$lines = "";
if (CommonFunctions::executeProgram('docker', 'stats --no-stream --format \'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.PIDs}}\'', $lines) && !empty($lines))
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT."/data/docker.txt", $lines) && !empty($lines))
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
default:
$this->global_error->addConfigError("execute()", "[docker] ACCESS");
break;
}
}
 
public function xml()
{
if (empty($this->_lines))
return $this->xml->getSimpleXmlElement();
 
$arrBuff = $this->getDocker();
if (sizeof($arrBuff) > 0) {
$docker = $this->xml->addChild("Docker");
foreach ($arrBuff as $arrValue) {
$item = $docker->addChild('Item');
$item->addAttribute('Name', $arrValue['Name']);
$item->addAttribute('CPUUsage', $arrValue['CPUUsage']);
$item->addAttribute('MemoryUsage', $arrValue['MemoryUsage']);
$item->addAttribute('MemoryUsed', Round($arrValue['MemoryUsed']));
$item->addAttribute('MemoryLimit', Round($arrValue['MemoryLimit']));
$item->addAttribute('NetIO', $arrValue['NetIO']);
$item->addAttribute('BlockIO', $arrValue['BlockIO']);
$item->addAttribute('PIDs', $arrValue['PIDs']);
}
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/docker/docker_bootstrap.html
0,0 → 1,37
<div class="col-lg-12" id="block_docker" style="display:none;">
<div class="card" id="panel_docker" style="display:none;">
<div class="card-header"><span class="lang_plugin_docker_001">Docker</span>
<div id="reload_docker" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="docker" class="table table-hover table-sm sortable">
<thead>
<tr>
<th id="docker_Name"><span class="lang_plugin_docker_101">Name</span></th>
<th><span class="lang_plugin_docker_102">CPU Usage</span></th>
<th><span class="lang_plugin_docker_103">Memory Usage</span></th>
<th class="rightCell sorttable_numeric"><span class="lang_plugin_docker_104">Memory Used</span></th>
<th class="rightCell sorttable_numeric"><span class="lang_plugin_docker_105">Memory Limit</span></th>
<th class="rightCell"><span class="lang_plugin_docker_106">Net I/O</span></th>
<th class="rightCell"><span class="lang_plugin_docker_107">Block I/O</span></th>
<th class="rightCell sorttable_numeric"><span class="lang_plugin_docker_108">PIDs</span></th>
</tr>
</thead>
<tbody id="docker-data">
<tr>
<th><span data-bind="Name"></span></th>
<td><span data-bind="CPUUsage"></span></td>
<td><span data-bind="MemoryUsage"></span></td>
<td class="rightCell"><span data-bind="MemoryUsed"></span></td>
<td class="rightCell"><span data-bind="MemoryLimit"></span></td>
<td class="rightCell"><span data-bind="NetIO"></span></td>
<td class="rightCell"><span data-bind="BlockIO"></span></td>
<td class="rightCell"><span data-bind="PIDs"></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/hyperv/class.hyperv.inc.php
0,0 → 1,102
<?php
/**
* HyperV Plugin, which displays Hyper-V machines state
*
* @category PHP
* @package PSI_Plugin_HyperV
* @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.hyperv.inc.php 661 2012-08-27 11:26:39Z namiltd $
* @link http://phpsysinfo.sourceforge.net
*/
class HyperV extends PSI_Plugin
{
 
/**
* variable, which holds the content of the command
* @var array
*/
private $_filecontent = 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);
}
 
/**
* doing all tasks to get the required informations that the plugin needs
* result is stored in an internal array<br>the array is build like a tree,
* so that it is possible to get only a specific process with the childs
*
* @return void
*/
public function execute()
{
switch (strtolower(PSI_PLUGIN_HYPERV_ACCESS)) {
case 'command':
if (PSI_OS == 'WINNT') {
try {
$objLocator = new COM('WbemScripting.SWbemLocator');
$wmic = $objLocator->ConnectServer('', 'root\CIMv2');
$buffer = CommonFunctions::getWMI($wmic, 'Win32_OperatingSystem', array('Version'));
if ($buffer && isset($buffer[0]) && isset($buffer[0]['Version'])) {
if (version_compare($buffer[0]['Version'], "6.2", ">=")) { // minimal windows 2012 or windows 8
$wmi = $objLocator->ConnectServer('', 'root\virtualization\v2');
} elseif (version_compare($buffer[0]['Version'], "6.0", ">=")) { // minimal windows 2008
$wmi = $objLocator->ConnectServer('', 'root\virtualization');
} else {
$this->global_error->addError("HyperV plugin", "Unsupported Windows version");
break;
}
} else {
$this->global_error->addError("HyperV plugin", "Unsupported Windows version");
break;
}
$result = CommonFunctions::getWMI($wmi, 'MSVM_ComputerSystem', array('InstallDate', 'EnabledState', 'ElementName'));
if (is_array($result)) foreach ($result as $machine) {
if ($machine['InstallDate'] !== null) {
$this->_filecontent[] = array($machine['ElementName'], $machine['EnabledState']);
}
}
} catch (Exception $e) {
}
}
break;
case 'data':
CommonFunctions::rfts(PSI_APP_ROOT."/data/hyperv.txt", $buffer);
$processes = preg_split("/\n/", $buffer, -1, PREG_SPLIT_NO_EMPTY);
foreach ($processes as $process) {
$ps = preg_split("/[\s]?\|[\s]?/", $process, -1, PREG_SPLIT_NO_EMPTY);
if (count($ps) == 2) {
$this->_filecontent[] = array(trim($ps[0]), trim($ps[1]));
}
}
break;
default:
$this->global_error->addConfigError("execute()", "[hyperv] ACCESS");
break;
}
}
 
/**
* generates the XML content for the plugin
*
* @return SimpleXMLElement entire XML content for the plugin
*/
public function xml()
{
foreach ($this->_filecontent as $machine) {
$xmlmach = $this->xml->addChild("Machine");
$xmlmach->addAttribute("Name", $machine[0]);
$xmlmach->addAttribute("State", $machine[1]);
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/hyperv/hyperv_bootstrap.html
0,0 → 1,25
<div class="col-lg-6" id="block_hyperv" style="display:none;">
<div class="card" id="panel_hyperv" style="display:none;">
<div class="card-header"><span class="lang_plugin_hyperv_001">Hyper-V Status</span>
<div id="reload_hyperv" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="hyperv" class="table table-hover table-sm sortable">
<thead>
<tr>
<th id="hyperv_Name"><span class="lang_plugin_hyperv_002">Machine Name</span></th>
<th class="rightCell"><span class="lang_plugin_hyperv_003">State</span></th>
</tr>
</thead>
<tbody id="hyperv-data">
<tr>
<th><span data-bind="Name"></span></th>
<td class="rightCell"><span class="badge badge-success" data-bind="State1"></span><span class="badge badge-danger" data-bind="State0"></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/iptables/class.iptables.inc.php
0,0 → 1,79
<?php
/**
* Iptables Plugin, which displays all iptables informations available
*
* @category PHP
* @package PSI_Plugin_Iptables
* @author erpomata
* @copyright 2016 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 iptables extends PSI_Plugin
{
private $_lines;
 
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
 
$this->_lines = array();
}
 
/**
* get iptables information
*
* @return array iptables in array with label
*/
 
private function getIptables()
{
$result = array();
$i = 0;
 
foreach ($this->_lines as $line) {
$result[$i]['rule'] = $line;
$i++;
}
 
return $result;
}
 
public function execute()
{
$this->_lines = array();
switch (strtolower(PSI_PLUGIN_IPTABLES_ACCESS)) {
case 'command':
$lines = "";
if (CommonFunctions::executeProgram('iptables-save', "", $lines) && !empty($lines))
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
case 'data':
if (CommonFunctions::rfts(PSI_APP_ROOT."/data/iptables.txt", $lines) && !empty($lines))
$this->_lines = preg_split("/\n/", $lines, -1, PREG_SPLIT_NO_EMPTY);
break;
default:
$this->global_error->addConfigError("execute()", "[iptables] ACCESS");
break;
}
}
 
public function xml()
{
if (empty($this->_lines))
return $this->xml->getSimpleXmlElement();
 
$arrBuff = $this->getIptables();
if (sizeof($arrBuff) > 0) {
$iptables = $this->xml->addChild("iptables");
foreach ($arrBuff as $arrValue) {
$item = $iptables->addChild('Item');
$item->addAttribute('Rule', $arrValue['rule']);
}
}
 
return $this->xml->getSimpleXmlElement();
}
}
/web/acc/phpsysinfo/plugins/iptables/iptables_bootstrap.html
0,0 → 1,23
<div class="col-lg-12" id="block_iptables" style="display:none;">
<div class="card" id="panel_iptables" style="display:none;">
<div class="card-header"><span class="lang_plugin_iptables_001">Iptables</span>
<div id="reload_iptables" class="reload" title="reload"></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table id="iptables" class="table table-hover table-sm">
<thead>
<tr>
<th><span class="lang_plugin_iptables_101">Rule</span></th>
</tr>
</thead>
<tbody id="iptables-data">
<tr>
<td><span data-bind="Rule"></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
/web/acc/phpsysinfo/plugins/pingtest/css/pingtest.css
0,0 → 1,6
/*
$Id: pingtest.css 1 2017-09-02 10:17:22Z namiltd $
*/
#Plugin_PingTestTable thead tr th {
cursor: pointer;
}
/web/acc/phpsysinfo/plugins/pingtest/js/pingtest.js
0,0 → 1,126
/***************************************************************************
* Copyright (C) 2008 by phpSysInfo - A PHP System Information Script *
* http://phpsysinfo.sourceforge.net/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
//
// $Id: pingtest.js 1 2017-09-01 08:23:45Z namiltd $
//
 
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */
 
"use strict";
 
var pingtest_show = false, pingtest_table;
 
 
/**
* insert content into table
* @param {jQuery} xml plugin-XML
*/
function pingtest_populate(xml) {
var address = "", pingtime = 0, state = "";
 
pingtest_table.fnClearTable();
 
$("Plugins Plugin_PingTest Ping", xml).each(function pingtest_getprocess(idp) {
address = $(this).attr("Address");
pingtime = parseInt($(this).attr("PingTime"), 10);
if (!isNaN(pingtime)) {
state = "<span style=\"display:none;\">" + pingtime.toString() + "</span>" + pingtime.toString() + "&nbsp;ms";
}
else {
state = "<span style=\"display:none;\">1000000</span>" + genlang(4, "PingTest");
}
pingtest_table.fnAddData(["<span style=\"display:none;\">" + address + "</span>" + address, state]);
pingtest_show = true;
});
}
 
/**
* fill the plugin block with table structure
*/
function pingtest_buildTable() {
var html = "";
 
html += "<div style=\"overflow-x:auto;\">\n";
html += " <table id=\"Plugin_PingTestTable\" style=\"border-collapse:collapse;\">\n";
html += " <thead>\n";
html += " <tr>\n";
html += " <th>" + genlang(2, "PingTest") + "</th>\n";
html += " <th>" + genlang(3, "PingTest") + "</th>\n";
html += " </tr>\n";
html += " </thead>\n";
html += " <tbody>\n";
html += " </tbody>\n";
html += " </table>\n";
html += "</div>\n";
 
$("#Plugin_PingTest").append(html);
 
pingtest_table = $("#Plugin_PingTestTable").dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bProcessing": true,
"bAutoWidth": false,
"bStateSave": true,
"aoColumns": [{
"sType": 'span-ip'
}, {
"sType": 'span-number'
}]
});
}
 
/**
* load the xml via ajax
*/
function pingtest_request() {
$("#Reload_PingTestTable").attr("title", "reload");
$.ajax({
url: "xml.php?plugin=PingTest",
dataType: "xml",
error: function pingtest_error() {
$.jGrowl("Error loading XML document for Plugin PingTest!");
},
success: function pingtest_buildblock(xml) {
populateErrors(xml);
pingtest_populate(xml);
if (pingtest_show) {
plugin_translate("PingTest");
$("#Plugin_PingTest").show();
}
}
});
}
 
$(document).ready(function pingtest_buildpage() {
$("#footer").before(buildBlock("PingTest", 1, true));
$("#Plugin_PingTest").css("width", "451px");
 
pingtest_buildTable();
 
pingtest_request();
 
$("#Reload_PingTestTable").click(function pingtest_reload(id) {
pingtest_request();
$(this).attr("title", datetime());
});
});
/web/acc/phpsysinfo/plugins/pingtest/js/pingtest_bootstrap.js
0,0 → 1,27
function renderPlugin_pingtest(data) {
 
var directives = {
PingTime: {
html: function () {
return ((this.PingTime === "lost") ? genlang(4, 'pingtest') : this.PingTime + String.fromCharCode(160) + "ms");
}
}
};
 
if (data.Plugins.Plugin_PingTest !== undefined) {
var psitems = items(data.Plugins.Plugin_PingTest.Ping);
if (psitems.length > 0) {
var pt_memory = [];
pt_memory.push_attrs(psitems);
$('#pingtest-data').render(pt_memory, directives);
$('#pingtest_Address').removeClass("sorttable_sorted"); // reset sort order
sorttable.innerSortFunction.apply($('#pingtest_Address')[0], []);
 
$('#block_pingtest').show();
} else {
$('#block_pingtest').hide();
}
} else {
$('#block_pingtest').hide();
}
}
/web/acc/phpsysinfo/plugins/pingtest/lang/de.xml
0,0 → 1,21
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: de.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: German Created by: Mieczyslaw Nalewaj
-->
<tns:translationPlugin language="german" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Ping-Test</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Adresse</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Pingzeit</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>verloren</exp>
</expression>
</tns:translationPlugin>
/web/acc/phpsysinfo/plugins/pingtest/lang/en.xml
0,0 → 1,21
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: en.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: English Created by: Mieczyslaw Nalewaj
-->
<tns:translationPlugin language="english" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Ping Test</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Address</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Ping Time</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>lost</exp>
</expression>
</tns:translationPlugin>
/web/acc/phpsysinfo/plugins/pingtest/lang/gr.xml
0,0 → 1,21
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: gr.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: Greek Created by: ChriZathens
-->
<tns:translationPlugin language="greek" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Δοκιμή Ping</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Διεύθυνση</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Χρόνος Απόκρισης</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>χάθηκε</exp>
</expression>
</tns:translationPlugin>
/web/acc/phpsysinfo/plugins/pingtest/lang/pl.xml
0,0 → 1,21
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: pl.xml 661 2017-09-01 09:01:17Z namiltd $ -->
<!--
phpSysInfo language file Language: Polish Created by: Mieczyslaw Nalewaj
-->
<tns:translationPlugin language="polish" charset="utf-8"
xmlns:tns="http://phpsysinfo.sourceforge.net/translation-plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://phpsysinfo.sourceforge.net/translation-plugin ../../../language/translation-plugin.xsd">
<expression id="plugin_pingtest_001" name="pingtest_title">
<exp>Test Pingu</exp>
</expression>
<expression id="plugin_pingtest_002" name="pingtest_address">
<exp>Adres</exp>
</expression>
<expression id="plugin_pingtest_003" name="pingtest_pingtime">
<exp>Czas Pingu</exp>
</expression>
<expression id="plugin_pingtest_004" name="pingtest_lost">
<exp>zagubiony</exp>
</expression>
</tns:translationPlugin>