Я настоятельно рекомендовал бы nagvis отсюда. Это - огромный инструмент для отображения nagios данных (от нескольких nagios экземпляров, если Вы хотите к) значимым способом. У нас также есть такое ТВ на стене, и у нас есть приблизительно 10 различных карт (это похоже на страницы со схемами и значками на нем), вращающийся каждые 15 секунд. Это абсолютно волшебно.
Вам будет требоваться некоторое время для конфигурирования его, но результаты являются ошеломляющими. Снимки экрана на сайте являются только небольшим примером того, что может быть сделано. Если Вы имеете какие-либо вопросы об этом, просто начинаете говорить. У нас есть приблизительно 200 хостов и 800 сервисов в nagios через 3 сайта, таким образом, существует очень мало, я не сделал с nagios/nagvis.
Почему ваше приложение должно запускаться с помощью сценария bash
? Upstart должен знать, сколько раз ваше приложение разветвляется. Вы сказали ему, что он не разветвляется (поскольку вы не указали строфу « expect
»), но тем не менее, вы произвели разветвление (потому что вы указали « &
» в раздел скрипта. Следовательно, Upstart не может отслеживать PID.
См.:
This is what usually happens with daemon programs:
The problem is that Java doesn't provide a mechanism to fork, and so this tried and tested pattern cannot be implemented properly. When executing Java daemons you are forced to background the process immediately (i.e. the &
symbol in the script). Upstart essentially starts the process and then immediately forgets about it -- the process has no way of indicating to Upstart whether it successfully started up or not.
The only way around this is to start the process, background it, and then check whether it's still running in order to determine whether it was successful or not. The catch of course is determining when to check whether it's still running. The simple solution is something like this:
#!/bin/sh
java MyClass >/dev/null 2>&1 &
PID=$!
sleep 3
if kill -0 $PID; then
exit 0
else
exit 1
fi
There are more elaborate schemes to determine when to check the process, like making the program close stdout and stderr or create its PID file when it has finished its startup routine, and waiting for these events in the startup script.
The simplest solution for you is to modify your Upstart script to something like this:
script
cd /usr/lib/app-dir
nohup ./appStartScript.sh &> /dev/null &
PID=$!
sleep 3
if kill -0 $PID; then
emit app_running
exit 0
else
exit 1
fi
end script