@@ -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(); |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** Get hostgroup list with filter (name) : hostgroup=<hostFilter> |
| 43 | - * returns in JSON : status=>OK/NOK hosts=>array of hosts |
|
| 44 | - */ |
|
| 43 | + * returns in JSON : status=>OK/NOK hosts=>array of hosts |
|
| 44 | + */ |
|
| 45 | 45 | public function gethostgroupsAction() |
| 46 | 46 | { |
| 47 | 47 | $postData=$this->getRequest()->getPost(); |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | /** Get service list by host name ( host=<host> ) |
| 71 | - * returns in JSON : |
|
| 72 | - * status=>OK/No services found/More than one host matches |
|
| 73 | - * services=>array of services (name) |
|
| 74 | - * hostid = host object id or -1 if not found. |
|
| 75 | - */ |
|
| 71 | + * returns in JSON : |
|
| 72 | + * status=>OK/No services found/More than one host matches |
|
| 73 | + * services=>array of services (name) |
|
| 74 | + * hostid = host object id or -1 if not found. |
|
| 75 | + */ |
|
| 76 | 76 | public function getservicesAction() |
| 77 | 77 | { |
| 78 | 78 | $postData=$this->getRequest()->getPost(); |
@@ -112,11 +112,11 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** Get service list by host group ( name=<host> ) |
| 115 | - * returns in JSON : |
|
| 116 | - * status=>OK/No services found/More than one host matches |
|
| 117 | - * services=>array of services (name) |
|
| 118 | - * groupid = group object id or -1 if not found. |
|
| 119 | - */ |
|
| 115 | + * returns in JSON : |
|
| 116 | + * status=>OK/No services found/More than one host matches |
|
| 117 | + * services=>array of services (name) |
|
| 118 | + * groupid = group object id or -1 if not found. |
|
| 119 | + */ |
|
| 120 | 120 | public function gethostgroupservicesAction() |
| 121 | 121 | { |
| 122 | 122 | $postData=$this->getRequest()->getPost(); |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** Get traps from mib : entry : mib=<mib> |
| 156 | - * returns in JSON : |
|
| 157 | - * status=>OK/No mib/Error getting mibs |
|
| 158 | - * traps=>array of array( oid -> name) |
|
| 159 | - */ |
|
| 156 | + * returns in JSON : |
|
| 157 | + * status=>OK/No mib/Error getting mibs |
|
| 158 | + * traps=>array of array( oid -> name) |
|
| 159 | + */ |
|
| 160 | 160 | public function gettrapsAction() |
| 161 | 161 | { |
| 162 | 162 | $postData=$this->getRequest()->getPost(); |
@@ -182,10 +182,10 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** Get trap objects from mib : entry : trap=<oid> |
| 185 | - * returns in JSON : |
|
| 186 | - * status=>OK/no trap/not found |
|
| 187 | - * objects=>array of array( oid -> name, oid->mib) |
|
| 188 | - */ |
|
| 185 | + * returns in JSON : |
|
| 186 | + * status=>OK/no trap/not found |
|
| 187 | + * objects=>array of array( oid -> name, oid->mib) |
|
| 188 | + */ |
|
| 189 | 189 | public function gettrapobjectsAction() |
| 190 | 190 | { |
| 191 | 191 | $postData=$this->getRequest()->getPost(); |
@@ -211,8 +211,8 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** Get list of all loaded mibs : entry : none |
| 214 | - * return : array of strings. |
|
| 215 | - */ |
|
| 214 | + * return : array of strings. |
|
| 215 | + */ |
|
| 216 | 216 | public function getmiblistAction() |
| 217 | 217 | { |
| 218 | 218 | try |
@@ -227,10 +227,10 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** Get MIB::Name from OID : entry : oid |
| 230 | - * status=>OK/No oid/not found |
|
| 231 | - * mib=>string |
|
| 232 | - * name=>string |
|
| 233 | - */ |
|
| 230 | + * status=>OK/No oid/not found |
|
| 231 | + * mib=>string |
|
| 232 | + * name=>string |
|
| 233 | + */ |
|
| 234 | 234 | public function translateoidAction() |
| 235 | 235 | { |
| 236 | 236 | $postData=$this->getRequest()->getPost(); |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | 'name' => $object['name'], |
| 259 | 259 | 'type' => $object['type'], |
| 260 | 260 | 'type_enum' => $object['type_enum'], |
| 261 | - 'description' => $object['description'] |
|
| 261 | + 'description' => $object['description'] |
|
| 262 | 262 | ) |
| 263 | 263 | ); |
| 264 | 264 | } |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | |
| 269 | 269 | /** Save or execute database purge of <n> days |
| 270 | - * days=>int |
|
| 271 | - * action=>save/execute |
|
| 272 | - * return : status=>OK/Message error |
|
| 273 | - */ |
|
| 270 | + * days=>int |
|
| 271 | + * action=>save/execute |
|
| 272 | + * return : status=>OK/Message error |
|
| 273 | + */ |
|
| 274 | 274 | public function dbmaintenanceAction() |
| 275 | 275 | { |
| 276 | 276 | |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | /** Save log output to db |
| 342 | - * destination=>log destination |
|
| 343 | - * file=>file name |
|
| 344 | - * level => int |
|
| 345 | - * return : status=>OK/Message error |
|
| 346 | - */ |
|
| 342 | + * destination=>log destination |
|
| 343 | + * file=>file name |
|
| 344 | + * level => int |
|
| 345 | + * return : status=>OK/Message error |
|
| 346 | + */ |
|
| 347 | 347 | public function logdestinationAction() |
| 348 | 348 | { |
| 349 | 349 | $postData=$this->getRequest()->getPost(); |
@@ -367,8 +367,8 @@ discard block |
||
| 367 | 367 | $fileHandler=@fopen($file,'w'); |
| 368 | 368 | if ($fileHandler == false) |
| 369 | 369 | { // File os note writabe / cannot create |
| 370 | - $this->_helper->json(array('status'=>'File not writable : '.$file)); |
|
| 371 | - return; |
|
| 370 | + $this->_helper->json(array('status'=>'File not writable : '.$file)); |
|
| 371 | + return; |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | else |
@@ -418,50 +418,50 @@ discard block |
||
| 418 | 418 | public function testruleAction() |
| 419 | 419 | { |
| 420 | 420 | |
| 421 | - $postData=$this->getRequest()->getPost(); |
|
| 422 | - if (isset($postData['rule'])) |
|
| 423 | - { |
|
| 424 | - $rule=$postData['rule']; |
|
| 425 | - } |
|
| 426 | - else |
|
| 427 | - { |
|
| 428 | - $this->_helper->json(array('status'=>'No Rule')); |
|
| 429 | - } |
|
| 430 | - if (isset($postData['action'])) |
|
| 431 | - { |
|
| 432 | - $action=$postData['action']; |
|
| 433 | - if ($action != 'evaluate') |
|
| 434 | - { |
|
| 435 | - $this->_helper->json(array('status'=>'unknown action '.$action)); |
|
| 436 | - return; |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - else |
|
| 440 | - { |
|
| 441 | - $this->_helper->json(array('status'=>'No action')); |
|
| 442 | - return; |
|
| 443 | - } |
|
| 444 | - if ($action == 'evaluate') |
|
| 445 | - { |
|
| 446 | - try |
|
| 447 | - { |
|
| 448 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 449 | - $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
| 450 | - $Trap = new Trap($icingaweb2_etc); |
|
| 451 | - // Cleanup spaces before eval |
|
| 452 | - $rule=$Trap->eval_cleanup($rule); |
|
| 453 | - // Eval |
|
| 454 | - $item=0; |
|
| 455 | - $rule=$Trap->evaluation($rule,$item); |
|
| 456 | - } |
|
| 457 | - catch (Exception $e) |
|
| 458 | - { |
|
| 459 | - $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 460 | - return; |
|
| 461 | - } |
|
| 462 | - $return=($rule==true)?'true':'false'; |
|
| 463 | - $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
|
| 464 | - } |
|
| 421 | + $postData=$this->getRequest()->getPost(); |
|
| 422 | + if (isset($postData['rule'])) |
|
| 423 | + { |
|
| 424 | + $rule=$postData['rule']; |
|
| 425 | + } |
|
| 426 | + else |
|
| 427 | + { |
|
| 428 | + $this->_helper->json(array('status'=>'No Rule')); |
|
| 429 | + } |
|
| 430 | + if (isset($postData['action'])) |
|
| 431 | + { |
|
| 432 | + $action=$postData['action']; |
|
| 433 | + if ($action != 'evaluate') |
|
| 434 | + { |
|
| 435 | + $this->_helper->json(array('status'=>'unknown action '.$action)); |
|
| 436 | + return; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + else |
|
| 440 | + { |
|
| 441 | + $this->_helper->json(array('status'=>'No action')); |
|
| 442 | + return; |
|
| 443 | + } |
|
| 444 | + if ($action == 'evaluate') |
|
| 445 | + { |
|
| 446 | + try |
|
| 447 | + { |
|
| 448 | + require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 449 | + $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
| 450 | + $Trap = new Trap($icingaweb2_etc); |
|
| 451 | + // Cleanup spaces before eval |
|
| 452 | + $rule=$Trap->eval_cleanup($rule); |
|
| 453 | + // Eval |
|
| 454 | + $item=0; |
|
| 455 | + $rule=$Trap->evaluation($rule,$item); |
|
| 456 | + } |
|
| 457 | + catch (Exception $e) |
|
| 458 | + { |
|
| 459 | + $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 460 | + return; |
|
| 461 | + } |
|
| 462 | + $return=($rule==true)?'true':'false'; |
|
| 463 | + $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
|
| 464 | + } |
|
| 465 | 465 | |
| 466 | 466 | } |
| 467 | 467 | |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 30 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 31 | 31 | |
| 32 | 32 | $hosts=$this->getHostByIP($hostFilter); |
| 33 | 33 | foreach ($hosts as $val) |
| 34 | 34 | { |
| 35 | - array_push($retHosts['hosts'],$val->name); |
|
| 35 | + array_push($retHosts['hosts'], $val->name); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $this->_helper->json($retHosts); |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 58 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 59 | 59 | |
| 60 | 60 | $hosts=$this->getHostGroupByName($hostFilter); |
| 61 | 61 | foreach ($hosts as $val) |
| 62 | 62 | { |
| 63 | - array_push($retHosts['hosts'],$val->name); |
|
| 63 | + array_push($retHosts['hosts'], $val->name); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $this->_helper->json($retHosts); |
@@ -82,31 +82,31 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | else |
| 84 | 84 | { |
| 85 | - $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
|
| 85 | + $this->_helper->json(array('status'=>'No Hosts', 'hostid' => -1)); |
|
| 86 | 86 | return; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $hostArray=$this->getHostByName($host); |
| 90 | 90 | if (count($hostArray) > 1) |
| 91 | 91 | { |
| 92 | - $this->_helper->json(array('status'=>'More than one host matches','hostid' => -1)); |
|
| 92 | + $this->_helper->json(array('status'=>'More than one host matches', 'hostid' => -1)); |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | else if (count($hostArray) == 0) |
| 96 | 96 | { |
| 97 | - $this->_helper->json(array('status'=>'No host matches','hostid' => -1)); |
|
| 97 | + $this->_helper->json(array('status'=>'No host matches', 'hostid' => -1)); |
|
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | $services=$this->getServicesByHostid($hostArray[0]->id); |
| 101 | 101 | if (count($services) < 1) |
| 102 | 102 | { |
| 103 | - $this->_helper->json(array('status'=>'No services found for host','hostid' => $hostArray[0]->id)); |
|
| 103 | + $this->_helper->json(array('status'=>'No services found for host', 'hostid' => $hostArray[0]->id)); |
|
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | - $retServices=array('status'=>'OK','services' => array(),'hostid' => $hostArray[0]->id); |
|
| 106 | + $retServices=array('status'=>'OK', 'services' => array(), 'hostid' => $hostArray[0]->id); |
|
| 107 | 107 | foreach ($services as $val) |
| 108 | 108 | { |
| 109 | - array_push($retServices['services'],array($val->id , $val->name)); |
|
| 109 | + array_push($retServices['services'], array($val->id, $val->name)); |
|
| 110 | 110 | } |
| 111 | 111 | $this->_helper->json($retServices); |
| 112 | 112 | } |
@@ -126,28 +126,28 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | else |
| 128 | 128 | { |
| 129 | - $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
|
| 129 | + $this->_helper->json(array('status'=>'No Hosts', 'hostid' => -1)); |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $hostArray=$this->getHostGroupByName($host); |
| 134 | 134 | if (count($hostArray) > 1) |
| 135 | 135 | { |
| 136 | - $this->_helper->json(array('status'=>'More than one hostgroup matches','hostid' => -1)); |
|
| 136 | + $this->_helper->json(array('status'=>'More than one hostgroup matches', 'hostid' => -1)); |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | else if (count($hostArray) == 0) |
| 140 | 140 | { |
| 141 | - $this->_helper->json(array('status'=>'No hostgroup matches','hostid' => -1)); |
|
| 141 | + $this->_helper->json(array('status'=>'No hostgroup matches', 'hostid' => -1)); |
|
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | $services=$this->getServicesByHostGroupid($hostArray[0]->id); |
| 145 | 145 | if (count($services) < 1) |
| 146 | 146 | { |
| 147 | - $this->_helper->json(array('status'=>'No services found for hostgroup','hostid' => $hostArray[0]->id)); |
|
| 147 | + $this->_helper->json(array('status'=>'No services found for hostgroup', 'hostid' => $hostArray[0]->id)); |
|
| 148 | 148 | return; |
| 149 | 149 | } |
| 150 | - $retServices=array('status'=>'OK','services' => $services,'hostid' => $hostArray[0]->id); |
|
| 150 | + $retServices=array('status'=>'OK', 'services' => $services, 'hostid' => $hostArray[0]->id); |
|
| 151 | 151 | |
| 152 | 152 | $this->_helper->json($retServices); |
| 153 | 153 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | try |
| 173 | 173 | { |
| 174 | 174 | $traplist=$this->getMIB()->getTrapList($mib); |
| 175 | - $retTraps=array('status'=>'OK','traps' => $traplist); |
|
| 175 | + $retTraps=array('status'=>'OK', 'traps' => $traplist); |
|
| 176 | 176 | } |
| 177 | 177 | catch (Exception $e) |
| 178 | 178 | { |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | try |
| 202 | 202 | { |
| 203 | 203 | $objectlist=$this->getMIB()->getObjectList($trap); |
| 204 | - $retObjects=array('status'=>'OK','objects' => $objectlist); |
|
| 204 | + $retObjects=array('status'=>'OK', 'objects' => $objectlist); |
|
| 205 | 205 | } |
| 206 | 206 | catch (Exception $e) |
| 207 | 207 | { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | if (isset($postData['days'])) |
| 279 | 279 | { |
| 280 | 280 | $days=$postData['days']; |
| 281 | - if (!preg_match('/^[0-9]+$/',$days)) |
|
| 281 | + if (!preg_match('/^[0-9]+$/', $days)) |
|
| 282 | 282 | { |
| 283 | 283 | $this->_helper->json(array('status'=>'invalid days : '.$days)); |
| 284 | 284 | return; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | if (isset($postData['action'])) |
| 293 | 293 | { |
| 294 | 294 | $action=$postData['action']; |
| 295 | - if ($action != 'save' && $action !='execute') |
|
| 295 | + if ($action != 'save' && $action != 'execute') |
|
| 296 | 296 | { |
| 297 | 297 | $this->_helper->json(array('status'=>'unknown action '.$action)); |
| 298 | 298 | return; |
@@ -307,11 +307,11 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | try |
| 309 | 309 | { |
| 310 | - $this->setDBConfigValue('db_remove_days',$days); |
|
| 310 | + $this->setDBConfigValue('db_remove_days', $days); |
|
| 311 | 311 | } |
| 312 | 312 | catch (Exception $e) |
| 313 | 313 | { |
| 314 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 314 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 315 | 315 | return; |
| 316 | 316 | } |
| 317 | 317 | $this->_helper->json(array('status'=>'OK')); |
@@ -321,16 +321,16 @@ discard block |
||
| 321 | 321 | { |
| 322 | 322 | try |
| 323 | 323 | { |
| 324 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 324 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 325 | 325 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 326 | 326 | $debug_level=4; |
| 327 | - $Trap = new Trap($icingaweb2_etc); |
|
| 328 | - $Trap->setLogging($debug_level,'syslog'); |
|
| 327 | + $Trap=new Trap($icingaweb2_etc); |
|
| 328 | + $Trap->setLogging($debug_level, 'syslog'); |
|
| 329 | 329 | $Trap->eraseOldTraps($days); |
| 330 | 330 | } |
| 331 | 331 | catch (Exception $e) |
| 332 | 332 | { |
| 333 | - $this->_helper->json(array('status'=>'execute error : '.$e->getMessage() )); |
|
| 333 | + $this->_helper->json(array('status'=>'execute error : '.$e->getMessage())); |
|
| 334 | 334 | return; |
| 335 | 335 | } |
| 336 | 336 | $this->_helper->json(array('status'=>'OK')); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | if (isset($postData['file'])) |
| 365 | 365 | { |
| 366 | 366 | $file=$postData['file']; |
| 367 | - $fileHandler=@fopen($file,'w'); |
|
| 367 | + $fileHandler=@fopen($file, 'w'); |
|
| 368 | 368 | if ($fileHandler == false) |
| 369 | 369 | { // File os note writabe / cannot create |
| 370 | 370 | $this->_helper->json(array('status'=>'File not writable : '.$file)); |
@@ -396,13 +396,13 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | try |
| 398 | 398 | { |
| 399 | - $this->setDBConfigValue('log_destination',$destination); |
|
| 400 | - $this->setDBConfigValue('log_file',$file); |
|
| 401 | - $this->setDBConfigValue('log_level',$level); |
|
| 399 | + $this->setDBConfigValue('log_destination', $destination); |
|
| 400 | + $this->setDBConfigValue('log_file', $file); |
|
| 401 | + $this->setDBConfigValue('log_level', $level); |
|
| 402 | 402 | } |
| 403 | 403 | catch (Exception $e) |
| 404 | 404 | { |
| 405 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 405 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 406 | 406 | return; |
| 407 | 407 | } |
| 408 | 408 | $this->_helper->json(array('status'=>'OK')); |
@@ -445,21 +445,21 @@ discard block |
||
| 445 | 445 | { |
| 446 | 446 | try |
| 447 | 447 | { |
| 448 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 448 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 449 | 449 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 450 | - $Trap = new Trap($icingaweb2_etc); |
|
| 450 | + $Trap=new Trap($icingaweb2_etc); |
|
| 451 | 451 | // Cleanup spaces before eval |
| 452 | 452 | $rule=$Trap->eval_cleanup($rule); |
| 453 | 453 | // Eval |
| 454 | 454 | $item=0; |
| 455 | - $rule=$Trap->evaluation($rule,$item); |
|
| 455 | + $rule=$Trap->evaluation($rule, $item); |
|
| 456 | 456 | } |
| 457 | 457 | catch (Exception $e) |
| 458 | 458 | { |
| 459 | - $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 459 | + $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage())); |
|
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | - $return=($rule==true)?'true':'false'; |
|
| 462 | + $return=($rule == true) ? 'true' : 'false'; |
|
| 463 | 463 | $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -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 | return; |
@@ -48,8 +47,7 @@ discard block |
||
| 48 | 47 | if (isset($postData['hostFilter'])) |
| 49 | 48 | { |
| 50 | 49 | $hostFilter=$postData['hostFilter']; |
| 51 | - } |
|
| 52 | - else |
|
| 50 | + } else |
|
| 53 | 51 | { |
| 54 | 52 | $this->_helper->json(array('status'=>'Error : no filter')); |
| 55 | 53 | return; |
@@ -79,8 +77,7 @@ discard block |
||
| 79 | 77 | if (isset($postData['host'])) |
| 80 | 78 | { |
| 81 | 79 | $host=$postData['host']; |
| 82 | - } |
|
| 83 | - else |
|
| 80 | + } else |
|
| 84 | 81 | { |
| 85 | 82 | $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
| 86 | 83 | return; |
@@ -91,8 +88,7 @@ discard block |
||
| 91 | 88 | { |
| 92 | 89 | $this->_helper->json(array('status'=>'More than one host matches','hostid' => -1)); |
| 93 | 90 | return; |
| 94 | - } |
|
| 95 | - else if (count($hostArray) == 0) |
|
| 91 | + } else if (count($hostArray) == 0) |
|
| 96 | 92 | { |
| 97 | 93 | $this->_helper->json(array('status'=>'No host matches','hostid' => -1)); |
| 98 | 94 | return; |
@@ -123,8 +119,7 @@ discard block |
||
| 123 | 119 | if (isset($postData['host'])) |
| 124 | 120 | { |
| 125 | 121 | $host=$postData['host']; |
| 126 | - } |
|
| 127 | - else |
|
| 122 | + } else |
|
| 128 | 123 | { |
| 129 | 124 | $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
| 130 | 125 | return; |
@@ -135,8 +130,7 @@ discard block |
||
| 135 | 130 | { |
| 136 | 131 | $this->_helper->json(array('status'=>'More than one hostgroup matches','hostid' => -1)); |
| 137 | 132 | return; |
| 138 | - } |
|
| 139 | - else if (count($hostArray) == 0) |
|
| 133 | + } else if (count($hostArray) == 0) |
|
| 140 | 134 | { |
| 141 | 135 | $this->_helper->json(array('status'=>'No hostgroup matches','hostid' => -1)); |
| 142 | 136 | return; |
@@ -163,8 +157,7 @@ discard block |
||
| 163 | 157 | if (isset($postData['mib'])) |
| 164 | 158 | { |
| 165 | 159 | $mib=$postData['mib']; |
| 166 | - } |
|
| 167 | - else |
|
| 160 | + } else |
|
| 168 | 161 | { |
| 169 | 162 | $this->_helper->json(array('status'=>'No mib')); |
| 170 | 163 | return; |
@@ -173,8 +166,7 @@ discard block |
||
| 173 | 166 | { |
| 174 | 167 | $traplist=$this->getMIB()->getTrapList($mib); |
| 175 | 168 | $retTraps=array('status'=>'OK','traps' => $traplist); |
| 176 | - } |
|
| 177 | - catch (Exception $e) |
|
| 169 | + } catch (Exception $e) |
|
| 178 | 170 | { |
| 179 | 171 | $retTraps=array('status' => 'Error getting mibs'); |
| 180 | 172 | } |
@@ -192,8 +184,7 @@ discard block |
||
| 192 | 184 | if (isset($postData['trap'])) |
| 193 | 185 | { |
| 194 | 186 | $trap=$postData['trap']; |
| 195 | - } |
|
| 196 | - else |
|
| 187 | + } else |
|
| 197 | 188 | { |
| 198 | 189 | $this->_helper->json(array('status'=>'No trap')); |
| 199 | 190 | return; |
@@ -202,8 +193,7 @@ discard block |
||
| 202 | 193 | { |
| 203 | 194 | $objectlist=$this->getMIB()->getObjectList($trap); |
| 204 | 195 | $retObjects=array('status'=>'OK','objects' => $objectlist); |
| 205 | - } |
|
| 206 | - catch (Exception $e) |
|
| 196 | + } catch (Exception $e) |
|
| 207 | 197 | { |
| 208 | 198 | $retObjects=array('status' => 'not found'); |
| 209 | 199 | } |
@@ -218,8 +208,7 @@ discard block |
||
| 218 | 208 | try |
| 219 | 209 | { |
| 220 | 210 | $miblist=$this->getMIB()->getMIBList(); |
| 221 | - } |
|
| 222 | - catch (Exception $e) |
|
| 211 | + } catch (Exception $e) |
|
| 223 | 212 | { |
| 224 | 213 | $miblist=array('Error getting mibs'); |
| 225 | 214 | } |
@@ -237,8 +226,7 @@ discard block |
||
| 237 | 226 | if (isset($postData['oid'])) |
| 238 | 227 | { |
| 239 | 228 | $oid=$postData['oid']; |
| 240 | - } |
|
| 241 | - else |
|
| 229 | + } else |
|
| 242 | 230 | { |
| 243 | 231 | $this->_helper->json(array('status'=>'No oid')); |
| 244 | 232 | return; |
@@ -249,8 +237,7 @@ discard block |
||
| 249 | 237 | { |
| 250 | 238 | $this->_helper->json(array('status'=>'Not found')); |
| 251 | 239 | return; |
| 252 | - } |
|
| 253 | - else |
|
| 240 | + } else |
|
| 254 | 241 | { |
| 255 | 242 | $this->_helper->json( |
| 256 | 243 | array('status'=>'OK', |
@@ -283,8 +270,7 @@ discard block |
||
| 283 | 270 | $this->_helper->json(array('status'=>'invalid days : '.$days)); |
| 284 | 271 | return; |
| 285 | 272 | } |
| 286 | - } |
|
| 287 | - else |
|
| 273 | + } else |
|
| 288 | 274 | { |
| 289 | 275 | $this->_helper->json(array('status'=>'No days')); |
| 290 | 276 | return; |
@@ -297,8 +283,7 @@ discard block |
||
| 297 | 283 | $this->_helper->json(array('status'=>'unknown action '.$action)); |
| 298 | 284 | return; |
| 299 | 285 | } |
| 300 | - } |
|
| 301 | - else |
|
| 286 | + } else |
|
| 302 | 287 | { |
| 303 | 288 | $this->_helper->json(array('status'=>'No action')); |
| 304 | 289 | return; |
@@ -308,8 +293,7 @@ discard block |
||
| 308 | 293 | try |
| 309 | 294 | { |
| 310 | 295 | $this->setDBConfigValue('db_remove_days',$days); |
| 311 | - } |
|
| 312 | - catch (Exception $e) |
|
| 296 | + } catch (Exception $e) |
|
| 313 | 297 | { |
| 314 | 298 | $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
| 315 | 299 | return; |
@@ -327,8 +311,7 @@ discard block |
||
| 327 | 311 | $Trap = new Trap($icingaweb2_etc); |
| 328 | 312 | $Trap->setLogging($debug_level,'syslog'); |
| 329 | 313 | $Trap->eraseOldTraps($days); |
| 330 | - } |
|
| 331 | - catch (Exception $e) |
|
| 314 | + } catch (Exception $e) |
|
| 332 | 315 | { |
| 333 | 316 | $this->_helper->json(array('status'=>'execute error : '.$e->getMessage() )); |
| 334 | 317 | return; |
@@ -356,8 +339,7 @@ discard block |
||
| 356 | 339 | $this->_helper->json(array('status'=>'invalid destination : '.$destination)); |
| 357 | 340 | return; |
| 358 | 341 | } |
| 359 | - } |
|
| 360 | - else |
|
| 342 | + } else |
|
| 361 | 343 | { |
| 362 | 344 | $this->_helper->json(array('status'=>'No destination')); |
| 363 | 345 | } |
@@ -370,14 +352,12 @@ discard block |
||
| 370 | 352 | $this->_helper->json(array('status'=>'File not writable : '.$file)); |
| 371 | 353 | return; |
| 372 | 354 | } |
| 373 | - } |
|
| 374 | - else |
|
| 355 | + } else |
|
| 375 | 356 | { |
| 376 | 357 | if ($destination != 'file') |
| 377 | 358 | { |
| 378 | 359 | $file=null; |
| 379 | - } |
|
| 380 | - else |
|
| 360 | + } else |
|
| 381 | 361 | { |
| 382 | 362 | $this->_helper->json(array('status'=>'No file')); |
| 383 | 363 | return; |
@@ -387,8 +367,7 @@ discard block |
||
| 387 | 367 | if (isset($postData['level'])) |
| 388 | 368 | { |
| 389 | 369 | $level=$postData['level']; |
| 390 | - } |
|
| 391 | - else |
|
| 370 | + } else |
|
| 392 | 371 | { |
| 393 | 372 | $this->_helper->json(array('status'=>'No level')); |
| 394 | 373 | return; |
@@ -399,8 +378,7 @@ discard block |
||
| 399 | 378 | $this->setDBConfigValue('log_destination',$destination); |
| 400 | 379 | $this->setDBConfigValue('log_file',$file); |
| 401 | 380 | $this->setDBConfigValue('log_level',$level); |
| 402 | - } |
|
| 403 | - catch (Exception $e) |
|
| 381 | + } catch (Exception $e) |
|
| 404 | 382 | { |
| 405 | 383 | $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
| 406 | 384 | return; |
@@ -422,8 +400,7 @@ discard block |
||
| 422 | 400 | if (isset($postData['rule'])) |
| 423 | 401 | { |
| 424 | 402 | $rule=$postData['rule']; |
| 425 | - } |
|
| 426 | - else |
|
| 403 | + } else |
|
| 427 | 404 | { |
| 428 | 405 | $this->_helper->json(array('status'=>'No Rule')); |
| 429 | 406 | } |
@@ -435,8 +412,7 @@ discard block |
||
| 435 | 412 | $this->_helper->json(array('status'=>'unknown action '.$action)); |
| 436 | 413 | return; |
| 437 | 414 | } |
| 438 | - } |
|
| 439 | - else |
|
| 415 | + } else |
|
| 440 | 416 | { |
| 441 | 417 | $this->_helper->json(array('status'=>'No action')); |
| 442 | 418 | return; |
@@ -453,8 +429,7 @@ discard block |
||
| 453 | 429 | // Eval |
| 454 | 430 | $item=0; |
| 455 | 431 | $rule=$Trap->evaluation($rule,$item); |
| 456 | - } |
|
| 457 | - catch (Exception $e) |
|
| 432 | + } catch (Exception $e) |
|
| 458 | 433 | { |
| 459 | 434 | $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
| 460 | 435 | return; |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** Mib management |
| 68 | - * Post param : action=update_mib_db : update mib database |
|
| 69 | - * Post param : ation=check_update : check if mib update is finished |
|
| 70 | - * File post : mibfile -> save mib file |
|
| 71 | - */ |
|
| 68 | + * Post param : action=update_mib_db : update mib database |
|
| 69 | + * Post param : ation=check_update : check if mib update is finished |
|
| 70 | + * File post : mibfile -> save mib file |
|
| 71 | + */ |
|
| 72 | 72 | public function mibAction() |
| 73 | 73 | { |
| 74 | 74 | $this->prepareTabs()->activate('mib'); |
@@ -87,22 +87,22 @@ discard block |
||
| 87 | 87 | $return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid'); |
| 88 | 88 | if (preg_match('/OK/',$return)) |
| 89 | 89 | { |
| 90 | - $this->_helper->json(array('status'=>'OK')); |
|
| 90 | + $this->_helper->json(array('status'=>'OK')); |
|
| 91 | 91 | } |
| 92 | 92 | // Error |
| 93 | 93 | $this->_helper->json(array('status'=>$return)); |
| 94 | 94 | } |
| 95 | 95 | if ($action == 'check_update') |
| 96 | 96 | { |
| 97 | - $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 98 | - if ($file == false) |
|
| 99 | - { // process is dead |
|
| 100 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 101 | - return; |
|
| 102 | - } |
|
| 103 | - $pid=fgets($file); |
|
| 104 | - $output=array(); |
|
| 105 | - $retVal=0; |
|
| 97 | + $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 98 | + if ($file == false) |
|
| 99 | + { // process is dead |
|
| 100 | + $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | + $pid=fgets($file); |
|
| 104 | + $output=array(); |
|
| 105 | + $retVal=0; |
|
| 106 | 106 | exec('ps '.$pid,$output,$retVal); |
| 107 | 107 | if ($retVal == 0) |
| 108 | 108 | { // process is alive |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | else |
| 112 | 112 | { // process is dead |
| 113 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 113 | + $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' )); |
@@ -259,20 +259,20 @@ discard block |
||
| 259 | 259 | // TODO : see if useless |
| 260 | 260 | class UploadForm extends Form |
| 261 | 261 | { |
| 262 | - public function __construct($options = null) |
|
| 263 | - { |
|
| 264 | - parent::__construct($options); |
|
| 265 | - $this->addElements2(); |
|
| 266 | - } |
|
| 262 | + public function __construct($options = null) |
|
| 263 | + { |
|
| 264 | + parent::__construct($options); |
|
| 265 | + $this->addElements2(); |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - public function addElements2() |
|
| 269 | - { |
|
| 270 | - // File Input |
|
| 271 | - $file = new File('mib-file'); |
|
| 272 | - $file->setLabel('Mib upload'); |
|
| 273 | - //->setAttrib('multiple', null); |
|
| 274 | - $this->addElement($file); |
|
| 268 | + public function addElements2() |
|
| 269 | + { |
|
| 270 | + // File Input |
|
| 271 | + $file = new File('mib-file'); |
|
| 272 | + $file->setLabel('Mib upload'); |
|
| 273 | + //->setAttrib('multiple', null); |
|
| 274 | + $this->addElement($file); |
|
| 275 | 275 | $button = new Submit("upload",array('ignore'=>false)); |
| 276 | 276 | $this->addElement($button);//->setIgnore(false); |
| 277 | - } |
|
| 277 | + } |
|
| 278 | 278 | } |
@@ -22,18 +22,18 @@ discard block |
||
| 22 | 22 | /************ Trapdb ***********/ |
| 23 | 23 | try |
| 24 | 24 | { |
| 25 | - $db = $this->getDb()->getConnection(); |
|
| 26 | - $query = $db->select()->from( |
|
| 25 | + $db=$this->getDb()->getConnection(); |
|
| 26 | + $query=$db->select()->from( |
|
| 27 | 27 | $this->getModuleConfig()->getTrapTableName(), |
| 28 | 28 | array('COUNT(*)') |
| 29 | 29 | ); |
| 30 | 30 | $this->view->trap_count=$db->fetchOne($query); |
| 31 | - $query = $db->select()->from( |
|
| 31 | + $query=$db->select()->from( |
|
| 32 | 32 | $this->getModuleConfig()->getTrapDataTableName(), |
| 33 | 33 | array('COUNT(*)') |
| 34 | 34 | ); |
| 35 | 35 | $this->view->trap_object_count=$db->fetchOne($query); |
| 36 | - $query = $db->select()->from( |
|
| 36 | + $query=$db->select()->from( |
|
| 37 | 37 | $this->getModuleConfig()->getTrapRuleName(), |
| 38 | 38 | array('COUNT(*)') |
| 39 | 39 | ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | catch (Exception $e) |
| 46 | 46 | { |
| 47 | - $this->displayExitError('status',$e->getMessage()); |
|
| 47 | + $this->displayExitError('status', $e->getMessage()); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /*************** Log destination *******************/ |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | catch (Exception $e) |
| 61 | 61 | { |
| 62 | - $this->displayExitError('status',$e->getMessage()); |
|
| 62 | + $this->displayExitError('status', $e->getMessage()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | if ($action == 'update_mib_db') |
| 86 | 86 | { // Do the update in background |
| 87 | 87 | $return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid'); |
| 88 | - if (preg_match('/OK/',$return)) |
|
| 88 | + if (preg_match('/OK/', $return)) |
|
| 89 | 89 | { |
| 90 | 90 | $this->_helper->json(array('status'=>'OK')); |
| 91 | 91 | } |
@@ -94,34 +94,34 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | if ($action == 'check_update') |
| 96 | 96 | { |
| 97 | - $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 97 | + $file=@fopen('/tmp/trapdirector_update.pid', 'r'); |
|
| 98 | 98 | if ($file == false) |
| 99 | 99 | { // process is dead |
| 100 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 100 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'Cannot open file')); |
|
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | $pid=fgets($file); |
| 104 | 104 | $output=array(); |
| 105 | 105 | $retVal=0; |
| 106 | - exec('ps '.$pid,$output,$retVal); |
|
| 106 | + exec('ps '.$pid, $output, $retVal); |
|
| 107 | 107 | if ($retVal == 0) |
| 108 | 108 | { // process is alive |
| 109 | 109 | $this->_helper->json(array('status'=>'Alive and kicking')); |
| 110 | 110 | } |
| 111 | 111 | else |
| 112 | 112 | { // process is dead |
| 113 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 113 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'no proc'.$pid)); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' )); |
|
| 116 | + $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible')); |
|
| 117 | 117 | } |
| 118 | 118 | /** Check for mib file UPLOAD */ |
| 119 | 119 | if (isset($_FILES['mibfile'])) |
| 120 | 120 | { |
| 121 | 121 | $name=$_FILES['mibfile']['name']; |
| 122 | - $DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 123 | - $destination = array_shift($DirConf) .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 124 | - if (move_uploaded_file($_FILES['mibfile']['tmp_name'],$destination)===false) |
|
| 122 | + $DirConf=explode(':', $this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 123 | + $destination=array_shift($DirConf).'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 124 | + if (move_uploaded_file($_FILES['mibfile']['tmp_name'], $destination) === false) |
|
| 125 | 125 | { |
| 126 | 126 | $this->view->uploadStatus='ERROR, file not loaded. Check mibs directory permission'; |
| 127 | 127 | } |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // snmptranslate tests |
| 137 | - $snmptranslate = $this->Config()->get('config', 'snmptranslate'); |
|
| 137 | + $snmptranslate=$this->Config()->get('config', 'snmptranslate'); |
|
| 138 | 138 | $this->view->snmptranslate_bin=$snmptranslate; |
| 139 | 139 | $this->view->snmptranslate_state='warn'; |
| 140 | - if (is_executable ( $snmptranslate )) |
|
| 140 | + if (is_executable($snmptranslate)) |
|
| 141 | 141 | { |
| 142 | - $translate=exec($snmptranslate . ' 1'); |
|
| 143 | - if (preg_match('/iso/',$translate)) |
|
| 142 | + $translate=exec($snmptranslate.' 1'); |
|
| 143 | + if (preg_match('/iso/', $translate)) |
|
| 144 | 144 | { |
| 145 | 145 | $this->view->snmptranslate='works fine'; |
| 146 | 146 | $this->view->snmptranslate_state='ok'; |
@@ -158,46 +158,46 @@ discard block |
||
| 158 | 158 | // mib database |
| 159 | 159 | |
| 160 | 160 | $this->view->mibDbCount=$this->getMIB()->countObjects(); |
| 161 | - $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null,21); |
|
| 161 | + $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null, 21); |
|
| 162 | 162 | |
| 163 | 163 | // mib dirs |
| 164 | 164 | $DirConf=$this->Config()->get('config', 'snmptranslate_dirs'); |
| 165 | - $dirArray=explode(':',$DirConf); |
|
| 165 | + $dirArray=explode(':', $DirConf); |
|
| 166 | 166 | |
| 167 | 167 | // Get base directories from net-snmp-config |
| 168 | 168 | $output=$matches=array(); |
| 169 | 169 | $retVal=0; |
| 170 | - $sysDirs=exec('net-snmp-config --default-mibdirs',$output,$retVal); |
|
| 171 | - if ($retVal==0) |
|
| 170 | + $sysDirs=exec('net-snmp-config --default-mibdirs', $output, $retVal); |
|
| 171 | + if ($retVal == 0) |
|
| 172 | 172 | { |
| 173 | - $dirArray=array_merge($dirArray,explode(':',$sysDirs)); |
|
| 173 | + $dirArray=array_merge($dirArray, explode(':', $sysDirs)); |
|
| 174 | 174 | } |
| 175 | 175 | else |
| 176 | 176 | { |
| 177 | - $translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 178 | - if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches)) |
|
| 177 | + $translateOut=exec($this->Config()->get('config', 'snmptranslate').' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 178 | + if (preg_match('/MIBDIRS.*\'([^\']+)\'/', $translateOut, $matches)) |
|
| 179 | 179 | { |
| 180 | - $dirArray=array_merge($dirArray,explode(':',$matches[1])); |
|
| 180 | + $dirArray=array_merge($dirArray, explode(':', $matches[1])); |
|
| 181 | 181 | } |
| 182 | 182 | else |
| 183 | 183 | { |
| 184 | - array_push($dirArray,'Install net-snmp-config to see system directories'); |
|
| 184 | + array_push($dirArray, 'Install net-snmp-config to see system directories'); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $this->view->dirArray=$dirArray; |
| 189 | 189 | |
| 190 | 190 | $output=null; |
| 191 | - foreach (explode(':',$DirConf) as $mibdir) |
|
| 191 | + foreach (explode(':', $DirConf) as $mibdir) |
|
| 192 | 192 | { |
| 193 | - exec('ls '.$mibdir.' | grep -v traplist.txt',$output); |
|
| 193 | + exec('ls '.$mibdir.' | grep -v traplist.txt', $output); |
|
| 194 | 194 | } |
| 195 | 195 | //$i=0;$listFiles='';while (isset($output[$i])) $listFiles.=$output[$i++]; |
| 196 | 196 | //$this->view->fileList=explode(' ',$listFiles); |
| 197 | 197 | $this->view->fileList=$output; |
| 198 | 198 | |
| 199 | 199 | // Zend form |
| 200 | - $this->view->form= new UploadForm(); |
|
| 200 | + $this->view->form=new UploadForm(); |
|
| 201 | 201 | //$this->view->form= new Form('upload-form'); |
| 202 | 202 | |
| 203 | 203 | |
@@ -221,18 +221,18 @@ discard block |
||
| 221 | 221 | $this->view->templateForm_output=''; |
| 222 | 222 | if (isset($postData['template_name']) && isset($postData['template_revert_time'])) |
| 223 | 223 | { |
| 224 | - $template_create = 'icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 225 | - $template_create .= '"check_interval": "' .$postData['template_revert_time']. '", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", '; |
|
| 226 | - $template_create .= '"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 224 | + $template_create='icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 225 | + $template_create.='"check_interval": "'.$postData['template_revert_time'].'", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", '; |
|
| 226 | + $template_create.='"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 227 | 227 | $output=array(); |
| 228 | 228 | $ret_code=0; |
| 229 | - exec($template_create,$output,$ret_code); |
|
| 229 | + exec($template_create, $output, $ret_code); |
|
| 230 | 230 | if ($ret_code != 0) |
| 231 | 231 | { |
| 232 | - $this->displayExitError("Status -> Services","Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 232 | + $this->displayExitError("Status -> Services", "Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 233 | 233 | } |
| 234 | - exec('icingacli director config deploy',$output,$ret_code); |
|
| 235 | - $this->view->templateForm_output='Template '.$postData['template_name']. ' created'; |
|
| 234 | + exec('icingacli director config deploy', $output, $ret_code); |
|
| 235 | + $this->view->templateForm_output='Template '.$postData['template_name'].' created'; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // template creation form |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | return $this->getTabs()->add('status', array( |
| 247 | 247 | 'label' => $this->translate('Status'), |
| 248 | - 'url' => $this->getModuleConfig()->urlPath() . '/status') |
|
| 248 | + 'url' => $this->getModuleConfig()->urlPath().'/status') |
|
| 249 | 249 | )->add('mib', array( |
| 250 | 250 | 'label' => $this->translate('MIB Management'), |
| 251 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/mib') |
|
| 251 | + 'url' => $this->getModuleConfig()->urlPath().'/status/mib') |
|
| 252 | 252 | )->add('services', array( |
| 253 | 253 | 'label' => $this->translate('Services management'), |
| 254 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/services') |
|
| 254 | + 'url' => $this->getModuleConfig()->urlPath().'/status/services') |
|
| 255 | 255 | ); |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | // TODO : see if useless |
| 260 | 260 | class UploadForm extends Form |
| 261 | 261 | { |
| 262 | - public function __construct($options = null) |
|
| 262 | + public function __construct($options=null) |
|
| 263 | 263 | { |
| 264 | 264 | parent::__construct($options); |
| 265 | 265 | $this->addElements2(); |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | public function addElements2() |
| 269 | 269 | { |
| 270 | 270 | // File Input |
| 271 | - $file = new File('mib-file'); |
|
| 271 | + $file=new File('mib-file'); |
|
| 272 | 272 | $file->setLabel('Mib upload'); |
| 273 | 273 | //->setAttrib('multiple', null); |
| 274 | 274 | $this->addElement($file); |
| 275 | - $button = new Submit("upload",array('ignore'=>false)); |
|
| 276 | - $this->addElement($button);//->setIgnore(false); |
|
| 275 | + $button=new Submit("upload", array('ignore'=>false)); |
|
| 276 | + $this->addElement($button); //->setIgnore(false); |
|
| 277 | 277 | } |
| 278 | 278 | } |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $this->view->trap_days_delete=$this->getDBConfigValue('db_remove_days'); |
| 43 | 43 | |
| 44 | - } |
|
| 45 | - catch (Exception $e) |
|
| 44 | + } catch (Exception $e) |
|
| 46 | 45 | { |
| 47 | 46 | $this->displayExitError('status',$e->getMessage()); |
| 48 | 47 | } |
@@ -56,8 +55,7 @@ discard block |
||
| 56 | 55 | $this->view->currentLogFile=$this->getDBConfigValue('log_file'); |
| 57 | 56 | $this->view->logLevels=$this->getModuleConfig()->getlogLevels(); |
| 58 | 57 | $this->view->currentLogLevel=$this->getDBConfigValue('log_level'); |
| 59 | - } |
|
| 60 | - catch (Exception $e) |
|
| 58 | + } catch (Exception $e) |
|
| 61 | 59 | { |
| 62 | 60 | $this->displayExitError('status',$e->getMessage()); |
| 63 | 61 | } |
@@ -107,8 +105,7 @@ discard block |
||
| 107 | 105 | if ($retVal == 0) |
| 108 | 106 | { // process is alive |
| 109 | 107 | $this->_helper->json(array('status'=>'Alive and kicking')); |
| 110 | - } |
|
| 111 | - else |
|
| 108 | + } else |
|
| 112 | 109 | { // process is dead |
| 113 | 110 | $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
| 114 | 111 | } |
@@ -124,8 +121,7 @@ discard block |
||
| 124 | 121 | if (move_uploaded_file($_FILES['mibfile']['tmp_name'],$destination)===false) |
| 125 | 122 | { |
| 126 | 123 | $this->view->uploadStatus='ERROR, file not loaded. Check mibs directory permission'; |
| 127 | - } |
|
| 128 | - else |
|
| 124 | + } else |
|
| 129 | 125 | { |
| 130 | 126 | $this->view->uploadStatus="File $name uploaded"; |
| 131 | 127 | } |
@@ -144,13 +140,11 @@ discard block |
||
| 144 | 140 | { |
| 145 | 141 | $this->view->snmptranslate='works fine'; |
| 146 | 142 | $this->view->snmptranslate_state='ok'; |
| 147 | - } |
|
| 148 | - else |
|
| 143 | + } else |
|
| 149 | 144 | { |
| 150 | 145 | $this->view->snmptranslate='can execute but no resolution'; |
| 151 | 146 | } |
| 152 | - } |
|
| 153 | - else |
|
| 147 | + } else |
|
| 154 | 148 | { |
| 155 | 149 | $this->view->snmptranslate='cannot execute'; |
| 156 | 150 | } |
@@ -171,15 +165,13 @@ discard block |
||
| 171 | 165 | if ($retVal==0) |
| 172 | 166 | { |
| 173 | 167 | $dirArray=array_merge($dirArray,explode(':',$sysDirs)); |
| 174 | - } |
|
| 175 | - else |
|
| 168 | + } else |
|
| 176 | 169 | { |
| 177 | 170 | $translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
| 178 | 171 | if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches)) |
| 179 | 172 | { |
| 180 | 173 | $dirArray=array_merge($dirArray,explode(':',$matches[1])); |
| 181 | - } |
|
| 182 | - else |
|
| 174 | + } else |
|
| 183 | 175 | { |
| 184 | 176 | array_push($dirArray,'Install net-snmp-config to see system directories'); |
| 185 | 177 | } |