I have been using monit
/mmonit
to monitor my system. One if its features is the check program
syntax, which runs a program and validates its return value:
# Asserts that there are more than 40 users in the DEV DB.
check program more_than_40_users_in_dev_db
with path /home/ubuntu/servers-scripts/monitoring/more_than_40_users_in_dev_db.py
with timeout 5 seconds
every 2 cycles
if status != 0 then alert
The problem is that the script should run as the user ubuntu
, but monit runs it as root
. I have tried the as uid ubuntu and gid ubuntu
syntax, but it does not seem to work for the check program
directive.
Is there a way to run this script as a specific user?