Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
statuspage-notifications
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Systems
statuspage-notifications
Commits
b8b8b80f
Commit
b8b8b80f
authored
Feb 13, 2018
by
Ryan Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
guessing at options for building out function
parent
99e55274
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
44 deletions
+16
-44
statuspage-notifications/statuspage-notifications-command.conf
...spage-notifications/statuspage-notifications-command.conf
+16
-44
No files found.
statuspage-notifications/statuspage-notifications-command.conf
View file @
b8b8b80f
...
@@ -25,12 +25,7 @@ object NotificationCommand "statuspage-notifications-command" {
...
@@ -25,12 +25,7 @@ object NotificationCommand "statuspage-notifications-command" {
var
service_check_attempt
=
macro
(
"$service.check_attempt$"
)
var
service_check_attempt
=
macro
(
"$service.check_attempt$"
)
var
service_last_state
=
macro
(
"$service.last_state$"
)
var
service_last_state
=
macro
(
"$service.last_state$"
)
var
service_output
=
macro
(
"$service.output$"
)
var
service_output
=
macro
(
"$service.output$"
)
var
host_name
=
macro
(
"$host.name$"
)
var
service_component_name
=
macro
(
"$service.vars.statuspage_notifications_component$"
)
var
host_display_name
=
macro
(
"$host.display_name$"
)
var
host_state
=
macro
(
"$host.state$"
)
var
host_check_attempt
=
macro
(
"$host.check_attempt$"
)
var
host_last_state
=
macro
(
"$host.last_state$"
)
var
host_output
=
macro
(
"$host.output$"
)
var
notification_data
= {
var
notification_data
= {
"notification.type"
=
notification_type
,
"notification.type"
=
notification_type
,
"notification.author"
=
notification_author
,
"notification.author"
=
notification_author
,
...
@@ -42,56 +37,33 @@ object NotificationCommand "statuspage-notifications-command" {
...
@@ -42,56 +37,33 @@ object NotificationCommand "statuspage-notifications-command" {
"service.check_attempt"
=
service_check_attempt
,
"service.check_attempt"
=
service_check_attempt
,
"service.last_state"
=
service_last_state
,
"service.last_state"
=
service_last_state
,
"service.output"
=
service_output
,
"service.output"
=
service_output
,
"host.name"
=
host_name
,
"service.vars.statuspage_notifications_component"
=
service_component_name
,
"host.display_name"
=
host_display_name
,
"host.state"
=
host_state
,
"host.check_attempt"
=
host_check_attempt
,
"host.last_state"
=
host_last_state
,
"host.output"
=
host_output
,
}
}
log
(
LogDebug
,
"statuspage-notifications"
,
"Sending notification...read notification data successfully: "
+
Json
.
encode
(
notification_data
))
log
(
LogDebug
,
"statuspage-notifications"
,
"Sending notification...read notification data successfully: "
+
Json
.
encode
(
notification_data
))
log
(
LogDebug
,
"statuspage-notifications"
,
"Sending notification...generating notification text"
)
log
(
LogDebug
,
"statuspage-notifications"
,
"Sending notification...generating component state"
)
var
short_host_output
=
host_output
.
substr
(
0
,
plugin_output_max_length
)
var
component_status
=
"operational"
var
host_name_with_link
=
"<"
+
icinga2_base_url
+
"/monitoring/host/show?host="
+
host_name
+
"|"
+
host_display_name
+
">"
if
(
service_state
!=
''
) {
var
text
=
"error crafting payload"
component_status
=
"major_outage"
if
(
service_name
!=
null
) {
var
service_name_with_link
=
"<"
+
icinga2_base_url
+
"/monitoring/service/show?host="
+
host_name
+
"&service="
+
service_name
+
"|"
+
service_display_name
+
">"
var
short_service_output
=
service_output
.
substr
(
0
,
plugin_output_max_length
)
var
service_state_text
=
" transitioned from state "
+
service_last_state
+
" to state "
+
service_state
if
(
service_last_state
==
service_state
) {
service_state_text
=
" is still in state "
+
service_state
}
}
text
=
":"
+
icon
+
": "
+
notification_type
+
notification_type_custom_text
+
": Service "
+
service_name_with_link
+
service_state_text
+
" on host "
+
host_name_with_link
+
". Plugin output: ```"
+
short_service_output
+
"```"
var
component_id
=
component_map
[
service_component_name
]
}
else
{
log
(
LogDebug
,
"statuspage-notifications"
,
"Sending notification...generated component successfully: "
+
component_status
)
var
host_state_text
=
" transitioned from state "
+
host_last_state
+
" to state "
+
host_state
if
(
host_last_state
==
host_state
) {
host_state_text
=
" is still in state "
+
host_state
}
text
=
":"
+
icon
+
": "
+
notification_type
+
notification_type_custom_text
+
": Host "
+
host_name_with_link
+
host_state_text
+
". Plugin output: ```"
+
short_host_output
+
"```"
}
log
(
LogDebug
,
"statuspage-notifications"
,
"Sending notification...generated notification text successfully: "
+
text
)
log
(
LogDebug
,
"statuspage-notifications"
,
"Generating notification command"
)
log
(
LogDebug
,
"statuspage-notifications"
,
"Generating notification command"
)
var
payload_dictionary
= {
var
statuspage_payload
=
"component[status]="
+
component_status
"channel"
=
slack_channel
,
var
payload_argument
=
escape_shell_arg
(
statuspage_payload
)
"username"
=
slack_botname
,
var
statuspage_api_key_argument
=
escape_shell_arg
(
statuspage_api_key
)
"text"
=
text
var
statuspage_api_url_argument
=
escape_shell_arg
(
statuspage_api_url
+
"/components/"
+
component_id
+
".json"
)
}
var
payload_json
=
Json
.
encode
(
payload_dictionary
)
var
slack_payload
=
"payload="
+
payload_json
var
payload_argument
=
escape_shell_arg
(
slack_payload
)
var
slack_webhook_url_argument
=
escape_shell_arg
(
slack_webhook_url
)
var
cmd
= [
var
cmd
= [
"curl"
,
"curl"
,
"--fail"
,
"--fail"
,
"--connect-timeout"
,
"30"
,
"--connect-timeout"
,
"30"
,
"--max-time"
,
"60"
,
"--max-time"
,
"60"
,
"--silent"
,
"--show-error"
,
"--silent"
,
"--show-error"
,
"-X"
,
"P
OST
"
,
"-X"
,
"P
ATCH
"
,
"-H"
,
"'Authorization: OAuth "
+
statuspage_api_key
+
"'"
,
"-H"
,
"'Authorization: OAuth "
+
statuspage_api_key_argument
+
"'"
,
"-
-data-urlencode"
,
payload_argument
,
"-
d"
,
"component[status]="
+
payload_argument
,
statuspage_api_url
statuspage_api_url
_agrument
]
]
var
notification_command
=
cmd
.
join
(
" "
)
var
notification_command
=
cmd
.
join
(
" "
)
log
(
LogDebug
,
"statuspage-notifications"
,
"Generated notification command successfully: "
+
notification_command
)
log
(
LogDebug
,
"statuspage-notifications"
,
"Generated notification command successfully: "
+
notification_command
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment