forked from alerta/alerta-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
104 lines (98 loc) · 3.82 KB
/
test.php
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
<?php
include_once 'alerta.php';
/**
* Team configuration
* Arrays of teams, the key being the Virtual Host FQDN, e.g. opsweekly.mycompany.com
*
* Options:
* display_name: Used for display purposes, your nice team name.
* email_report_to: The email address the weekly reports users write should be emailed to
* database: The name of the MySQL database the data for this team is stored in
* oncall: false or an array. If false, hides the oncall sections of the interface. If true, please complete the other information.
* - provider: The plugin you wish to use to retrieve on call information for the user to complete
* - provider_options: An array of options that you wish to pass to the provider for this team's on call searching
* - There are variables for the options that are subsituted within the provider. See their docs for more info
* - timezone: The PHP timezone string that your on-call rotation starts in
* - start: Inputted into strtotime, this is when your oncall rotation starts.
* e.g. Match this to Pagerduty if you use that for scheduling.
* - end: Inputted into strtotime, this is when your oncall rotation ends.
* e.g. Match this to Pagerduty if you use that for scheduling.
**/
$teams = array(
"opsweekly.alerta.io" => array(
"root_url" => "/opsweekly",
"display_name" => "Ops",
"email_report_to" => "[email protected]",
"database" => "opsweekly",
"oncall" => array(
"provider" => "alerta",
"provider_options" => array(
"alerta_search" => 'tags=watch:#logged_in_username#',
),
"timezone" => "America/New_York",
"start" => "friday 18:00",
"end" => "friday 18:00",
),
"weekly_hints" => array("jira", "github"),
"irc_channel" => "#ops"
),
);
/**
* Oncall providers
* These are used to retrieve information given a time period about the alerts the requesting
* user received.
**/
$oncall_providers = array(
"alerta" => array(
"display_name" => "Alerta",
"lib" => "providers/oncall/alerta.php",
"options" => array(
"base_url" => "http://api.alerta.io",
"apikey" => "demo-key"
),
),
"splunk" => array(
"display_name" => "Splunk",
"lib" => "providers/oncall/splunk.php",
"options" => array(
"base_url" => "https://splunk.mycompany.com:8089",
"username" => "splunkapiusername",
"password" => "splunkapipassword",
),
),
"example" => array(
"display_name" => "Example",
"lib" => "providers/oncall/example.php",
),
"logstash" => array(
"display_name" => "Logstash",
"lib" => "providers/oncall/logstash.php",
"options" => array(
"base_url" => "http://localhost:9200",
),
),
"pagerduty" => array(
"display_name" => "Pagerduty",
"lib" => "providers/oncall/pagerduty.php",
"options" => array(
"base_url" => "https://mycompany.pagerduty.com/api/v1",
// Supports two auth methods. Username/password or apikey.
// If you define apikey, then the username/password will be ignored
"username" => "[email protected]",
"password" => "password",
// uncomment and define if you use apikeys
// "apikey" => "XXXXXX",
),
),
);
// The number of search results per page
$search_results_per_page = 25;
// Path to disk where a debug error log file can be written
$error_log_file = "/var/log/httpd/opsweekly_debug.log";
print_r(getOnCallNotifications(
'John Doe',
$oncall_providers["alerta"]["options"],
$teams["opsweekly.alerta.io"]["oncall"]["provider_options"],
date('U', strtotime('last monday')),
date('U', strtotime('next monday')))
);