@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | /** Get host list with filter (IP or name) : host=<filter> |
| 15 | - * returns in JSON : status=>OK/NOK hosts=>array of hosts |
|
| 16 | - */ |
|
| 15 | + * returns in JSON : status=>OK/NOK hosts=>array of hosts |
|
| 16 | + */ |
|
| 17 | 17 | public function gethostsAction() |
| 18 | 18 | { |
| 19 | 19 | $postData=$this->getRequest()->getPost(); |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | /** Get hostgroup list with filter (name) : hostgroup=<hostFilter> |
| 42 | - * returns in JSON : status=>OK/NOK hosts=>array of hosts |
|
| 43 | - */ |
|
| 42 | + * returns in JSON : status=>OK/NOK hosts=>array of hosts |
|
| 43 | + */ |
|
| 44 | 44 | public function gethostgroupsAction() |
| 45 | 45 | { |
| 46 | 46 | $postData=$this->getRequest()->getPost(); |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | /** Get service list by host name ( host=<host> ) |
| 69 | - * returns in JSON : |
|
| 70 | - * status=>OK/No services found/More than one host matches |
|
| 71 | - * services=>array of services (name) |
|
| 72 | - * hostid = host object id or -1 if not found. |
|
| 73 | - */ |
|
| 69 | + * returns in JSON : |
|
| 70 | + * status=>OK/No services found/More than one host matches |
|
| 71 | + * services=>array of services (name) |
|
| 72 | + * hostid = host object id or -1 if not found. |
|
| 73 | + */ |
|
| 74 | 74 | public function getservicesAction() |
| 75 | 75 | { |
| 76 | 76 | $postData=$this->getRequest()->getPost(); |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** Get service list by host group ( name=<host> ) |
| 109 | - * returns in JSON : |
|
| 110 | - * status=>OK/No services found/More than one host matches |
|
| 111 | - * services=>array of services (name) |
|
| 112 | - * groupid = group object id or -1 if not found. |
|
| 113 | - */ |
|
| 109 | + * returns in JSON : |
|
| 110 | + * status=>OK/No services found/More than one host matches |
|
| 111 | + * services=>array of services (name) |
|
| 112 | + * groupid = group object id or -1 if not found. |
|
| 113 | + */ |
|
| 114 | 114 | public function gethostgroupservicesAction() |
| 115 | 115 | { |
| 116 | 116 | $postData=$this->getRequest()->getPost(); |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** Get traps from mib : entry : mib=<mib> |
| 146 | - * returns in JSON : |
|
| 147 | - * status=>OK/No mib/Error getting mibs |
|
| 148 | - * traps=>array of array( oid -> name) |
|
| 149 | - */ |
|
| 146 | + * returns in JSON : |
|
| 147 | + * status=>OK/No mib/Error getting mibs |
|
| 148 | + * traps=>array of array( oid -> name) |
|
| 149 | + */ |
|
| 150 | 150 | public function gettrapsAction() |
| 151 | 151 | { |
| 152 | 152 | $postData=$this->getRequest()->getPost(); |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** Get trap objects from mib : entry : trap=<oid> |
| 174 | - * returns in JSON : |
|
| 175 | - * status=>OK/no trap/not found |
|
| 176 | - * objects=>array of array( oid -> name, oid->mib) |
|
| 177 | - */ |
|
| 174 | + * returns in JSON : |
|
| 175 | + * status=>OK/no trap/not found |
|
| 176 | + * objects=>array of array( oid -> name, oid->mib) |
|
| 177 | + */ |
|
| 178 | 178 | public function gettrapobjectsAction() |
| 179 | 179 | { |
| 180 | 180 | $postData=$this->getRequest()->getPost(); |
@@ -199,8 +199,8 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** Get list of all loaded mibs : entry : none |
| 202 | - * return : array of strings. |
|
| 203 | - */ |
|
| 202 | + * return : array of strings. |
|
| 203 | + */ |
|
| 204 | 204 | public function getmiblistAction() |
| 205 | 205 | { |
| 206 | 206 | try |
@@ -215,10 +215,10 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** Get MIB::Name from OID : entry : oid |
| 218 | - * status=>OK/No oid/not found |
|
| 219 | - * mib=>string |
|
| 220 | - * name=>string |
|
| 221 | - */ |
|
| 218 | + * status=>OK/No oid/not found |
|
| 219 | + * mib=>string |
|
| 220 | + * name=>string |
|
| 221 | + */ |
|
| 222 | 222 | public function translateoidAction() |
| 223 | 223 | { |
| 224 | 224 | $postData=$this->getRequest()->getPost(); |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | 'name' => $object['name'], |
| 245 | 245 | 'type' => $object['type'], |
| 246 | 246 | 'type_enum' => $object['type_enum'], |
| 247 | - 'description' => $object['description'] |
|
| 247 | + 'description' => $object['description'] |
|
| 248 | 248 | ) |
| 249 | 249 | ); |
| 250 | 250 | } |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | /** Save or execute database purge of <n> days |
| 256 | - * days=>int |
|
| 257 | - * action=>save/execute |
|
| 258 | - * return : status=>OK/Message error |
|
| 259 | - */ |
|
| 256 | + * days=>int |
|
| 257 | + * action=>save/execute |
|
| 258 | + * return : status=>OK/Message error |
|
| 259 | + */ |
|
| 260 | 260 | public function dbmaintenanceAction() |
| 261 | 261 | { |
| 262 | 262 | |
@@ -323,11 +323,11 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** Save log output to db |
| 326 | - * destination=>log destination |
|
| 327 | - * file=>file name |
|
| 328 | - * level => int |
|
| 329 | - * return : status=>OK/Message error |
|
| 330 | - */ |
|
| 326 | + * destination=>log destination |
|
| 327 | + * file=>file name |
|
| 328 | + * level => int |
|
| 329 | + * return : status=>OK/Message error |
|
| 330 | + */ |
|
| 331 | 331 | public function logdestinationAction() |
| 332 | 332 | { |
| 333 | 333 | $postData=$this->getRequest()->getPost(); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | $fileHandler=@fopen($file,'w'); |
| 351 | 351 | if ($fileHandler == false) |
| 352 | 352 | { // File os note writabe / cannot create |
| 353 | - $this->_helper->json(array('status'=>'File not writable : '.$file)); |
|
| 353 | + $this->_helper->json(array('status'=>'File not writable : '.$file)); |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | else |
@@ -406,50 +406,50 @@ discard block |
||
| 406 | 406 | public function testruleAction() |
| 407 | 407 | { |
| 408 | 408 | |
| 409 | - $postData=$this->getRequest()->getPost(); |
|
| 410 | - if (isset($postData['rule'])) |
|
| 411 | - { |
|
| 412 | - $rule=$postData['rule']; |
|
| 413 | - } |
|
| 414 | - else |
|
| 415 | - { |
|
| 416 | - $this->_helper->json(array('status'=>'No Rule')); |
|
| 417 | - } |
|
| 418 | - if (isset($postData['action'])) |
|
| 419 | - { |
|
| 420 | - $action=$postData['action']; |
|
| 421 | - if ($action != 'evaluate') |
|
| 422 | - { |
|
| 423 | - $this->_helper->json(array('status'=>'unknown action '.$action)); |
|
| 424 | - return; |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - else |
|
| 428 | - { |
|
| 429 | - $this->_helper->json(array('status'=>'No action')); |
|
| 430 | - return; |
|
| 431 | - } |
|
| 432 | - if ($action == 'evaluate') |
|
| 433 | - { |
|
| 434 | - try |
|
| 435 | - { |
|
| 436 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 437 | - $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
| 438 | - $Trap = new Trap($icingaweb2_etc); |
|
| 439 | - // Cleanup spaces before eval |
|
| 440 | - $rule=$Trap->eval_cleanup($rule); |
|
| 441 | - // Eval |
|
| 442 | - $item=0; |
|
| 443 | - $rule=$Trap->evaluation($rule,$item); |
|
| 444 | - } |
|
| 445 | - catch (Exception $e) |
|
| 446 | - { |
|
| 447 | - $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 448 | - return; |
|
| 449 | - } |
|
| 450 | - $return=($rule==true)?'true':'false'; |
|
| 451 | - $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
|
| 452 | - } |
|
| 409 | + $postData=$this->getRequest()->getPost(); |
|
| 410 | + if (isset($postData['rule'])) |
|
| 411 | + { |
|
| 412 | + $rule=$postData['rule']; |
|
| 413 | + } |
|
| 414 | + else |
|
| 415 | + { |
|
| 416 | + $this->_helper->json(array('status'=>'No Rule')); |
|
| 417 | + } |
|
| 418 | + if (isset($postData['action'])) |
|
| 419 | + { |
|
| 420 | + $action=$postData['action']; |
|
| 421 | + if ($action != 'evaluate') |
|
| 422 | + { |
|
| 423 | + $this->_helper->json(array('status'=>'unknown action '.$action)); |
|
| 424 | + return; |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + else |
|
| 428 | + { |
|
| 429 | + $this->_helper->json(array('status'=>'No action')); |
|
| 430 | + return; |
|
| 431 | + } |
|
| 432 | + if ($action == 'evaluate') |
|
| 433 | + { |
|
| 434 | + try |
|
| 435 | + { |
|
| 436 | + require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 437 | + $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
| 438 | + $Trap = new Trap($icingaweb2_etc); |
|
| 439 | + // Cleanup spaces before eval |
|
| 440 | + $rule=$Trap->eval_cleanup($rule); |
|
| 441 | + // Eval |
|
| 442 | + $item=0; |
|
| 443 | + $rule=$Trap->evaluation($rule,$item); |
|
| 444 | + } |
|
| 445 | + catch (Exception $e) |
|
| 446 | + { |
|
| 447 | + $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 448 | + return; |
|
| 449 | + } |
|
| 450 | + $return=($rule==true)?'true':'false'; |
|
| 451 | + $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | 454 | } |
| 455 | 455 | |
@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | $this->_helper->json(array('status'=>'KO')); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 29 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 30 | 30 | |
| 31 | 31 | $hosts=$this->getHostByIP($hostFilter); |
| 32 | 32 | foreach ($hosts as $val) |
| 33 | 33 | { |
| 34 | - array_push($retHosts['hosts'],$val->name); |
|
| 34 | + array_push($retHosts['hosts'], $val->name); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $this->_helper->json($retHosts); |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | $this->_helper->json(array('status'=>'Error : no filter')); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 56 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 57 | 57 | |
| 58 | 58 | $hosts=$this->getHostGroupByName($hostFilter); |
| 59 | 59 | foreach ($hosts as $val) |
| 60 | 60 | { |
| 61 | - array_push($retHosts['hosts'],$val->name); |
|
| 61 | + array_push($retHosts['hosts'], $val->name); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $this->_helper->json($retHosts); |
@@ -80,27 +80,27 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | else |
| 82 | 82 | { |
| 83 | - $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
|
| 83 | + $this->_helper->json(array('status'=>'No Hosts', 'hostid' => -1)); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $hostArray=$this->getHostByName($host); |
| 87 | 87 | if (count($hostArray) > 1) |
| 88 | 88 | { |
| 89 | - $this->_helper->json(array('status'=>'More than one host matches','hostid' => -1)); |
|
| 89 | + $this->_helper->json(array('status'=>'More than one host matches', 'hostid' => -1)); |
|
| 90 | 90 | } |
| 91 | 91 | else if (count($hostArray) == 0) |
| 92 | 92 | { |
| 93 | - $this->_helper->json(array('status'=>'No host matches','hostid' => -1)); |
|
| 93 | + $this->_helper->json(array('status'=>'No host matches', 'hostid' => -1)); |
|
| 94 | 94 | } |
| 95 | 95 | $services=$this->getServicesByHostid($hostArray[0]->id); |
| 96 | 96 | if (count($services) < 1) |
| 97 | 97 | { |
| 98 | - $this->_helper->json(array('status'=>'No services found for host','hostid' => $hostArray[0]->id)); |
|
| 98 | + $this->_helper->json(array('status'=>'No services found for host', 'hostid' => $hostArray[0]->id)); |
|
| 99 | 99 | } |
| 100 | - $retServices=array('status'=>'OK','services' => array(),'hostid' => $hostArray[0]->id); |
|
| 100 | + $retServices=array('status'=>'OK', 'services' => array(), 'hostid' => $hostArray[0]->id); |
|
| 101 | 101 | foreach ($services as $val) |
| 102 | 102 | { |
| 103 | - array_push($retServices['services'],array($val->id , $val->name)); |
|
| 103 | + array_push($retServices['services'], array($val->id, $val->name)); |
|
| 104 | 104 | } |
| 105 | 105 | $this->_helper->json($retServices); |
| 106 | 106 | } |
@@ -120,24 +120,24 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | else |
| 122 | 122 | { |
| 123 | - $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
|
| 123 | + $this->_helper->json(array('status'=>'No Hosts', 'hostid' => -1)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $hostArray=$this->getHostGroupByName($host); |
| 127 | 127 | if (count($hostArray) > 1) |
| 128 | 128 | { |
| 129 | - $this->_helper->json(array('status'=>'More than one hostgroup matches','hostid' => -1)); |
|
| 129 | + $this->_helper->json(array('status'=>'More than one hostgroup matches', 'hostid' => -1)); |
|
| 130 | 130 | } |
| 131 | 131 | else if (count($hostArray) == 0) |
| 132 | 132 | { |
| 133 | - $this->_helper->json(array('status'=>'No hostgroup matches','hostid' => -1)); |
|
| 133 | + $this->_helper->json(array('status'=>'No hostgroup matches', 'hostid' => -1)); |
|
| 134 | 134 | } |
| 135 | 135 | $services=$this->getServicesByHostGroupid($hostArray[0]->id); |
| 136 | 136 | if (count($services) < 1) |
| 137 | 137 | { |
| 138 | - $this->_helper->json(array('status'=>'No services found for hostgroup','hostid' => $hostArray[0]->id)); |
|
| 138 | + $this->_helper->json(array('status'=>'No services found for hostgroup', 'hostid' => $hostArray[0]->id)); |
|
| 139 | 139 | } |
| 140 | - $retServices=array('status'=>'OK','services' => $services,'hostid' => $hostArray[0]->id); |
|
| 140 | + $retServices=array('status'=>'OK', 'services' => $services, 'hostid' => $hostArray[0]->id); |
|
| 141 | 141 | |
| 142 | 142 | $this->_helper->json($retServices); |
| 143 | 143 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | try |
| 162 | 162 | { |
| 163 | 163 | $traplist=$this->getMIB()->getTrapList($mib); |
| 164 | - $retTraps=array('status'=>'OK','traps' => $traplist); |
|
| 164 | + $retTraps=array('status'=>'OK', 'traps' => $traplist); |
|
| 165 | 165 | } |
| 166 | 166 | catch (Exception $e) |
| 167 | 167 | { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | try |
| 190 | 190 | { |
| 191 | 191 | $objectlist=$this->getMIB()->getObjectList($trap); |
| 192 | - $retObjects=array('status'=>'OK','objects' => $objectlist); |
|
| 192 | + $retObjects=array('status'=>'OK', 'objects' => $objectlist); |
|
| 193 | 193 | } |
| 194 | 194 | catch (Exception $e) |
| 195 | 195 | { |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | if (isset($postData['days'])) |
| 265 | 265 | { |
| 266 | 266 | $days=$postData['days']; |
| 267 | - if (!preg_match('/^[0-9]+$/',$days)) |
|
| 267 | + if (!preg_match('/^[0-9]+$/', $days)) |
|
| 268 | 268 | { |
| 269 | 269 | $this->_helper->json(array('status'=>'invalid days : '.$days)); |
| 270 | 270 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | if (isset($postData['action'])) |
| 277 | 277 | { |
| 278 | 278 | $action=$postData['action']; |
| 279 | - if ($action != 'save' && $action !='execute') |
|
| 279 | + if ($action != 'save' && $action != 'execute') |
|
| 280 | 280 | { |
| 281 | 281 | $this->_helper->json(array('status'=>'unknown action '.$action)); |
| 282 | 282 | return; |
@@ -291,11 +291,11 @@ discard block |
||
| 291 | 291 | { |
| 292 | 292 | try |
| 293 | 293 | { |
| 294 | - $this->setDBConfigValue('db_remove_days',$days); |
|
| 294 | + $this->setDBConfigValue('db_remove_days', $days); |
|
| 295 | 295 | } |
| 296 | 296 | catch (Exception $e) |
| 297 | 297 | { |
| 298 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 298 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 299 | 299 | return; |
| 300 | 300 | } |
| 301 | 301 | $this->_helper->json(array('status'=>'OK')); |
@@ -305,16 +305,16 @@ discard block |
||
| 305 | 305 | { |
| 306 | 306 | try |
| 307 | 307 | { |
| 308 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 308 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 309 | 309 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 310 | 310 | $debug_level=4; |
| 311 | - $Trap = new Trap($icingaweb2_etc); |
|
| 312 | - $Trap->setLogging($debug_level,'syslog'); |
|
| 311 | + $Trap=new Trap($icingaweb2_etc); |
|
| 312 | + $Trap->setLogging($debug_level, 'syslog'); |
|
| 313 | 313 | $Trap->eraseOldTraps($days); |
| 314 | 314 | } |
| 315 | 315 | catch (Exception $e) |
| 316 | 316 | { |
| 317 | - $this->_helper->json(array('status'=>'execute error : '.$e->getMessage() )); |
|
| 317 | + $this->_helper->json(array('status'=>'execute error : '.$e->getMessage())); |
|
| 318 | 318 | return; |
| 319 | 319 | } |
| 320 | 320 | $this->_helper->json(array('status'=>'OK')); |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | if (isset($postData['file'])) |
| 348 | 348 | { |
| 349 | 349 | $file=$postData['file']; |
| 350 | - $fileHandler=@fopen($file,'w'); |
|
| 350 | + $fileHandler=@fopen($file, 'w'); |
|
| 351 | 351 | if ($fileHandler == false) |
| 352 | 352 | { // File os note writabe / cannot create |
| 353 | 353 | $this->_helper->json(array('status'=>'File not writable : '.$file)); |
@@ -384,13 +384,13 @@ discard block |
||
| 384 | 384 | |
| 385 | 385 | try |
| 386 | 386 | { |
| 387 | - $this->setDBConfigValue('log_destination',$destination); |
|
| 388 | - $this->setDBConfigValue('log_file',$file); |
|
| 389 | - $this->setDBConfigValue('log_level',$level); |
|
| 387 | + $this->setDBConfigValue('log_destination', $destination); |
|
| 388 | + $this->setDBConfigValue('log_file', $file); |
|
| 389 | + $this->setDBConfigValue('log_level', $level); |
|
| 390 | 390 | } |
| 391 | 391 | catch (Exception $e) |
| 392 | 392 | { |
| 393 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 393 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 394 | 394 | return; |
| 395 | 395 | } |
| 396 | 396 | $this->_helper->json(array('status'=>'OK')); |
@@ -433,21 +433,21 @@ discard block |
||
| 433 | 433 | { |
| 434 | 434 | try |
| 435 | 435 | { |
| 436 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 436 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 437 | 437 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 438 | - $Trap = new Trap($icingaweb2_etc); |
|
| 438 | + $Trap=new Trap($icingaweb2_etc); |
|
| 439 | 439 | // Cleanup spaces before eval |
| 440 | 440 | $rule=$Trap->eval_cleanup($rule); |
| 441 | 441 | // Eval |
| 442 | 442 | $item=0; |
| 443 | - $rule=$Trap->evaluation($rule,$item); |
|
| 443 | + $rule=$Trap->evaluation($rule, $item); |
|
| 444 | 444 | } |
| 445 | 445 | catch (Exception $e) |
| 446 | 446 | { |
| 447 | - $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 447 | + $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage())); |
|
| 448 | 448 | return; |
| 449 | 449 | } |
| 450 | - $return=($rule==true)?'true':'false'; |
|
| 450 | + $return=($rule == true) ? 'true' : 'false'; |
|
| 451 | 451 | $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
| 452 | 452 | } |
| 453 | 453 | |
@@ -20,8 +20,7 @@ discard block |
||
| 20 | 20 | if (isset($postData['hostFilter'])) |
| 21 | 21 | { |
| 22 | 22 | $hostFilter=$postData['hostFilter']; |
| 23 | - } |
|
| 24 | - else |
|
| 23 | + } else |
|
| 25 | 24 | { |
| 26 | 25 | $this->_helper->json(array('status'=>'KO')); |
| 27 | 26 | } |
@@ -47,8 +46,7 @@ discard block |
||
| 47 | 46 | if (isset($postData['hostFilter'])) |
| 48 | 47 | { |
| 49 | 48 | $hostFilter=$postData['hostFilter']; |
| 50 | - } |
|
| 51 | - else |
|
| 49 | + } else |
|
| 52 | 50 | { |
| 53 | 51 | $this->_helper->json(array('status'=>'Error : no filter')); |
| 54 | 52 | } |
@@ -77,8 +75,7 @@ discard block |
||
| 77 | 75 | if (isset($postData['host'])) |
| 78 | 76 | { |
| 79 | 77 | $host=$postData['host']; |
| 80 | - } |
|
| 81 | - else |
|
| 78 | + } else |
|
| 82 | 79 | { |
| 83 | 80 | $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
| 84 | 81 | } |
@@ -87,8 +84,7 @@ discard block |
||
| 87 | 84 | if (count($hostArray) > 1) |
| 88 | 85 | { |
| 89 | 86 | $this->_helper->json(array('status'=>'More than one host matches','hostid' => -1)); |
| 90 | - } |
|
| 91 | - else if (count($hostArray) == 0) |
|
| 87 | + } else if (count($hostArray) == 0) |
|
| 92 | 88 | { |
| 93 | 89 | $this->_helper->json(array('status'=>'No host matches','hostid' => -1)); |
| 94 | 90 | } |
@@ -117,8 +113,7 @@ discard block |
||
| 117 | 113 | if (isset($postData['host'])) |
| 118 | 114 | { |
| 119 | 115 | $host=$postData['host']; |
| 120 | - } |
|
| 121 | - else |
|
| 116 | + } else |
|
| 122 | 117 | { |
| 123 | 118 | $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
| 124 | 119 | } |
@@ -127,8 +122,7 @@ discard block |
||
| 127 | 122 | if (count($hostArray) > 1) |
| 128 | 123 | { |
| 129 | 124 | $this->_helper->json(array('status'=>'More than one hostgroup matches','hostid' => -1)); |
| 130 | - } |
|
| 131 | - else if (count($hostArray) == 0) |
|
| 125 | + } else if (count($hostArray) == 0) |
|
| 132 | 126 | { |
| 133 | 127 | $this->_helper->json(array('status'=>'No hostgroup matches','hostid' => -1)); |
| 134 | 128 | } |
@@ -153,8 +147,7 @@ discard block |
||
| 153 | 147 | if (isset($postData['mib'])) |
| 154 | 148 | { |
| 155 | 149 | $mib=$postData['mib']; |
| 156 | - } |
|
| 157 | - else |
|
| 150 | + } else |
|
| 158 | 151 | { |
| 159 | 152 | $this->_helper->json(array('status'=>'No mib')); |
| 160 | 153 | } |
@@ -162,8 +155,7 @@ discard block |
||
| 162 | 155 | { |
| 163 | 156 | $traplist=$this->getMIB()->getTrapList($mib); |
| 164 | 157 | $retTraps=array('status'=>'OK','traps' => $traplist); |
| 165 | - } |
|
| 166 | - catch (Exception $e) |
|
| 158 | + } catch (Exception $e) |
|
| 167 | 159 | { |
| 168 | 160 | $retTraps=array('status' => 'Error getting mibs'); |
| 169 | 161 | } |
@@ -181,8 +173,7 @@ discard block |
||
| 181 | 173 | if (isset($postData['trap'])) |
| 182 | 174 | { |
| 183 | 175 | $trap=$postData['trap']; |
| 184 | - } |
|
| 185 | - else |
|
| 176 | + } else |
|
| 186 | 177 | { |
| 187 | 178 | $this->_helper->json(array('status'=>'No trap')); |
| 188 | 179 | } |
@@ -190,8 +181,7 @@ discard block |
||
| 190 | 181 | { |
| 191 | 182 | $objectlist=$this->getMIB()->getObjectList($trap); |
| 192 | 183 | $retObjects=array('status'=>'OK','objects' => $objectlist); |
| 193 | - } |
|
| 194 | - catch (Exception $e) |
|
| 184 | + } catch (Exception $e) |
|
| 195 | 185 | { |
| 196 | 186 | $retObjects=array('status' => 'not found'); |
| 197 | 187 | } |
@@ -206,8 +196,7 @@ discard block |
||
| 206 | 196 | try |
| 207 | 197 | { |
| 208 | 198 | $miblist=$this->getMIB()->getMIBList(); |
| 209 | - } |
|
| 210 | - catch (Exception $e) |
|
| 199 | + } catch (Exception $e) |
|
| 211 | 200 | { |
| 212 | 201 | $miblist=array('Error getting mibs'); |
| 213 | 202 | } |
@@ -225,8 +214,7 @@ discard block |
||
| 225 | 214 | if (isset($postData['oid'])) |
| 226 | 215 | { |
| 227 | 216 | $oid=$postData['oid']; |
| 228 | - } |
|
| 229 | - else |
|
| 217 | + } else |
|
| 230 | 218 | { |
| 231 | 219 | $this->_helper->json(array('status'=>'No oid')); |
| 232 | 220 | } |
@@ -235,8 +223,7 @@ discard block |
||
| 235 | 223 | if (($object=$this->getMIB()->translateOID($oid)) == null) |
| 236 | 224 | { |
| 237 | 225 | $this->_helper->json(array('status'=>'Not found')); |
| 238 | - } |
|
| 239 | - else |
|
| 226 | + } else |
|
| 240 | 227 | { |
| 241 | 228 | $this->_helper->json( |
| 242 | 229 | array('status'=>'OK', |
@@ -268,8 +255,7 @@ discard block |
||
| 268 | 255 | { |
| 269 | 256 | $this->_helper->json(array('status'=>'invalid days : '.$days)); |
| 270 | 257 | } |
| 271 | - } |
|
| 272 | - else |
|
| 258 | + } else |
|
| 273 | 259 | { |
| 274 | 260 | $this->_helper->json(array('status'=>'No days')); |
| 275 | 261 | } |
@@ -281,8 +267,7 @@ discard block |
||
| 281 | 267 | $this->_helper->json(array('status'=>'unknown action '.$action)); |
| 282 | 268 | return; |
| 283 | 269 | } |
| 284 | - } |
|
| 285 | - else |
|
| 270 | + } else |
|
| 286 | 271 | { |
| 287 | 272 | $this->_helper->json(array('status'=>'No action')); |
| 288 | 273 | return; |
@@ -292,8 +277,7 @@ discard block |
||
| 292 | 277 | try |
| 293 | 278 | { |
| 294 | 279 | $this->setDBConfigValue('db_remove_days',$days); |
| 295 | - } |
|
| 296 | - catch (Exception $e) |
|
| 280 | + } catch (Exception $e) |
|
| 297 | 281 | { |
| 298 | 282 | $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
| 299 | 283 | return; |
@@ -311,8 +295,7 @@ discard block |
||
| 311 | 295 | $Trap = new Trap($icingaweb2_etc); |
| 312 | 296 | $Trap->setLogging($debug_level,'syslog'); |
| 313 | 297 | $Trap->eraseOldTraps($days); |
| 314 | - } |
|
| 315 | - catch (Exception $e) |
|
| 298 | + } catch (Exception $e) |
|
| 316 | 299 | { |
| 317 | 300 | $this->_helper->json(array('status'=>'execute error : '.$e->getMessage() )); |
| 318 | 301 | return; |
@@ -339,8 +322,7 @@ discard block |
||
| 339 | 322 | { |
| 340 | 323 | $this->_helper->json(array('status'=>'invalid destination : '.$destination)); |
| 341 | 324 | } |
| 342 | - } |
|
| 343 | - else |
|
| 325 | + } else |
|
| 344 | 326 | { |
| 345 | 327 | $this->_helper->json(array('status'=>'No destination')); |
| 346 | 328 | } |
@@ -352,14 +334,12 @@ discard block |
||
| 352 | 334 | { // File os note writabe / cannot create |
| 353 | 335 | $this->_helper->json(array('status'=>'File not writable : '.$file)); |
| 354 | 336 | } |
| 355 | - } |
|
| 356 | - else |
|
| 337 | + } else |
|
| 357 | 338 | { |
| 358 | 339 | if ($destination != 'file') |
| 359 | 340 | { |
| 360 | 341 | $file=null; |
| 361 | - } |
|
| 362 | - else |
|
| 342 | + } else |
|
| 363 | 343 | { |
| 364 | 344 | $this->_helper->json(array('status'=>'No file')); |
| 365 | 345 | } |
@@ -368,14 +348,12 @@ discard block |
||
| 368 | 348 | if (isset($postData['level'])) |
| 369 | 349 | { |
| 370 | 350 | $level=$postData['level']; |
| 371 | - } |
|
| 372 | - else |
|
| 351 | + } else |
|
| 373 | 352 | { |
| 374 | 353 | if ($destination != 'level') |
| 375 | 354 | { |
| 376 | 355 | $level=null; |
| 377 | - } |
|
| 378 | - else |
|
| 356 | + } else |
|
| 379 | 357 | { |
| 380 | 358 | $this->_helper->json(array('status'=>'No level')); |
| 381 | 359 | } |
@@ -387,8 +365,7 @@ discard block |
||
| 387 | 365 | $this->setDBConfigValue('log_destination',$destination); |
| 388 | 366 | $this->setDBConfigValue('log_file',$file); |
| 389 | 367 | $this->setDBConfigValue('log_level',$level); |
| 390 | - } |
|
| 391 | - catch (Exception $e) |
|
| 368 | + } catch (Exception $e) |
|
| 392 | 369 | { |
| 393 | 370 | $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
| 394 | 371 | return; |
@@ -410,8 +387,7 @@ discard block |
||
| 410 | 387 | if (isset($postData['rule'])) |
| 411 | 388 | { |
| 412 | 389 | $rule=$postData['rule']; |
| 413 | - } |
|
| 414 | - else |
|
| 390 | + } else |
|
| 415 | 391 | { |
| 416 | 392 | $this->_helper->json(array('status'=>'No Rule')); |
| 417 | 393 | } |
@@ -423,8 +399,7 @@ discard block |
||
| 423 | 399 | $this->_helper->json(array('status'=>'unknown action '.$action)); |
| 424 | 400 | return; |
| 425 | 401 | } |
| 426 | - } |
|
| 427 | - else |
|
| 402 | + } else |
|
| 428 | 403 | { |
| 429 | 404 | $this->_helper->json(array('status'=>'No action')); |
| 430 | 405 | return; |
@@ -441,8 +416,7 @@ discard block |
||
| 441 | 416 | // Eval |
| 442 | 417 | $item=0; |
| 443 | 418 | $rule=$Trap->evaluation($rule,$item); |
| 444 | - } |
|
| 445 | - catch (Exception $e) |
|
| 419 | + } catch (Exception $e) |
|
| 446 | 420 | { |
| 447 | 421 | $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
| 448 | 422 | return; |