monit is showing syntax error even though python script running fine.

Issue #1048 closed
Venkata M created an issue

"Ubuntu 20.04.4 LTS"

below error its returning when we ran “monit -t”, even we included python shebang line too.

/etc/monit/conf.d/pagerduty-trigger-resolve.py:3: syntax error 'import'

our python script contains following script

#!/usr/bin/env python3

import requests
import json
import argparse
import sys
import hashlib
import os
import datetime

SERVICE_ID = 'PYY8IMS'
fromemailaddress = 'monit@pagerduty.com'
incstatus=""
import socket

Comments (3)

  1. Henning Bopp

    You cannot put a non-monit-configuration file into ubuntu/debian's /etc/monit/conf.d directory. ALL files inside this directory are used as config files. See the last lines of /etc/monit/monitrc on your Ubuntu host.

    Simply move the py-script into a directory outside conf.d and it should work... For sure you also have to alter the path inside the config file that uses this script.

  2. Log in to comment