_processObservation(); } /** * Adds additional editor fields to the Contentserv interface * * @param CSGuiEditor $editor * @param CSMonitorObserver $observer */ public function prepareEditor(CSGuiEditor $editor, CSMonitorObserver $observer) { $this->_observer = $observer; $editor->addField("timeOut", CS::translate('timeOut', 'csalive'), 5, '', FALSE, array( 'PaneTitle' => CS::translate('REST_GUI_EDIT_SETTINGS'), 'noEmptyOption' => true )); $editor->addField("searchText", CS::translate('SEARCH_TEXT', 'csalive'), 'SOAP-ENV', '', FALSE, array( 'PaneTitle' => CS::translate('REST_GUI_EDIT_SETTINGS'), 'noEmptyOption' => true )); } ///// PROTECTED METHODS ////////////////////////////////////////////////////// /** * Checks wether a HTTP content exists and saves the corresponding value * 1: TRUE | 2: FALSE */ protected function _processObservation() { foreach (CSIndesign::getServerConfigurations() as $arrServerConfigurationKey => $arrServerConfigurationValue) { foreach ($arrServerConfigurationValue as $strServerConfigurationKey => $strServerConfigurationValue) { if (strpos($strServerConfigurationKey, 'SoapUrl') !== FALSE) { $arrURLs[] = $strServerConfigurationValue; } } } $intInDesignName = 1; foreach ($arrURLs as $strURL) { $observation = CSMonitor::createObservation($this->_observer->getID(), 'InDesignServer.' . $intInDesignName); $observation->setTimestamp(CS::getDate()); $observation->setUnit('Status'); $state = CSMonitor::MONITOR_GUI_NOTIFICATION_NONE_ID; $observation->setState($state); $observation->setWarningValue(1); $observation->setCriticalValue(2); $intMeasuredValue = 2; if ($this->getContentStatus($strURL) === true) { $intMeasuredValue = 1; } $observation->setMeasuredValue($intMeasuredValue); $observation->store(); $intInDesignName++; } } ///// PRIVATE METHODS ////////////////////////////////////////////////////// /** * Gets Status if the value from searchText exist in value from URL Response * * @return boolean */ private function getContentStatus($strUrl) { $objCurl = curl_init(); $arrCurlOpt = array( CURLOPT_URL => $strUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => $this->getTimeOut() ); curl_setopt_array($objCurl, $arrCurlOpt); $strResult = curl_exec($objCurl); curl_close($objCurl); if (strstr($strResult, $this->getSearchText())) { return true; } else { return false; } } private function getTimeOut() { $intTimeOut = $this->_observer->getValue('timeOut'); return $intTimeOut; } private function getSearchText() { $strSearchText = $this->_observer->getValue('searchText'); return $strSearchText; } }