Po dlouhe dobe jsem opet zkousel monitorovat stav http. Pouzivam
monit (1:5.9-1+deb8u1) v Debianu Jessie.
Pokud TVheadend bezi, vrati HTTP 302:
/usr/bin/curl -o /dev/null --silent --head --write-out '%{http_code}\n' rpi.lan:9981
302
Pokud nebezi, vrati HTTP 000 (nebo nic):
/usr/bin/curl -o /dev/null --silent --head --write-out '%{http_code}\n' rpi.lan:9981
000
Zkousel jsem:
check host rpi.lan with address rpi.lan
start program "/usr/bin/ssh pi@rpi.lan /usr/sbin/service tvheadend start"
stop program "/usr/bin/ssh pi@rpi.lan /usr/sbin/service tvheadend stop"
if failed
port 9981
protocol http
status != 302
then restart
Ale vzdy skonci s chybou:
Port Response time: connection failed to rpi.lan:9981 [HTTP via TCP]
Pak jsem zkousel:
check process tvheadend with path "/usr/bin/curl -o /dev/null --silent --head --write-out '%{http_code}\n' rpi.lan:9981"
start program "/usr/bin/ssh pi@rpi.lan /usr/sbin/service tvheadend start"
stop program "/usr/bin/ssh pi@rpi.lan /usr/sbin/service tvheadend stop"
protocol http
if status != 302 then restart
ale to se monit ani nespusti:
# systemctl status monit.service
● monit.service - LSB: service and resource monitoring daemon
Loaded: loaded (/etc/init.d/monit)
Active: failed (Result: exit-code) since Ne 2016-02-07 10:27:14 CET; 7s ago
Process: 31373 ExecStop=/etc/init.d/monit stop (code=exited, status=0/SUCCESS)
Process: 28851 ExecReload=/etc/init.d/monit reload (code=exited, status=0/SUCCESS)
Process: 31377 ExecStart=/etc/init.d/monit start (code=exited, status=1/FAILURE)
úno 07 10:27:14 server monit[31377]: Starting daemon monitor: monit/etc/monit/monitrc:293: syntax error 'protocol'
úno 07 10:27:14 server monit[31377]: failed!
Muzete mi nekdo prosim poradit, jak monitorovat HTTP pozadavek na host:port a overit, ze vrati status 302? V opacnem pripade vykona restart.