@@ -36,39 +36,39 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function updateAction() |
| 38 | 38 | { |
| 39 | - $background = $this->params->get('pid', null); |
|
| 40 | - $logLevel= $this->params->has('verb') ? 4 : 2; |
|
| 41 | - if ($this->params->has('force-check')) { echo "Not implemented"; return;} |
|
| 42 | - $forceCheck=$this->params->has('force-check')?True:False; |
|
| 39 | + $background=$this->params->get('pid', null); |
|
| 40 | + $logLevel=$this->params->has('verb') ? 4 : 2; |
|
| 41 | + if ($this->params->has('force-check')) { echo "Not implemented"; return; } |
|
| 42 | + $forceCheck=$this->params->has('force-check') ?True:False; |
|
| 43 | 43 | $pid=1; |
| 44 | 44 | if ($background != null) |
| 45 | 45 | { |
| 46 | - $file=@fopen($background,'w'); |
|
| 46 | + $file=@fopen($background, 'w'); |
|
| 47 | 47 | if ($file == false) |
| 48 | 48 | { |
| 49 | 49 | echo 'Error : cannot open pid file '.$background; |
| 50 | 50 | return 1; |
| 51 | 51 | } |
| 52 | - $pid = pcntl_fork(); |
|
| 52 | + $pid=pcntl_fork(); |
|
| 53 | 53 | if ($pid == -1) { |
| 54 | 54 | echo 'Error : Cannot fork process'; |
| 55 | 55 | return 1; |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
| 59 | - require_once($module->getBaseDir() .'/bin/trap_class.php'); |
|
| 59 | + require_once($module->getBaseDir().'/bin/trap_class.php'); |
|
| 60 | 60 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 61 | - $trap = new Trap($icingaweb2_etc); |
|
| 61 | + $trap=new Trap($icingaweb2_etc); |
|
| 62 | 62 | if ($pid == 1) |
| 63 | 63 | { |
| 64 | - $trap->setLogging($logLevel,'display'); |
|
| 64 | + $trap->setLogging($logLevel, 'display'); |
|
| 65 | 65 | } |
| 66 | 66 | else |
| 67 | 67 | { // use default display TODO : if default is 'display' son process will be killed at first output.... |
| 68 | 68 | if ($pid != 0) |
| 69 | 69 | { |
| 70 | 70 | // father process |
| 71 | - fwrite($file,$pid); |
|
| 71 | + fwrite($file, $pid); |
|
| 72 | 72 | fclose($file); |
| 73 | 73 | echo "OK : process $pid in bckground"; |
| 74 | 74 | return 0; |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | fclose(STDERR); |
| 83 | 83 | try |
| 84 | 84 | { |
| 85 | - $trap->update_mib_database(false,$forceCheck); |
|
| 85 | + $trap->update_mib_database(false, $forceCheck); |
|
| 86 | 86 | } |
| 87 | 87 | catch (Exception $e) |
| 88 | 88 | { |
| 89 | - $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
|
| 89 | + $trap->trapLog('Error in updating : '.$e->getMessage(), 2); |
|
| 90 | 90 | } |
| 91 | 91 | unlink($background); |
| 92 | 92 | return 0; |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | echo "Update main mib database : \n"; |
| 100 | 100 | echo "# (trap found) C (trap already processed) . (every 2 seconds) : \n"; |
| 101 | - $trap->update_mib_database(true,$forceCheck); |
|
| 101 | + $trap->update_mib_database(true, $forceCheck); |
|
| 102 | 102 | echo "Done\n"; |
| 103 | 103 | |
| 104 | 104 | } |
| 105 | 105 | catch (Exception $e) |
| 106 | 106 | { |
| 107 | - echo 'Error in updating : ' . $e->getMessage(); |
|
| 107 | + echo 'Error in updating : '.$e->getMessage(); |
|
| 108 | 108 | } |
| 109 | 109 | if ($pid != 1) |
| 110 | 110 | { |
@@ -128,26 +128,26 @@ discard block |
||
| 128 | 128 | echo "Not implemented"; |
| 129 | 129 | // TODO : implement |
| 130 | 130 | return; |
| 131 | - $Config = new TrapModuleConfig($db_prefix); |
|
| 131 | + $Config=new TrapModuleConfig($db_prefix); |
|
| 132 | 132 | |
| 133 | 133 | try |
| 134 | 134 | { |
| 135 | 135 | |
| 136 | 136 | $dbresource=$this->Config()->get('config', 'database'); |
| 137 | 137 | echo "DB name : $dbresource\n"; |
| 138 | - $db = IcingaDbConnection::fromResourceName($dbresource)->getConnection(); |
|
| 138 | + $db=IcingaDbConnection::fromResourceName($dbresource)->getConnection(); |
|
| 139 | 139 | |
| 140 | - $query = $db->select()->from($Config->getTrapTableName(),array('COUNT(*)')); |
|
| 141 | - echo "Number of traps : " . $db->fetchOne($query) ."\n"; |
|
| 142 | - $query = $db->select()->from($Config->getTrapDataTableName(),array('COUNT(*)')); |
|
| 143 | - echo "Number of trap objects : " . $db->fetchOne($query) ."\n"; |
|
| 144 | - $query = $db->select()->from($Config->getTrapRuleName(),array('COUNT(*)')); |
|
| 145 | - echo "Number of rules : " . $db->fetchOne($query) ."\n"; |
|
| 140 | + $query=$db->select()->from($Config->getTrapTableName(), array('COUNT(*)')); |
|
| 141 | + echo "Number of traps : ".$db->fetchOne($query)."\n"; |
|
| 142 | + $query=$db->select()->from($Config->getTrapDataTableName(), array('COUNT(*)')); |
|
| 143 | + echo "Number of trap objects : ".$db->fetchOne($query)."\n"; |
|
| 144 | + $query=$db->select()->from($Config->getTrapRuleName(), array('COUNT(*)')); |
|
| 145 | + echo "Number of rules : ".$db->fetchOne($query)."\n"; |
|
| 146 | 146 | |
| 147 | 147 | } |
| 148 | 148 | catch (Exception $e) |
| 149 | 149 | { |
| 150 | - echo 'Error in DB : ' . $e->getMessage(); |
|
| 150 | + echo 'Error in DB : '.$e->getMessage(); |
|
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |