Status application written in rust.
This program is for running tests, and check the status of different test executables you write.
Communication is done over ZeroMQ.
You need to have rust installed to run this
$ git clone https://github.com/Aadniz/status.git
$ cd status
$ cargo run
Now it won't really do anything out of the box without a settings.json
file
To get started you need to make a settings.json
.
In this file, you define what executables should be run to test the status of
Template/Example:
{
"protocol": "tcp", // Can be tcp, ipc, pgm, epgm
"port": 5747,
"interval": 600, // Sets the global default interval for all service tests in seconds
"timeout": 15.0, // Global default timeout for all service tests in seconds
"pause_on_no_internet": true, // Do nothing when testing if there is no internet availability
"services": [
{
"name": "website_1",
"command": "commands/test_website_routing.py",
"args": [
"--my-arg", "argument"
],
"pause_on_no_internet": false // Overrides the default "pause_on_no_internet: true"
},
{
"name": "website_2",
"command": "commands/web2.sh"
},
{
"name": "vps",
"command": "commands/vps.py",
"timeout": 45, // Overrides the default timeout
"interval": 1800 // Overrides the default interval
},
{
"name": "something",
"command": "/path/to/my/executable"
}
]
}
The output of these tests must return one of these patterns:
Pattern | Description |
---|---|
Status code | The simplest form the status checker checks for a success or not is by pure status return code. If this is != 0, then it failed. |
Name-success-description | Displays a plain text result split by newline. First being name, second being if it succeeded, last is the description. To distinguish between multiple tests, you can use 2 newlines \n\n |
JSON output | The last way of writing a test script is using JSON. In the JSON you are required to have a name , success and result . |
Status code example:
$ ./path/to/program
$ echo $?
0 # Success
Name-success-description example:
Key | Type | Description |
---|---|---|
name | str | Providing the name of the test |
success | bool, int<0,1>, float<0.0, 1.0> | How successful was the test. Was it false /0 or true /1 .or maybe something within the test was wrong, and so you can use float in that case instead |
result | str | Some description of the result, can be as long as you want till it reached the end or hits \n\n which indicates a new test |
Status code gets ignored if it finds this pattern.
$ ./path/to/program
postgres
1
Postgres is up
web
true
It works
elasticsearch
1.0
it's up
bot
0.5
Bot is partially running!
This is not good
JSON output example:
Similarly to Name-success-description, the JSON output also requires these keys. The result
key can be whatever type supported by JSON.
Key | Type | Description |
---|---|---|
name | str | Providing the name of the test |
success | bool, int<0,1>, float<0.0, 1.0> | How successful was the test. Was it false /0 or true /1 .or maybe something within the test was wrong, and so you can use float in that case instead |
result | json | JSON object, number, string, bool, float, whatever supported by JSON. |
$ ./test_vps.py
[
{
"name": "test_hetzner_vps",
"success": true,
"result": 200
},
{
"name": "test_ovh_vps",
"success": false,
"result": 500
}
]
An example with different result
type:
$ ./test_website_routing.py
{
"name": "test_redirects_for_example_org",
"success": true,
"result": {
"ip": "82.153.138.97",
"return_code": 200,
"ping": 643,
"redirects": "example.org => https://example.org/"
}
}
Just outputting the object (not array) is also valid, it will be handled as a single item test
Lastly, this format is also valid, putting the name as the key:
{
"test_hetzner_vps": {
"success": true,
"result": 200
},
"test_ovh_vps": {
"success": false,
"result": 500
}
}
Communicating is done over ZeroMQ. There is an example script you can use in the daemon folder.
$ ./main.py version
$ ./main.py help
$ ./main.py settings
$ ./main.py service
$ ./main.py service website_1 website_2 vps something
Expected responds for checking services:
[
{
"name": "website_1",
"command": "commands/test_website_routing.py",
"successes": 1.0,
"result": [
{
"name": "example.org",
"success": 1.0,
"result": {
"ip": "82.153.138.97",
"ping": 643,
"redirects": "example.org => https://example.org/",
"return_code": 200
}
}
]
},
{
"name": "website_2",
"command": "/path/to/program",
"successes": 0.875,
"result": [
{
"name": "postgres",
"success": 1.0,
"result": "Postgres is up"
},
{
"name": "web",
"success": 1.0,
"result": "It works"
},
{
"name": "elasticsearch",
"success": 1.0,
"result": "it's up"
},
{
"name": "bot",
"success": 0.5,
"result": "Bot is partially running!\nThis is not good"
}
]
},
{
"name": "vps",
"command": "commands/vps.py",
"successes": 0.0,
"result": "signal: 15 (SIGTERM)"
},
{
"name": "something",
"command": "/path/to/my/executable",
"successes": 1.0,
"result": "yeah\n"
}
]