@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | try |
23 | 23 | { |
24 | 24 | $dbConn = $this->getUIDatabase()->getDbConn(); |
25 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
25 | + if ($dbConn === null) { |
|
26 | + throw new \ErrorException('uncatched db error'); |
|
27 | + } |
|
26 | 28 | $query = $dbConn->select()->from( |
27 | 29 | $this->getModuleConfig()->getTrapTableName(), |
28 | 30 | array('COUNT(*)') |
@@ -41,8 +43,7 @@ discard block |
||
41 | 43 | |
42 | 44 | $this->view->trap_days_delete=$this->getUIDatabase()->getDBConfigValue('db_remove_days'); |
43 | 45 | |
44 | - } |
|
45 | - catch (Exception $e) |
|
46 | + } catch (Exception $e) |
|
46 | 47 | { |
47 | 48 | $this->displayExitError('status',$e->getMessage()); |
48 | 49 | } |
@@ -56,8 +57,7 @@ discard block |
||
56 | 57 | $this->view->currentLogFile=$this->getUIDatabase()->getDBConfigValue('log_file'); |
57 | 58 | $this->view->logLevels=$this->getModuleConfig()->getlogLevels(); |
58 | 59 | $this->view->currentLogLevel=$this->getUIDatabase()->getDBConfigValue('log_level'); |
59 | - } |
|
60 | - catch (Exception $e) |
|
60 | + } catch (Exception $e) |
|
61 | 61 | { |
62 | 62 | $this->displayExitError('status',$e->getMessage()); |
63 | 63 | } |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid'); |
70 | 70 | $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE; |
71 | 71 | |
72 | - } |
|
73 | - catch (Exception $e) |
|
72 | + } catch (Exception $e) |
|
74 | 73 | { |
75 | 74 | $this->displayExitError('status',$e->getMessage()); |
76 | 75 | } |
@@ -120,8 +119,7 @@ discard block |
||
120 | 119 | if ($retVal == 0) |
121 | 120 | { // process is alive |
122 | 121 | $this->_helper->json(array('status'=>'Alive and kicking')); |
123 | - } |
|
124 | - else |
|
122 | + } else |
|
125 | 123 | { // process is dead |
126 | 124 | $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
127 | 125 | } |
@@ -137,22 +135,19 @@ discard block |
||
137 | 135 | if (!is_dir($destDir)) |
138 | 136 | { |
139 | 137 | $this->view->uploadStatus="ERROR : no $destDir directory, check module configuration"; |
140 | - } |
|
141 | - else |
|
138 | + } else |
|
142 | 139 | { |
143 | 140 | if (!is_writable($destDir)) |
144 | 141 | { |
145 | 142 | $this->view->uploadStatus="ERROR : $destDir directory is not writable"; |
146 | - } |
|
147 | - else |
|
143 | + } else |
|
148 | 144 | { |
149 | 145 | $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
150 | 146 | $sourceTmpNam=htmlspecialchars($_FILES['mibfile']['tmp_name']); |
151 | 147 | if (move_uploaded_file($sourceTmpNam,$destination)===false) |
152 | 148 | { |
153 | 149 | $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations"; |
154 | - } |
|
155 | - else |
|
150 | + } else |
|
156 | 151 | { |
157 | 152 | $this->view->uploadStatus="File $name uploaded in $destDir"; |
158 | 153 | } |
@@ -177,18 +172,15 @@ discard block |
||
177 | 172 | { |
178 | 173 | $this->view->snmptranslate='works fine'; |
179 | 174 | $this->view->snmptranslate_state='ok'; |
180 | - } |
|
181 | - else |
|
175 | + } else |
|
182 | 176 | { |
183 | 177 | $this->view->snmptranslate='works fine but missing basic MIBs'; |
184 | 178 | } |
185 | - } |
|
186 | - else |
|
179 | + } else |
|
187 | 180 | { |
188 | 181 | $this->view->snmptranslate='Can execute but no OID to name resolution'; |
189 | 182 | } |
190 | - } |
|
191 | - else |
|
183 | + } else |
|
192 | 184 | { |
193 | 185 | $this->view->snmptranslate='Cannot execute'; |
194 | 186 | } |
@@ -209,15 +201,13 @@ discard block |
||
209 | 201 | if ($retVal==0) |
210 | 202 | { |
211 | 203 | $dirArray=array_merge($dirArray,explode(':',$sysDirs)); |
212 | - } |
|
213 | - else |
|
204 | + } else |
|
214 | 205 | { |
215 | 206 | $translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
216 | 207 | if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches)) |
217 | 208 | { |
218 | 209 | $dirArray=array_merge($dirArray,explode(':',$matches[1])); |
219 | - } |
|
220 | - else |
|
210 | + } else |
|
221 | 211 | { |
222 | 212 | array_push($dirArray,'Install net-snmp-config to see system directories'); |
223 | 213 | } |
@@ -256,8 +246,7 @@ discard block |
||
256 | 246 | if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1) |
257 | 247 | { |
258 | 248 | $this->view->setError='Max rows must be a number'; |
259 | - } |
|
260 | - else |
|
249 | + } else |
|
261 | 250 | { |
262 | 251 | $this->setitemListDisplay($maxRows); |
263 | 252 | $this->view->setOKMsg='Set max rows to ' . $maxRows; |
@@ -276,8 +265,9 @@ discard block |
||
276 | 265 | $index = $this->getRequest()->getPost('index',NULL); |
277 | 266 | $newname = $this->getRequest()->getPost('newname',NULL); |
278 | 267 | |
279 | - if (!preg_match('/^[0-9]+$/', $index) || $index < 1) |
|
280 | - $this->_helper->json(array('status'=>'Bad index')); |
|
268 | + if (!preg_match('/^[0-9]+$/', $index) || $index < 1) { |
|
269 | + $this->_helper->json(array('status'=>'Bad index')); |
|
270 | + } |
|
281 | 271 | |
282 | 272 | switch ($type) |
283 | 273 | { |
@@ -126,8 +126,7 @@ discard block |
||
126 | 126 | $this->trapController->redirectNow('trapdirector/settings?dberror=5'); |
127 | 127 | return false; |
128 | 128 | } |
129 | - } |
|
130 | - catch (Exception $e) |
|
129 | + } catch (Exception $e) |
|
131 | 130 | { |
132 | 131 | if ($test === true) |
133 | 132 | { |
@@ -152,8 +151,7 @@ discard block |
||
152 | 151 | try |
153 | 152 | { |
154 | 153 | $dbconn = IcingaDbConnection::fromResourceName($DBname); |
155 | - } |
|
156 | - catch (Exception $e) |
|
154 | + } catch (Exception $e) |
|
157 | 155 | { |
158 | 156 | if ($test === true) |
159 | 157 | { |
@@ -167,8 +165,7 @@ discard block |
||
167 | 165 | { |
168 | 166 | $dbAdapter=$dbconn->getDbAdapter(); |
169 | 167 | |
170 | - } |
|
171 | - catch (Exception $e) |
|
168 | + } catch (Exception $e) |
|
172 | 169 | { |
173 | 170 | if ($test === true) |
174 | 171 | { |
@@ -195,7 +192,9 @@ discard block |
||
195 | 192 | */ |
196 | 193 | public function getDb() |
197 | 194 | { |
198 | - if ( $this->trapDB != null ) return $this->trapDB; |
|
195 | + if ( $this->trapDB != null ) { |
|
196 | + return $this->trapDB; |
|
197 | + } |
|
199 | 198 | |
200 | 199 | |
201 | 200 | $dbresource=$this->trapController->Config()->get('config', 'database'); |
@@ -223,7 +222,9 @@ discard block |
||
223 | 222 | */ |
224 | 223 | public function getDbConn() |
225 | 224 | { |
226 | - if ($this->getDb() == null) return null; |
|
225 | + if ($this->getDb() == null) { |
|
226 | + return null; |
|
227 | + } |
|
227 | 228 | return $this->getDb()->getDbAdapter(); |
228 | 229 | // return $this->getDb()->getConnection(); |
229 | 230 | } |
@@ -254,7 +255,9 @@ discard block |
||
254 | 255 | */ |
255 | 256 | public function getIdoDb() |
256 | 257 | { |
257 | - if ( $this->idoDB != null ) return $this->idoDB; |
|
258 | + if ( $this->idoDB != null ) { |
|
259 | + return $this->idoDB; |
|
260 | + } |
|
258 | 261 | // TODO : get ido database directly from icingaweb2 config -> (or not if using only API) |
259 | 262 | $dbresource=$this->trapController->Config()->get('config', 'IDOdatabase');; |
260 | 263 | |
@@ -267,8 +270,7 @@ discard block |
||
267 | 270 | try |
268 | 271 | { |
269 | 272 | $dbconn = IcingaDbConnection::fromResourceName($dbresource); |
270 | - } |
|
271 | - catch (Exception $e) |
|
273 | + } catch (Exception $e) |
|
272 | 274 | { |
273 | 275 | $this->trapController->redirectNow('trapdirector/settings?idodberror=2'); |
274 | 276 | return null; |
@@ -285,7 +287,9 @@ discard block |
||
285 | 287 | */ |
286 | 288 | public function getIdoDbConn() |
287 | 289 | { |
288 | - if ($this->getIdoDb() == null) return null; |
|
290 | + if ($this->getIdoDb() == null) { |
|
291 | + return null; |
|
292 | + } |
|
289 | 293 | return $this->getIdoDb()->getConnection(); |
290 | 294 | } |
291 | 295 | |
@@ -307,8 +311,7 @@ discard block |
||
307 | 311 | try |
308 | 312 | { |
309 | 313 | $dbconn = IcingaDbConnection::fromResourceName($dbresource); |
310 | - } |
|
311 | - catch (Exception $e) |
|
314 | + } catch (Exception $e) |
|
312 | 315 | { |
313 | 316 | throw new DBException( array(2,"Database $dbresource does not exists in IcingaWeb2") ); |
314 | 317 | } |
@@ -322,8 +325,7 @@ discard block |
||
322 | 325 | { |
323 | 326 | throw new DBException( array(4,"$dbresource does not look like an IDO database")); |
324 | 327 | } |
325 | - } |
|
326 | - catch (Exception $e) |
|
328 | + } catch (Exception $e) |
|
327 | 329 | { |
328 | 330 | throw new DBException( array(3,"Error connecting to $dbresource : " . $e->getMessage())); |
329 | 331 | } |
@@ -46,8 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | $this->getLogging()->log($message,$log_level); |
48 | 48 | return false; |
49 | - } |
|
50 | - else |
|
49 | + } else |
|
51 | 50 | { |
52 | 51 | $option_var=$option_array[$option_category][$option_name]; |
53 | 52 | return true; |
@@ -60,16 +59,20 @@ discard block |
||
60 | 59 | protected function getDatabaseOptions() |
61 | 60 | { |
62 | 61 | // Database options |
63 | - if ($this->logSetup === false) // Only if logging was no setup in constructor |
|
62 | + if ($this->logSetup === false) { |
|
63 | + // Only if logging was no setup in constructor |
|
64 | 64 | { |
65 | 65 | $this->getDBConfigIfSet('log_level',$this->getLogging()->debugLevel); |
66 | + } |
|
66 | 67 | $this->getDBConfigIfSet('log_destination',$this->getLogging()->outputMode); |
67 | 68 | $this->getDBConfigIfSet('log_file',$this->getLogging()->outputFile); |
68 | 69 | } |
69 | 70 | |
70 | 71 | $tmpVal = -1; // Get boolean coded in database as 1/0 |
71 | 72 | $this->getDBConfigIfSet('use_SnmpTrapAddess', $tmpVal); |
72 | - if ($tmpVal != -1) $this->useSnmpTrapAddess = ($tmpVal == 1) ? TRUE : FALSE; |
|
73 | + if ($tmpVal != -1) { |
|
74 | + $this->useSnmpTrapAddess = ($tmpVal == 1) ? TRUE : FALSE; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | $this->getDBConfigIfSet('SnmpTrapAddess_oid', $this->snmpTrapAddressOID); // Get oid then replace '.' with '\.' to use in regexp whrn reading traps |
75 | 78 | $this->snmpTrapAddressOID = preg_replace('/\./', '\\.', $this->snmpTrapAddressOID); |
@@ -82,7 +85,9 @@ discard block |
||
82 | 85 | protected function getDBConfigIfSet($element,&$variable) |
83 | 86 | { |
84 | 87 | $value=$this->getDBConfig($element); |
85 | - if ($value != null) $variable=$value; |
|
88 | + if ($value != null) { |
|
89 | + $variable=$value; |
|
90 | + } |
|
86 | 91 | } |
87 | 92 | |
88 | 93 | /** |
@@ -119,8 +124,7 @@ discard block |
||
119 | 124 | { |
120 | 125 | $this->getLogging()->log('Unknown node status '.$nodeStatus.' : setting to MASTER',WARN); |
121 | 126 | $this->getTrapApi()->setStatusMaster(); |
122 | - } |
|
123 | - else |
|
127 | + } else |
|
124 | 128 | { |
125 | 129 | if ($this->getTrapApi()->getStatus() != TrapApi::MASTER) |
126 | 130 | { |
@@ -189,7 +193,10 @@ discard block |
||
189 | 193 | $this->logging->log("API Use : ".print_r($this->apiUse,true),DEBUG ); |
190 | 194 | |
191 | 195 | //TODO enable this again when API queries are all done : |
192 | - if ($this->apiUse === true) return; // In case of API use, no IDO is necessary |
|
196 | + if ($this->apiUse === true) { |
|
197 | + return; |
|
198 | + } |
|
199 | + // In case of API use, no IDO is necessary |
|
193 | 200 | |
194 | 201 | // IDO Database |
195 | 202 | if (!array_key_exists('IDOdatabase',$trapConfig['config'])) |
@@ -98,8 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | $this->logging->setLogging($baseLogLevel, $baseLogMode,$baseLogFile); |
100 | 100 | $this->logSetup=true; |
101 | - } |
|
102 | - else |
|
101 | + } else |
|
103 | 102 | { |
104 | 103 | $this->logSetup=false; |
105 | 104 | } |
@@ -130,7 +129,10 @@ discard block |
||
130 | 129 | $this->getDatabaseOptions(); // Get options in database |
131 | 130 | |
132 | 131 | // Setup API |
133 | - if ($this->apiUse === true) $this->getAPI(); // Setup API |
|
132 | + if ($this->apiUse === true) { |
|
133 | + $this->getAPI(); |
|
134 | + } |
|
135 | + // Setup API |
|
134 | 136 | |
135 | 137 | // Setup MIB |
136 | 138 | $this->mibClass = new Mib($this->logging,$this->trapsDB,$this->snmptranslate,$this->snmptranslate_dirs); // Create Mib class |
@@ -149,7 +151,7 @@ discard block |
||
149 | 151 | // Setup Plugins |
150 | 152 | //Create plugin class. Plugins are not loaded here, but by calling registerAllPlugins |
151 | 153 | $this->pluginClass = new Plugins($this); |
152 | - }catch (Exception $e){ return; } |
|
154 | + } catch (Exception $e){ return; } |
|
153 | 155 | |
154 | 156 | } |
155 | 157 | |
@@ -239,8 +241,7 @@ discard block |
||
239 | 241 | { |
240 | 242 | $this->writeTrapErrorToDB("Error parsing trap (code 2/IP)"); |
241 | 243 | $this->logging->log('Error parsing IP : '.$IP,ERROR,''); |
242 | - } |
|
243 | - else |
|
244 | + } else |
|
244 | 245 | { |
245 | 246 | $this->trapData['source_ip']=$matches[1]; |
246 | 247 | $this->trapData['destination_ip']=$matches[3]; |
@@ -323,10 +324,10 @@ discard block |
||
323 | 324 | $this->logging->log('SQL query : '.$sql,DEBUG ); |
324 | 325 | if (($ret_code=$db_conn->query($sql)) === false) { |
325 | 326 | $this->logging->log('No result in query : ' . $sql,ERROR,''); |
326 | - } |
|
327 | - else { |
|
328 | - if (($name=$ret_code->fetch()) !== false) |
|
329 | - return array('trap_name_mib'=>$name['mib'],'trap_name'=>$name['name']); |
|
327 | + } else { |
|
328 | + if (($name=$ret_code->fetch()) !== false) { |
|
329 | + return array('trap_name_mib'=>$name['mib'],'trap_name'=>$name['name']); |
|
330 | + } |
|
330 | 331 | } |
331 | 332 | |
332 | 333 | // Also check if it is an instance of OID |
@@ -336,10 +337,10 @@ discard block |
||
336 | 337 | $this->logging->log('SQL query : '.$sql,DEBUG ); |
337 | 338 | if (($ret_code=$db_conn->query($sql)) === false) { |
338 | 339 | $this->logging->log('No result in query : ' . $sql,ERROR,''); |
339 | - } |
|
340 | - else { |
|
341 | - if (($name=$ret_code->fetch()) !== false) |
|
342 | - return array('trap_name_mib'=>$name['mib'],'trap_name'=>$name['name']); |
|
340 | + } else { |
|
341 | + if (($name=$ret_code->fetch()) !== false) { |
|
342 | + return array('trap_name_mib'=>$name['mib'],'trap_name'=>$name['name']); |
|
343 | + } |
|
343 | 344 | } |
344 | 345 | |
345 | 346 | // Try to get oid name from snmptranslate |
@@ -438,7 +439,9 @@ discard block |
||
438 | 439 | } |
439 | 440 | |
440 | 441 | $inserted_id=$ret_code->fetch(PDO::FETCH_ASSOC)['LAST_INSERT_ID()']; |
441 | - if ($inserted_id==false) throw new Exception("Weird SQL error : last_insert_id returned false : open issue"); |
|
442 | + if ($inserted_id==false) { |
|
443 | + throw new Exception("Weird SQL error : last_insert_id returned false : open issue"); |
|
444 | + } |
|
442 | 445 | $this->trapId=$inserted_id; |
443 | 446 | break; |
444 | 447 | default: |
@@ -454,7 +457,9 @@ discard block |
||
454 | 457 | { |
455 | 458 | |
456 | 459 | // If action is ignore -> don't send t DB |
457 | - if ($this->trapToDb === false) return; |
|
460 | + if ($this->trapToDb === false) { |
|
461 | + return; |
|
462 | + } |
|
458 | 463 | |
459 | 464 | |
460 | 465 | $db_conn=$this->trapsDB->db_connect_trap(); |
@@ -511,7 +516,9 @@ discard block |
||
511 | 516 | } |
512 | 517 | |
513 | 518 | $inserted_id=$ret_code->fetch(PDO::FETCH_ASSOC)['LAST_INSERT_ID()']; |
514 | - if ($inserted_id==false) throw new Exception("Weird SQL error : last_insert_id returned false : open issue"); |
|
519 | + if ($inserted_id==false) { |
|
520 | + throw new Exception("Weird SQL error : last_insert_id returned false : open issue"); |
|
521 | + } |
|
515 | 522 | $this->trapId=$inserted_id; |
516 | 523 | break; |
517 | 524 | default: |
@@ -592,7 +599,7 @@ discard block |
||
592 | 599 | continue; |
593 | 600 | } |
594 | 601 | $grouphosts=$ret_code2->fetchAll(); |
595 | - }else{ |
|
602 | + } else{ |
|
596 | 603 | $api = $this->getAPI(); |
597 | 604 | $api->setCredentials($this->apiUsername, $this->apiPassword); |
598 | 605 | $grouphosts=$api->getHostsIPByHostGroup($rule['host_group_name']); |
@@ -600,7 +607,9 @@ discard block |
||
600 | 607 | //echo "rule grp :\n";print_r($grouphosts);echo "\n"; |
601 | 608 | foreach ( $grouphosts as $host) |
602 | 609 | { |
603 | - if( is_object( $host ) ) $host=(array)$host; |
|
610 | + if( is_object( $host ) ) { |
|
611 | + $host=(array)$host; |
|
612 | + } |
|
604 | 613 | //echo $host['address']."\n"; |
605 | 614 | if ($host['address']==$ip || $host['address6']==$ip) |
606 | 615 | { |
@@ -649,8 +658,7 @@ discard block |
||
649 | 658 | // TODO : file_put_contents & fopen (,'w' or 'a') does not work. See why. Or not as using API will be by default.... |
650 | 659 | exec('echo "'.$send.'" > ' .$this->icinga2cmd); |
651 | 660 | return true; |
652 | - } |
|
653 | - else |
|
661 | + } else |
|
654 | 662 | { |
655 | 663 | // Get perfdata if found |
656 | 664 | $matches=array(); |
@@ -658,8 +666,7 @@ discard block |
||
658 | 666 | { |
659 | 667 | $display=$matches[1]; |
660 | 668 | $perfdata=$matches[2]; |
661 | - } |
|
662 | - else |
|
669 | + } else |
|
663 | 670 | { |
664 | 671 | $perfdata=''; |
665 | 672 | } |
@@ -671,8 +678,7 @@ discard block |
||
671 | 678 | { |
672 | 679 | $this->logging->log( "Error sending result : " .$retmessage,WARN,''); |
673 | 680 | return false; |
674 | - } |
|
675 | - else |
|
681 | + } else |
|
676 | 682 | { |
677 | 683 | $this->logging->log( "Sent result : " .$retmessage,INFO ); |
678 | 684 | return true; |
@@ -771,20 +777,17 @@ discard block |
||
771 | 777 | if ($this->serviceCheckResult($host_name,$service_name,$action,$display) == false) |
772 | 778 | { |
773 | 779 | $this->trapAction.='Error sending status : check cmd/API'; |
774 | - } |
|
775 | - else |
|
780 | + } else |
|
776 | 781 | { |
777 | 782 | $this->add_rule_match($rule['id'],$rule['num_match']+1); |
778 | 783 | $this->trapAction.='Status '.$action.' to '.$host_name.'/'.$service_name; |
779 | 784 | } |
780 | - } |
|
781 | - else |
|
785 | + } else |
|
782 | 786 | { |
783 | 787 | $this->add_rule_match($rule['id'],$rule['num_match']+1); |
784 | 788 | } |
785 | 789 | $this->trapToDb=($action==-2)?false:true; |
786 | - } |
|
787 | - else |
|
790 | + } else |
|
788 | 791 | { |
789 | 792 | //$this->logging->log('rules KOO : '.print_r($rule),INFO ); |
790 | 793 | |
@@ -795,14 +798,12 @@ discard block |
||
795 | 798 | if ($this->serviceCheckResult($host_name,$service_name,$action,$display)==false) |
796 | 799 | { |
797 | 800 | $this->trapAction.='Error sending status : check cmd/API'; |
798 | - } |
|
799 | - else |
|
801 | + } else |
|
800 | 802 | { |
801 | 803 | $this->add_rule_match($rule['id'],$rule['num_match']+1); |
802 | 804 | $this->trapAction.='Status '.$action.' to '.$host_name.'/'.$service_name; |
803 | 805 | } |
804 | - } |
|
805 | - else |
|
806 | + } else |
|
806 | 807 | { |
807 | 808 | $this->add_rule_match($rule['id'],$rule['num_match']+1); |
808 | 809 | } |
@@ -812,16 +813,14 @@ discard block |
||
812 | 813 | if (!isset($this->trapData['source_name'])) |
813 | 814 | { |
814 | 815 | $this->trapData['source_name']=$rule['host_name']; |
815 | - } |
|
816 | - else |
|
816 | + } else |
|
817 | 817 | { |
818 | 818 | if (!preg_match('/'.$rule['host_name'].'/',$this->trapData['source_name'])) |
819 | 819 | { // only add if not present |
820 | 820 | $this->trapData['source_name'].=','.$rule['host_name']; |
821 | 821 | } |
822 | 822 | } |
823 | - } |
|
824 | - catch (Exception $e) |
|
823 | + } catch (Exception $e) |
|
825 | 824 | { |
826 | 825 | $this->logging->log('Error in rule eval : '.$e->getMessage(),WARN,''); |
827 | 826 | $this->trapAction.=' ERR : '.$e->getMessage(); |
@@ -832,8 +831,7 @@ discard block |
||
832 | 831 | if ($this->trapData['status']=='error') |
833 | 832 | { |
834 | 833 | $this->trapToDb=true; // Always put errors in DB for the use can see |
835 | - } |
|
836 | - else |
|
834 | + } else |
|
837 | 835 | { |
838 | 836 | $this->trapData['status']='done'; |
839 | 837 | } |
@@ -880,7 +878,7 @@ discard block |
||
880 | 878 | return 0; |
881 | 879 | } |
882 | 880 | $services=$services_db->fetchAll(); |
883 | - }else{ |
|
881 | + } else{ |
|
884 | 882 | $api = $this->getAPI(); |
885 | 883 | $api->setCredentials($this->apiUsername, $this->apiPassword); |
886 | 884 | $services=$api->getNOKservice(); |
@@ -900,7 +898,9 @@ discard block |
||
900 | 898 | $numreset=0; |
901 | 899 | foreach ($rules as $rule) |
902 | 900 | { |
903 | - if( is_object( $services ) ) $services=(array)$services; |
|
901 | + if( is_object( $services ) ) { |
|
902 | + $services=(array)$services; |
|
903 | + } |
|
904 | 904 | foreach ($services as $service) |
905 | 905 | { |
906 | 906 | if ($service['name'] == $rule['service_name'] && |