_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("FilePath", CS::translate('CSALIVE_MONITOR_FILE_PATH', 'sawsalive'), '', '', FALSE, array( 'PaneTitle' => CS::translate('REST_GUI_EDIT_SETTINGS'), 'onlyFolder' => true )); $editor->addField("SelectedShare", CS::translate('CSALIVE_MONITOR_SERVICE_SHARE', 'sawsalive'), $this->getShareNames(), 'Share1', FALSE, array( 'PaneTitle' => CS::translate('REST_GUI_EDIT_SETTINGS'), 'noEmptyOption' => true )); } ///// PROTECTED METHODS ////////////////////////////////////////////////////// /** * Checks wether a path exists and saves the corresponding value * 1: TRUE | 2: FALSE */ protected function _processObservation() { $observation = CSMonitor::createObservation($this->_observer->getID(), 'Fileshare.' . $this->getSelectedShare()); $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 (!empty($this->getSelectedShare())) { if (!empty($this->getSelectedPath())) { if (file_exists($this->getSelectedPath())) { $intMeasuredValue = 1; } } } $observation->setMeasuredValue($intMeasuredValue); $observation->store(); } ///// PRIVATE METHODS ////////////////////////////////////////////////////// /** * Gets the entered value from the editor * * @return string Returns the entered path */ private function getSelectedPath() { $strPath = $this->_observer->getValue('FilePath'); return $strPath; } /** * Gets the entered value from the editor * * @return String Share name */ private function getSelectedShare() { $strShare = $this->_observer->getValue('SelectedShare'); return $strShare; } /** * Creates an array of 10 share names to choose from. * So that they don't overwrite each other accidentally * * @return array List of all selectable shares */ private function getShareNames() { $arrSelectableShares = array(); for ($intI = 1; $intI <= 10; $intI++) { $arrSelectableShares['Share' . $intI] = 'Share' . $intI; } return $arrSelectableShares; } }