2014-04-02 Sergio Martin <sergio.martin@artica.es>
* include/functions_api.php: Added new API function to validate alerts from PagerDuty notification service git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9704 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
95275d2f15
commit
33ba6ee953
|
@ -1,3 +1,8 @@
|
|||
2014-04-02 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_api.php: Added new API function to validate
|
||||
alerts from PagerDuty notification service
|
||||
|
||||
2014-04-02 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* operation/search_results.php, operation/search_users.getdata.php:
|
||||
|
|
|
@ -6643,4 +6643,46 @@ function api_set_enable_disable_agent ($id, $thrash2, $other, $thrash3) {
|
|||
}
|
||||
}
|
||||
|
||||
function api_set_pagerduty_webhook($type, $matchup_path, $tresh2, $return_type) {
|
||||
global $config;
|
||||
|
||||
$pagerduty_data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
foreach($pagerduty_data['messages'] as $pm) {
|
||||
$incident = $pm['data']['incident'];
|
||||
$incident_type = $pm['type'];
|
||||
// incident.acknowledge
|
||||
// incident.resolve
|
||||
// incident.trigger
|
||||
|
||||
switch($type) {
|
||||
case 'alert':
|
||||
// Get all the alerts that the user can see
|
||||
$id_groups = array_keys(users_get_groups($config["id_user"], 'AR', false));
|
||||
$alerts = get_group_alerts($id_groups);
|
||||
|
||||
// When an alert is resolved, the Pandoras alert will be validated
|
||||
if ($incident_type != 'incident.resolve') {
|
||||
break;
|
||||
}
|
||||
|
||||
$alert_id = 0;
|
||||
foreach($alerts as $al) {
|
||||
$key = file_get_contents($matchup_path . '/.pandora_pagerduty_id_' . $al['id']);
|
||||
if ($key == $incident['incident_key']) {
|
||||
$alert_id = $al['id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($alert_id != 0) {
|
||||
alerts_validate_alert_agent_module($alert_id);
|
||||
}
|
||||
break;
|
||||
case 'event':
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue