@@ -6,8 +6,8 @@ |
||
| 6 | 6 | $this->providePermission('trapdirector/config', $this->translate('Allow to create and modify traps services')); |
| 7 | 7 | |
| 8 | 8 | $this->provideConfigTab('config', array( |
| 9 | - 'title' => 'Configuration', |
|
| 10 | - 'url' => 'settings' |
|
| 9 | + 'title' => 'Configuration', |
|
| 10 | + 'url' => 'settings' |
|
| 11 | 11 | )); |
| 12 | 12 | |
| 13 | 13 | $section = $this->menuSection(N_('Traps'),array ( |
@@ -17,10 +17,10 @@ |
||
| 17 | 17 | class StatusCommand extends Command |
| 18 | 18 | { |
| 19 | 19 | /** |
| 20 | - * Get database counts |
|
| 21 | - * |
|
| 22 | - * Get number of traps, rules |
|
| 23 | - */ |
|
| 20 | + * Get database counts |
|
| 21 | + * |
|
| 22 | + * Get number of traps, rules |
|
| 23 | + */ |
|
| 24 | 24 | public function dbAction() |
| 25 | 25 | { |
| 26 | 26 | $db_prefix=$this->Config()->get('config', 'database_prefix'); |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | class TrapsCommand extends Command |
| 18 | 18 | { |
| 19 | 19 | /** |
| 20 | - * Delete old traps |
|
| 21 | - * |
|
| 22 | - * USAGE |
|
| 23 | - * |
|
| 24 | - * icingali trapdirector traps rotate [options] |
|
| 25 | - * |
|
| 26 | - * OPTIONS |
|
| 27 | - * |
|
| 28 | - * --days remove traps older than <n> days |
|
| 29 | - */ |
|
| 20 | + * Delete old traps |
|
| 21 | + * |
|
| 22 | + * USAGE |
|
| 23 | + * |
|
| 24 | + * icingali trapdirector traps rotate [options] |
|
| 25 | + * |
|
| 26 | + * OPTIONS |
|
| 27 | + * |
|
| 28 | + * --days remove traps older than <n> days |
|
| 29 | + */ |
|
| 30 | 30 | public function rotateAction() |
| 31 | 31 | { |
| 32 | 32 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * Reset services to OK state if timeout is passed |
|
| 60 | - * |
|
| 61 | - * USAGE |
|
| 62 | - * |
|
| 63 | - * icingali trapdirector traps reset_services |
|
| 64 | - * |
|
| 65 | - */ |
|
| 59 | + * Reset services to OK state if timeout is passed |
|
| 60 | + * |
|
| 61 | + * USAGE |
|
| 62 | + * |
|
| 63 | + * icingali trapdirector traps reset_services |
|
| 64 | + * |
|
| 65 | + */ |
|
| 66 | 66 | public function resetOKAction() |
| 67 | 67 | { |
| 68 | 68 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function setDefaultIDODB($idoDbName) |
| 34 | 34 | { |
| 35 | - $this->idoDbName=$idoDbName; |
|
| 36 | - return $this; |
|
| 35 | + $this->idoDbName=$idoDbName; |
|
| 36 | + return $this; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function createElements(array $formData) |
|
| 40 | - { |
|
| 41 | - $this->addElement( |
|
| 39 | + public function createElements(array $formData) |
|
| 40 | + { |
|
| 41 | + $this->addElement( |
|
| 42 | 42 | 'select', |
| 43 | 43 | 'config_database', |
| 44 | 44 | array( |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | ) |
| 73 | 73 | ); |
| 74 | 74 | $this->addElement( |
| 75 | - 'text', |
|
| 76 | - 'config_icingaweb2_etc', |
|
| 77 | - array( |
|
| 78 | - 'required' => true, |
|
| 79 | - 'label' => $this->translate('icingaweb2 config dir'), |
|
| 75 | + 'text', |
|
| 76 | + 'config_icingaweb2_etc', |
|
| 77 | + array( |
|
| 78 | + 'required' => true, |
|
| 79 | + 'label' => $this->translate('icingaweb2 config dir'), |
|
| 80 | 80 | 'value' => $this->icinga_base_path, |
| 81 | - ) |
|
| 82 | - ); |
|
| 81 | + ) |
|
| 82 | + ); |
|
| 83 | 83 | $retval=0; |
| 84 | 84 | $output=array(); |
| 85 | 85 | $snmptranslate=exec('which snmptranslate',$output,$retval); |
@@ -88,68 +88,68 @@ discard block |
||
| 88 | 88 | $snmptranslate='/usr/bin/snmptranslate'; |
| 89 | 89 | } |
| 90 | 90 | $this->addElement( |
| 91 | - 'text', |
|
| 92 | - 'config_snmptranslate', |
|
| 93 | - array( |
|
| 94 | - 'required' => true, |
|
| 95 | - 'label' => $this->translate('snmptranslate binary with path'), |
|
| 91 | + 'text', |
|
| 92 | + 'config_snmptranslate', |
|
| 93 | + array( |
|
| 94 | + 'required' => true, |
|
| 95 | + 'label' => $this->translate('snmptranslate binary with path'), |
|
| 96 | 96 | 'value' => $snmptranslate, |
| 97 | - ) |
|
| 98 | - ); |
|
| 97 | + ) |
|
| 98 | + ); |
|
| 99 | 99 | $this->addElement( |
| 100 | - 'text', |
|
| 101 | - 'config_snmptranslate_dirs', |
|
| 102 | - array( |
|
| 103 | - 'required' => true, |
|
| 104 | - 'label' => $this->translate('Path for mibs'), |
|
| 100 | + 'text', |
|
| 101 | + 'config_snmptranslate_dirs', |
|
| 102 | + array( |
|
| 103 | + 'required' => true, |
|
| 104 | + 'label' => $this->translate('Path for mibs'), |
|
| 105 | 105 | 'value' => $this->module_base_path.'/mibs', |
| 106 | - ) |
|
| 107 | - ); |
|
| 106 | + ) |
|
| 107 | + ); |
|
| 108 | 108 | $this->addElement( |
| 109 | - 'text', |
|
| 110 | - 'config_icingacmd', |
|
| 111 | - array( |
|
| 112 | - 'required' => true, |
|
| 113 | - 'label' => $this->translate('icingacmd with path'), |
|
| 109 | + 'text', |
|
| 110 | + 'config_icingacmd', |
|
| 111 | + array( |
|
| 112 | + 'required' => true, |
|
| 113 | + 'label' => $this->translate('icingacmd with path'), |
|
| 114 | 114 | 'value' => '/var/run/icinga2/cmd/icinga2.cmd', |
| 115 | - ) |
|
| 116 | - ); |
|
| 115 | + ) |
|
| 116 | + ); |
|
| 117 | 117 | $this->addElement( |
| 118 | - 'text', |
|
| 119 | - 'config_icingaAPI_host', |
|
| 120 | - array( |
|
| 121 | - 'required' => false, |
|
| 122 | - 'label' => $this->translate('icinga2 API Host IP'), |
|
| 123 | - 'value' => '', |
|
| 124 | - ) |
|
| 118 | + 'text', |
|
| 119 | + 'config_icingaAPI_host', |
|
| 120 | + array( |
|
| 121 | + 'required' => false, |
|
| 122 | + 'label' => $this->translate('icinga2 API Host IP'), |
|
| 123 | + 'value' => '', |
|
| 124 | + ) |
|
| 125 | 125 | ); |
| 126 | 126 | $this->addElement( |
| 127 | - 'text', |
|
| 128 | - 'config_icingaAPI_port', |
|
| 129 | - array( |
|
| 130 | - 'required' => false, |
|
| 131 | - 'label' => $this->translate('icinga2 API TCP Port'), |
|
| 132 | - 'value' => '5665', |
|
| 133 | - ) |
|
| 134 | - ); |
|
| 127 | + 'text', |
|
| 128 | + 'config_icingaAPI_port', |
|
| 129 | + array( |
|
| 130 | + 'required' => false, |
|
| 131 | + 'label' => $this->translate('icinga2 API TCP Port'), |
|
| 132 | + 'value' => '5665', |
|
| 133 | + ) |
|
| 134 | + ); |
|
| 135 | 135 | $this->addElement( |
| 136 | - 'text', |
|
| 137 | - 'config_icingaAPI_user', |
|
| 138 | - array( |
|
| 139 | - 'required' => false, |
|
| 140 | - 'label' => $this->translate('icinga2 API username'), |
|
| 141 | - 'value' => '', |
|
| 142 | - ) |
|
| 143 | - ); |
|
| 136 | + 'text', |
|
| 137 | + 'config_icingaAPI_user', |
|
| 138 | + array( |
|
| 139 | + 'required' => false, |
|
| 140 | + 'label' => $this->translate('icinga2 API username'), |
|
| 141 | + 'value' => '', |
|
| 142 | + ) |
|
| 143 | + ); |
|
| 144 | 144 | $this->addElement( |
| 145 | - 'text', |
|
| 146 | - 'config_icingaAPI_password', |
|
| 147 | - array( |
|
| 148 | - 'required' => false, |
|
| 149 | - 'label' => $this->translate('icinga2 API password'), |
|
| 150 | - 'value' => '', |
|
| 151 | - ) |
|
| 152 | - ); |
|
| 145 | + 'text', |
|
| 146 | + 'config_icingaAPI_password', |
|
| 147 | + array( |
|
| 148 | + 'required' => false, |
|
| 149 | + 'label' => $this->translate('icinga2 API password'), |
|
| 150 | + 'value' => '', |
|
| 151 | + ) |
|
| 152 | + ); |
|
| 153 | 153 | /*$this->addElement( |
| 154 | 154 | 'radio', |
| 155 | 155 | 'config_icinga2api_use', |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | 'value' => array('Yes', 'No'),//array('1' => 'Yes', '0' => 'No'), |
| 160 | 160 | ) |
| 161 | 161 | );*/ |
| 162 | - // For Icinga2 API connexion |
|
| 162 | + // For Icinga2 API connexion |
|
| 163 | 163 | // $icinga2API=new Fieldset('Icinga2 API connection'); |
| 164 | 164 | /* $icinga2API_select=new radioBtn('icinga2API_use'); |
| 165 | 165 | $icinga2API_select->setLabel('Use icinga2 API instead of cmd file?'); |
@@ -169,30 +169,30 @@ discard block |
||
| 169 | 169 | ]); |
| 170 | 170 | $icinga2API->add($icinga2API_select); |
| 171 | 171 | $this->add($icinga2API); */ |
| 172 | - } |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | - public function render(Zend_View_Interface $view = NULL) |
|
| 176 | - { |
|
| 175 | + public function render(Zend_View_Interface $view = NULL) |
|
| 176 | + { |
|
| 177 | 177 | |
| 178 | 178 | |
| 179 | - //return $html; |
|
| 180 | - return parent::render($view); |
|
| 181 | - } |
|
| 179 | + //return $html; |
|
| 180 | + return parent::render($view); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * {@inheritdoc} |
|
| 185 | - */ |
|
| 186 | - public function onSuccess() |
|
| 187 | - { |
|
| 188 | - parent::onSuccess(); |
|
| 189 | - } |
|
| 183 | + /** |
|
| 184 | + * {@inheritdoc} |
|
| 185 | + */ |
|
| 186 | + public function onSuccess() |
|
| 187 | + { |
|
| 188 | + parent::onSuccess(); |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * {@inheritdoc} |
|
| 193 | - */ |
|
| 191 | + /** |
|
| 192 | + * {@inheritdoc} |
|
| 193 | + */ |
|
| 194 | 194 | public function save() |
| 195 | - { |
|
| 195 | + { |
|
| 196 | 196 | parent::save(); |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Trap detail page |
|
| 43 | - */ |
|
| 42 | + * Trap detail page |
|
| 43 | + */ |
|
| 44 | 44 | public function trapdetailAction() |
| 45 | 45 | { |
| 46 | 46 | |
@@ -141,22 +141,22 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function hostsAction() |
| 143 | 143 | { |
| 144 | - $this->checkReadPermission(); |
|
| 145 | - $this->prepareTabs()->activate('hosts'); |
|
| 144 | + $this->checkReadPermission(); |
|
| 145 | + $this->prepareTabs()->activate('hosts'); |
|
| 146 | 146 | |
| 147 | - $db = $this->getDb(); |
|
| 148 | - $this->getTrapHostListTable()->setConnection($db); |
|
| 147 | + $db = $this->getDb(); |
|
| 148 | + $this->getTrapHostListTable()->setConnection($db); |
|
| 149 | 149 | |
| 150 | - // Apply pagination limits |
|
| 151 | - $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
| 150 | + // Apply pagination limits |
|
| 151 | + $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
| 152 | 152 | |
| 153 | - // Set Filter |
|
| 154 | - //$postData=$this->getRequest()->getPost(); |
|
| 155 | - $filter=array(); |
|
| 156 | - $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; |
|
| 157 | - $filter['done']=$this->params->get('done'); |
|
| 158 | - $this->view->filter=$filter; |
|
| 159 | - $this->view->table->updateFilter(Url::fromRequest(),$filter); |
|
| 153 | + // Set Filter |
|
| 154 | + //$postData=$this->getRequest()->getPost(); |
|
| 155 | + $filter=array(); |
|
| 156 | + $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; |
|
| 157 | + $filter['done']=$this->params->get('done'); |
|
| 158 | + $this->view->filter=$filter; |
|
| 159 | + $this->view->table->updateFilter(Url::fromRequest(),$filter); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | public function deleteAction() |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | return $this->getTabs()->add('traps', array( |
| 177 | 177 | 'label' => $this->translate('Traps'), |
| 178 | 178 | 'url' => $this->getModuleConfig()->urlPath() . '/received') |
| 179 | - ) |
|
| 180 | - ->add('hosts', array( |
|
| 181 | - 'label' => $this->translate('Hosts'), |
|
| 182 | - 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts') |
|
| 183 | - ) |
|
| 184 | - ->add('delete', array( |
|
| 179 | + ) |
|
| 180 | + ->add('hosts', array( |
|
| 181 | + 'label' => $this->translate('Hosts'), |
|
| 182 | + 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts') |
|
| 183 | + ) |
|
| 184 | + ->add('delete', array( |
|
| 185 | 185 | 'label' => $this->translate('Delete'), |
| 186 | 186 | 'url' => $this->getModuleConfig()->urlPath() . '/received/delete') |
| 187 | 187 | ); |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | protected $lastHost; |
| 22 | 22 | // Filters |
| 23 | 23 | |
| 24 | - protected $filter; |
|
| 25 | - protected $enforcedFilters = array(); |
|
| 26 | - protected $searchColumns = array(); |
|
| 24 | + protected $filter; |
|
| 25 | + protected $enforcedFilters = array(); |
|
| 26 | + protected $searchColumns = array(); |
|
| 27 | 27 | |
| 28 | 28 | protected function getTitles() { |
| 29 | 29 | // TODO : check moduleconfig is set |
| 30 | - return $this->moduleConfig->getTrapHostListTitles(); |
|
| 30 | + return $this->moduleConfig->getTrapHostListTitles(); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // ****************** Render table in html |
@@ -35,45 +35,45 @@ discard block |
||
| 35 | 35 | // Host grouping |
| 36 | 36 | protected function renderHostIfNew($IP,$hostname) |
| 37 | 37 | { |
| 38 | - $view = $this->getView(); |
|
| 38 | + $view = $this->getView(); |
|
| 39 | 39 | |
| 40 | - if ($this->lastHost === $IP) { |
|
| 41 | - return; |
|
| 42 | - } |
|
| 40 | + if ($this->lastHost === $IP) { |
|
| 41 | + return; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - if ($this->lastHost === null) |
|
| 45 | - { |
|
| 46 | - $htm = "<thead>\n <tr>\n"; |
|
| 47 | - } else { |
|
| 48 | - $htm = "</tbody>\n<thead>\n <tr>\n"; |
|
| 49 | - } |
|
| 44 | + if ($this->lastHost === null) |
|
| 45 | + { |
|
| 46 | + $htm = "<thead>\n <tr>\n"; |
|
| 47 | + } else { |
|
| 48 | + $htm = "</tbody>\n<thead>\n <tr>\n"; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($this->columnCount === null) |
|
| 52 | - { |
|
| 53 | - $this->columnCount = count($this->getTitles()); |
|
| 54 | - } |
|
| 51 | + if ($this->columnCount === null) |
|
| 52 | + { |
|
| 53 | + $this->columnCount = count($this->getTitles()); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP); |
|
| 57 | - if ($hostname != null) |
|
| 58 | - { |
|
| 59 | - $htm .= ' ('.$hostname.')'; |
|
| 60 | - } |
|
| 61 | - $htm .= '</th>' . "\n"; |
|
| 62 | - if ($this->lastHost === null) { |
|
| 63 | - $htm .= " </tr>\n"; |
|
| 64 | - } else { |
|
| 65 | - $htm .= " </tr>\n</thead>\n"; |
|
| 66 | - } |
|
| 56 | + $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP); |
|
| 57 | + if ($hostname != null) |
|
| 58 | + { |
|
| 59 | + $htm .= ' ('.$hostname.')'; |
|
| 60 | + } |
|
| 61 | + $htm .= '</th>' . "\n"; |
|
| 62 | + if ($this->lastHost === null) { |
|
| 63 | + $htm .= " </tr>\n"; |
|
| 64 | + } else { |
|
| 65 | + $htm .= " </tr>\n</thead>\n"; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $this->lastHost = $IP; |
|
| 68 | + $this->lastHost = $IP; |
|
| 69 | 69 | |
| 70 | - return $htm . "<tbody>\n"; |
|
| 70 | + return $htm . "<tbody>\n"; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function __toString() |
|
| 74 | - { |
|
| 75 | - return $this->render(); |
|
| 76 | - } |
|
| 73 | + public function __toString() |
|
| 74 | + { |
|
| 75 | + return $this->render(); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | public function render() |
| 79 | 79 | { |
@@ -139,9 +139,9 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function count() |
|
| 143 | - { |
|
| 144 | - $db=$this->db(); |
|
| 142 | + public function count() |
|
| 143 | + { |
|
| 144 | + $db=$this->db(); |
|
| 145 | 145 | |
| 146 | 146 | $query = $this->getBaseQuery(); |
| 147 | 147 | $this->applyFiltersToQuery($query); |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | return count($values); |
| 151 | 151 | |
| 152 | - //return $db->fetchOne($query); |
|
| 153 | - } |
|
| 152 | + //return $db->fetchOne($query); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - public function getPaginator() |
|
| 156 | - { |
|
| 157 | - $paginator = new Paginator(); |
|
| 158 | - $paginator->setQuery($this); |
|
| 155 | + public function getPaginator() |
|
| 156 | + { |
|
| 157 | + $paginator = new Paginator(); |
|
| 158 | + $paginator->setQuery($this); |
|
| 159 | 159 | |
| 160 | - return $paginator; |
|
| 161 | - } |
|
| 160 | + return $paginator; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | // ****************** DB connection and query |
| 164 | 164 | |
@@ -168,24 +168,24 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $query = $this->getBaseQuery(); |
| 170 | 170 | $this->applyFiltersToQuery($query); |
| 171 | - if ($this->hasLimit() || $this->hasOffset()) { |
|
| 172 | - $query->limit($this->getLimit(), $this->getOffset()); |
|
| 173 | - } |
|
| 171 | + if ($this->hasLimit() || $this->hasOffset()) { |
|
| 172 | + $query->limit($this->getLimit(), $this->getOffset()); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | return $db->fetchAll($query); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - public function getBaseQuery() |
|
| 179 | - { |
|
| 178 | + public function getBaseQuery() |
|
| 179 | + { |
|
| 180 | 180 | $db=$this->db(); |
| 181 | 181 | $query = $db->select()->from( |
| 182 | - $this->moduleConfig->getTrapTableName(), |
|
| 183 | - $this->moduleConfig->getTrapHostListDisplayColumns() |
|
| 184 | - )->group(array('t.source_ip','t.source_name','t.trap_oid')) |
|
| 185 | - ->order('t.source_ip'); |
|
| 182 | + $this->moduleConfig->getTrapTableName(), |
|
| 183 | + $this->moduleConfig->getTrapHostListDisplayColumns() |
|
| 184 | + )->group(array('t.source_ip','t.source_name','t.trap_oid')) |
|
| 185 | + ->order('t.source_ip'); |
|
| 186 | 186 | |
| 187 | - return $query; |
|
| 188 | - } |
|
| 187 | + return $query; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | // ****************** Filters |
| 191 | 191 | |
@@ -215,39 +215,39 @@ discard block |
||
| 215 | 215 | $this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - protected function getSearchColumns() |
|
| 219 | - { |
|
| 220 | - return $this->getColumns(); |
|
| 221 | - } |
|
| 218 | + protected function getSearchColumns() |
|
| 219 | + { |
|
| 220 | + return $this->getColumns(); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | public function getColumns() |
| 224 | 224 | { |
| 225 | 225 | return $this->moduleConfig->getTrapListDisplayColumns(); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - public function setFilter($filter) |
|
| 229 | - { |
|
| 230 | - $this->filter = $filter; |
|
| 231 | - return $this; |
|
| 232 | - } |
|
| 228 | + public function setFilter($filter) |
|
| 229 | + { |
|
| 230 | + $this->filter = $filter; |
|
| 231 | + return $this; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | public function getFilterEditor(Request $request) |
| 235 | - { |
|
| 236 | - $filterEditor = Widget::create('filterEditor') |
|
| 237 | - ->setColumns(array_keys($this->getColumns())) |
|
| 238 | - ->setSearchColumns(array_keys($this->getSearchColumns())) |
|
| 239 | - ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
|
| 240 | - ->ignoreParams('page') |
|
| 241 | - ->handleRequest($request); |
|
| 235 | + { |
|
| 236 | + $filterEditor = Widget::create('filterEditor') |
|
| 237 | + ->setColumns(array_keys($this->getColumns())) |
|
| 238 | + ->setSearchColumns(array_keys($this->getSearchColumns())) |
|
| 239 | + ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
|
| 240 | + ->ignoreParams('page') |
|
| 241 | + ->handleRequest($request); |
|
| 242 | 242 | |
| 243 | - $filter = $filterEditor->getFilter(); |
|
| 244 | - $this->setFilter($filter); |
|
| 243 | + $filter = $filterEditor->getFilter(); |
|
| 244 | + $this->setFilter($filter); |
|
| 245 | 245 | |
| 246 | - return $filterEditor; |
|
| 247 | - } |
|
| 246 | + return $filterEditor; |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - protected function applyFiltersToQuery($query) |
|
| 250 | - { |
|
| 249 | + protected function applyFiltersToQuery($query) |
|
| 250 | + { |
|
| 251 | 251 | |
| 252 | 252 | $sql=''; |
| 253 | 253 | if ($this->filter_query != '') |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | $sql.="(status != 'done')"; |
| 269 | 269 | } |
| 270 | 270 | if ($sql != '') $query->where($sql); |
| 271 | - return $query; |
|
| 272 | - } |
|
| 271 | + return $query; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | 274 | } |
| 275 | 275 | |
@@ -4,9 +4,9 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class TrapModuleConfig |
| 6 | 6 | { |
| 7 | - /********** Database configuration ***********************/ |
|
| 7 | + /********** Database configuration ***********************/ |
|
| 8 | 8 | // Database prefix for tables |
| 9 | - protected $table_prefix; //< Database prefix for tables |
|
| 9 | + protected $table_prefix; //< Database prefix for tables |
|
| 10 | 10 | protected $DBConfigDefaults=array( |
| 11 | 11 | 'db_remove_days' => 60, // number of days before removing traps |
| 12 | 12 | 'log_destination' => 'syslog', // Log destination for trap handler |
@@ -113,27 +113,27 @@ discard block |
||
| 113 | 113 | // Note : must have 'source_ip' and 'last_sent' |
| 114 | 114 | public function getTrapHostListDisplayColumns() |
| 115 | 115 | { |
| 116 | - return array( |
|
| 117 | - 'source_name' => 't.source_name', |
|
| 118 | - 'source_ip' => 't.source_ip', |
|
| 119 | - 'trap_oid' => 't.trap_oid', |
|
| 120 | - 'count' => 'count(*)', |
|
| 121 | - 'last_sent' => 'UNIX_TIMESTAMP(max(t.date_received))' |
|
| 122 | - ); |
|
| 116 | + return array( |
|
| 117 | + 'source_name' => 't.source_name', |
|
| 118 | + 'source_ip' => 't.source_ip', |
|
| 119 | + 'trap_oid' => 't.trap_oid', |
|
| 120 | + 'count' => 'count(*)', |
|
| 121 | + 'last_sent' => 'UNIX_TIMESTAMP(max(t.date_received))' |
|
| 122 | + ); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public function getTrapHostListSearchColumns() |
| 126 | 126 | { |
| 127 | - return array(); // No search needed on this table |
|
| 127 | + return array(); // No search needed on this table |
|
| 128 | 128 | } |
| 129 | 129 | // Titles display in Trap List table |
| 130 | 130 | public function getTrapHostListTitles() |
| 131 | 131 | { |
| 132 | - return array( |
|
| 133 | - 'trap_oid' => 'Trap OID', |
|
| 134 | - 'count' => 'Number of traps received', |
|
| 135 | - 'last_sent' => 'Last trap received' |
|
| 136 | - ); |
|
| 132 | + return array( |
|
| 133 | + 'trap_oid' => 'Trap OID', |
|
| 134 | + 'count' => 'Number of traps received', |
|
| 135 | + 'last_sent' => 'Last trap received' |
|
| 136 | + ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | 'revert_ok' => 'r.revert_ok', |
| 189 | 189 | 'display' => 'r.display', |
| 190 | 190 | 'modified' => 'UNIX_TIMESTAMP(r.modified)', |
| 191 | - 'modifier' => 'r.modifier' |
|
| 191 | + 'modifier' => 'r.modifier' |
|
| 192 | 192 | ); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -9,113 +9,113 @@ |
||
| 9 | 9 | class Logging |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - //**** Options from config database |
|
| 13 | - // Default values |
|
| 14 | - public $debugLevel=2; // 0=No output 1=critical 2=warning 3=trace 4=ALL |
|
| 15 | - public $outputMode='syslog'; // alert type : file, syslog, display |
|
| 16 | - public $outputFile="/tmp/trapdebug.txt"; |
|
| 17 | - protected $logLevels=array("","Error","Warning","Info","Debug"); |
|
| 18 | - protected $outputList=array('file', 'syslog', 'display'); |
|
| 12 | + //**** Options from config database |
|
| 13 | + // Default values |
|
| 14 | + public $debugLevel=2; // 0=No output 1=critical 2=warning 3=trace 4=ALL |
|
| 15 | + public $outputMode='syslog'; // alert type : file, syslog, display |
|
| 16 | + public $outputFile="/tmp/trapdebug.txt"; |
|
| 17 | + protected $logLevels=array("","Error","Warning","Info","Debug"); |
|
| 18 | + protected $outputList=array('file', 'syslog', 'display'); |
|
| 19 | 19 | |
| 20 | - /** Send log. Throws exception on critical error |
|
| 21 | - * @param string $message Message to log |
|
| 22 | - * @param int $level 1=critical 2=warning 3=trace 4=debug |
|
| 23 | - * @param string $destination file/syslog/display |
|
| 24 | - * @return void |
|
| 25 | - * @throws Exception |
|
| 26 | - **/ |
|
| 27 | - public function log( $message, $level, $destination ='') |
|
| 28 | - { |
|
| 29 | - if ($this->debugLevel >= $level) |
|
| 30 | - { |
|
| 31 | - $message = '['. date("Y/m/d H:i:s") . '] ' . |
|
| 32 | - '[TrapDirector] ['.$this->logLevels[$level].']: ' .$message . "\n"; |
|
| 20 | + /** Send log. Throws exception on critical error |
|
| 21 | + * @param string $message Message to log |
|
| 22 | + * @param int $level 1=critical 2=warning 3=trace 4=debug |
|
| 23 | + * @param string $destination file/syslog/display |
|
| 24 | + * @return void |
|
| 25 | + * @throws Exception |
|
| 26 | + **/ |
|
| 27 | + public function log( $message, $level, $destination ='') |
|
| 28 | + { |
|
| 29 | + if ($this->debugLevel >= $level) |
|
| 30 | + { |
|
| 31 | + $message = '['. date("Y/m/d H:i:s") . '] ' . |
|
| 32 | + '[TrapDirector] ['.$this->logLevels[$level].']: ' .$message . "\n"; |
|
| 33 | 33 | |
| 34 | - $output = ( $destination != '' ) ? $destination : $this->outputMode; |
|
| 35 | - switch ($output) |
|
| 36 | - { |
|
| 37 | - case 'file': |
|
| 38 | - file_put_contents ($this->outputFile, $message , FILE_APPEND); |
|
| 39 | - break; |
|
| 40 | - case 'syslog': |
|
| 41 | - switch($level) |
|
| 42 | - { |
|
| 43 | - case 1 : $prio = LOG_ERR;break; |
|
| 44 | - case 2 : $prio = LOG_WARNING;break; |
|
| 45 | - case 3 : $prio = LOG_INFO;break; |
|
| 46 | - case 4 : $prio = LOG_DEBUG;break; |
|
| 47 | - default: $prio = LOG_ERR; |
|
| 48 | - } |
|
| 49 | - syslog($prio,$message); |
|
| 50 | - break; |
|
| 51 | - case 'display': |
|
| 52 | - echo $message; |
|
| 53 | - break; |
|
| 54 | - default : // nothing we can do at this point |
|
| 55 | - throw new Exception($message); |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - if ($level == 1) |
|
| 59 | - { |
|
| 60 | - throw new Exception($message); |
|
| 61 | - } |
|
| 62 | - } |
|
| 34 | + $output = ( $destination != '' ) ? $destination : $this->outputMode; |
|
| 35 | + switch ($output) |
|
| 36 | + { |
|
| 37 | + case 'file': |
|
| 38 | + file_put_contents ($this->outputFile, $message , FILE_APPEND); |
|
| 39 | + break; |
|
| 40 | + case 'syslog': |
|
| 41 | + switch($level) |
|
| 42 | + { |
|
| 43 | + case 1 : $prio = LOG_ERR;break; |
|
| 44 | + case 2 : $prio = LOG_WARNING;break; |
|
| 45 | + case 3 : $prio = LOG_INFO;break; |
|
| 46 | + case 4 : $prio = LOG_DEBUG;break; |
|
| 47 | + default: $prio = LOG_ERR; |
|
| 48 | + } |
|
| 49 | + syslog($prio,$message); |
|
| 50 | + break; |
|
| 51 | + case 'display': |
|
| 52 | + echo $message; |
|
| 53 | + break; |
|
| 54 | + default : // nothing we can do at this point |
|
| 55 | + throw new Exception($message); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + if ($level == 1) |
|
| 59 | + { |
|
| 60 | + throw new Exception($message); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | - public function setLogging($debugLvl,$outputType,$outputFile=null) |
|
| 66 | - { |
|
| 67 | - $this->setLevel($debugLvl); |
|
| 68 | - switch ($outputType) |
|
| 69 | - { |
|
| 70 | - case 'file': |
|
| 71 | - if ($outputFile == null) throw new Exception("File logging without file !"); |
|
| 72 | - $this->setFile($outputFile); |
|
| 73 | - $this->setDestination('file'); |
|
| 74 | - break; |
|
| 75 | - default: |
|
| 76 | - $this->setDestination($outputType); |
|
| 77 | - } |
|
| 78 | - } |
|
| 65 | + public function setLogging($debugLvl,$outputType,$outputFile=null) |
|
| 66 | + { |
|
| 67 | + $this->setLevel($debugLvl); |
|
| 68 | + switch ($outputType) |
|
| 69 | + { |
|
| 70 | + case 'file': |
|
| 71 | + if ($outputFile == null) throw new Exception("File logging without file !"); |
|
| 72 | + $this->setFile($outputFile); |
|
| 73 | + $this->setDestination('file'); |
|
| 74 | + break; |
|
| 75 | + default: |
|
| 76 | + $this->setDestination($outputType); |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Set logging level |
|
| 82 | - * @param integer $level |
|
| 83 | - * @throws Exception |
|
| 84 | - */ |
|
| 85 | - public function setLevel($level) |
|
| 86 | - { |
|
| 87 | - if (!is_integer($level) || $level < 0 || $level > 10) |
|
| 88 | - { |
|
| 89 | - throw new Exception('Invalid log level'); |
|
| 90 | - } |
|
| 91 | - $this->debugLevel=$level; |
|
| 92 | - } |
|
| 80 | + /** |
|
| 81 | + * Set logging level |
|
| 82 | + * @param integer $level |
|
| 83 | + * @throws Exception |
|
| 84 | + */ |
|
| 85 | + public function setLevel($level) |
|
| 86 | + { |
|
| 87 | + if (!is_integer($level) || $level < 0 || $level > 10) |
|
| 88 | + { |
|
| 89 | + throw new Exception('Invalid log level'); |
|
| 90 | + } |
|
| 91 | + $this->debugLevel=$level; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Set logging destination |
|
| 96 | - * @param string $destination |
|
| 97 | - * @throws Exception |
|
| 98 | - */ |
|
| 99 | - public function setDestination($destination) |
|
| 100 | - { |
|
| 101 | - if (!is_string($destination) || ! in_array($destination, $this->outputList)) |
|
| 102 | - { |
|
| 103 | - throw new Exception('Invalid log destination'); |
|
| 104 | - } |
|
| 105 | - $this->outputMode=$destination; |
|
| 106 | - } |
|
| 107 | - /** |
|
| 108 | - * Set file destination |
|
| 109 | - * @param string $file |
|
| 110 | - * @throws Exception |
|
| 111 | - */ |
|
| 112 | - public function setFile($file) |
|
| 113 | - { |
|
| 114 | - if (!is_string($file)) |
|
| 115 | - { |
|
| 116 | - throw new Exception('Invalid log file'); |
|
| 117 | - } |
|
| 118 | - $this->outputFile=$file; |
|
| 119 | - } |
|
| 94 | + /** |
|
| 95 | + * Set logging destination |
|
| 96 | + * @param string $destination |
|
| 97 | + * @throws Exception |
|
| 98 | + */ |
|
| 99 | + public function setDestination($destination) |
|
| 100 | + { |
|
| 101 | + if (!is_string($destination) || ! in_array($destination, $this->outputList)) |
|
| 102 | + { |
|
| 103 | + throw new Exception('Invalid log destination'); |
|
| 104 | + } |
|
| 105 | + $this->outputMode=$destination; |
|
| 106 | + } |
|
| 107 | + /** |
|
| 108 | + * Set file destination |
|
| 109 | + * @param string $file |
|
| 110 | + * @throws Exception |
|
| 111 | + */ |
|
| 112 | + public function setFile($file) |
|
| 113 | + { |
|
| 114 | + if (!is_string($file)) |
|
| 115 | + { |
|
| 116 | + throw new Exception('Invalid log file'); |
|
| 117 | + } |
|
| 118 | + $this->outputFile=$file; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | } |
| 122 | 122 | \ No newline at end of file |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | protected $trapClass; //< Trap class for bin/trap_class.php |
| 33 | 33 | |
| 34 | 34 | /** Get instance of TrapModuleConfig class |
| 35 | - * @return TrapModuleConfig |
|
| 36 | - */ |
|
| 35 | + * @return TrapModuleConfig |
|
| 36 | + */ |
|
| 37 | 37 | public function getModuleConfig() |
| 38 | 38 | { |
| 39 | 39 | if ($this->moduleConfig == Null) |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function getTrapHostListTable() |
| 60 | 60 | { |
| 61 | - if ($this->trapTableHostList == Null) |
|
| 61 | + if ($this->trapTableHostList == Null) |
|
| 62 | 62 | { |
| 63 | - $this->trapTableHostList = new TrapTableHostList(); |
|
| 64 | - $this->trapTableHostList->setConfig($this->getModuleConfig()); |
|
| 65 | - } |
|
| 66 | - return $this->trapTableHostList; |
|
| 63 | + $this->trapTableHostList = new TrapTableHostList(); |
|
| 64 | + $this->trapTableHostList->setConfig($this->getModuleConfig()); |
|
| 65 | + } |
|
| 66 | + return $this->trapTableHostList; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function getHandlerListTable() |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** Get Database connexion |
| 80 | - * @param $DBname string DB name in resource.ini_ge |
|
| 81 | - * @param $test bool if set to true, returns error code and not database |
|
| 82 | - * @param $test_version bool if set to flase, does not test database version of trapDB |
|
| 83 | - * @return array<integer,mixed>|mixed : if test=false, returns DB connexion, else array(error_num,message) or null on error. |
|
| 84 | - */ |
|
| 80 | + * @param $DBname string DB name in resource.ini_ge |
|
| 81 | + * @param $test bool if set to true, returns error code and not database |
|
| 82 | + * @param $test_version bool if set to flase, does not test database version of trapDB |
|
| 83 | + * @return array<integer,mixed>|mixed : if test=false, returns DB connexion, else array(error_num,message) or null on error. |
|
| 84 | + */ |
|
| 85 | 85 | public function getDbByName($DBname,$test=false,$test_version=true) |
| 86 | 86 | { |
| 87 | 87 | try |
@@ -166,20 +166,20 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | if ( ! $dbresource ) |
| 168 | 168 | { |
| 169 | - if ($test) return array(1,'No database in config.ini'); |
|
| 170 | - $this->redirectNow('trapdirector/settings?idodberror=1'); |
|
| 171 | - return null; |
|
| 169 | + if ($test) return array(1,'No database in config.ini'); |
|
| 170 | + $this->redirectNow('trapdirector/settings?idodberror=1'); |
|
| 171 | + return null; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | try |
| 175 | 175 | { |
| 176 | - $dbconn = IcingaDbConnection::fromResourceName($dbresource); |
|
| 176 | + $dbconn = IcingaDbConnection::fromResourceName($dbresource); |
|
| 177 | 177 | } |
| 178 | 178 | catch (Exception $e) |
| 179 | 179 | { |
| 180 | - if ($test) return array(2,"Database $dbresource does not exists in IcingaWeb2"); |
|
| 181 | - $this->redirectNow('trapdirector/settings?idodberror=2'); |
|
| 182 | - return null; |
|
| 180 | + if ($test) return array(2,"Database $dbresource does not exists in IcingaWeb2"); |
|
| 181 | + $this->redirectNow('trapdirector/settings?idodberror=2'); |
|
| 182 | + return null; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | if ($test == false) |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | try |
| 192 | 192 | { |
| 193 | - $query = $dbconn->select() |
|
| 194 | - ->from('icinga_dbversion',array('version')); |
|
| 195 | - $version=$dbconn->fetchRow($query); |
|
| 196 | - if ( ($version == null) || ! property_exists($version,'version') ) |
|
| 197 | - { |
|
| 198 | - return array(4,"$dbresource does not look like an IDO database"); |
|
| 199 | - } |
|
| 193 | + $query = $dbconn->select() |
|
| 194 | + ->from('icinga_dbversion',array('version')); |
|
| 195 | + $version=$dbconn->fetchRow($query); |
|
| 196 | + if ( ($version == null) || ! property_exists($version,'version') ) |
|
| 197 | + { |
|
| 198 | + return array(4,"$dbresource does not look like an IDO database"); |
|
| 199 | + } |
|
| 200 | 200 | } |
| 201 | 201 | catch (Exception $e) |
| 202 | 202 | { |
@@ -206,15 +206,15 @@ discard block |
||
| 206 | 206 | return array(0,''); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 210 | - { |
|
| 211 | - $limit = $this->params->get('limit', $limit); |
|
| 212 | - $page = $this->params->get('page', $offset); |
|
| 209 | + protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 210 | + { |
|
| 211 | + $limit = $this->params->get('limit', $limit); |
|
| 212 | + $page = $this->params->get('page', $offset); |
|
| 213 | 213 | |
| 214 | - $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
|
| 214 | + $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
|
| 215 | 215 | |
| 216 | - return $paginatable; |
|
| 217 | - } |
|
| 216 | + return $paginatable; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | public function displayExitError($source,$message) |
| 220 | 220 | { // TODO : check better ways to transmit data (with POST ?) |
@@ -223,33 +223,33 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | protected function checkReadPermission() |
| 225 | 225 | { |
| 226 | - if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 227 | - $this->displayExitError('Permissions','No permission fo view content'); |
|
| 228 | - } |
|
| 226 | + if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 227 | + $this->displayExitError('Permissions','No permission fo view content'); |
|
| 228 | + } |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | protected function checkConfigPermission() |
| 232 | 232 | { |
| 233 | - if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 234 | - $this->displayExitError('Permissions','No permission fo configure'); |
|
| 235 | - } |
|
| 233 | + if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 234 | + $this->displayExitError('Permissions','No permission fo configure'); |
|
| 235 | + } |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Check if user has write permission |
|
| 240 | - * @param number $check optional : if set to 1, return true (user has permission) or false instead of displaying error page |
|
| 241 | - * @return boolean : user has permission |
|
| 242 | - */ |
|
| 238 | + /** |
|
| 239 | + * Check if user has write permission |
|
| 240 | + * @param number $check optional : if set to 1, return true (user has permission) or false instead of displaying error page |
|
| 241 | + * @return boolean : user has permission |
|
| 242 | + */ |
|
| 243 | 243 | protected function checkModuleConfigPermission($check=0) |
| 244 | 244 | { |
| 245 | - if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 246 | - if ($check == 0) |
|
| 247 | - { |
|
| 248 | - $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 249 | - } |
|
| 250 | - return false; |
|
| 251 | - } |
|
| 252 | - return true; |
|
| 245 | + if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 246 | + if ($check == 0) |
|
| 247 | + { |
|
| 248 | + $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 249 | + } |
|
| 250 | + return false; |
|
| 251 | + } |
|
| 252 | + return true; |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /************************* Trap class get **********************/ |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | /************************** MIB related **************************/ |
| 270 | 270 | |
| 271 | 271 | /** Get MIBLoader class |
| 272 | - * @return MIBLoader class |
|
| 273 | - */ |
|
| 272 | + * @return MIBLoader class |
|
| 273 | + */ |
|
| 274 | 274 | protected function getMIB() |
| 275 | 275 | { |
| 276 | 276 | if ($this->MIBData == null) |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | /************************** Database queries *******************/ |
| 289 | 289 | |
| 290 | 290 | /** Get host(s) by IP (v4 or v6) or by name in IDO database |
| 291 | - * does not catch exceptions |
|
| 292 | - * @return array of objects ( name, id (object_id), display_name) |
|
| 293 | - */ |
|
| 291 | + * does not catch exceptions |
|
| 292 | + * @return array of objects ( name, id (object_id), display_name) |
|
| 293 | + */ |
|
| 294 | 294 | protected function getHostByIP($ip) |
| 295 | 295 | { |
| 296 | 296 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** Get host(s) by name in IDO database |
| 312 | - * does not catch exceptions |
|
| 313 | - * @return array of objects ( name, id (object_id), display_name) |
|
| 314 | - */ |
|
| 312 | + * does not catch exceptions |
|
| 313 | + * @return array of objects ( name, id (object_id), display_name) |
|
| 314 | + */ |
|
| 315 | 315 | protected function getHostByName($name) |
| 316 | 316 | { |
| 317 | 317 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | /** Get host groups by name in IDO database |
| 333 | - * does not catch exceptions |
|
| 334 | - * @return array of objects ( name, id (object_id), display_name) |
|
| 335 | - */ |
|
| 333 | + * does not catch exceptions |
|
| 334 | + * @return array of objects ( name, id (object_id), display_name) |
|
| 335 | + */ |
|
| 336 | 336 | protected function getHostGroupByName($ip) |
| 337 | 337 | { |
| 338 | 338 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
@@ -352,9 +352,9 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | |
| 354 | 354 | /** Get host IP (v4 and v6) by name in IDO database |
| 355 | - * does not catch exceptions |
|
| 356 | - * @return array ( name, display_name, ip4, ip6) |
|
| 357 | - */ |
|
| 355 | + * does not catch exceptions |
|
| 356 | + * @return array ( name, display_name, ip4, ip6) |
|
| 357 | + */ |
|
| 358 | 358 | protected function getHostInfoByID($id) |
| 359 | 359 | { |
| 360 | 360 | if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
@@ -373,9 +373,9 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | |
| 375 | 375 | /** Get host by objectid in IDO database |
| 376 | - * does not catch exceptions |
|
| 377 | - * @return array of objects ( id, name, display_name, ip, ip6, ) |
|
| 378 | - */ |
|
| 376 | + * does not catch exceptions |
|
| 377 | + * @return array of objects ( id, name, display_name, ip, ip6, ) |
|
| 378 | + */ |
|
| 379 | 379 | protected function getHostByObjectID($id) // TODO : duplicate of getHostInfoByID above |
| 380 | 380 | { |
| 381 | 381 | if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** Get services from object ( host_object_id) in IDO database |
| 396 | - * does not catch exceptions |
|
| 397 | - * @param $id int object_id |
|
| 398 | - * @return array display_name (of service), service_object_id |
|
| 399 | - */ |
|
| 396 | + * does not catch exceptions |
|
| 397 | + * @param $id int object_id |
|
| 398 | + * @return array display_name (of service), service_object_id |
|
| 399 | + */ |
|
| 400 | 400 | protected function getServicesByHostid($id) |
| 401 | 401 | { |
| 402 | 402 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
@@ -416,11 +416,11 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** Get services from hostgroup object id ( hostgroup_object_id) in IDO database |
| 419 | - * gets all hosts in hostgroup and return common services |
|
| 420 | - * does not catch exceptions |
|
| 421 | - * @param $id int object_id |
|
| 422 | - * @return array display_name (of service), service_object_id |
|
| 423 | - */ |
|
| 419 | + * gets all hosts in hostgroup and return common services |
|
| 420 | + * does not catch exceptions |
|
| 421 | + * @param $id int object_id |
|
| 422 | + * @return array display_name (of service), service_object_id |
|
| 423 | + */ |
|
| 424 | 424 | protected function getServicesByHostGroupid($id) |
| 425 | 425 | { |
| 426 | 426 | if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | //print_r($common_services); |
| 460 | 460 | foreach (array_keys($common_services) as $key) |
| 461 | 461 | { |
| 462 | - if ($common_services[$key]['num'] == $num_hosts) |
|
| 462 | + if ($common_services[$key]['num'] == $num_hosts) |
|
| 463 | 463 | { |
| 464 | 464 | array_push($result,array($key,$common_services[$key]['name'])); |
| 465 | 465 | } |
@@ -469,11 +469,11 @@ discard block |
||
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** Get services object id by host name / service name in IDO database |
| 472 | - * does not catch exceptions |
|
| 473 | - * @param $hostname string host name |
|
| 474 | - * @param $name string service name |
|
| 475 | - * @return array service id |
|
| 476 | - */ |
|
| 472 | + * does not catch exceptions |
|
| 473 | + * @param $hostname string host name |
|
| 474 | + * @param $name string service name |
|
| 475 | + * @return array service id |
|
| 476 | + */ |
|
| 477 | 477 | protected function getServiceIDByName($hostname,$name) |
| 478 | 478 | { |
| 479 | 479 | $db = $this->getIdoDb()->getConnection(); |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** Get object name from object_id in IDO database |
| 499 | - * does not catch exceptions |
|
| 500 | - * @param int $id object_id (default to null, used first if not null) |
|
| 501 | - * @return array name1 (host) name2 (service) |
|
| 502 | - */ |
|
| 499 | + * does not catch exceptions |
|
| 500 | + * @param int $id object_id (default to null, used first if not null) |
|
| 501 | + * @return array name1 (host) name2 (service) |
|
| 502 | + */ |
|
| 503 | 503 | protected function getObjectNameByid($id) |
| 504 | 504 | { |
| 505 | 505 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | /** Add handler rule in traps DB |
| 518 | - * @param array $params : array(<db item>=><value>) |
|
| 519 | - * @return int inserted id |
|
| 520 | - */ |
|
| 518 | + * @param array $params : array(<db item>=><value>) |
|
| 519 | + * @return int inserted id |
|
| 520 | + */ |
|
| 521 | 521 | protected function addHandlerRule($params) |
| 522 | 522 | { |
| 523 | 523 | // TODO Check for rule consistency |
@@ -539,10 +539,10 @@ discard block |
||
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** Update handler rule in traps DB |
| 542 | - * @param array $params : (<db item>=><value>) |
|
| 543 | - * @param integer $ruleID : rule id in db |
|
| 544 | - * @return array affected rows |
|
| 545 | - */ |
|
| 542 | + * @param array $params : (<db item>=><value>) |
|
| 543 | + * @param integer $ruleID : rule id in db |
|
| 544 | + * @return array affected rows |
|
| 545 | + */ |
|
| 546 | 546 | protected function updateHandlerRule($params,$ruleID) |
| 547 | 547 | { |
| 548 | 548 | // TODO Check for rule consistency |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /** Delete rule by id |
| 563 | - * @param int $ruleID rule id |
|
| 564 | - */ |
|
| 563 | + * @param int $ruleID rule id |
|
| 564 | + */ |
|
| 565 | 565 | protected function deleteRule($ruleID) |
| 566 | 566 | { |
| 567 | 567 | if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
@@ -575,9 +575,9 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | /** Delete trap by ip & oid |
| 578 | - * @param $ip string source IP (v4 or v6) |
|
| 579 | - * @param $oid string oid |
|
| 580 | - */ |
|
| 578 | + * @param $ip string source IP (v4 or v6) |
|
| 579 | + * @param $oid string oid |
|
| 580 | + */ |
|
| 581 | 581 | protected function deleteTrap($ip,$oid) |
| 582 | 582 | { |
| 583 | 583 | |
@@ -603,9 +603,9 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | |
| 605 | 605 | /** count trap by ip & oid |
| 606 | - * @param $ip string source IP (v4 or v6) |
|
| 607 | - * @param $oid string oid |
|
| 608 | - */ |
|
| 606 | + * @param $ip string source IP (v4 or v6) |
|
| 607 | + * @param $oid string oid |
|
| 608 | + */ |
|
| 609 | 609 | protected function countTrap($ip,$oid) |
| 610 | 610 | { |
| 611 | 611 | |
@@ -631,8 +631,8 @@ discard block |
||
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | /** get configuration value |
| 634 | - * @param string $element : configuration name in db |
|
| 635 | - */ |
|
| 634 | + * @param string $element : configuration name in db |
|
| 635 | + */ |
|
| 636 | 636 | protected function getDBConfigValue($element) |
| 637 | 637 | { |
| 638 | 638 | |
@@ -663,9 +663,9 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** add configuration value |
| 666 | - * @param string $element : name of config element |
|
| 667 | - * @param string $value : value |
|
| 668 | - */ |
|
| 666 | + * @param string $element : name of config element |
|
| 667 | + * @param string $value : value |
|
| 668 | + */ |
|
| 669 | 669 | |
| 670 | 670 | protected function addDBConfigValue($element,$value) |
| 671 | 671 | { |
@@ -683,9 +683,9 @@ discard block |
||
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /** set configuration value |
| 686 | - * @param string $element : name of config element |
|
| 687 | - * @param string $value : value |
|
| 688 | - */ |
|
| 686 | + * @param string $element : name of config element |
|
| 687 | + * @param string $value : value |
|
| 688 | + */ |
|
| 689 | 689 | protected function setDBConfigValue($element,$value) |
| 690 | 690 | { |
| 691 | 691 | |
@@ -699,13 +699,13 @@ discard block |
||
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | /** Check if director is installed |
| 702 | - * @return bool true/false |
|
| 703 | - */ |
|
| 702 | + * @return bool true/false |
|
| 703 | + */ |
|
| 704 | 704 | protected function isDirectorInstalled() |
| 705 | 705 | { |
| 706 | - $output=array(); |
|
| 707 | - exec('icingacli module list',$output); |
|
| 708 | - foreach ($output as $line) |
|
| 706 | + $output=array(); |
|
| 707 | + exec('icingacli module list',$output); |
|
| 708 | + foreach ($output as $line) |
|
| 709 | 709 | { |
| 710 | 710 | if (preg_match('/^director .*enabled/',$line)) |
| 711 | 711 | { |