@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | |
19 | 19 | // Filters |
20 | 20 | |
21 | - protected $filter; |
|
22 | - protected $enforcedFilters = array(); |
|
23 | - protected $searchColumns = array(); |
|
21 | + protected $filter; |
|
22 | + protected $enforcedFilters = array(); |
|
23 | + protected $searchColumns = array(); |
|
24 | 24 | |
25 | 25 | protected function getTitles() { |
26 | 26 | // TODO : check moduleconfig is set |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | // ****************** Render table in html |
31 | - public function __toString() |
|
32 | - { |
|
33 | - return $this->render(); |
|
34 | - } |
|
31 | + public function __toString() |
|
32 | + { |
|
33 | + return $this->render(); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | public function render() |
37 | 37 | { |
@@ -95,26 +95,26 @@ discard block |
||
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | - public function count() |
|
99 | - { |
|
100 | - $db=$this->db(); |
|
98 | + public function count() |
|
99 | + { |
|
100 | + $db=$this->db(); |
|
101 | 101 | |
102 | 102 | $query = $db->select()->from( |
103 | - $this->moduleConfig->getTrapTableName(), |
|
104 | - array('COUNT(*)') |
|
105 | - ); |
|
103 | + $this->moduleConfig->getTrapTableName(), |
|
104 | + array('COUNT(*)') |
|
105 | + ); |
|
106 | 106 | $this->applyFiltersToQuery($query); |
107 | 107 | |
108 | - return $db->fetchOne($query); |
|
109 | - } |
|
108 | + return $db->fetchOne($query); |
|
109 | + } |
|
110 | 110 | |
111 | - public function getPaginator() |
|
112 | - { |
|
113 | - $paginator = new Paginator(); |
|
114 | - $paginator->setQuery($this); |
|
111 | + public function getPaginator() |
|
112 | + { |
|
113 | + $paginator = new Paginator(); |
|
114 | + $paginator->setQuery($this); |
|
115 | 115 | |
116 | - return $paginator; |
|
117 | - } |
|
116 | + return $paginator; |
|
117 | + } |
|
118 | 118 | |
119 | 119 | // ****************** DB connection and query |
120 | 120 | |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | |
125 | 125 | $query = $this->getBaseQuery(); |
126 | 126 | $this->applyFiltersToQuery($query); |
127 | - if ($this->hasLimit() || $this->hasOffset()) { |
|
128 | - $query->limit($this->getLimit(), $this->getOffset()); |
|
129 | - } |
|
127 | + if ($this->hasLimit() || $this->hasOffset()) { |
|
128 | + $query->limit($this->getLimit(), $this->getOffset()); |
|
129 | + } |
|
130 | 130 | |
131 | 131 | return $db->fetchAll($query); |
132 | 132 | } |
133 | 133 | |
134 | - public function getBaseQuery() |
|
135 | - { |
|
134 | + public function getBaseQuery() |
|
135 | + { |
|
136 | 136 | $db=$this->db(); |
137 | 137 | |
138 | 138 | $query = $db->select()->from( |
139 | - $this->moduleConfig->getTrapTableName(), |
|
140 | - $this->moduleConfig->getTrapListDisplayColumns() |
|
141 | - )->order('timestamp DESC'); |
|
139 | + $this->moduleConfig->getTrapTableName(), |
|
140 | + $this->moduleConfig->getTrapListDisplayColumns() |
|
141 | + )->order('timestamp DESC'); |
|
142 | 142 | |
143 | - return $query; |
|
144 | - } |
|
143 | + return $query; |
|
144 | + } |
|
145 | 145 | |
146 | 146 | // ****************** Filters |
147 | 147 | |
@@ -171,39 +171,39 @@ discard block |
||
171 | 171 | $this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0; |
172 | 172 | } |
173 | 173 | |
174 | - protected function getSearchColumns() |
|
175 | - { |
|
176 | - return $this->getColumns(); |
|
177 | - } |
|
174 | + protected function getSearchColumns() |
|
175 | + { |
|
176 | + return $this->getColumns(); |
|
177 | + } |
|
178 | 178 | |
179 | 179 | public function getColumns() |
180 | 180 | { |
181 | 181 | return $this->moduleConfig->getTrapListDisplayColumns(); |
182 | 182 | } |
183 | 183 | |
184 | - public function setFilter($filter) |
|
185 | - { |
|
186 | - $this->filter = $filter; |
|
187 | - return $this; |
|
188 | - } |
|
184 | + public function setFilter($filter) |
|
185 | + { |
|
186 | + $this->filter = $filter; |
|
187 | + return $this; |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public function getFilterEditor(Request $request) |
191 | - { |
|
192 | - $filterEditor = Widget::create('filterEditor') |
|
193 | - ->setColumns(array_keys($this->getColumns())) |
|
194 | - ->setSearchColumns(array_keys($this->getSearchColumns())) |
|
195 | - ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
|
196 | - ->ignoreParams('page') |
|
197 | - ->handleRequest($request); |
|
191 | + { |
|
192 | + $filterEditor = Widget::create('filterEditor') |
|
193 | + ->setColumns(array_keys($this->getColumns())) |
|
194 | + ->setSearchColumns(array_keys($this->getSearchColumns())) |
|
195 | + ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
|
196 | + ->ignoreParams('page') |
|
197 | + ->handleRequest($request); |
|
198 | 198 | |
199 | - $filter = $filterEditor->getFilter(); |
|
200 | - $this->setFilter($filter); |
|
199 | + $filter = $filterEditor->getFilter(); |
|
200 | + $this->setFilter($filter); |
|
201 | 201 | |
202 | - return $filterEditor; |
|
203 | - } |
|
202 | + return $filterEditor; |
|
203 | + } |
|
204 | 204 | |
205 | - protected function applyFiltersToQuery($query) |
|
206 | - { |
|
205 | + protected function applyFiltersToQuery($query) |
|
206 | + { |
|
207 | 207 | |
208 | 208 | $sql=''; |
209 | 209 | if ($this->filter_query != '') |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $sql.="(status != 'done')"; |
225 | 225 | } |
226 | 226 | if ($sql != '') $query->where($sql); |
227 | - return $query; |
|
228 | - } |
|
227 | + return $query; |
|
228 | + } |
|
229 | 229 | |
230 | 230 | } |
231 | 231 | \ No newline at end of file |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | */ |
26 | 26 | private function get_param() |
27 | 27 | { |
28 | - $dberrorMsg=$this->params->get('dberror'); |
|
29 | - if ($dberrorMsg != '') |
|
30 | - { |
|
31 | - $this->view->errorDetected=$dberrorMsg; |
|
32 | - } |
|
33 | - $dberrorMsg=$this->params->get('idodberror'); |
|
34 | - if ($dberrorMsg != '') |
|
35 | - { |
|
36 | - $this->view->errorDetected=$dberrorMsg; |
|
37 | - } |
|
28 | + $dberrorMsg=$this->params->get('dberror'); |
|
29 | + if ($dberrorMsg != '') |
|
30 | + { |
|
31 | + $this->view->errorDetected=$dberrorMsg; |
|
32 | + } |
|
33 | + $dberrorMsg=$this->params->get('idodberror'); |
|
34 | + if ($dberrorMsg != '') |
|
35 | + { |
|
36 | + $this->view->errorDetected=$dberrorMsg; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,22 +43,22 @@ discard block |
||
43 | 43 | */ |
44 | 44 | private function check_empty_config() |
45 | 45 | { |
46 | - $this->view->configErrorDetected == NULL; // Displayed error on various conifugration errors. |
|
47 | - if ($this->Config()->isEmpty() == true) |
|
48 | - { |
|
49 | - $this->Config()->setSection('config'); // Set base config section. |
|
50 | - try |
|
51 | - { |
|
52 | - $this->Config()->saveIni(); |
|
53 | - $this->view->configErrorDetected='Configuration is empty : you can run install script with parameters (see Automatic installation below)'; |
|
54 | - //$emptyConfig=1; |
|
55 | - } |
|
56 | - catch (Exception $e) |
|
57 | - { |
|
58 | - $this->view->configErrorDetected=$e->getMessage(); |
|
59 | - } |
|
46 | + $this->view->configErrorDetected == NULL; // Displayed error on various conifugration errors. |
|
47 | + if ($this->Config()->isEmpty() == true) |
|
48 | + { |
|
49 | + $this->Config()->setSection('config'); // Set base config section. |
|
50 | + try |
|
51 | + { |
|
52 | + $this->Config()->saveIni(); |
|
53 | + $this->view->configErrorDetected='Configuration is empty : you can run install script with parameters (see Automatic installation below)'; |
|
54 | + //$emptyConfig=1; |
|
55 | + } |
|
56 | + catch (Exception $e) |
|
57 | + { |
|
58 | + $this->view->configErrorDetected=$e->getMessage(); |
|
59 | + } |
|
60 | 60 | |
61 | - } |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -71,45 +71,45 @@ discard block |
||
71 | 71 | */ |
72 | 72 | private function check_db() |
73 | 73 | { |
74 | - $db_message=array( // index => ( message OK, message NOK, optional link if NOK ) |
|
75 | - 0 => array('Database configuration OK','',''), |
|
76 | - 1 => array('Database set in config.ini','No database in config.ini',''), |
|
77 | - 2 => array('Database exists in Icingaweb2 config','Database does not exist in Icingaweb2 : ', |
|
78 | - Url::fromPath('config/resource')), |
|
79 | - 3 => array('Database credentials OK','Database does not exist/invalid credentials/no schema : ', |
|
80 | - Url::fromPath('trapdirector/settings/createschema')), |
|
81 | - 4 => array('Schema is set','Schema is not set for ', |
|
82 | - Url::fromPath('trapdirector/settings/createschema')), |
|
83 | - 5 => array('Schema is up to date','Schema is outdated :', |
|
84 | - Url::fromPath('trapdirector/settings/updateschema')), |
|
85 | - ); |
|
74 | + $db_message=array( // index => ( message OK, message NOK, optional link if NOK ) |
|
75 | + 0 => array('Database configuration OK','',''), |
|
76 | + 1 => array('Database set in config.ini','No database in config.ini',''), |
|
77 | + 2 => array('Database exists in Icingaweb2 config','Database does not exist in Icingaweb2 : ', |
|
78 | + Url::fromPath('config/resource')), |
|
79 | + 3 => array('Database credentials OK','Database does not exist/invalid credentials/no schema : ', |
|
80 | + Url::fromPath('trapdirector/settings/createschema')), |
|
81 | + 4 => array('Schema is set','Schema is not set for ', |
|
82 | + Url::fromPath('trapdirector/settings/createschema')), |
|
83 | + 5 => array('Schema is up to date','Schema is outdated :', |
|
84 | + Url::fromPath('trapdirector/settings/updateschema')), |
|
85 | + ); |
|
86 | 86 | |
87 | - $dberror=$this->getDb(true); // Get DB in test mode |
|
87 | + $dberror=$this->getDb(true); // Get DB in test mode |
|
88 | 88 | |
89 | - $this->view->db_error=$dberror[0]; |
|
90 | - switch ($dberror[0]) |
|
91 | - { |
|
92 | - case 2: |
|
93 | - case 4: |
|
94 | - $db_message[$dberror[0]][1] .= $dberror[1]; |
|
95 | - break; |
|
96 | - case 3: |
|
97 | - $db_message[$dberror[0]][1] .= $dberror[1] . ', Message : ' . $dberror[2]; |
|
98 | - break; |
|
99 | - case 5: |
|
100 | - $db_message[$dberror[0]][1] .= ' version '. $dberror[1] . ', version needed : ' .$dberror[2]; |
|
101 | - break; |
|
102 | - case 0: |
|
103 | - case 1: |
|
104 | - break; |
|
105 | - default: |
|
106 | - new ProgrammingError('Out of bond result from database test'); |
|
107 | - } |
|
108 | - $this->view->message=$db_message; |
|
89 | + $this->view->db_error=$dberror[0]; |
|
90 | + switch ($dberror[0]) |
|
91 | + { |
|
92 | + case 2: |
|
93 | + case 4: |
|
94 | + $db_message[$dberror[0]][1] .= $dberror[1]; |
|
95 | + break; |
|
96 | + case 3: |
|
97 | + $db_message[$dberror[0]][1] .= $dberror[1] . ', Message : ' . $dberror[2]; |
|
98 | + break; |
|
99 | + case 5: |
|
100 | + $db_message[$dberror[0]][1] .= ' version '. $dberror[1] . ', version needed : ' .$dberror[2]; |
|
101 | + break; |
|
102 | + case 0: |
|
103 | + case 1: |
|
104 | + break; |
|
105 | + default: |
|
106 | + new ProgrammingError('Out of bond result from database test'); |
|
107 | + } |
|
108 | + $this->view->message=$db_message; |
|
109 | 109 | |
110 | - $dberror=$this->getIdoDb(true); // Get IDO DB in test mode |
|
111 | - $this->view->ido_db_error=$dberror[0]; |
|
112 | - $this->view->ido_message='IDO Database : ' . $dberror[1]; |
|
110 | + $dberror=$this->getIdoDb(true); // Get IDO DB in test mode |
|
111 | + $this->view->ido_db_error=$dberror[0]; |
|
112 | + $this->view->ido_message='IDO Database : ' . $dberror[1]; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -119,23 +119,23 @@ discard block |
||
119 | 119 | */ |
120 | 120 | private function check_api() |
121 | 121 | { |
122 | - if ($this->Config()->get('config', 'icingaAPI_host') != '') |
|
123 | - { |
|
124 | - $apitest=new Icinga2Api($this->Config()->get('config', 'icingaAPI_host'),$this->Config()->get('config', 'icingaAPI_port')); |
|
125 | - $apitest->setCredentials($this->Config()->get('config', 'icingaAPI_user'), $this->Config()->get('config', 'icingaAPI_password')); |
|
126 | - try { |
|
127 | - list($this->view->apimessageError,$this->view->apimessage)=$apitest->test($this->getModuleConfig()::getapiUserPermissions()); |
|
128 | - //$this->view->apimessageError=false; |
|
129 | - } catch (RuntimeException $e) { |
|
130 | - $this->view->apimessage='API config : ' . $e->getMessage(); |
|
131 | - $this->view->apimessageError=true; |
|
132 | - } |
|
133 | - } |
|
134 | - else |
|
135 | - { |
|
136 | - $this->view->apimessage='API parameters not configured'; |
|
137 | - $this->view->apimessageError=true; |
|
138 | - } |
|
122 | + if ($this->Config()->get('config', 'icingaAPI_host') != '') |
|
123 | + { |
|
124 | + $apitest=new Icinga2Api($this->Config()->get('config', 'icingaAPI_host'),$this->Config()->get('config', 'icingaAPI_port')); |
|
125 | + $apitest->setCredentials($this->Config()->get('config', 'icingaAPI_user'), $this->Config()->get('config', 'icingaAPI_password')); |
|
126 | + try { |
|
127 | + list($this->view->apimessageError,$this->view->apimessage)=$apitest->test($this->getModuleConfig()::getapiUserPermissions()); |
|
128 | + //$this->view->apimessageError=false; |
|
129 | + } catch (RuntimeException $e) { |
|
130 | + $this->view->apimessage='API config : ' . $e->getMessage(); |
|
131 | + $this->view->apimessageError=true; |
|
132 | + } |
|
133 | + } |
|
134 | + else |
|
135 | + { |
|
136 | + $this->view->apimessage='API parameters not configured'; |
|
137 | + $this->view->apimessageError=true; |
|
138 | + } |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -146,21 +146,21 @@ discard block |
||
146 | 146 | */ |
147 | 147 | private function check_icingaweb_path() |
148 | 148 | { |
149 | - $this->view->icingaEtcWarn=0; |
|
150 | - $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
151 | - if ($icingaweb2_etc != "/etc/icingaweb2/" && $icingaweb2_etc != '') |
|
152 | - { |
|
153 | - $output=array(); |
|
149 | + $this->view->icingaEtcWarn=0; |
|
150 | + $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
151 | + if ($icingaweb2_etc != "/etc/icingaweb2/" && $icingaweb2_etc != '') |
|
152 | + { |
|
153 | + $output=array(); |
|
154 | 154 | |
155 | - exec('cat ' . $this->module->getBaseDir() .'/bin/trap_in.php | grep "\$icingaweb2Etc=" ',$output); |
|
155 | + exec('cat ' . $this->module->getBaseDir() .'/bin/trap_in.php | grep "\$icingaweb2Etc=" ',$output); |
|
156 | 156 | |
157 | 157 | |
158 | - if (! isset($output[0]) || ! preg_match('#"'. $icingaweb2_etc .'"#',$output[0])) |
|
159 | - { |
|
160 | - $this->view->icingaEtcWarn=1; |
|
161 | - $this->view->icingaweb2_etc=$icingaweb2_etc; |
|
162 | - } |
|
163 | - } |
|
158 | + if (! isset($output[0]) || ! preg_match('#"'. $icingaweb2_etc .'"#',$output[0])) |
|
159 | + { |
|
160 | + $this->view->icingaEtcWarn=1; |
|
161 | + $this->view->icingaweb2_etc=$icingaweb2_etc; |
|
162 | + } |
|
163 | + } |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
@@ -171,15 +171,15 @@ discard block |
||
171 | 171 | */ |
172 | 172 | private function get_db_list($allowed) |
173 | 173 | { |
174 | - $resources = array(); |
|
175 | - foreach (ResourceFactory::getResourceConfigs() as $name => $resource) |
|
176 | - { |
|
177 | - if ($resource->get('type') === 'db' && in_array($resource->get('db'), $allowed)) |
|
178 | - { |
|
179 | - $resources[$name] = $name; |
|
180 | - } |
|
181 | - } |
|
182 | - return $resources; |
|
174 | + $resources = array(); |
|
175 | + foreach (ResourceFactory::getResourceConfigs() as $name => $resource) |
|
176 | + { |
|
177 | + if ($resource->get('type') === 'db' && in_array($resource->get('db'), $allowed)) |
|
178 | + { |
|
179 | + $resources[$name] = $name; |
|
180 | + } |
|
181 | + } |
|
182 | + return $resources; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | public function indexAction() |
199 | 199 | { |
200 | 200 | |
201 | - // CHeck permissions : display tests in any case, but no configuration. |
|
201 | + // CHeck permissions : display tests in any case, but no configuration. |
|
202 | 202 | $this->view->configPermission=$this->checkModuleConfigPermission(1); |
203 | 203 | // But check read permission |
204 | 204 | $this->checkReadPermission(); |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | $this->view->tabs = $this->Module()->getConfigTabs()->activate('config'); |
207 | 207 | |
208 | 208 | // Get message : sent on configuration problems detected by controllers |
209 | - $this->get_param(); |
|
209 | + $this->get_param(); |
|
210 | 210 | |
211 | - // Test if configuration exists, if not create for installer script |
|
211 | + // Test if configuration exists, if not create for installer script |
|
212 | 212 | $this->check_empty_config(); |
213 | 213 | |
214 | 214 | // Test Database |
215 | - $this->check_db(); |
|
215 | + $this->check_db(); |
|
216 | 216 | |
217 | 217 | //********* Test API |
218 | - $this->check_api(); |
|
218 | + $this->check_api(); |
|
219 | 219 | |
220 | 220 | //*********** Test snmptrapd alive and options |
221 | 221 | list ($this->view->snmptrapdError, $this->view->snmptrapdMessage) = $this->checkSnmpTrapd(); |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | $this->view->traps_in_config= PHP_BINARY . ' ' . $this->Module()->getBaseDir() . '/bin/trap_in.php'; |
231 | 231 | |
232 | 232 | $this->view->installer= $this->Module()->getBaseDir() . '/bin/installer.sh ' |
233 | - . ' -c all ' |
|
234 | - . ' -d ' . $this->Module()->getBaseDir() |
|
235 | - . ' -p ' . PHP_BINARY |
|
236 | - . ' -a ' . exec('whoami') |
|
237 | - . ' -w ' . Icinga::app()->getConfigDir(); |
|
233 | + . ' -c all ' |
|
234 | + . ' -d ' . $this->Module()->getBaseDir() |
|
235 | + . ' -p ' . PHP_BINARY |
|
236 | + . ' -a ' . exec('whoami') |
|
237 | + . ' -w ' . Icinga::app()->getConfigDir(); |
|
238 | 238 | |
239 | 239 | // ******************* configuration form setup******************* |
240 | 240 | $this->view->form = $form = new TrapsConfigForm(); |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | $dbResource = ResourceFactory::getResourceConfig($dbName); |
280 | 280 | $dbType=$dbResource->get('db'); |
281 | 281 | switch ($dbType) { |
282 | - case 'mysql': |
|
283 | - $dbFileExt='sql'; |
|
284 | - break; |
|
285 | - case 'pgsql': |
|
286 | - $dbFileExt='pgsql'; |
|
287 | - break; |
|
288 | - default: |
|
289 | - throw new ConfigurationError('Unsuported database : '.$dbType); |
|
282 | + case 'mysql': |
|
283 | + $dbFileExt='sql'; |
|
284 | + break; |
|
285 | + case 'pgsql': |
|
286 | + $dbFileExt='pgsql'; |
|
287 | + break; |
|
288 | + default: |
|
289 | + throw new ConfigurationError('Unsuported database : '.$dbType); |
|
290 | 290 | } |
291 | 291 | } catch (ConfigurationError $e ) |
292 | 292 | { |
293 | - printf("Database configuration error : %s",$e->getMessage()); |
|
294 | - return; |
|
293 | + printf("Database configuration error : %s",$e->getMessage()); |
|
294 | + return; |
|
295 | 295 | } |
296 | 296 | printf('<pre>'); |
297 | 297 | require_once $this->Module()->getBaseDir() .'/bin/trap_class.php'; |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | public function updateschemaAction() |
316 | 316 | { |
317 | 317 | $this->checkModuleConfigPermission(); |
318 | - $this->getTabs()->add('get',array( |
|
319 | - 'active' => true, |
|
320 | - 'label' => $this->translate('Update Schema'), |
|
321 | - 'url' => Url::fromRequest() |
|
322 | - )); |
|
318 | + $this->getTabs()->add('get',array( |
|
319 | + 'active' => true, |
|
320 | + 'label' => $this->translate('Update Schema'), |
|
321 | + 'url' => Url::fromRequest() |
|
322 | + )); |
|
323 | 323 | // check if needed |
324 | 324 | |
325 | 325 | $dberror=$this->getDb(true); // Get DB in test mode |
@@ -328,15 +328,15 @@ discard block |
||
328 | 328 | |
329 | 329 | if ($dberror[0] == 0) |
330 | 330 | { |
331 | - echo 'Schema already exists and is up to date<br>'; |
|
332 | - return; |
|
331 | + echo 'Schema already exists and is up to date<br>'; |
|
332 | + return; |
|
333 | 333 | } |
334 | 334 | if ($dberror[0] != 5) |
335 | 335 | { |
336 | - echo 'Database does not exists or is not setup correctly<br>'; |
|
337 | - return; |
|
336 | + echo 'Database does not exists or is not setup correctly<br>'; |
|
337 | + return; |
|
338 | 338 | } |
339 | - // setup |
|
339 | + // setup |
|
340 | 340 | require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
341 | 341 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
342 | 342 | $debug_level=4; |
@@ -349,20 +349,20 @@ discard block |
||
349 | 349 | $target_version=$dberror[2]; |
350 | 350 | |
351 | 351 | if ($this->params->get('msgok') == null) { |
352 | - // Check for messages and display if any |
|
353 | - echo "Upgrade databse is going to start.<br>Don't forget to backup your database before update<br>"; |
|
354 | - $Trap->setLogging(2,'syslog'); |
|
355 | - $message = $Trap->trapsDB->update_schema($updateSchema,$target_version,$prefix,true); |
|
356 | - if ($message != '') |
|
357 | - { |
|
358 | - echo 'Note :<br><pre>'; |
|
359 | - echo $message; |
|
360 | - echo '</pre>'; |
|
361 | - echo '<br>'; |
|
362 | - echo '<a class="link-button" style="font-size:large;font-weight:bold" href="' . Url::fromPath('trapdirector/settings/updateschema') .'?msgok=1">Click here to update</a>'; |
|
363 | - echo '<br>'; |
|
364 | - return; |
|
365 | - } |
|
352 | + // Check for messages and display if any |
|
353 | + echo "Upgrade databse is going to start.<br>Don't forget to backup your database before update<br>"; |
|
354 | + $Trap->setLogging(2,'syslog'); |
|
355 | + $message = $Trap->trapsDB->update_schema($updateSchema,$target_version,$prefix,true); |
|
356 | + if ($message != '') |
|
357 | + { |
|
358 | + echo 'Note :<br><pre>'; |
|
359 | + echo $message; |
|
360 | + echo '</pre>'; |
|
361 | + echo '<br>'; |
|
362 | + echo '<a class="link-button" style="font-size:large;font-weight:bold" href="' . Url::fromPath('trapdirector/settings/updateschema') .'?msgok=1">Click here to update</a>'; |
|
363 | + echo '<br>'; |
|
364 | + return; |
|
365 | + } |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | $Trap->setLogging($debug_level,'display'); |
@@ -376,28 +376,28 @@ discard block |
||
376 | 376 | |
377 | 377 | private function checkSnmpTrapd() |
378 | 378 | { |
379 | - $psOutput=array(); |
|
380 | - // First check is someone is listening to port 162. As not root, we can't have pid... |
|
381 | - exec('netstat -an |grep -E "udp.*:162"',$psOutput); |
|
382 | - if (count($psOutput) == 0) |
|
383 | - { |
|
384 | - return array(1,'Port UDP/162 is not open : snmptrapd must not be started'); |
|
385 | - } |
|
386 | - $psOutput=array(); |
|
387 | - exec('ps fax |grep snmptrapd |grep -v grep',$psOutput); |
|
388 | - if (count($psOutput) == 0) |
|
389 | - { |
|
390 | - return array(1,"UDP/162 : OK, but no snmptrapd process (?)"); |
|
391 | - } |
|
392 | - // Assume there is only one line... TODO : see if there is a better way to do this |
|
393 | - $line = preg_replace('/^.*snmptrapd /','',$psOutput[0]); |
|
394 | - if (!preg_match('/-n/',$line)) |
|
395 | - return array(1,'snmptrapd has no -n option : '.$line); |
|
396 | - if (!preg_match('/-O[^ ]*n/',$line)) |
|
397 | - return array(1,'snmptrapd has no -On option : '.$line); |
|
398 | - if (!preg_match('/-O[^ ]*e/',$line)) |
|
399 | - return array(1,'snmptrapd has no -Oe option : '.$line); |
|
379 | + $psOutput=array(); |
|
380 | + // First check is someone is listening to port 162. As not root, we can't have pid... |
|
381 | + exec('netstat -an |grep -E "udp.*:162"',$psOutput); |
|
382 | + if (count($psOutput) == 0) |
|
383 | + { |
|
384 | + return array(1,'Port UDP/162 is not open : snmptrapd must not be started'); |
|
385 | + } |
|
386 | + $psOutput=array(); |
|
387 | + exec('ps fax |grep snmptrapd |grep -v grep',$psOutput); |
|
388 | + if (count($psOutput) == 0) |
|
389 | + { |
|
390 | + return array(1,"UDP/162 : OK, but no snmptrapd process (?)"); |
|
391 | + } |
|
392 | + // Assume there is only one line... TODO : see if there is a better way to do this |
|
393 | + $line = preg_replace('/^.*snmptrapd /','',$psOutput[0]); |
|
394 | + if (!preg_match('/-n/',$line)) |
|
395 | + return array(1,'snmptrapd has no -n option : '.$line); |
|
396 | + if (!preg_match('/-O[^ ]*n/',$line)) |
|
397 | + return array(1,'snmptrapd has no -On option : '.$line); |
|
398 | + if (!preg_match('/-O[^ ]*e/',$line)) |
|
399 | + return array(1,'snmptrapd has no -Oe option : '.$line); |
|
400 | 400 | |
401 | - return array(0,'snmptrapd listening to UDP/162, options : '.$line); |
|
401 | + return array(0,'snmptrapd listening to UDP/162, options : '.$line); |
|
402 | 402 | } |
403 | 403 | } |