initial commit of file from CVS for smeserver-phpsysinfo on Sat Sep 7 20:53:46 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:53:46 +10:00
parent 8f9c36d1f5
commit 9552652292
693 changed files with 86806 additions and 2 deletions

View File

@@ -0,0 +1,179 @@
<?php
/**
* PSStatus Plugin
*
* PHP version 5
*
* @category PHP
* @package PSI_Plugin_PSStatus
* @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.psstatus.inc.php 692 2012-09-08 17:12:08Z namiltd $
* @link http://phpsysinfo.sourceforge.net
*/
/**
* process Plugin, which displays the status of configured processes
* a simple view which shows a process name and the status
* status determined by calling the "pidof" command line utility, another way is to provide
* a file with the output of the pidof utility, so there is no need to run a executeable by the
* webserver, the format of the command is written down in the phpsysinfo.ini file, where also
* the method of getting the information is configured
* processes that should be checked are also defined in phpsysinfo.ini
*
* @category PHP
* @package PSI_Plugin_PSStatus
* @author Michael Cramer <BigMichi1@users.sourceforge.net>
* @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 PSStatus 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 target encoding
*/
public function __construct($enc)
{
parent::__construct(__CLASS__, $enc);
switch (strtolower(PSI_PLUGIN_PSSTATUS_ACCESS)) {
case 'command':
if (PSI_OS == 'WINNT') {
try {
$objLocator = new COM("WbemScripting.SWbemLocator");
$wmi = $objLocator->ConnectServer();
$process_wmi = $wmi->InstancesOf('Win32_Process');
foreach ($process_wmi as $process) {
$this->_filecontent[] = array(strtolower(trim($process->Caption)), trim($process->ProcessId));
}
} catch (Exception $e) {
}
} else {
if (defined('PSI_PLUGIN_PSSTATUS_PROCESSES') && is_string(PSI_PLUGIN_PSSTATUS_PROCESSES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_PSSTATUS_PROCESSES)) {
$processes = eval(PSI_PLUGIN_PSSTATUS_PROCESSES);
} else {
$processes = array(PSI_PLUGIN_PSSTATUS_PROCESSES);
}
if (defined('PSI_PLUGIN_PSSTATUS_USE_REGEX') && PSI_PLUGIN_PSSTATUS_USE_REGEX === true) {
foreach ($processes as $process) {
CommonFunctions::executeProgram("pgrep", "-n -x ".$process, $buffer, PSI_DEBUG);
if (strlen(trim($buffer)) > 0) {
$this->_filecontent[] = array($process, trim($buffer));
}
}
} else {
foreach ($processes as $process) {
CommonFunctions::executeProgram("pidof", "-s ".$process, $buffer, PSI_DEBUG);
if (strlen(trim($buffer)) > 0) {
$this->_filecontent[] = array($process, trim($buffer));
}
}
}
}
}
break;
case 'data':
CommonFunctions::rfts(APP_ROOT."/data/psstatus.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->addError("switch(PSI_PLUGIN_PSSTATUS_ACCESS)", "Bad psstatus configuration in phpsysinfo.ini");
break;
}
}
/**
* 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()
{
if (empty($this->_filecontent)) {
return;
}
if (defined('PSI_PLUGIN_PSSTATUS_PROCESSES') && is_string(PSI_PLUGIN_PSSTATUS_PROCESSES)) {
if (preg_match(ARRAY_EXP, PSI_PLUGIN_PSSTATUS_PROCESSES)) {
$processes = eval(PSI_PLUGIN_PSSTATUS_PROCESSES);
} else {
$processes = array(PSI_PLUGIN_PSSTATUS_PROCESSES);
}
if ((PSI_OS == 'WINNT') && (strtolower(PSI_PLUGIN_PSSTATUS_ACCESS) == 'command')) {
foreach ($processes as $process) {
if ($this->_recursiveinarray(strtolower($process), $this->_filecontent)) {
$this->_result[] = array($process, true);
} else {
$this->_result[] = array($process, false);
}
}
} else {
foreach ($processes as $process) {
if ($this->_recursiveinarray($process, $this->_filecontent)) {
$this->_result[] = array($process, true);
} else {
$this->_result[] = array($process, false);
}
}
}
}
}
/**
* generates the XML content for the plugin
*
* @return SimpleXMLElement entire XML content for the plugin
*/
public function xml()
{
foreach ($this->_result as $ps) {
$xmlps = $this->xml->addChild("Process");
$xmlps->addAttribute("Name", $ps[0]);
$xmlps->addAttribute("Status", $ps[1] ? 1 : 0);
}
return $this->xml->getSimpleXmlElement();
}
/**
* checks an array recursive if an value is in, extended version of in_array()
*
* @param mixed $needle what to find
* @param array $haystack where to find
*
* @return boolean true - found<br>false - not found
*/
private function _recursiveinarray($needle, $haystack)
{
foreach ($haystack as $stalk) {
if ($needle == $stalk || (is_array($stalk) && $this->_recursiveinarray($needle, $stalk))) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,6 @@
/*
$Id: psstatus.css 661 2012-08-27 11:26:39Z namiltd $
*/
#plugin_psstatusTable thead tr .header {
cursor: pointer;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

View File

@@ -0,0 +1,124 @@
/***************************************************************************
* 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: psstatus.js 679 2012-09-04 10:10:11Z namiltd $
//
/*global $, jQuery, buildBlock, datetime, plugin_translate, genlang */
"use strict";
var psstatus_show = false, psstatus_table;
//appendcss("./plugins/PSStatus/css/PSStatus.css");
/**
* insert content into table
* @param {jQuery} xml plugin-XML
*/
function psstatus_populate(xml) {
var name = "", status = 0, state = "";
psstatus_table.fnClearTable();
$("Plugins Plugin_PSStatus Process", xml).each(function psstatus_getprocess(idp) {
name = $(this).attr("Name");
status = parseInt($(this).attr("Status"), 10);
if (!isNaN(status) && (status === 1)) {
state = "<span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/psstatus/gfx/online.png\" alt=\"online\" />";
}
else {
state = "<span style=\"display:none;\">" + status.toString() + "</span><img src=\"./plugins/psstatus/gfx/offline.png\" alt=\"offline\" />";
}
psstatus_table.fnAddData(["<span style=\"display:none;\">" + name + "</span>" + name, state]);
psstatus_show = true;
});
}
/**
* fill the plugin block with table structure
*/
function psstatus_buildTable() {
var html = "";
html += "<table id=\"Plugin_PSStatusTable\" style=\"border-spacing:0;\">\n";
html += " <thead>\n";
html += " <tr>\n";
html += " <th>" + genlang(3, false, "PSStatus") + "</th>\n";
html += " <th>" + genlang(4, false, "PSStatus") + "</th>\n";
html += " </tr>\n";
html += " </thead>\n";
html += " <tbody>\n";
html += " </tbody>\n";
html += "</table>\n";
$("#Plugin_PSStatus").append(html);
psstatus_table = $("#Plugin_PSStatusTable").dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bProcessing": true,
"bAutoWidth": false,
"bStateSave": true,
"aoColumns": [{
"sType": 'span-string'
}, {
"sType": 'span-number'
}]
});
}
/**
* load the xml via ajax
*/
function psstatus_request() {
$.ajax({
url: "xml.php?plugin=PSStatus",
dataType: "xml",
error: function psstatus_error() {
$.jGrowl("Error loading XML document for Plugin PSStatus!");
},
success: function psstatus_buildblock(xml) {
populateErrors(xml);
psstatus_populate(xml);
if (psstatus_show) {
plugin_translate("PSStatus");
$("#Plugin_PSStatus").show();
}
}
});
}
$(document).ready(function psstatus_buildpage() {
$("#footer").before(buildBlock("PSStatus", 1, true));
$("#Plugin_PSStatus").css("width", "451px");
psstatus_buildTable();
psstatus_request();
$("#Reload_PSStatusTable").click(function psstatus_reload(id) {
psstatus_request();
$("#Reload_PSStatusTable").attr("title",datetime());
});
});

View File

@@ -0,0 +1,27 @@
function renderPlugin_psstatus(data) {
var directives = {
Status: {
text: function () {
return (this['Status'] === "1") ? "ON" : "OFF";
}
}
};
if (data['Plugins']['Plugin_PSStatus'] !== undefined) {
var psitems = items(data['Plugins']['Plugin_PSStatus']['Process']);
if (psitems.length > 0) {
var ps_memory = [];
ps_memory.push_attrs(psitems);
$('#psstatus-data').render(ps_memory, directives);
$('#psstatus_Name').removeClass("sorttable_sorted"); // reset sort order
sorttable.innerSortFunction.apply($('#psstatus_Name')[0], []);
$('#block_psstatus').show();
} else {
$('#block_psstatus').hide();
}
} else {
$('#block_psstatus').hide();
}
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: cz.xml 661 2012-08-27 11:26:39Z namiltd $ -->
<!--
phpSysInfo language file Language: Czech Created by: Tomáš Růžička
-->
<tns:translationPlugin language="czech" 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_psstatus_001" name="ps_title">
<exp>Stav procesů</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Aktualizováno</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Název</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Stav</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: de.xml 661 2012-08-27 11:26:39Z namiltd $ -->
<!--
phpSysInfo language file Language: German Created by: Michael Cramer
-->
<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_psstatus_001" name="ps_title">
<exp>Prozess Status</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Letzte Aktualisierung</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Name</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Status</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: en.xml 661 2012-08-27 11:26:39Z namiltd $ -->
<!--
phpSysInfo language file Language: English Created by: Michael Cramer
-->
<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_psstatus_001" name="ps_title">
<exp>Process Status</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Last refresh</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Name</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Status</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: fr.xml 661 2012-08-27 11:26:39Z namiltd $ -->
<!--
phpSysInfo language file Language: French Created by: Erkan VALENTIN
-->
<tns:translationPlugin language="french" 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_psstatus_001" name="ps_title">
<exp>Etat des processus</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Dernière actualisation</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Nom</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Etat</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: gr.xml 661 2012-08-27 11:26:39Z namiltd $ -->
<!--
phpSysInfo language file Language: Greek Created by: mojiro
-->
<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_psstatus_001" name="ps_title">
<exp>Κατάσταση Κρίσιμων Διεργασιών</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Ενημέρωση</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Διεργασία</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Κατάσταση</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: pl.xml 661 2012-08-27 11:26:39Z 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_psstatus_001" name="ps_title">
<exp>Status Procesów</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Ostatnie odświeżenie</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Nazwa</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Status</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: ro.xml 661 2014-05-02 11:26:39Z namiltd $ -->
<!--
phpSysInfo language file Language: Romană Created by: Iulian Alexe
-->
<tns:translationPlugin language="romana" 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_psstatus_001" name="ps_title">
<exp>Stare proces</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Ultimul refresh</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Nume</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Stare</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: en.xml 661 2012-08-27 11:26:39Z namiltd $ -->
<!--
phpSysInfo language file Language: Russian Created by: Denis Sevostyanov (den007)
-->
<tns:translationPlugin language="russian" 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_psstatus_001" name="ps_title">
<exp>Статус служб</exp>
</expression>
<expression id="plugin_psstatus_002" name="ps_date">
<exp>Последнее обновление</exp>
</expression>
<expression id="plugin_psstatus_003" name="ps_name">
<exp>Имя службы</exp>
</expression>
<expression id="plugin_psstatus_004" name="ps_status">
<exp>Статус</exp>
</expression>
</tns:translationPlugin>

View File

@@ -0,0 +1,21 @@
<div class="col-lg-6" id="block_psstatus" style="display:none">
<div class="panel panel-primary">
<div class="panel-heading">Processes Status</div>
<div class="panel-body">
<table id="psstatus" class="table table-hover table-condensed sortable">
<thead>
<tr>
<th id="psstatus_Name">Name</th>
<th class="rightCell">Status</th>
</tr>
</thead>
<tbody id="psstatus-data">
<tr>
<th><span data-bind="Name"></span></th>
<td class="rightCell"><span class="badge" data-bind="Status"></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>