From 88a1bce545f0879e96715fac739257c0ee0c9a30 Mon Sep 17 00:00:00 2001 From: Faelix Incident Handler Date: Fri, 15 Jun 2018 22:15:46 +0000 Subject: [PATCH] add some help and incident commander guidance --- fih.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/fih.py b/fih.py index fe2184a..b4a4958 100644 --- a/fih.py +++ b/fih.py @@ -2,6 +2,7 @@ from flask import Flask, request import os import incident +import datetime app = Flask( __name__ ) app.config.from_envvar( 'FIH_SETTINGS' ) @@ -33,8 +34,8 @@ def mattermost_incident(): channel = app.mm.channels.create_channel( options = { "team_id": request.form[ 'team_id' ], "name": channel_name, "display_name": fi_number, - "purpose": "Internal discussion about incident " + fi_number, - "header": purpose, + "purpose": purpose, + "header": "", "type": "O", } ) @@ -42,11 +43,52 @@ def mattermost_incident(): app.mm.client.make_request( 'post', '/channels/' + channel[ 'id' ] + '/members', options = { 'user_id': request.form[ 'user_id' ], } ) app.mm.posts.create_post( options = { 'channel_id': channel[ 'id' ], - 'message': "Incident Channel for %s created by @%s" % ( fi_number, request.form[ 'user_name' ] ), + 'message': "Incident discussion channel for [%s](https://status.faelix.net/incident/%s) created by @%s." % ( fi_number, incident_number, request.form[ 'user_name' ] ), + } ) + + now = datetime.datetime.utcnow().strftime( "%Y-%m-%dT%H:%M:%S" ) + + app.mm.posts.create_post( options = { 'channel_id': channel[ 'id' ], + 'message': """\ +# Incident Response Communication Procedure + +The contents of this channel are strictly confidential. + +## Public Announcement + +1. adjust the name of the incident with **/purpose** +2. adjust the description of the incident with **/header** +3. choose a front page status (see below) +4. publish https://status.faelix.net/incident/%(incident_number)s with **@FIH PUBLISH** + +## Status Updates + +* add an update: **@FIH TIMELINE** _text_ +* set the incident start: **@FIH START** _%(now)s_ (UTC) +* set the incident ETR: **@FIH ETR** _%(now)s_ (UTC) +* set the incident resolved time: **@FIH RESOLVED** _%(now)s_ (UTC) +* set the incident finished time: **@FIH CLOSED** _%(now)s_ (UTC) + +Again, don't forget to **@FIH PUBLISH** once making changes. + +## Front Page Status + +* **@FIH INCIDENT** +* **@FIH DEGRADED** +* **@FIH MAINTENANCE** +* **@FIH NOTICE** +* **@FIH OK** + +Again, after setting the headline status you must: **@FIH PUBLISH** + +## Good luck, Incident Commander @%(commander_name)s!""" % { "incident_number": incident_number, + "commander_name": request.form[ 'user_name' ], + "now": now, + }, } ) app.mm.posts.create_post( options = { 'channel_id': request.form[ 'channel_id' ], - 'message': 'Starting incident %s with discussion in channel ~%s' % ( fi_number, channel_name, ), + 'message': 'On behalf of @%s I have started incident ~%s.' % ( request.form[ 'user_name' ], channel_name, ), } ) return ""