File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -93,4 +93,37 @@ function alert_sms_twilio($data, $context) {
93
93
}
94
94
}
95
95
96
+ /*
97
+ * Notifies a web hook over HTTP regarding alert.
98
+ * All context parameters are sent, via GET.
99
+ *
100
+ * data['url']: the target web hook
101
+ * context: encoded as GET parameters
102
+ */
103
+ function alert_http ($ data , $ context ) {
104
+ if (!isset ($ data ['url ' ])) {
105
+ die ("alert_http: missing url \n" );
106
+ }
107
+
108
+ $ url = $ data ['url ' ] . '? ' ;
109
+ $ first = true ;
110
+
111
+ foreach ($ context as $ k => $ v ) {
112
+ if ($ first ) {
113
+ $ first = false ;
114
+ } else {
115
+ $ url .= '& ' ;
116
+ }
117
+
118
+ $ url .= urlencode ($ k ) . '= ' . urlencode ($ v );
119
+ }
120
+
121
+ require_once ('checks.php ' );
122
+ $ result = check_http_helper (array ('url ' => $ url ));
123
+
124
+ if ($ result ['status ' ] == 'fail ' && isset ($ result ['message ' ])) {
125
+ echo "alert_http: error: {$ result ['message ' ]}\n" ;
126
+ }
127
+ }
128
+
96
129
?>
You can’t perform that action at this time.
0 commit comments