forked from olindata/tribily-zabbix-drupal-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzabbix_bridge.admin.inc
executable file
·539 lines (464 loc) · 27.5 KB
/
zabbix_bridge.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
<?php
// $Id$
/**
* @file
* Settings form for admin configuration
*
*/
include_once 'zabbix_functions.php';
/**
* This function returns a table with a h2 header with all zabbix hosts and
* their roles. Visible for admins only
*
* @return $output - a string with the html code for the table
*/
function zabbix_bridge_hosts_form() {
drupal_set_title('Hosts of zabbix_bridge');
$output = '<h2>' . t('User defined hosts') . '</h2>';
$output .= t('These are all the hosts with their roles created by all users.');
$output .= zabbix_hosts_table();
$output .= l('Import from Zabbix', 'hosts/import');
return $output;
}
/**
* This function returns a table with a h2 header with all alert emails for
* notification. Visible for admins only
*
* @return $output - a string with the html code for the table
*/
function zabbix_bridge_admin_emails() {
drupal_set_title('Emails of zabbix_bridge');
$output = '<h2>' . t('User defined emails') . '</h2>';
$output .= t('These are all the emails defined by users for notification.');
$output .= zabbix_emails_table();
$output .= l('Add email', 'emails/add') . ' | ' . l('Import from zabbix', 'emails/import');
return $output;
}
/**
* This function returns a table with a h2 header with all jabber alert addresses
* for notifications. Visible for admins only.
*
* @return $output - the html code for the table
*/
function zabbix_bridge_admin_jabbers() {
drupal_set_title('Jabbers of zabbix_bridge');
$output = '<h2>' . t('User defined jabbers') . '</h2>';
$output .= t('These are all the jabber accounts defined by users for notification.');
$output .= zabbix_jabbers_table();
$output .= l('Add jabber', 'jabbers/add') . ' | ' . l('Import from zabbix', 'jabbers/import');
return $output;
}
/**
* This function returns a table with a h2 header with all mobile phone number
* for notifications. Visible for admins only.
*
* @return $output - the html code for the table
*/
function zabbix_bridge_admin_mobiles() {
drupal_set_title('Mobiles of zabbix_bridge');
$output = '<h2>' . t('User defined mobiles') . '</h2>';
$output .= t('These are all the jabber accounts defined by users for notification.');
$output .= zabbix_mobiles_table();
$output .= l('Add mobile number', 'mobiles/add') . ' | ' . l('Import from zabbix', 'mobiles/import');
return $output;
}
/**
*
* @return <type>
*/
function zabbix_bridge_admin_user_mappings() {
drupal_set_title('User mappings of zabbix_bridge');
$output .= '<h2>' . t('Mapping of Drupal vs Zabbix objects') . '</h2>';
$output .= t('This is teh list of currently configured mappings for drupal users to their corresponding zabbix object id\s');
$output .= zabbix_user_mapping_table();
$output .= l('Add mapping', 'zabbix-user-mapping/add');
return $output;
}
/**
*
* @return <type>
*/
function zabbix_bridge_admin_roles_mapping() {
drupal_set_title('Mapping of roles of zabbix_bridge');
$output .= '<h2>' . t('Roles and their corresponding Zabbix Templates') . '</h2>';
$output .= t('These are all the roles with their corresponding zabbix templateids.');
$output .= zabbix_roletype_tables();
$output .= l('Add mapping', 'zabbix-role-mapping/add') . ' | ' . l('Import from zabbix', 'zabbix-role-mapping/import');
return $output;
}
/**
*
* @return <type>
*/
function zabbix_bridge_settings_form() {
$form['zabbix_bridge_credentials'] = array(
'#type' => 'fieldset',
'#title' => t('Zabbix credentials'),
);
$form['zabbix_bridge_credentials']['zabbix_bridge_API_url'] = array(
'#type' => 'textfield',
'#title' => t('Zabbix API url'),
'#default_value' => variable_get('zabbix_bridge_API_url', zabbix_bridge_API_url),
'#required' => TRUE,
'#description' => t('Url used for API calls. If you don\'t know what to put here, try the full path to your zabbix install, like: http://example.com/zabbix')
);
$form['zabbix_bridge_credentials']['zabbix_bridge_API_user'] = array(
'#type' => 'textfield',
'#title' => t('Zabbix API user'),
'#default_value' => variable_get('zabbix_bridge_API_user', zabbix_bridge_API_user),
'#description' => t('User used for API calls. Has to have API calling enabled, and has to be a super-admin.')
);
$form['zabbix_bridge_credentials']['zabbix_bridge_API_pass'] = array(
'#type' => 'password_confirm',
'#title' => t('Zabbix API password'),
'#size' => 25,
'#description' => t('Password used for API calls. This is the zabbix password of the API user.')
);
// Add zabbix trace deletion options
$trace_options = array(
'yes' => 'Yes',
'no' => 'No'
);
$form['zabbix_bridge_trace'] = array(
'#type' => 'radios',
'#title' => t('Delete Zabbix Traces Upon Account Deletion'),
'#default_value' => variable_get('zabbix_bridge_trace', 'no'),
'#description' => t('If checked, deleting a user account will remove all Zabbix traces (user, usergroup, host, hostgroup, media, actions)'),
'#options' => $trace_options
);
// add debug message options
$debug_options = array(
'yes' => 'Yes',
'no' => 'No'
);
$form['zabbix_bridge_debug'] = array(
'#type' => 'radios',
'#title' => T('Enable Debug Messages'),
'#default_value' => variable_get('zabbix_bridge_debug', 'no'),
'#description' => t('Determines whether debug messages show up or not. This should NOT be enabled in production!'),
'#options' => $debug_options
);
$form['zabbix_bridge_debug_verbose'] = array(
'#type' => 'radios',
'#title' => T('Enable Verbose Debug Messages'),
'#default_value' => variable_get('zabbix_bridge_debug_verbose', 'no'),
'#description' => t('Determines whether debug messages show full information. Less readable, more debuggable :)'),
'#options' => $debug_options
);
return system_settings_form($form);
}
function zabbix_bridge_alert_notifications() {
return drupal_get_form('zabbix_bridge_alert_notifications_form');
}
function zabbix_bridge_alert_notifications_form($formstate) {
$form['zabbix_bridge_notifications'] = array(
'#type' => 'fieldset',
'#title' => t('Zabbix Alert Notifications'),
);
$form['zabbix_bridge_notifications']['average'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Zabbix Alert Notifications - Average'),
);
$form['zabbix_bridge_notifications']['high'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Zabbix Alert Notifications - High'),
);
$form['zabbix_bridge_notifications']['disaster'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Zabbix Alert Notifications - Disaster'),
);
$form['zabbix_bridge_notifications']['infowarn'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Zabbix Alert Notifications - Information & Warning'),
);
$form['zabbix_bridge_notifications']['sms'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Zabbix Alert Notifications - SMS'),
);
$form['zabbix_bridge_notifications']['jabber'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Zabbix Alert Notifications - Jabber'),
);
//average alert
$form['zabbix_bridge_notifications']['average']['zabbix_bridge_alert_average_subject'] = array(
'#type' => 'textfield',
'#title' => t('Average alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_average_subject', t('Average alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>average</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['average']['zabbix_bridge_alert_average'] = array(
'#type' => 'textarea',
'#title' => t('Average alert'),
'#default_value' => variable_get('zabbix_bridge_alert_average', t('Average alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>average</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['average']['zabbix_bridge_alert_average_subject_recovery'] = array(
'#type' => 'textfield',
'#title' => t('Average recovery alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_average_subject_recovery', t('Average recovery alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>average</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['average']['zabbix_bridge_alert_average_recovery'] = array(
'#type' => 'textarea',
'#title' => t('Average recovery alert'),
'#default_value' => variable_get('zabbix_bridge_alert_average_recovery', t('Average recovery alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>average</strong>. This can use all of the template variables available to zabbix.')
);
// high alert
$form['zabbix_bridge_notifications']['high']['zabbix_bridge_alert_high_subject'] = array(
'#type' => 'textfield',
'#title' => t('High alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_high_subject', t('High alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>high</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['high']['zabbix_bridge_alert_high'] = array(
'#type' => 'textarea',
'#title' => t('High alert'),
'#default_value' => variable_get('zabbix_bridge_alert_high', t('High alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>high</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['high']['zabbix_bridge_alert_high_subject_recovery'] = array(
'#type' => 'textfield',
'#title' => t('High recovery alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_high_subject_recovery', t('High recovery alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>high</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['high']['zabbix_bridge_alert_high_recovery'] = array(
'#type' => 'textarea',
'#title' => t('High recovery alert'),
'#default_value' => variable_get('zabbix_bridge_alert_high_recovery', t('High recovery alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>high</strong>. This can use all of the template variables available to zabbix.')
);
// disaster alert
$form['zabbix_bridge_notifications']['disaster']['zabbix_bridge_alert_disaster_subject'] = array(
'#type' => 'textfield',
'#title' => t('Disaster alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_disaster_subject', t('Disaster alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>disaster</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['disaster']['zabbix_bridge_alert_disaster'] = array(
'#type' => 'textarea',
'#title' => t('Disaster alert'),
'#default_value' => variable_get('zabbix_bridge_alert_disaster', t('Disaster alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>disaster</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['disaster']['zabbix_bridge_alert_disaster_subject_recovery'] = array(
'#type' => 'textfield',
'#title' => t('Disaster recovery alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_disaster_subject_recovery', t('Disaster recovery alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>disaster</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['disaster']['zabbix_bridge_alert_disaster_recovery'] = array(
'#type' => 'textarea',
'#title' => t('Disaster recovery alert'),
'#default_value' => variable_get('zabbix_bridge_alert_disaster_recovery', t('Disaster recovery alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>disaster</strong>. This can use all of the template variables available to zabbix.')
);
// info_warn alert
$form['zabbix_bridge_notifications']['infowarn']['zabbix_bridge_alert_info_warn_subject'] = array(
'#type' => 'textfield',
'#title' => t('Information & Warning alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_info_warn_subject', t('Information & Warning alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>Information</strong> or <strong>Warning</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['infowarn']['zabbix_bridge_alert_info_warn'] = array(
'#type' => 'textarea',
'#title' => t('Information & Warning alert'),
'#default_value' => variable_get('zabbix_bridge_alert_info_warn', t('Information & Warning alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>Information</strong> or <strong>Warning</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['infowarn']['zabbix_bridge_alert_info_warn_subject_recovery'] = array(
'#type' => 'textfield',
'#title' => t('Information & Warning recovery alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_info_warn_subject_recovery', t('Information & Warning recovery alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the email that you want to send to customers when they receive an alert of the level <strong>Information</strong> or <strong>Warning</strong>. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['infowarn']['zabbix_bridge_alert_info_warn_recovery'] = array(
'#type' => 'textarea',
'#title' => t('Information & Warning recovery alert'),
'#default_value' => variable_get('zabbix_bridge_alert_info_warn_recovery', t('Information & Warning recovery alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert of the level <strong>Information</strong> or <strong>Warning</strong>. This can use all of the template variables available to zabbix.')
);
// sms alert
$form['zabbix_bridge_notifications']['sms']['zabbix_bridge_alert_sms_subject'] = array(
'#type' => 'textfield',
'#title' => t('SMS alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_sms_subject', t('SMS alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the sms that you want to send to customers when they receive an alert by text message. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['sms']['zabbix_bridge_alert_sms'] = array(
'#type' => 'textarea',
'#title' => t('SMS alert'),
'#default_value' => variable_get('zabbix_bridge_alert_sms', t('SMS alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert by text message. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['sms']['zabbix_bridge_alert_sms_subject_recovery'] = array(
'#type' => 'textfield',
'#title' => t('SMS recovery alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_sms_subject_recovery', t('SMS recovery alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the sms that you want to send to customers when they receive an alert by text message. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['sms']['zabbix_bridge_alert_sms_recovery'] = array(
'#type' => 'textarea',
'#title' => t('SMS recovery alert'),
'#default_value' => variable_get('zabbix_bridge_alert_sms_recovery', t('SMS recovery alert')),
'#required' => TRUE,
'#description' => t('The full email that you want to send to customers when they receive an alert by text message. This can use all of the template variables available to zabbix.')
);
// jabber alert
$form['zabbix_bridge_notifications']['jabber']['zabbix_bridge_alert_jabber_subject'] = array(
'#type' => 'textfield',
'#title' => t('Jabber alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_jabber_subject', t('Jabber alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the jabber message that you want to send to customers when they receive an alert by jabber. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['jabber']['zabbix_bridge_alert_jabber'] = array(
'#type' => 'textarea',
'#title' => t('Jabber alert'),
'#default_value' => variable_get('zabbix_bridge_alert_jabber', t('Jabber alert')),
'#required' => TRUE,
'#description' => t('The full jabber message that you want to send to customers when they receive an alert by text jabber. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['jabber']['zabbix_bridge_alert_jabber_subject_recovery'] = array(
'#type' => 'textfield',
'#title' => t('Jabber recovery alert subject'),
'#default_value' => variable_get('zabbix_bridge_alert_jabber_subject_recovery', t('Jabber recovery alert subject')),
'#required' => TRUE,
'#description' => t('The subject line of the jabber message that you want to send to customers when they receive an alert by jabber. This can use all of the template variables available to zabbix.')
);
$form['zabbix_bridge_notifications']['jabber']['zabbix_bridge_alert_jabber_recovery'] = array(
'#type' => 'textarea',
'#title' => t('Jabber recovery alert'),
'#default_value' => variable_get('zabbix_bridge_alert_jabber_recovery', t('Jabber recovery alert')),
'#required' => TRUE,
'#description' => t('The full jabber message that you want to send to customers when they receive an alert by text jabber. This can use all of the template variables available to zabbix.')
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save')
);
return($form);
}
function zabbix_bridge_alert_notifications_form_submit($form, &$form_state){
// get the values from the form
$alert_avg = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_average'];
$alert_high = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_high'];
$alert_info = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_info_warn'];
$alert_disaster = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_disaster'];
$alert_sms = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_sms'];
$alert_jabber = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_jabber'];
$alert_avg_subject = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_average_subject'];
$alert_high_subject = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_high_subject'];
$alert_info_subject = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_info_warn_subject'];
$alert_disaster_subject = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_disaster_subject'];
$alert_sms_subject = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_sms_subject'];
$alert_jabber_subject = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_jabber_subject'];
$alert_avg_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_average_recovery'];
$alert_high_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_high_recovery'];
$alert_info_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_info_warn_recovery'];
$alert_disaster_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_disaster_recovery'];
$alert_sms_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_sms_recovery'];
$alert_jabber_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_jabber_recovery'];
$alert_avg_subject_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_average_subject_recovery'];
$alert_high_subject_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_high_subject_recovery'];
$alert_info_subject_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_info_warn_subject_recovery'];
$alert_disaster_subject_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_disaster_subject_recovery'];
$alert_sms_subject_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_sms_subject_recovery'];
$alert_jabber_subject_recovery = $form['zabbix_bridge_notifications']['#post']['zabbix_bridge_alert_jabber_subject_recovery'];
//store the varaiables in drupal
variable_set('zabbix_bridge_alert_average', $alert_avg);
variable_set('zabbix_bridge_alert_high', $alert_high);
variable_set('zabbix_bridge_alert_info_warn', $alert_info);
variable_set('zabbix_bridge_alert_disaster', $alert_disaster);
variable_set('zabbix_bridge_alert_sms', $alert_sms);
variable_set('zabbix_bridge_alert_jabber', $alert_jabber);
variable_set('zabbix_bridge_alert_average_subject', $alert_avg_subject);
variable_set('zabbix_bridge_alert_high_subject', $alert_high_subject);
variable_set('zabbix_bridge_alert_info_warn_subject', $alert_info_subject);
variable_set('zabbix_bridge_alert_disaster_subject', $alert_disaster_subject);
variable_set('zabbix_bridge_alert_sms_subject', $alert_sms_subject);
variable_set('zabbix_bridge_alert_jabber_subject', $alert_jabber_subject);
variable_set('zabbix_bridge_alert_average_recovery', $alert_avg_recovery);
variable_set('zabbix_bridge_alert_high_recovery', $alert_high_recovery);
variable_set('zabbix_bridge_alert_info_warn_recovery', $alert_info_recovery);
variable_set('zabbix_bridge_alert_disaster_recovery', $alert_disaster_recovery);
variable_set('zabbix_bridge_alert_sms_recovery', $alert_sms_recovery);
variable_set('zabbix_bridge_alert_jabber_recovery', $alert_jabber_recovery);
variable_set('zabbix_bridge_alert_average_subject_recovery', $alert_avg_subject_recovery);
variable_set('zabbix_bridge_alert_high_subject_recovery', $alert_high_subject_recovery);
variable_set('zabbix_bridge_alert_info_warn_subject_recovery', $alert_info_subject_recovery);
variable_set('zabbix_bridge_alert_disaster_subject_recovery', $alert_disaster_subject_recovery);
variable_set('zabbix_bridge_alert_sms_subject_recovery', $alert_sms_subject_recovery);
variable_set('zabbix_bridge_alert_jabber_subject_recovery', $alert_jabber_subject_recovery);
// get a list of all zabbix users from zabbix
$userids = zabbix_bridge_get_all_users_from_zabbix();
// loop through list
foreach ($userids as $user => $userid) {
$name = $userid['alias'];
if (strlen($name) < 1)
drupal_set_message("Notification update failed. Error tr-1b.");
// search in all of the usergroups for this user for a usergroup that has our
// name structure. if it does, this customer needs to be processed.
$zabbixusergroupid = 0;
foreach ($userid['usrgrps'] as $usrgrp) {
if (!(strpos($usrgrp['name'], STR_CUST_USERGROUP) === FALSE)) {
$zabbixusergroupid = $usrgrp['usrgrpid'];
}
}
if ($zabbixusergroupid) {
// for every userid, get the connected hostgroupid (a businessrule for
// tribily is that 1 user is in 1 usergroup that has rights to just 1 hostgroup)
$hostgroupid = zabbix_bridge_get_all_hostgroupids_from_drupal($userid['userid']);
if (!empty($hostgroupid)) {
// if we did indeed find a hostgroup, get all actions including the operations and conditions
$actions = array();
$actions = zabbix_bridge_get_all_actions_from_zabbix($hostgroupid[0]);
// due to a bug in 1.8.3 API, the media stuff gets messed up if we just try
// to update an action, so as a workaround we delete and recreate the action
foreach ($actions as $action) {
if (!ZabbixAPI::query('action', 'delete', array($action['actionid']))) {
drupal_set_message("Notification update failed. Error tr-1a.");
}
}
zabbix_bridge_create_basic_actions($name . '_INFO_WARN', TRIGGER_SEVERITY_WARNING, $zabbixusergroupid, $hostgroupid[0]);
zabbix_bridge_create_basic_actions($name . '_HIGH', TRIGGER_SEVERITY_HIGH, $zabbixusergroupid, $hostgroupid[0]);
zabbix_bridge_create_basic_actions($name . '_DISASTER', TRIGGER_SEVERITY_DISASTER, $zabbixusergroupid, $hostgroupid[0]);
zabbix_bridge_create_basic_actions($name . '_AVERAGE', TRIGGER_SEVERITY_AVERAGE, $zabbixusergroupid, $hostgroupid[0]);
zabbix_bridge_create_mobile_action($name . '_SMS', $zabbixusergroupid, $hostgroupid[0]);
zabbix_bridge_create_jabber_action($name . '_JABBER', $zabbixusergroupid, $hostgroupid[0]);
}
}
}
}