log-checker checks journal logs for siad. Arguments: 1. path to a .env file (default is none so env variables can already be preset) 2. systemd service name (default: "siad") 3. number of hours to look back in log (used as --since value in journalctl command) (default: 1 hour) """ DEFAULT_CHECK_INTERVAL = timedelta(hours=1) bot_token = setup() client = discord.Client() @client.event async def on_ready(): await run_checks() await client.close() async def run_checks(): print("Running Skynet portal log checks") try: await check_journal() except: # catch all exceptions
CHECK_HOURS = int(sys.argv[3]) # Discord messages have a limit on their length set at 2000 bytes. We use # a lower limit in order to leave some space for additional message text. DISCORD_MAX_MESSAGE_LENGTH = 1900 GB = 1 << 30 # 1 GiB in bytes # Free disk space threshold used for notices and shutting down siad. FREE_DISK_SPACE_THRESHOLD = 100 * GB FREE_DISK_SPACE_THRESHOLD_CRITICAL = 60 * GB # Disk usage dump log file (relative to this .py script). DISK_USAGE_DUMP_LOG = "../../devops/disk-monitor/disk-usage-dump.log" setup() async def run_checks(): print("Running Skynet portal health checks") try: await check_load_average() await check_disk() await check_health() await check_alerts() await check_portal_size() except: trace = traceback.format_exc() print("[DEBUG] run_checks() failed.") await send_msg( "Failed to run the portal health checks!",