monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Starting & stopping applications depending on AC state


From: Tom Shirpen
Subject: RE: Starting & stopping applications depending on AC state
Date: Sat, 25 Oct 2014 08:38:39 +0000

Hi Martin,

Apologise for the late response.

I will try your suggestion and reply back if I encounter any issue.

Thanks!

Tom


From: address@hidden
Subject: Re: Starting & stopping applications depending on AC state
Date: Mon, 6 Oct 2014 11:30:53 +0200
To: address@hidden

Hi,

Monit executes the program directly - not via shell => you need to wrap it if you want to use pipe, etc.:

check program "/bin/bash -c 'upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -qP discharging'"
if status != 0 then exec "/usr/bin/systemctl start application_service"

Regards,
Martin


On 06 Oct 2014, at 06:53, Tom Shirpen <address@hidden> wrote:

Hi everyone,

I am new to monit and want to use it to run a couple of applications depending on the AC state of my laptop.

If my laptop is running on battery:

 then start a number of systemd services

if running on AC:

 stop a number of systemd services

I looked for inspiration in some of the existing examples but fail to properly set up a config. This is what I have so far:

check program upower -i /org/freedesktop/UPower/devices/battery_BAT0 " grep -qP "state:\s*discharging" if status != 0 then exec "/usr/bin/systemctl start application_service"

I would very much appreciate any advice on the right syntax!

Bests,

Tom
--
To unsubscribe:
https://lists.nongnu.org/mailman/listinfo/monit-general


-- To unsubscribe: https://lists.nongnu.org/mailman/listinfo/monit-general

reply via email to

[Prev in Thread] Current Thread [Next in Thread]