@@ -6,8 +6,8 @@ |
||
6 | 6 | $this->providePermission('trapdirector/config', $this->translate('Allow to create and modify traps services')); |
7 | 7 | |
8 | 8 | $this->provideConfigTab('config', array( |
9 | - 'title' => 'Configuration', |
|
10 | - 'url' => 'settings' |
|
9 | + 'title' => 'Configuration', |
|
10 | + 'url' => 'settings' |
|
11 | 11 | )); |
12 | 12 | |
13 | 13 | $section = $this->menuSection(N_('Traps'),array ( |
@@ -17,10 +17,10 @@ |
||
17 | 17 | class StatusCommand extends Command |
18 | 18 | { |
19 | 19 | /** |
20 | - * Get database counts |
|
21 | - * |
|
22 | - * Get number of traps, rules |
|
23 | - */ |
|
20 | + * Get database counts |
|
21 | + * |
|
22 | + * Get number of traps, rules |
|
23 | + */ |
|
24 | 24 | public function dbAction() |
25 | 25 | { |
26 | 26 | $db_prefix=$this->Config()->get('config', 'database_prefix'); |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | class TrapsCommand extends Command |
18 | 18 | { |
19 | 19 | /** |
20 | - * Delete old traps |
|
21 | - * |
|
22 | - * USAGE |
|
23 | - * |
|
24 | - * icingali trapdirector traps rotate [options] |
|
25 | - * |
|
26 | - * OPTIONS |
|
27 | - * |
|
28 | - * --days remove traps older than <n> days |
|
29 | - */ |
|
20 | + * Delete old traps |
|
21 | + * |
|
22 | + * USAGE |
|
23 | + * |
|
24 | + * icingali trapdirector traps rotate [options] |
|
25 | + * |
|
26 | + * OPTIONS |
|
27 | + * |
|
28 | + * --days remove traps older than <n> days |
|
29 | + */ |
|
30 | 30 | public function rotateAction() |
31 | 31 | { |
32 | 32 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
59 | - * Reset services to OK state if timeout is passed |
|
60 | - * |
|
61 | - * USAGE |
|
62 | - * |
|
63 | - * icingali trapdirector traps reset_services |
|
64 | - * |
|
65 | - */ |
|
59 | + * Reset services to OK state if timeout is passed |
|
60 | + * |
|
61 | + * USAGE |
|
62 | + * |
|
63 | + * icingali trapdirector traps reset_services |
|
64 | + * |
|
65 | + */ |
|
66 | 66 | public function resetOKAction() |
67 | 67 | { |
68 | 68 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
@@ -20,77 +20,77 @@ discard block |
||
20 | 20 | class MibCommand extends Command |
21 | 21 | { |
22 | 22 | /** |
23 | - * Update mib database |
|
24 | - * |
|
25 | - * USAGE |
|
26 | - * |
|
27 | - * icingli trapdirector mib update |
|
28 | - * |
|
29 | - * OPTIONS |
|
30 | - * |
|
31 | - * --pid <file> : run in background with pid in <file> |
|
32 | - * |
|
33 | - * --verb : Set output log to verbose |
|
34 | - * |
|
35 | - * --force-check : force check of all traps & objects for change. (NOT IMPLEMENTED) |
|
36 | - */ |
|
23 | + * Update mib database |
|
24 | + * |
|
25 | + * USAGE |
|
26 | + * |
|
27 | + * icingli trapdirector mib update |
|
28 | + * |
|
29 | + * OPTIONS |
|
30 | + * |
|
31 | + * --pid <file> : run in background with pid in <file> |
|
32 | + * |
|
33 | + * --verb : Set output log to verbose |
|
34 | + * |
|
35 | + * --force-check : force check of all traps & objects for change. (NOT IMPLEMENTED) |
|
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; |
|
43 | - $pid=1; |
|
44 | - if ($background != null) |
|
45 | - { |
|
46 | - $file=@fopen($background,'w'); |
|
47 | - if ($file == false) |
|
48 | - { |
|
49 | - echo 'Error : cannot open pid file '.$background; |
|
50 | - return 1; |
|
51 | - } |
|
52 | - $pid = pcntl_fork(); |
|
53 | - if ($pid == -1) { |
|
54 | - echo 'Error : Cannot fork process'; |
|
55 | - return 1; |
|
56 | - } |
|
57 | - } |
|
58 | - $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
|
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 | + $pid=1; |
|
44 | + if ($background != null) |
|
45 | + { |
|
46 | + $file=@fopen($background,'w'); |
|
47 | + if ($file == false) |
|
48 | + { |
|
49 | + echo 'Error : cannot open pid file '.$background; |
|
50 | + return 1; |
|
51 | + } |
|
52 | + $pid = pcntl_fork(); |
|
53 | + if ($pid == -1) { |
|
54 | + echo 'Error : Cannot fork process'; |
|
55 | + return 1; |
|
56 | + } |
|
57 | + } |
|
58 | + $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
|
59 | 59 | require_once($module->getBaseDir() .'/bin/trap_class.php'); |
60 | 60 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
61 | 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 | - if ($pid != 0) |
|
69 | - { |
|
70 | - // father process |
|
71 | - fwrite($file,$pid); |
|
72 | - fclose($file); |
|
73 | - echo "OK : process $pid in bckground"; |
|
74 | - return 0; |
|
75 | - } |
|
76 | - else |
|
77 | - { // son process : close all file descriptors and go to a new session |
|
78 | - fclose($file); |
|
68 | + if ($pid != 0) |
|
69 | + { |
|
70 | + // father process |
|
71 | + fwrite($file,$pid); |
|
72 | + fclose($file); |
|
73 | + echo "OK : process $pid in bckground"; |
|
74 | + return 0; |
|
75 | + } |
|
76 | + else |
|
77 | + { // son process : close all file descriptors and go to a new session |
|
78 | + fclose($file); |
|
79 | 79 | // $sid = posix_setsid(); |
80 | - fclose(STDIN); |
|
81 | - fclose(STDOUT); |
|
82 | - fclose(STDERR); |
|
83 | - try |
|
84 | - { |
|
85 | - $trap->update_mib_database(false,$forceCheck); |
|
86 | - } |
|
87 | - catch (Exception $e) |
|
88 | - { |
|
89 | - $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
|
90 | - } |
|
91 | - unlink($background); |
|
92 | - exit(0); |
|
93 | - } |
|
80 | + fclose(STDIN); |
|
81 | + fclose(STDOUT); |
|
82 | + fclose(STDERR); |
|
83 | + try |
|
84 | + { |
|
85 | + $trap->update_mib_database(false,$forceCheck); |
|
86 | + } |
|
87 | + catch (Exception $e) |
|
88 | + { |
|
89 | + $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
|
90 | + } |
|
91 | + unlink($background); |
|
92 | + exit(0); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | } |
96 | 96 | |
@@ -108,20 +108,20 @@ discard block |
||
108 | 108 | } |
109 | 109 | if ($pid != 1) |
110 | 110 | { |
111 | - unlink($background); |
|
111 | + unlink($background); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | /** |
115 | - * purge all mib database NOT IMPLEMENTED |
|
116 | - * |
|
117 | - * USAGE |
|
118 | - * |
|
119 | - * icingli trapdirector mib purge --confirm yes |
|
120 | - * |
|
121 | - * OPTIONS |
|
122 | - * |
|
123 | - * --confirm yes : needed to execute purge |
|
124 | - */ |
|
115 | + * purge all mib database NOT IMPLEMENTED |
|
116 | + * |
|
117 | + * USAGE |
|
118 | + * |
|
119 | + * icingli trapdirector mib purge --confirm yes |
|
120 | + * |
|
121 | + * OPTIONS |
|
122 | + * |
|
123 | + * --confirm yes : needed to execute purge |
|
124 | + */ |
|
125 | 125 | public function purgeAction() |
126 | 126 | { |
127 | 127 | $db_prefix=$this->Config()->get('config', 'database_prefix'); |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | |
33 | 33 | public function setDefaultIDODB($idoDbName) |
34 | 34 | { |
35 | - $this->idoDbName=$idoDbName; |
|
36 | - return $this; |
|
35 | + $this->idoDbName=$idoDbName; |
|
36 | + return $this; |
|
37 | 37 | } |
38 | 38 | |
39 | - public function createElements(array $formData) |
|
40 | - { |
|
41 | - $this->addElement( |
|
39 | + public function createElements(array $formData) |
|
40 | + { |
|
41 | + $this->addElement( |
|
42 | 42 | 'select', |
43 | 43 | 'config_database', |
44 | 44 | array( |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | ) |
73 | 73 | ); |
74 | 74 | $this->addElement( |
75 | - 'text', |
|
76 | - 'config_icingaweb2_etc', |
|
77 | - array( |
|
78 | - 'required' => true, |
|
79 | - 'label' => $this->translate('icingaweb2 config dir'), |
|
75 | + 'text', |
|
76 | + 'config_icingaweb2_etc', |
|
77 | + array( |
|
78 | + 'required' => true, |
|
79 | + 'label' => $this->translate('icingaweb2 config dir'), |
|
80 | 80 | 'value' => $this->icinga_base_path, |
81 | - ) |
|
82 | - ); |
|
81 | + ) |
|
82 | + ); |
|
83 | 83 | $retval=0; |
84 | 84 | $output=array(); |
85 | 85 | $snmptranslate=exec('which snmptranslate',$output,$retval); |
@@ -88,68 +88,68 @@ discard block |
||
88 | 88 | $snmptranslate='/usr/bin/snmptranslate'; |
89 | 89 | } |
90 | 90 | $this->addElement( |
91 | - 'text', |
|
92 | - 'config_snmptranslate', |
|
93 | - array( |
|
94 | - 'required' => true, |
|
95 | - 'label' => $this->translate('snmptranslate binary with path'), |
|
91 | + 'text', |
|
92 | + 'config_snmptranslate', |
|
93 | + array( |
|
94 | + 'required' => true, |
|
95 | + 'label' => $this->translate('snmptranslate binary with path'), |
|
96 | 96 | 'value' => $snmptranslate, |
97 | - ) |
|
98 | - ); |
|
97 | + ) |
|
98 | + ); |
|
99 | 99 | $this->addElement( |
100 | - 'text', |
|
101 | - 'config_snmptranslate_dirs', |
|
102 | - array( |
|
103 | - 'required' => true, |
|
104 | - 'label' => $this->translate('Path for mibs'), |
|
100 | + 'text', |
|
101 | + 'config_snmptranslate_dirs', |
|
102 | + array( |
|
103 | + 'required' => true, |
|
104 | + 'label' => $this->translate('Path for mibs'), |
|
105 | 105 | 'value' => $this->module_base_path.'/mibs', |
106 | - ) |
|
107 | - ); |
|
106 | + ) |
|
107 | + ); |
|
108 | 108 | $this->addElement( |
109 | - 'text', |
|
110 | - 'config_icingacmd', |
|
111 | - array( |
|
112 | - 'required' => true, |
|
113 | - 'label' => $this->translate('icingacmd with path'), |
|
109 | + 'text', |
|
110 | + 'config_icingacmd', |
|
111 | + array( |
|
112 | + 'required' => true, |
|
113 | + 'label' => $this->translate('icingacmd with path'), |
|
114 | 114 | 'value' => '/var/run/icinga2/cmd/icinga2.cmd', |
115 | - ) |
|
116 | - ); |
|
115 | + ) |
|
116 | + ); |
|
117 | 117 | $this->addElement( |
118 | - 'text', |
|
119 | - 'config_icingaAPI_host', |
|
120 | - array( |
|
121 | - 'required' => false, |
|
122 | - 'label' => $this->translate('icinga2 API Host IP'), |
|
123 | - 'value' => '', |
|
124 | - ) |
|
118 | + 'text', |
|
119 | + 'config_icingaAPI_host', |
|
120 | + array( |
|
121 | + 'required' => false, |
|
122 | + 'label' => $this->translate('icinga2 API Host IP'), |
|
123 | + 'value' => '', |
|
124 | + ) |
|
125 | 125 | ); |
126 | 126 | $this->addElement( |
127 | - 'text', |
|
128 | - 'config_icingaAPI_port', |
|
129 | - array( |
|
130 | - 'required' => false, |
|
131 | - 'label' => $this->translate('icinga2 API TCP Port'), |
|
132 | - 'value' => '5665', |
|
133 | - ) |
|
134 | - ); |
|
127 | + 'text', |
|
128 | + 'config_icingaAPI_port', |
|
129 | + array( |
|
130 | + 'required' => false, |
|
131 | + 'label' => $this->translate('icinga2 API TCP Port'), |
|
132 | + 'value' => '5665', |
|
133 | + ) |
|
134 | + ); |
|
135 | 135 | $this->addElement( |
136 | - 'text', |
|
137 | - 'config_icingaAPI_user', |
|
138 | - array( |
|
139 | - 'required' => false, |
|
140 | - 'label' => $this->translate('icinga2 API username'), |
|
141 | - 'value' => '', |
|
142 | - ) |
|
143 | - ); |
|
136 | + 'text', |
|
137 | + 'config_icingaAPI_user', |
|
138 | + array( |
|
139 | + 'required' => false, |
|
140 | + 'label' => $this->translate('icinga2 API username'), |
|
141 | + 'value' => '', |
|
142 | + ) |
|
143 | + ); |
|
144 | 144 | $this->addElement( |
145 | - 'text', |
|
146 | - 'config_icingaAPI_password', |
|
147 | - array( |
|
148 | - 'required' => false, |
|
149 | - 'label' => $this->translate('icinga2 API password'), |
|
150 | - 'value' => '', |
|
151 | - ) |
|
152 | - ); |
|
145 | + 'text', |
|
146 | + 'config_icingaAPI_password', |
|
147 | + array( |
|
148 | + 'required' => false, |
|
149 | + 'label' => $this->translate('icinga2 API password'), |
|
150 | + 'value' => '', |
|
151 | + ) |
|
152 | + ); |
|
153 | 153 | /*$this->addElement( |
154 | 154 | 'radio', |
155 | 155 | 'config_icinga2api_use', |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'value' => array('Yes', 'No'),//array('1' => 'Yes', '0' => 'No'), |
160 | 160 | ) |
161 | 161 | );*/ |
162 | - // For Icinga2 API connexion |
|
162 | + // For Icinga2 API connexion |
|
163 | 163 | // $icinga2API=new Fieldset('Icinga2 API connection'); |
164 | 164 | /* $icinga2API_select=new radioBtn('icinga2API_use'); |
165 | 165 | $icinga2API_select->setLabel('Use icinga2 API instead of cmd file?'); |
@@ -169,30 +169,30 @@ discard block |
||
169 | 169 | ]); |
170 | 170 | $icinga2API->add($icinga2API_select); |
171 | 171 | $this->add($icinga2API); */ |
172 | - } |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | - public function render(Zend_View_Interface $view = NULL) |
|
176 | - { |
|
175 | + public function render(Zend_View_Interface $view = NULL) |
|
176 | + { |
|
177 | 177 | |
178 | 178 | |
179 | - //return $html; |
|
180 | - return parent::render($view); |
|
181 | - } |
|
179 | + //return $html; |
|
180 | + return parent::render($view); |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * {@inheritdoc} |
|
185 | - */ |
|
186 | - public function onSuccess() |
|
187 | - { |
|
188 | - parent::onSuccess(); |
|
189 | - } |
|
183 | + /** |
|
184 | + * {@inheritdoc} |
|
185 | + */ |
|
186 | + public function onSuccess() |
|
187 | + { |
|
188 | + parent::onSuccess(); |
|
189 | + } |
|
190 | 190 | |
191 | - /** |
|
192 | - * {@inheritdoc} |
|
193 | - */ |
|
191 | + /** |
|
192 | + * {@inheritdoc} |
|
193 | + */ |
|
194 | 194 | public function save() |
195 | - { |
|
195 | + { |
|
196 | 196 | parent::save(); |
197 | 197 | } |
198 | 198 | } |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * Trap detail page |
|
43 | - */ |
|
42 | + * Trap detail page |
|
43 | + */ |
|
44 | 44 | public function trapdetailAction() |
45 | 45 | { |
46 | 46 | |
@@ -141,22 +141,22 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function hostsAction() |
143 | 143 | { |
144 | - $this->checkReadPermission(); |
|
145 | - $this->prepareTabs()->activate('hosts'); |
|
144 | + $this->checkReadPermission(); |
|
145 | + $this->prepareTabs()->activate('hosts'); |
|
146 | 146 | |
147 | - $db = $this->getDb(); |
|
148 | - $this->getTrapHostListTable()->setConnection($db); |
|
147 | + $db = $this->getDb(); |
|
148 | + $this->getTrapHostListTable()->setConnection($db); |
|
149 | 149 | |
150 | - // Apply pagination limits |
|
151 | - $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
150 | + // Apply pagination limits |
|
151 | + $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
152 | 152 | |
153 | - // Set Filter |
|
154 | - //$postData=$this->getRequest()->getPost(); |
|
155 | - $filter=array(); |
|
156 | - $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; |
|
157 | - $filter['done']=$this->params->get('done'); |
|
158 | - $this->view->filter=$filter; |
|
159 | - $this->view->table->updateFilter(Url::fromRequest(),$filter); |
|
153 | + // Set Filter |
|
154 | + //$postData=$this->getRequest()->getPost(); |
|
155 | + $filter=array(); |
|
156 | + $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; |
|
157 | + $filter['done']=$this->params->get('done'); |
|
158 | + $this->view->filter=$filter; |
|
159 | + $this->view->table->updateFilter(Url::fromRequest(),$filter); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | public function deleteAction() |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | return $this->getTabs()->add('traps', array( |
177 | 177 | 'label' => $this->translate('Traps'), |
178 | 178 | 'url' => $this->getModuleConfig()->urlPath() . '/received') |
179 | - ) |
|
180 | - ->add('hosts', array( |
|
181 | - 'label' => $this->translate('Hosts'), |
|
182 | - 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts') |
|
183 | - ) |
|
184 | - ->add('delete', array( |
|
179 | + ) |
|
180 | + ->add('hosts', array( |
|
181 | + 'label' => $this->translate('Hosts'), |
|
182 | + 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts') |
|
183 | + ) |
|
184 | + ->add('delete', array( |
|
185 | 185 | 'label' => $this->translate('Delete'), |
186 | 186 | 'url' => $this->getModuleConfig()->urlPath() . '/received/delete') |
187 | 187 | ); |
@@ -22,37 +22,37 @@ discard block |
||
22 | 22 | public function indexAction() |
23 | 23 | { |
24 | 24 | |
25 | - // CHeck permissions : display tests in any case, but no configuration. |
|
25 | + // CHeck permissions : display tests in any case, but no configuration. |
|
26 | 26 | $this->view->configPermission=$this->checkModuleConfigPermission(1); |
27 | 27 | // But check read permission |
28 | 28 | $this->checkReadPermission(); |
29 | 29 | // Get message : sent on configuration problems detected by controllers |
30 | 30 | $dberrorMsg=$this->params->get('dberror'); |
31 | 31 | if ($dberrorMsg != '') |
32 | - $this->view->errorDetected=$dberrorMsg; |
|
33 | - $dberrorMsg=$this->params->get('idodberror'); |
|
34 | - if ($dberrorMsg != '') |
|
35 | - $this->view->errorDetected=$dberrorMsg; |
|
32 | + $this->view->errorDetected=$dberrorMsg; |
|
33 | + $dberrorMsg=$this->params->get('idodberror'); |
|
34 | + if ($dberrorMsg != '') |
|
35 | + $this->view->errorDetected=$dberrorMsg; |
|
36 | 36 | |
37 | - $this->view->configErrorDetected == NULL; // Displayed error on various conifugration errors. |
|
37 | + $this->view->configErrorDetected == NULL; // Displayed error on various conifugration errors. |
|
38 | 38 | |
39 | - // Test if configuration exists, if not create for installer script |
|
39 | + // Test if configuration exists, if not create for installer script |
|
40 | 40 | $emptyConfig=0; |
41 | - if ($this->Config()->isEmpty() == true) |
|
42 | - { |
|
43 | - $this->Config()->setSection('config'); // Set base config section. |
|
44 | - try |
|
45 | - { |
|
46 | - $this->Config()->saveIni(); |
|
47 | - $this->view->configErrorDetected='Configuration is empty : you can run install script with parameters (see Automatic installation below)'; |
|
41 | + if ($this->Config()->isEmpty() == true) |
|
42 | + { |
|
43 | + $this->Config()->setSection('config'); // Set base config section. |
|
44 | + try |
|
45 | + { |
|
46 | + $this->Config()->saveIni(); |
|
47 | + $this->view->configErrorDetected='Configuration is empty : you can run install script with parameters (see Automatic installation below)'; |
|
48 | 48 | $emptyConfig=1; |
49 | - } |
|
50 | - catch (Exception $e) |
|
51 | - { |
|
52 | - $this->view->configErrorDetected=$e->getMessage(); |
|
53 | - } |
|
49 | + } |
|
50 | + catch (Exception $e) |
|
51 | + { |
|
52 | + $this->view->configErrorDetected=$e->getMessage(); |
|
53 | + } |
|
54 | 54 | |
55 | - } |
|
55 | + } |
|
56 | 56 | // Test Database |
57 | 57 | $db_message=array( // index => ( message OK, message NOK, optional link if NOK ) |
58 | 58 | 0 => array('Database configuration OK','',''), |
@@ -97,20 +97,20 @@ discard block |
||
97 | 97 | //********* Test API |
98 | 98 | if ($this->Config()->get('config', 'icingaAPI_host') != '') |
99 | 99 | { |
100 | - $apitest=new Icinga2Api($this->Config()->get('config', 'icingaAPI_host'),$this->Config()->get('config', 'icingaAPI_port')); |
|
101 | - $apitest->setCredentials($this->Config()->get('config', 'icingaAPI_user'), $this->Config()->get('config', 'icingaAPI_password')); |
|
102 | - try { |
|
103 | - list($this->view->apimessageError,$this->view->apimessage)=$apitest->test($this->getModuleConfig()::getapiUserPermissions()); |
|
104 | - //$this->view->apimessageError=false; |
|
105 | - } catch (RuntimeException $e) { |
|
106 | - $this->view->apimessage='API config : ' . $e->getMessage(); |
|
107 | - $this->view->apimessageError=true; |
|
108 | - } |
|
100 | + $apitest=new Icinga2Api($this->Config()->get('config', 'icingaAPI_host'),$this->Config()->get('config', 'icingaAPI_port')); |
|
101 | + $apitest->setCredentials($this->Config()->get('config', 'icingaAPI_user'), $this->Config()->get('config', 'icingaAPI_password')); |
|
102 | + try { |
|
103 | + list($this->view->apimessageError,$this->view->apimessage)=$apitest->test($this->getModuleConfig()::getapiUserPermissions()); |
|
104 | + //$this->view->apimessageError=false; |
|
105 | + } catch (RuntimeException $e) { |
|
106 | + $this->view->apimessage='API config : ' . $e->getMessage(); |
|
107 | + $this->view->apimessageError=true; |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
112 | - $this->view->apimessage='API parameters not configured'; |
|
113 | - $this->view->apimessageError=true; |
|
112 | + $this->view->apimessage='API parameters not configured'; |
|
113 | + $this->view->apimessageError=true; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | //*********** Test snmptrapd alive and options |
@@ -125,33 +125,33 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | - $this->view->tabs = $this->Module()->getConfigTabs()->activate('config'); |
|
128 | + $this->view->tabs = $this->Module()->getConfigTabs()->activate('config'); |
|
129 | 129 | |
130 | 130 | // Check standard Icingaweb2 path |
131 | 131 | $this->view->icingaEtcWarn=0; |
132 | 132 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
133 | 133 | if ($icingaweb2_etc != "/etc/icingaweb2/" && $icingaweb2_etc != '') |
134 | 134 | { |
135 | - $output=array(); |
|
135 | + $output=array(); |
|
136 | 136 | |
137 | - exec('cat ' . $this->module->getBaseDir() .'/bin/trap_in.php | grep "\$icingaweb2_etc=" ',$output); |
|
137 | + exec('cat ' . $this->module->getBaseDir() .'/bin/trap_in.php | grep "\$icingaweb2_etc=" ',$output); |
|
138 | 138 | |
139 | - if (! preg_match('#"'. $icingaweb2_etc .'"#',$output[0])) |
|
140 | - { |
|
141 | - $this->view->icingaEtcWarn=1; |
|
142 | - $this->view->icingaweb2_etc=$icingaweb2_etc; |
|
143 | - } |
|
139 | + if (! preg_match('#"'. $icingaweb2_etc .'"#',$output[0])) |
|
140 | + { |
|
141 | + $this->view->icingaEtcWarn=1; |
|
142 | + $this->view->icingaweb2_etc=$icingaweb2_etc; |
|
143 | + } |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // Setup path for mini documentation |
147 | 147 | $this->view->traps_in_config= PHP_BINARY . ' ' . $this->Module()->getBaseDir() . '/bin/trap_in.php'; |
148 | 148 | |
149 | 149 | $this->view->installer= $this->Module()->getBaseDir() . '/bin/installer.sh ' |
150 | - . ' -c all ' |
|
151 | - . ' -d ' . $this->Module()->getBaseDir() |
|
152 | - . ' -p ' . PHP_BINARY |
|
153 | - . ' -a ' . exec('whoami') |
|
154 | - . ' -w ' . Icinga::app()->getConfigDir(); |
|
150 | + . ' -c all ' |
|
151 | + . ' -d ' . $this->Module()->getBaseDir() |
|
152 | + . ' -p ' . PHP_BINARY |
|
153 | + . ' -a ' . exec('whoami') |
|
154 | + . ' -w ' . Icinga::app()->getConfigDir(); |
|
155 | 155 | |
156 | 156 | // ******************* configuration form setup******************* |
157 | 157 | $this->view->form = $form = new TrapsConfigForm(); |
@@ -196,19 +196,19 @@ discard block |
||
196 | 196 | $dbResource = ResourceFactory::getResourceConfig($dbName); |
197 | 197 | $dbType=$dbResource->get('db'); |
198 | 198 | switch ($dbType) { |
199 | - case 'mysql': |
|
200 | - $dbFileExt='sql'; |
|
201 | - break; |
|
202 | - case 'pgsql': |
|
203 | - $dbFileExt='pgsql'; |
|
204 | - break; |
|
205 | - default: |
|
206 | - throw new ConfigurationError('Unsuported database : '.$dbType); |
|
199 | + case 'mysql': |
|
200 | + $dbFileExt='sql'; |
|
201 | + break; |
|
202 | + case 'pgsql': |
|
203 | + $dbFileExt='pgsql'; |
|
204 | + break; |
|
205 | + default: |
|
206 | + throw new ConfigurationError('Unsuported database : '.$dbType); |
|
207 | 207 | } |
208 | 208 | } catch (ConfigurationError $e ) |
209 | 209 | { |
210 | - printf("Database configuration error : %s",$e->getMessage()); |
|
211 | - return; |
|
210 | + printf("Database configuration error : %s",$e->getMessage()); |
|
211 | + return; |
|
212 | 212 | } |
213 | 213 | printf('<pre>'); |
214 | 214 | require_once $this->Module()->getBaseDir() .'/bin/trap_class.php'; |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | public function updateschemaAction() |
233 | 233 | { |
234 | 234 | $this->checkModuleConfigPermission(); |
235 | - $this->getTabs()->add('get',array( |
|
236 | - 'active' => true, |
|
237 | - 'label' => $this->translate('Update Schema'), |
|
238 | - 'url' => Url::fromRequest() |
|
239 | - )); |
|
235 | + $this->getTabs()->add('get',array( |
|
236 | + 'active' => true, |
|
237 | + 'label' => $this->translate('Update Schema'), |
|
238 | + 'url' => Url::fromRequest() |
|
239 | + )); |
|
240 | 240 | // check if needed |
241 | 241 | |
242 | 242 | $dberror=$this->getDb(true); // Get DB in test mode |
@@ -245,15 +245,15 @@ discard block |
||
245 | 245 | |
246 | 246 | if ($dberror[0] == 0) |
247 | 247 | { |
248 | - echo 'Schema already exists and is up to date<br>'; |
|
249 | - return; |
|
248 | + echo 'Schema already exists and is up to date<br>'; |
|
249 | + return; |
|
250 | 250 | } |
251 | 251 | if ($dberror[0] != 5) |
252 | 252 | { |
253 | - echo 'Database does not exists or is not setup correctly<br>'; |
|
254 | - return; |
|
253 | + echo 'Database does not exists or is not setup correctly<br>'; |
|
254 | + return; |
|
255 | 255 | } |
256 | - // setup |
|
256 | + // setup |
|
257 | 257 | require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
258 | 258 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
259 | 259 | $debug_level=4; |
@@ -266,20 +266,20 @@ discard block |
||
266 | 266 | $target_version=$dberror[2]; |
267 | 267 | |
268 | 268 | if ($this->params->get('msgok') == null) { |
269 | - // Check for messages and display if any |
|
270 | - echo "Upgrade databse is going to start.<br>Don't forget to backup your database before update<br>"; |
|
271 | - $Trap->setLogging(2,'syslog'); |
|
272 | - $message = $Trap->update_schema($updateSchema,$target_version,$prefix,true); |
|
273 | - if ($message != '') |
|
274 | - { |
|
275 | - echo 'Note :<br><pre>'; |
|
276 | - echo $message; |
|
277 | - echo '</pre>'; |
|
278 | - echo '<br>'; |
|
279 | - echo '<a class="link-button" style="font-size:large;font-weight:bold" href="' . Url::fromPath('trapdirector/settings/updateschema') .'?msgok=1">Click here to update</a>'; |
|
280 | - echo '<br>'; |
|
281 | - return; |
|
282 | - } |
|
269 | + // Check for messages and display if any |
|
270 | + echo "Upgrade databse is going to start.<br>Don't forget to backup your database before update<br>"; |
|
271 | + $Trap->setLogging(2,'syslog'); |
|
272 | + $message = $Trap->update_schema($updateSchema,$target_version,$prefix,true); |
|
273 | + if ($message != '') |
|
274 | + { |
|
275 | + echo 'Note :<br><pre>'; |
|
276 | + echo $message; |
|
277 | + echo '</pre>'; |
|
278 | + echo '<br>'; |
|
279 | + echo '<a class="link-button" style="font-size:large;font-weight:bold" href="' . Url::fromPath('trapdirector/settings/updateschema') .'?msgok=1">Click here to update</a>'; |
|
280 | + echo '<br>'; |
|
281 | + return; |
|
282 | + } |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | $Trap->setLogging($debug_level,'display'); |
@@ -293,28 +293,28 @@ discard block |
||
293 | 293 | |
294 | 294 | private function checkSnmpTrapd() |
295 | 295 | { |
296 | - $psOutput=array(); |
|
297 | - // First check is someone is listening to port 162. As not root, we can't have pid... |
|
298 | - exec('netstat -an |grep -E "udp.*:162"',$psOutput); |
|
299 | - if (count($psOutput) == 0) |
|
300 | - { |
|
301 | - return array(1,'Port UDP/162 is not open : snmptrapd must not be started'); |
|
302 | - } |
|
303 | - $psOutput=array(); |
|
304 | - exec('ps fax |grep snmptrapd |grep -v grep',$psOutput); |
|
305 | - if (count($psOutput) == 0) |
|
306 | - { |
|
307 | - return array(1,"UDP/162 : OK, but no snmptrapd process (?)"); |
|
308 | - } |
|
309 | - // Assume there is only one line... TODO : see if there is a better way to do this |
|
310 | - $line = preg_replace('/^.*snmptrapd /','',$psOutput[0]); |
|
311 | - if (!preg_match('/-n/',$line)) |
|
312 | - return array(1,'snmptrapd has no -n option : '.$line); |
|
313 | - if (!preg_match('/-O[^ ]*n/',$line)) |
|
314 | - return array(1,'snmptrapd has no -On option : '.$line); |
|
315 | - if (!preg_match('/-O[^ ]*e/',$line)) |
|
316 | - return array(1,'snmptrapd has no -Oe option : '.$line); |
|
296 | + $psOutput=array(); |
|
297 | + // First check is someone is listening to port 162. As not root, we can't have pid... |
|
298 | + exec('netstat -an |grep -E "udp.*:162"',$psOutput); |
|
299 | + if (count($psOutput) == 0) |
|
300 | + { |
|
301 | + return array(1,'Port UDP/162 is not open : snmptrapd must not be started'); |
|
302 | + } |
|
303 | + $psOutput=array(); |
|
304 | + exec('ps fax |grep snmptrapd |grep -v grep',$psOutput); |
|
305 | + if (count($psOutput) == 0) |
|
306 | + { |
|
307 | + return array(1,"UDP/162 : OK, but no snmptrapd process (?)"); |
|
308 | + } |
|
309 | + // Assume there is only one line... TODO : see if there is a better way to do this |
|
310 | + $line = preg_replace('/^.*snmptrapd /','',$psOutput[0]); |
|
311 | + if (!preg_match('/-n/',$line)) |
|
312 | + return array(1,'snmptrapd has no -n option : '.$line); |
|
313 | + if (!preg_match('/-O[^ ]*n/',$line)) |
|
314 | + return array(1,'snmptrapd has no -On option : '.$line); |
|
315 | + if (!preg_match('/-O[^ ]*e/',$line)) |
|
316 | + return array(1,'snmptrapd has no -Oe option : '.$line); |
|
317 | 317 | |
318 | - return array(0,'snmptrapd listening to UDP/162, options : '.$line); |
|
318 | + return array(0,'snmptrapd listening to UDP/162, options : '.$line); |
|
319 | 319 | } |
320 | 320 | } |
@@ -11,13 +11,12 @@ discard block |
||
11 | 11 | |
12 | 12 | //use Icinga\Web\Form as Form; |
13 | 13 | /** Rules management |
14 | - |
|
15 | -*/ |
|
14 | + */ |
|
16 | 15 | class HandlerController extends TrapsController |
17 | 16 | { |
18 | 17 | |
19 | 18 | /** index : list existing rules |
20 | - */ |
|
19 | + */ |
|
21 | 20 | public function indexAction() |
22 | 21 | { |
23 | 22 | $this->checkReadPermission(); |
@@ -39,29 +38,29 @@ discard block |
||
39 | 38 | */ |
40 | 39 | public function testruleAction() |
41 | 40 | { |
42 | - $this->checkReadPermission(); |
|
43 | - $this->getTabs()->add('get',array( |
|
44 | - 'active' => true, |
|
45 | - 'label' => $this->translate('Test Rule'), |
|
46 | - 'url' => Url::fromRequest() |
|
47 | - )); |
|
41 | + $this->checkReadPermission(); |
|
42 | + $this->getTabs()->add('get',array( |
|
43 | + 'active' => true, |
|
44 | + 'label' => $this->translate('Test Rule'), |
|
45 | + 'url' => Url::fromRequest() |
|
46 | + )); |
|
48 | 47 | |
49 | - //$db = $this->getDb(); |
|
48 | + //$db = $this->getDb(); |
|
50 | 49 | |
51 | - if ($this->params->get('rule') !== null) |
|
52 | - { |
|
53 | - $this->view->rule= $this->params->get('rule'); |
|
54 | - } |
|
55 | - else |
|
56 | - { |
|
57 | - $this->view->rule=''; |
|
58 | - } |
|
50 | + if ($this->params->get('rule') !== null) |
|
51 | + { |
|
52 | + $this->view->rule= $this->params->get('rule'); |
|
53 | + } |
|
54 | + else |
|
55 | + { |
|
56 | + $this->view->rule=''; |
|
57 | + } |
|
59 | 58 | } |
60 | 59 | |
61 | 60 | /** Add a handler |
62 | - * Get params fromid : setup from existing trap (id of trap table) |
|
63 | - * Get param ruleid : edit from existing handler (id of rule table) |
|
64 | - */ |
|
61 | + * Get params fromid : setup from existing trap (id of trap table) |
|
62 | + * Get param ruleid : edit from existing handler (id of rule table) |
|
63 | + */ |
|
65 | 64 | public function addAction() |
66 | 65 | { |
67 | 66 | $this->checkConfigPermission(); |
@@ -162,7 +161,7 @@ discard block |
||
162 | 161 | $currentObjectTypeEnum=$allObjects[$val->oid]['type_enum']; |
163 | 162 | } |
164 | 163 | $currentObject=array( |
165 | - $oid_index, |
|
164 | + $oid_index, |
|
166 | 165 | $val->oid, |
167 | 166 | $val->oid_name_mib, |
168 | 167 | $val->oid_name, |
@@ -184,7 +183,7 @@ discard block |
||
184 | 183 | { |
185 | 184 | if ($val==null) { continue; } |
186 | 185 | array_push($this->view->objectList, array( |
187 | - $oid_index, |
|
186 | + $oid_index, |
|
188 | 187 | $key, |
189 | 188 | $allObjects[$key]['mib'], |
190 | 189 | $allObjects[$key]['name'], |
@@ -223,61 +222,61 @@ discard block |
||
223 | 222 | $this->view->warning_message=''; |
224 | 223 | if ($this->view->hostname != null) |
225 | 224 | { |
226 | - $this->view->selectGroup=false; |
|
227 | - // Check if hostname still exists |
|
228 | - $host_get=$this->getHostByName($this->view->hostname); |
|
225 | + $this->view->selectGroup=false; |
|
226 | + // Check if hostname still exists |
|
227 | + $host_get=$this->getHostByName($this->view->hostname); |
|
229 | 228 | |
230 | - if (count($host_get)==0) |
|
231 | - { |
|
232 | - $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore'; |
|
233 | - $this->view->serviceGet=false; |
|
234 | - } |
|
235 | - else |
|
236 | - { |
|
237 | - // Tell JS to get services when page is loaded |
|
238 | - $this->view->serviceGet=true; |
|
239 | - // get service id for form to set : |
|
240 | - $serviceID=$this->getServiceIDByName($this->view->hostname,$ruleDetail->service_name); |
|
241 | - if (count($serviceID) ==0) |
|
242 | - { |
|
243 | - $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
244 | - } |
|
245 | - else |
|
246 | - { |
|
247 | - $this->view->serviceSet=$serviceID[0]->id; |
|
248 | - } |
|
249 | - } |
|
229 | + if (count($host_get)==0) |
|
230 | + { |
|
231 | + $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore'; |
|
232 | + $this->view->serviceGet=false; |
|
233 | + } |
|
234 | + else |
|
235 | + { |
|
236 | + // Tell JS to get services when page is loaded |
|
237 | + $this->view->serviceGet=true; |
|
238 | + // get service id for form to set : |
|
239 | + $serviceID=$this->getServiceIDByName($this->view->hostname,$ruleDetail->service_name); |
|
240 | + if (count($serviceID) ==0) |
|
241 | + { |
|
242 | + $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
243 | + } |
|
244 | + else |
|
245 | + { |
|
246 | + $this->view->serviceSet=$serviceID[0]->id; |
|
247 | + } |
|
248 | + } |
|
250 | 249 | } |
251 | 250 | else |
252 | 251 | { |
253 | - $this->view->selectGroup=true; |
|
254 | - // Check if groupe exists |
|
255 | - $group_get=$this->getHostGroupByName($this->view->hostgroupname); |
|
256 | - if (count($group_get)==0) |
|
257 | - { |
|
258 | - $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore'; |
|
259 | - $this->view->serviceGroupGet=false; |
|
260 | - } |
|
261 | - else |
|
262 | - { |
|
263 | - $grpServices=$this->getServicesByHostGroupid($group_get[0]->id); |
|
264 | - $foundGrpService=0; |
|
265 | - foreach ($grpServices as $grpService) |
|
266 | - { |
|
267 | - if ($grpService[0] == $ruleDetail->service_name) |
|
268 | - { |
|
269 | - $foundGrpService=1; |
|
270 | - $this->view->serviceSet=$ruleDetail->service_name; |
|
271 | - } |
|
272 | - } |
|
252 | + $this->view->selectGroup=true; |
|
253 | + // Check if groupe exists |
|
254 | + $group_get=$this->getHostGroupByName($this->view->hostgroupname); |
|
255 | + if (count($group_get)==0) |
|
256 | + { |
|
257 | + $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore'; |
|
258 | + $this->view->serviceGroupGet=false; |
|
259 | + } |
|
260 | + else |
|
261 | + { |
|
262 | + $grpServices=$this->getServicesByHostGroupid($group_get[0]->id); |
|
263 | + $foundGrpService=0; |
|
264 | + foreach ($grpServices as $grpService) |
|
265 | + { |
|
266 | + if ($grpService[0] == $ruleDetail->service_name) |
|
267 | + { |
|
268 | + $foundGrpService=1; |
|
269 | + $this->view->serviceSet=$ruleDetail->service_name; |
|
270 | + } |
|
271 | + } |
|
273 | 272 | |
274 | - // Tell JS to get services when page is loaded |
|
275 | - $this->view->serviceGroupGet=true; |
|
276 | - if ($foundGrpService==0) |
|
277 | - { |
|
278 | - $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
279 | - } |
|
280 | - } |
|
273 | + // Tell JS to get services when page is loaded |
|
274 | + $this->view->serviceGroupGet=true; |
|
275 | + if ($foundGrpService==0) |
|
276 | + { |
|
277 | + $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
278 | + } |
|
279 | + } |
|
281 | 280 | } |
282 | 281 | $this->view->mainoid=$ruleDetail->trap_oid; |
283 | 282 | $oidName=$this->getMIB()->translateOID($ruleDetail->trap_oid); |
@@ -302,7 +301,7 @@ discard block |
||
302 | 301 | if (($object=$this->getMIB()->translateOID($curOid)) != null) |
303 | 302 | { |
304 | 303 | array_push($curObjectList, array( |
305 | - $index, |
|
304 | + $index, |
|
306 | 305 | $curOid, |
307 | 306 | $object['mib'], |
308 | 307 | $object['name'], |
@@ -314,7 +313,7 @@ discard block |
||
314 | 313 | else |
315 | 314 | { |
316 | 315 | array_push($curObjectList, array( |
317 | - $index, |
|
316 | + $index, |
|
318 | 317 | $curOid, |
319 | 318 | 'not found', |
320 | 319 | 'not found', |
@@ -335,9 +334,9 @@ discard block |
||
335 | 334 | } |
336 | 335 | |
337 | 336 | /** Validate form and output message to user |
338 | - * @param in postdata |
|
339 | - * @return string status : OK / <Message> |
|
340 | - **/ |
|
337 | + * @param in postdata |
|
338 | + * @return string status : OK / <Message> |
|
339 | + **/ |
|
341 | 340 | protected function handlerformAction() |
342 | 341 | { |
343 | 342 | $postData=$this->getRequest()->getPost(); |
@@ -378,7 +377,7 @@ discard block |
||
378 | 377 | //$this->Module()-> |
379 | 378 | $this->_helper->json(array( |
380 | 379 | 'status'=>'OK', |
381 | - 'redirect'=>'trapdirector/handler' |
|
380 | + 'redirect'=>'trapdirector/handler' |
|
382 | 381 | |
383 | 382 | )); |
384 | 383 | } |
@@ -462,9 +461,9 @@ discard block |
||
462 | 461 | } |
463 | 462 | |
464 | 463 | /** Get trap detail by trapid. |
465 | - * @param $trapid int id of trap in received table |
|
466 | - * @return array (objects) |
|
467 | - */ |
|
464 | + * @param $trapid int id of trap in received table |
|
465 | + * @return array (objects) |
|
466 | + */ |
|
468 | 467 | protected function getTrapDetail($trapid) |
469 | 468 | { |
470 | 469 | if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
@@ -495,9 +494,9 @@ discard block |
||
495 | 494 | } |
496 | 495 | |
497 | 496 | /** Get trap objects |
498 | - * @param : trap id |
|
499 | - * @return array of objects |
|
500 | - */ |
|
497 | + * @param : trap id |
|
498 | + * @return array of objects |
|
499 | + */ |
|
501 | 500 | protected function getTrapobjects($trapid) |
502 | 501 | { |
503 | 502 | if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
@@ -527,9 +526,9 @@ discard block |
||
527 | 526 | } |
528 | 527 | |
529 | 528 | /** Get rule detail by ruleid. |
530 | - * @param $ruleid int id of rule in rule table |
|
531 | - * @return array (objects) |
|
532 | - */ |
|
529 | + * @param $ruleid int id of rule in rule table |
|
530 | + * @return array (objects) |
|
531 | + */ |
|
533 | 532 | protected function getRuleDetail($ruleid) |
534 | 533 | { |
535 | 534 | if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id'); } |
@@ -555,7 +554,7 @@ discard block |
||
555 | 554 | } |
556 | 555 | |
557 | 556 | /** Setup tabs for rules |
558 | - */ |
|
557 | + */ |
|
559 | 558 | protected function prepareTabs() |
560 | 559 | { |
561 | 560 | return $this->getTabs()->add('status', array( |
@@ -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,21 +87,21 @@ 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 | - } |
|
102 | - $pid=fgets($file); |
|
103 | - $output=array(); |
|
104 | - $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 | + } |
|
102 | + $pid=fgets($file); |
|
103 | + $output=array(); |
|
104 | + $retVal=0; |
|
105 | 105 | exec('ps '.$pid,$output,$retVal); |
106 | 106 | if ($retVal == 0) |
107 | 107 | { // process is alive |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | else |
111 | 111 | { // process is dead |
112 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
112 | + $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | $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 | } |