Hallo liebe Joomla!-Community
Bin neu hier und mit Joomla befasse ich mich nun schon gut zweieinhalb Wochen. Da ich das firmeneigene Intranet auf Joomla! portieren solle (Chef halt), komme ich nun an die erste Herausforderung. Ich erdreiste mich mal zu behaupten, PHP am besten zu beherrschen. Jedoch bekomme ich es "um's verrecken" nicht hin, ein von mir geschriebenes PHP-Skript unter Joomla! gänzlich fehlerfrei zum Laufen zu bringen. Ich verwende die Extension Sourcerer und eigentlich funktioniert alles einwandfrei. Jedoch scheint Joomla! sich mit SMNP schwer zu tun, da er mir einen grundlegenden PHP Befehl nicht entgegennehmen möchte: snmpwalk();
Beim Ausführen des besagten Skripts bekomme ich folgende Fehlermeldung:
ZitatFatal error: Call to undefined function snmpwalk()
Zitatin C:\xampp\htdocs\joomla\plugins\system\sourcerer\helper.php(645) : runtime-created function on line 25
Hier der Auszug aus der helper.php:
<?php/** * @package Sourcerer * @version 6.2.1 * * @author Peter van Westen <info@regularlabs.com> * @link http://www.regularlabs.com * @copyright Copyright © 2016 Regular Labs All Rights Reserved * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */defined('_JEXEC') or die;require_once JPATH_LIBRARIES . '/regularlabs/helpers/helper.php';require_once JPATH_LIBRARIES . '/regularlabs/helpers/functions.php';require_once JPATH_LIBRARIES . '/regularlabs/helpers/tags.php';require_once JPATH_LIBRARIES . '/regularlabs/helpers/text.php';require_once JPATH_LIBRARIES . '/regularlabs/helpers/protect.php';RLFunctions::loadLanguage('plg_system_sourcerer');/** * Plugin that replaces Sourcerer code with its HTML / CSS / JavaScript / PHP equivalent */class PlgSystemSourcererHelper{ var $option = ''; var $src_params = null; public function __construct(&$params) { $this->option = JFactory::getApplication()->input->get('option'); // Set plugin parameters $this->src_params = new stdClass; $this->src_params->syntax_word = trim($params->syntax_word); // Tag character start and end $this->src_params->tag_characters = $params->tag_characters; list($tag_start, $tag_end) = $this->getTagCharacters(true); // Break/paragraph start and end tags $this->src_params->breaks_start = RLTags::getRegexSurroundingTagPre(); $this->src_params->breaks_end = RLTags::getRegexSurroundingTagPost(); $breaks_start = $this->src_params->breaks_start; $breaks_end = $this->src_params->breaks_end; $spaces = RLTags::getRegexSpaces('*'); $inside_tag = RLTags::getRegexInsideTag(); $this->src_params->regex = '#(' . '(?P<start_pre>' . $breaks_start . ')' . $tag_start . preg_quote($this->src_params->syntax_word, '#') . $spaces . '(?P<data>' . $inside_tag . ')' . $tag_end . '(?P<start_post>' . $breaks_end . ')' . '(?P<content>.*?)' . '(?P<end_pre>' . $breaks_start . ')' . $tag_start . '\/' . preg_quote($this->src_params->syntax_word, '#') . $tag_end . '(?P<end_post>' . $breaks_end . ')' . ')#s'; $this->src_params->tags_syntax = array(array('<', '>'), array('\[\[', '\]\]')); $this->src_params->splitter = '<!-- START: SRC_SPLIT -->'; $this->src_params->protected_tags = array( $this->src_params->tag_character_start . $this->src_params->syntax_word, ); $this->src_params->trim = (bool) $params->trim; $this->src_params->include_path = str_replace('//', '/', ('/' . trim($params->include_path, ' /\\') . '/')); $user = JFactory::getUser(); $this->src_params->user_is_admin = $user->authorise('core.admin', 1); // Initialise the different enables $this->src_params->areas = array(); $this->src_params->areas['default'] = array(); $this->src_params->areas['default']['enable_css'] = $params->enable_css; $this->src_params->areas['default']['enable_js'] = $params->enable_js; $this->src_params->areas['default']['enable_php'] = $params->enable_php; $this->src_params->areas['default']['forbidden_php'] = $params->forbidden_php; $this->src_params->areas['default']['forbidden_tags'] = $params->forbidden_tags; $this->src_params->currentarea = 'default'; $this->src_params->remove_from_search = $params->remove_from_search; }[...][b]
Und hier das Skript, dass bis auf den Teil mit SNMPWalk nicht funktioniert:
<?
$daten=@file_get_contents("URL");
$daten_array = explode(";", $daten);
$temp = substr($daten_array[2], 0, 4);
if ($temp <= "17,0" || $temp >= "24,0"){
$temp_serverraum_1 = "<p style='text-align:center; font-weight:bold; color:red;'>".$temp." °C</p>";
}else{
$temp_serverraum_1 = "<p style='text-align:center; font-weight:bold; color:green;'>".$temp." °C</p>";
}
$daten=@file_get_contents("URL");
$daten_array = explode(";", $daten);
$temp = substr($daten_array[2], 0, 4);
if ($temp <= "17,0" || $temp >= "24,0"){
$temp_serverraum_2 = "<p style='text-align:center; font-weight:bold; color:red;'>".$temp." °C</p>";
}else{
$temp_serverraum_2 = "<p style='text-align:center; font-weight:bold; color:green;'>".$temp." °C</p>";
}
$sysdescr = snmpwalk("HOSTNAME", "COMMUNITY", "OBJEKT_ID");
$dummy = $sysdescr[0];
$ary = explode(": ", $dummy);
$temp = $ary[1];
if ($temp <= "17" || $temp >= "24"){
$temp_serverraum_3 = "<p style='text-align:center; font-weight:bold; color:red;'>".$temp.",0 °C</p>";
}else{
$temp_serverraum_3 = "<p style='text-align:center; font-weight:bold; color:green;'>".$temp.",0 °C</p>";
}
?>
Alles anzeigen
Ich verwende derzeit:
Joomla Version: Joomla! 3.6.2 Stable [ Noether ] 4-August-2016 23:41 GMT
Plattform Version: Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
Anzumerken sei, dass sich das Thermostat, welches über SNMP läuft in einer USVs in einem unserer Serverräume befindet. Die anderen beiden sind lediglich Temperaturfühler, welche sich am Deckenbereich in den jeweiligen Serverräumen befinden. Soll heißen, dass diese eine lediglich über SNMP ansprechbar ist. Meine Frage jetzt: Gibt es eine Extension für Joomla, die es mir erlaubt SNMP zu verwenden?
Vielen Dank für eure Hilfe im Voraus!
Liebe Grüße
Montreal