|
451 | 451 | $alertm .= "-----------------------------------------------\n\n"; |
452 | 452 |
|
453 | 453 | if ($alert['method'] == 1) { |
| 454 | + //The syslog_sendemail should be called prior to syslog_log_alert, otherwise, the $found always larger than 0 |
| 455 | + if ($alertm != '') { |
| 456 | + $resend = true; |
| 457 | + if ($alert['repeat_alert'] > 0) { |
| 458 | + $found = syslog_db_fetch_cell('SELECT count(*) |
| 459 | + FROM syslog_logs |
| 460 | + WHERE alert_id=' . $alert['id'] . " |
| 461 | + AND logtime>'$date'"); |
| 462 | + |
| 463 | + if ($found) $resend = false; |
| 464 | + } |
| 465 | + |
| 466 | + if ($resend) { |
| 467 | + syslog_sendemail(trim($alert['email']), $from, __esc('Event Alert - %s', $alert['name'], 'syslog'), ($html ? $htmlm:$alertm), $smsalert); |
| 468 | + |
| 469 | + if ($alert['open_ticket'] == 'on' && strlen(read_config_option('syslog_ticket_command'))) { |
| 470 | + if (is_executable(read_config_option('syslog_ticket_command'))) { |
| 471 | + exec(read_config_option('syslog_ticket_command') . |
| 472 | + " --alert-name='" . clean_up_name($alert['name']) . "'" . |
| 473 | + " --severity='" . $alert['severity'] . "'" . |
| 474 | + " --hostlist='" . implode(',',$hostlist) . "'" . |
| 475 | + " --message='" . $alert['message'] . "'"); |
| 476 | + } |
| 477 | + } |
| 478 | + } |
| 479 | + } |
| 480 | + |
454 | 481 | $sequence = syslog_log_alert($alert['id'], $alert['name'], $alert['severity'], $at[0], sizeof($at), $htmlm, $hostlist); |
455 | 482 | $smsalert = __('Sev:', 'syslog') . $severities[$alert['severity']] . __(', Count:', 'syslog') . sizeof($at) . __(', URL:', 'syslog') . read_config_option('base_url', true) . '/plugins/syslog/syslog.php?tab=current&id=' . $sequence; |
456 | 483 | } |
|
459 | 486 | } |
460 | 487 | } |
461 | 488 | } |
462 | | - |
463 | | - if ($alertm != '' && $alert['method'] == 1) { |
464 | | - $resend = true; |
465 | | - if ($alert['repeat_alert'] > 0) { |
466 | | - $found = syslog_db_fetch_cell('SELECT count(*) |
467 | | - FROM syslog_logs |
468 | | - WHERE alert_id=' . $alert['id'] . " |
469 | | - AND logtime>'$date'"); |
470 | | - |
471 | | - if ($found) $resend = false; |
472 | | - } |
473 | | - |
474 | | - if ($resend) { |
475 | | - syslog_sendemail(trim($alert['email']), $from, __esc('Event Alert - %s', $alert['name'], 'syslog'), ($html ? $htmlm:$alertm), $smsalert); |
476 | | - |
477 | | - if ($alert['open_ticket'] == 'on' && strlen(read_config_option('syslog_ticket_command'))) { |
478 | | - if (is_executable(read_config_option('syslog_ticket_command'))) { |
479 | | - exec(read_config_option('syslog_ticket_command') . |
480 | | - " --alert-name='" . clean_up_name($alert['name']) . "'" . |
481 | | - " --severity='" . $alert['severity'] . "'" . |
482 | | - " --hostlist='" . implode(',',$hostlist) . "'" . |
483 | | - " --message='" . $alert['message'] . "'"); |
484 | | - } |
485 | | - } |
486 | | - } |
487 | | - } |
488 | 489 | } |
489 | 490 | } |
490 | 491 |
|
|
0 commit comments