@@ -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()); |
@@ -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 | ); |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | protected $lastHost; |
22 | 22 | // Filters |
23 | 23 | |
24 | - protected $filter; |
|
25 | - protected $enforcedFilters = array(); |
|
26 | - protected $searchColumns = array(); |
|
24 | + protected $filter; |
|
25 | + protected $enforcedFilters = array(); |
|
26 | + protected $searchColumns = array(); |
|
27 | 27 | |
28 | 28 | protected function getTitles() { |
29 | 29 | // TODO : check moduleconfig is set |
30 | - return $this->moduleConfig->getTrapHostListTitles(); |
|
30 | + return $this->moduleConfig->getTrapHostListTitles(); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | // ****************** Render table in html |
@@ -35,45 +35,45 @@ discard block |
||
35 | 35 | // Host grouping |
36 | 36 | protected function renderHostIfNew($IP,$hostname) |
37 | 37 | { |
38 | - $view = $this->getView(); |
|
38 | + $view = $this->getView(); |
|
39 | 39 | |
40 | - if ($this->lastHost === $IP) { |
|
41 | - return; |
|
42 | - } |
|
40 | + if ($this->lastHost === $IP) { |
|
41 | + return; |
|
42 | + } |
|
43 | 43 | |
44 | - if ($this->lastHost === null) |
|
45 | - { |
|
46 | - $htm = "<thead>\n <tr>\n"; |
|
47 | - } else { |
|
48 | - $htm = "</tbody>\n<thead>\n <tr>\n"; |
|
49 | - } |
|
44 | + if ($this->lastHost === null) |
|
45 | + { |
|
46 | + $htm = "<thead>\n <tr>\n"; |
|
47 | + } else { |
|
48 | + $htm = "</tbody>\n<thead>\n <tr>\n"; |
|
49 | + } |
|
50 | 50 | |
51 | - if ($this->columnCount === null) |
|
52 | - { |
|
53 | - $this->columnCount = count($this->getTitles()); |
|
54 | - } |
|
51 | + if ($this->columnCount === null) |
|
52 | + { |
|
53 | + $this->columnCount = count($this->getTitles()); |
|
54 | + } |
|
55 | 55 | |
56 | - $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP); |
|
57 | - if ($hostname != null) |
|
58 | - { |
|
59 | - $htm .= ' ('.$hostname.')'; |
|
60 | - } |
|
61 | - $htm .= '</th>' . "\n"; |
|
62 | - if ($this->lastHost === null) { |
|
63 | - $htm .= " </tr>\n"; |
|
64 | - } else { |
|
65 | - $htm .= " </tr>\n</thead>\n"; |
|
66 | - } |
|
56 | + $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP); |
|
57 | + if ($hostname != null) |
|
58 | + { |
|
59 | + $htm .= ' ('.$hostname.')'; |
|
60 | + } |
|
61 | + $htm .= '</th>' . "\n"; |
|
62 | + if ($this->lastHost === null) { |
|
63 | + $htm .= " </tr>\n"; |
|
64 | + } else { |
|
65 | + $htm .= " </tr>\n</thead>\n"; |
|
66 | + } |
|
67 | 67 | |
68 | - $this->lastHost = $IP; |
|
68 | + $this->lastHost = $IP; |
|
69 | 69 | |
70 | - return $htm . "<tbody>\n"; |
|
70 | + return $htm . "<tbody>\n"; |
|
71 | 71 | } |
72 | 72 | |
73 | - public function __toString() |
|
74 | - { |
|
75 | - return $this->render(); |
|
76 | - } |
|
73 | + public function __toString() |
|
74 | + { |
|
75 | + return $this->render(); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | public function render() |
79 | 79 | { |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | - public function count() |
|
143 | - { |
|
144 | - $db=$this->db(); |
|
142 | + public function count() |
|
143 | + { |
|
144 | + $db=$this->db(); |
|
145 | 145 | |
146 | 146 | $query = $this->getBaseQuery(); |
147 | 147 | $this->applyFiltersToQuery($query); |
@@ -149,16 +149,16 @@ discard block |
||
149 | 149 | |
150 | 150 | return count($values); |
151 | 151 | |
152 | - //return $db->fetchOne($query); |
|
153 | - } |
|
152 | + //return $db->fetchOne($query); |
|
153 | + } |
|
154 | 154 | |
155 | - public function getPaginator() |
|
156 | - { |
|
157 | - $paginator = new Paginator(); |
|
158 | - $paginator->setQuery($this); |
|
155 | + public function getPaginator() |
|
156 | + { |
|
157 | + $paginator = new Paginator(); |
|
158 | + $paginator->setQuery($this); |
|
159 | 159 | |
160 | - return $paginator; |
|
161 | - } |
|
160 | + return $paginator; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | // ****************** DB connection and query |
164 | 164 | |
@@ -168,24 +168,24 @@ discard block |
||
168 | 168 | |
169 | 169 | $query = $this->getBaseQuery(); |
170 | 170 | $this->applyFiltersToQuery($query); |
171 | - if ($this->hasLimit() || $this->hasOffset()) { |
|
172 | - $query->limit($this->getLimit(), $this->getOffset()); |
|
173 | - } |
|
171 | + if ($this->hasLimit() || $this->hasOffset()) { |
|
172 | + $query->limit($this->getLimit(), $this->getOffset()); |
|
173 | + } |
|
174 | 174 | |
175 | 175 | return $db->fetchAll($query); |
176 | 176 | } |
177 | 177 | |
178 | - public function getBaseQuery() |
|
179 | - { |
|
178 | + public function getBaseQuery() |
|
179 | + { |
|
180 | 180 | $db=$this->db(); |
181 | 181 | $query = $db->select()->from( |
182 | - $this->moduleConfig->getTrapTableName(), |
|
183 | - $this->moduleConfig->getTrapHostListDisplayColumns() |
|
184 | - )->group(array('t.source_ip','t.source_name','t.trap_oid')) |
|
185 | - ->order('t.source_ip'); |
|
182 | + $this->moduleConfig->getTrapTableName(), |
|
183 | + $this->moduleConfig->getTrapHostListDisplayColumns() |
|
184 | + )->group(array('t.source_ip','t.source_name','t.trap_oid')) |
|
185 | + ->order('t.source_ip'); |
|
186 | 186 | |
187 | - return $query; |
|
188 | - } |
|
187 | + return $query; |
|
188 | + } |
|
189 | 189 | |
190 | 190 | // ****************** Filters |
191 | 191 | |
@@ -215,39 +215,39 @@ discard block |
||
215 | 215 | $this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0; |
216 | 216 | } |
217 | 217 | |
218 | - protected function getSearchColumns() |
|
219 | - { |
|
220 | - return $this->getColumns(); |
|
221 | - } |
|
218 | + protected function getSearchColumns() |
|
219 | + { |
|
220 | + return $this->getColumns(); |
|
221 | + } |
|
222 | 222 | |
223 | 223 | public function getColumns() |
224 | 224 | { |
225 | 225 | return $this->moduleConfig->getTrapListDisplayColumns(); |
226 | 226 | } |
227 | 227 | |
228 | - public function setFilter($filter) |
|
229 | - { |
|
230 | - $this->filter = $filter; |
|
231 | - return $this; |
|
232 | - } |
|
228 | + public function setFilter($filter) |
|
229 | + { |
|
230 | + $this->filter = $filter; |
|
231 | + return $this; |
|
232 | + } |
|
233 | 233 | |
234 | 234 | public function getFilterEditor(Request $request) |
235 | - { |
|
236 | - $filterEditor = Widget::create('filterEditor') |
|
237 | - ->setColumns(array_keys($this->getColumns())) |
|
238 | - ->setSearchColumns(array_keys($this->getSearchColumns())) |
|
239 | - ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
|
240 | - ->ignoreParams('page') |
|
241 | - ->handleRequest($request); |
|
235 | + { |
|
236 | + $filterEditor = Widget::create('filterEditor') |
|
237 | + ->setColumns(array_keys($this->getColumns())) |
|
238 | + ->setSearchColumns(array_keys($this->getSearchColumns())) |
|
239 | + ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
|
240 | + ->ignoreParams('page') |
|
241 | + ->handleRequest($request); |
|
242 | 242 | |
243 | - $filter = $filterEditor->getFilter(); |
|
244 | - $this->setFilter($filter); |
|
243 | + $filter = $filterEditor->getFilter(); |
|
244 | + $this->setFilter($filter); |
|
245 | 245 | |
246 | - return $filterEditor; |
|
247 | - } |
|
246 | + return $filterEditor; |
|
247 | + } |
|
248 | 248 | |
249 | - protected function applyFiltersToQuery($query) |
|
250 | - { |
|
249 | + protected function applyFiltersToQuery($query) |
|
250 | + { |
|
251 | 251 | |
252 | 252 | $sql=''; |
253 | 253 | if ($this->filter_query != '') |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $sql.="(status != 'done')"; |
269 | 269 | } |
270 | 270 | if ($sql != '') $query->where($sql); |
271 | - return $query; |
|
272 | - } |
|
271 | + return $query; |
|
272 | + } |
|
273 | 273 | |
274 | 274 | } |
275 | 275 |
@@ -4,9 +4,9 @@ discard block |
||
4 | 4 | |
5 | 5 | class TrapModuleConfig |
6 | 6 | { |
7 | - /********** Database configuration ***********************/ |
|
7 | + /********** Database configuration ***********************/ |
|
8 | 8 | // Database prefix for tables |
9 | - protected $table_prefix; //< Database prefix for tables |
|
9 | + protected $table_prefix; //< Database prefix for tables |
|
10 | 10 | protected $DBConfigDefaults=array( |
11 | 11 | 'db_remove_days' => 60, // number of days before removing traps |
12 | 12 | 'log_destination' => 'syslog', // Log destination for trap handler |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | // Note : must have 'source_ip' and 'last_sent' |
114 | 114 | public function getTrapHostListDisplayColumns() |
115 | 115 | { |
116 | - return array( |
|
117 | - 'source_name' => 't.source_name', |
|
118 | - 'source_ip' => 't.source_ip', |
|
119 | - 'trap_oid' => 't.trap_oid', |
|
120 | - 'count' => 'count(*)', |
|
121 | - 'last_sent' => 'UNIX_TIMESTAMP(max(t.date_received))' |
|
122 | - ); |
|
116 | + return array( |
|
117 | + 'source_name' => 't.source_name', |
|
118 | + 'source_ip' => 't.source_ip', |
|
119 | + 'trap_oid' => 't.trap_oid', |
|
120 | + 'count' => 'count(*)', |
|
121 | + 'last_sent' => 'UNIX_TIMESTAMP(max(t.date_received))' |
|
122 | + ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public function getTrapHostListSearchColumns() |
126 | 126 | { |
127 | - return array(); // No search needed on this table |
|
127 | + return array(); // No search needed on this table |
|
128 | 128 | } |
129 | 129 | // Titles display in Trap List table |
130 | 130 | public function getTrapHostListTitles() |
131 | 131 | { |
132 | - return array( |
|
133 | - 'trap_oid' => 'Trap OID', |
|
134 | - 'count' => 'Number of traps received', |
|
135 | - 'last_sent' => 'Last trap received' |
|
136 | - ); |
|
132 | + return array( |
|
133 | + 'trap_oid' => 'Trap OID', |
|
134 | + 'count' => 'Number of traps received', |
|
135 | + 'last_sent' => 'Last trap received' |
|
136 | + ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | 'revert_ok' => 'r.revert_ok', |
189 | 189 | 'display' => 'r.display', |
190 | 190 | 'modified' => 'UNIX_TIMESTAMP(r.modified)', |
191 | - 'modifier' => 'r.modifier' |
|
191 | + 'modifier' => 'r.modifier' |
|
192 | 192 | ); |
193 | 193 | } |
194 | 194 |
@@ -14,40 +14,40 @@ |
||
14 | 14 | |
15 | 15 | if (!array_key_exists('v',$options) || !array_key_exists('c',$options) || !array_key_exists('b',$options)|| !array_key_exists('a',$options)) |
16 | 16 | { |
17 | - printf("Need version -v, path -a, database -b (mysql,pgsql) command -c (create/update)\n"); |
|
18 | - exit(1); |
|
17 | + printf("Need version -v, path -a, database -b (mysql,pgsql) command -c (create/update)\n"); |
|
18 | + exit(1); |
|
19 | 19 | } |
20 | 20 | $command=$options['c']; |
21 | 21 | $path=$options['a']; |
22 | 22 | try { |
23 | - switch($command) |
|
24 | - { |
|
25 | - case 'create': |
|
26 | - $schema=($options['b']=='mysql')?'schema_v'.$options['v'].'.sql':'schema_v'.$options['v'].'.pgsql'; |
|
27 | - $schema=$path.'/SQL/'.$schema; |
|
28 | - $trap->trapsDB->create_schema($schema, 'traps_'); |
|
29 | - break; |
|
30 | - case 'update': |
|
31 | - $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_',true); |
|
32 | - printf("Update message : %s\n",$message); |
|
33 | - if ($message == 'ERROR') |
|
34 | - { |
|
35 | - exit(1); |
|
36 | - } |
|
37 | - printf("Messages DONE, updating : \n"); |
|
38 | - $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_'); |
|
39 | - if ($message == 'ERROR') |
|
40 | - { |
|
41 | - exit(1); |
|
42 | - } |
|
43 | - break; |
|
44 | - default: |
|
45 | - printf("Unknown command\n"); |
|
46 | - exit(1); |
|
47 | - } |
|
23 | + switch($command) |
|
24 | + { |
|
25 | + case 'create': |
|
26 | + $schema=($options['b']=='mysql')?'schema_v'.$options['v'].'.sql':'schema_v'.$options['v'].'.pgsql'; |
|
27 | + $schema=$path.'/SQL/'.$schema; |
|
28 | + $trap->trapsDB->create_schema($schema, 'traps_'); |
|
29 | + break; |
|
30 | + case 'update': |
|
31 | + $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_',true); |
|
32 | + printf("Update message : %s\n",$message); |
|
33 | + if ($message == 'ERROR') |
|
34 | + { |
|
35 | + exit(1); |
|
36 | + } |
|
37 | + printf("Messages DONE, updating : \n"); |
|
38 | + $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_'); |
|
39 | + if ($message == 'ERROR') |
|
40 | + { |
|
41 | + exit(1); |
|
42 | + } |
|
43 | + break; |
|
44 | + default: |
|
45 | + printf("Unknown command\n"); |
|
46 | + exit(1); |
|
47 | + } |
|
48 | 48 | } catch (Exception $e) { |
49 | - printf("Caught Exception %s\n",$e->getMessage()); |
|
50 | - exit (1); |
|
49 | + printf("Caught Exception %s\n",$e->getMessage()); |
|
50 | + exit (1); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | exit(0); |
@@ -22,77 +22,77 @@ discard block |
||
22 | 22 | class MibCommand extends Command |
23 | 23 | { |
24 | 24 | /** |
25 | - * Update mib database |
|
26 | - * |
|
27 | - * USAGE |
|
28 | - * |
|
29 | - * icingli trapdirector mib update |
|
30 | - * |
|
31 | - * OPTIONS |
|
32 | - * |
|
33 | - * --pid <file> : run in background with pid in <file> |
|
34 | - * |
|
35 | - * --verb : Set output log to verbose |
|
36 | - * |
|
37 | - * --force-check : force check of all traps & objects for change. (NOT IMPLEMENTED) |
|
38 | - */ |
|
25 | + * Update mib database |
|
26 | + * |
|
27 | + * USAGE |
|
28 | + * |
|
29 | + * icingli trapdirector mib update |
|
30 | + * |
|
31 | + * OPTIONS |
|
32 | + * |
|
33 | + * --pid <file> : run in background with pid in <file> |
|
34 | + * |
|
35 | + * --verb : Set output log to verbose |
|
36 | + * |
|
37 | + * --force-check : force check of all traps & objects for change. (NOT IMPLEMENTED) |
|
38 | + */ |
|
39 | 39 | public function updateAction() |
40 | 40 | { |
41 | - $background = $this->params->get('pid', null); |
|
42 | - $logLevel= $this->params->has('verb') ? 4 : 2; |
|
43 | - if ($this->params->has('force-check')) { echo "Not implemented"; return;} |
|
44 | - $forceCheck=$this->params->has('force-check')?True:False; |
|
45 | - $pid=1; |
|
46 | - if ($background != null) |
|
47 | - { |
|
48 | - $file=@fopen($background,'w'); |
|
49 | - if ($file == false) |
|
50 | - { |
|
51 | - echo 'Error : cannot open pid file '.$background; |
|
52 | - return 1; |
|
53 | - } |
|
54 | - $pid = pcntl_fork(); |
|
55 | - if ($pid == -1) { |
|
56 | - echo 'Error : Cannot fork process'; |
|
57 | - return 1; |
|
58 | - } |
|
59 | - } |
|
60 | - $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
|
41 | + $background = $this->params->get('pid', null); |
|
42 | + $logLevel= $this->params->has('verb') ? 4 : 2; |
|
43 | + if ($this->params->has('force-check')) { echo "Not implemented"; return;} |
|
44 | + $forceCheck=$this->params->has('force-check')?True:False; |
|
45 | + $pid=1; |
|
46 | + if ($background != null) |
|
47 | + { |
|
48 | + $file=@fopen($background,'w'); |
|
49 | + if ($file == false) |
|
50 | + { |
|
51 | + echo 'Error : cannot open pid file '.$background; |
|
52 | + return 1; |
|
53 | + } |
|
54 | + $pid = pcntl_fork(); |
|
55 | + if ($pid == -1) { |
|
56 | + echo 'Error : Cannot fork process'; |
|
57 | + return 1; |
|
58 | + } |
|
59 | + } |
|
60 | + $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
|
61 | 61 | require_once($module->getBaseDir() .'/bin/trap_class.php'); |
62 | 62 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
63 | 63 | $trap = new Trap($icingaweb2_etc); |
64 | 64 | if ($pid == 1) |
65 | 65 | { |
66 | - $trap->setLogging($logLevel,'display'); |
|
66 | + $trap->setLogging($logLevel,'display'); |
|
67 | 67 | } |
68 | 68 | else |
69 | 69 | { // use default display TODO : if default is 'display' son process will be killed at first output.... |
70 | - if ($pid != 0) |
|
71 | - { |
|
72 | - // father process |
|
73 | - fwrite($file,$pid); |
|
74 | - fclose($file); |
|
75 | - echo "OK : process $pid in bckground"; |
|
76 | - return 0; |
|
77 | - } |
|
78 | - else |
|
79 | - { // son process : close all file descriptors and go to a new session |
|
80 | - fclose($file); |
|
70 | + if ($pid != 0) |
|
71 | + { |
|
72 | + // father process |
|
73 | + fwrite($file,$pid); |
|
74 | + fclose($file); |
|
75 | + echo "OK : process $pid in bckground"; |
|
76 | + return 0; |
|
77 | + } |
|
78 | + else |
|
79 | + { // son process : close all file descriptors and go to a new session |
|
80 | + fclose($file); |
|
81 | 81 | // $sid = posix_setsid(); |
82 | - fclose(STDIN); |
|
83 | - fclose(STDOUT); |
|
84 | - fclose(STDERR); |
|
85 | - try |
|
86 | - { |
|
87 | - $trap->mibClass->update_mib_database(false,$forceCheck); |
|
88 | - } |
|
89 | - catch (Exception $e) |
|
90 | - { |
|
91 | - $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
|
92 | - } |
|
93 | - unlink($background); |
|
94 | - return 0; |
|
95 | - } |
|
82 | + fclose(STDIN); |
|
83 | + fclose(STDOUT); |
|
84 | + fclose(STDERR); |
|
85 | + try |
|
86 | + { |
|
87 | + $trap->mibClass->update_mib_database(false,$forceCheck); |
|
88 | + } |
|
89 | + catch (Exception $e) |
|
90 | + { |
|
91 | + $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
|
92 | + } |
|
93 | + unlink($background); |
|
94 | + return 0; |
|
95 | + } |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -110,28 +110,28 @@ discard block |
||
110 | 110 | } |
111 | 111 | if ($pid != 1) |
112 | 112 | { |
113 | - unlink($background); |
|
113 | + unlink($background); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | /** |
117 | - * purge all mib database NOT IMPLEMENTED |
|
118 | - * |
|
119 | - * USAGE |
|
120 | - * |
|
121 | - * icingli trapdirector mib purge --confirm |
|
122 | - * |
|
123 | - * OPTIONS |
|
124 | - * |
|
125 | - * --confirm : needed to execute purge |
|
126 | - */ |
|
117 | + * purge all mib database NOT IMPLEMENTED |
|
118 | + * |
|
119 | + * USAGE |
|
120 | + * |
|
121 | + * icingli trapdirector mib purge --confirm |
|
122 | + * |
|
123 | + * OPTIONS |
|
124 | + * |
|
125 | + * --confirm : needed to execute purge |
|
126 | + */ |
|
127 | 127 | public function purgeAction() |
128 | 128 | { |
129 | 129 | $db_prefix=$this->Config()->get('config', 'database_prefix'); |
130 | 130 | |
131 | 131 | if (!$this->params->has('confirm')) |
132 | 132 | { |
133 | - echo "This needs confirmation with '--confirm'\n"; |
|
134 | - return; |
|
133 | + echo "This needs confirmation with '--confirm'\n"; |
|
134 | + return; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $Config = new TrapModuleConfig($db_prefix); |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | $db = IcingaDbConnection::fromResourceName($dbresource)->getConnection(); |
145 | 145 | |
146 | 146 | $query = $db->delete( |
147 | - $Config->getMIBCacheTableName(), |
|
148 | - 'id>0'); |
|
149 | - echo 'Deleted '. $query . " traps and objects\n"; |
|
147 | + $Config->getMIBCacheTableName(), |
|
148 | + 'id>0'); |
|
149 | + echo 'Deleted '. $query . " traps and objects\n"; |
|
150 | 150 | } |
151 | 151 | catch (Exception $e) |
152 | 152 | { |