# Check Result Messages

Checks indicate if the resource under monitoring is OK or CRITICAL using the status code of the script. To provide more details, the check can return a result message.

Simply write the result message to the file $CHECKSON_DIR/message. CHECKSON_DIR is an environment variable that is set by the Checkson cloud executor when it runs your check.

Let's look at an example:

import sys
import random
import os

checkson_dir = os.environ['CHECKSON_DIR']


def write_message(message):
    with open(f"{checkson_dir}/message", "w") as f:
        f.write(message)


if random.random() > 0.5:
    print("Check successful")
    write_message("Check successful")
    sys.exit(0)
else:
    print("Check unsuccessful")
    write_message("Check unsuccessful")
    sys.exit(1)

This script creates a simple helper function (write_message) for writing to the $CHECKSON_DIR/message file.

The result message of the last executed run is displayed on the status page of the check. It is also included in notifications.

The complete example can be found on GitHub.