Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Amonit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TeDomum
Amonit
Commits
016e007e
Commit
016e007e
authored
Mar 05, 2019
by
kaiyou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the very first http check and message notifier
parent
3ffc882e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
amonit/check/http.py
amonit/check/http.py
+9
-0
amonit/notifier/message.py
amonit/notifier/message.py
+13
-0
No files found.
amonit/check/http.py
0 → 100644
View file @
016e007e
import
requests
def
simple
(
url
,
expected_code
=
None
,
expected_string
=
None
):
req
=
requests
.
get
(
url
)
if
expected_code
and
req
.
status_code
!=
expected_code
:
raise
RuntimeError
(
"HTTP code should be {}"
.
format
(
expected_code
))
if
expected_string
and
string
not
in
req
.
text
:
raise
RuntimeError
(
"Result did not contain expected string"
)
amonit/notifier/message.py
0 → 100644
View file @
016e007e
from
matrix_client
import
client
as
matrix_client
from
amonit
import
util
def
mail
(
name
,
state
,
title
,
body
):
print
(
name
,
state
,
title
,
body
)
def
matrix_room
(
name
,
state
,
hs
,
token
,
roomid
,
message
):
matrix
=
matrix_client
.
MatrixHttpApi
(
hs
,
token
=
token
)
message
=
util
.
render
(
message
,
state
)
matrix
.
send_message
(
roomid
,
message
)
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