那么在下面的情况下是什么导致了这个错误呢?
- /etc/init.d/monit 存在
- 安装使用
sudo apt-get install monit
通过 apt 标准安装
vagrant@vagrant-ubuntu-trusty-64:~$ sudo apt-get install monit
Reading package lists... Done
Building dependency tree
Reading state information... Done
monit is already the newest version.
The following packages were automatically installed and are no longer required:
chef-zero erubis ohai ruby-diff-lcs ruby-erubis ruby-hashie ruby-highline
ruby-ipaddress ruby-mime-types ruby-mixlib-authentication ruby-mixlib-cli
ruby-mixlib-config ruby-mixlib-log ruby-mixlib-shellout ruby-net-ssh
ruby-net-ssh-gateway ruby-net-ssh-multi ruby-rack ruby-rest-client
ruby-sigar ruby-systemu ruby-yajl
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
/etc/init.d/monit
存在
vagrant@vagrant-ubuntu-trusty-64:~$ cat /etc/init.d/monit
#!/bin/sh
### BEGIN INIT INFO
# Provides: monit
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: service and resource monitoring daemon
# Description: monit is a utility for managing and monitoring
# processes, programs, files, directories and filesystems
# on a Unix system. Monit conducts automatic maintenance
# and repair and can execute meaningful causal actions
# in error situations.
### END INIT INFO
set -e
. /lib/lsb/init-functions
DAEMON=/usr/bin/monit
CONFIG=/etc/monit/monitrc
NAME=monit
DESC="daemon monitor"
MONIT_OPTS=
PID="/run/$NAME.pid"
# Check if DAEMON binary exist
[ -f $DAEMON ] || exit 0
[ -f "/etc/default/$NAME" ] && . /etc/default/$NAME
MONIT_OPTS="-c $CONFIG $MONIT_OPTS"
monit_not_configured () {
if [ "$1" != "stop" ]
then
printf "\tplease configure $NAME and then edit /etc/default/$NAME\n"
printf "\tand set the \"START\" variable to \"yes\" in order to allow\n"
printf "\t$NAME to start\n"
fi
exit 0
}
monit_checks () {
# Check if START variable is set to "yes", if not we exit.
if [ "$START" != "yes" ]
then
monit_not_configured $1
fi
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
monit_checks $1
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $MONIT_OPTS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
if start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
reload)
log_daemon_msg "Reloading $DESC configuration" "$NAME"
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID --exec $DAEMON -- $MONIT_OPTS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
start-stop-daemon --retry TERM/5/KILL/5 --oknodo --stop --quiet --pidfile $PID 1>/dev/null
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $MONIT_OPTS 1>/dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
;;
syntax)
$DAEMON $MONIT_OPTS -t
;;
status)
status_of_proc -p $PID $DAEMON $NAME
;;
*)
log_action_msg "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|syntax|status}"
;;
esac
exit 0
没有运行监控服务
vagrant@vagrant-ubuntu-trusty-64:~$ ps aux | grep monit
vagrant 7338 0.0 0.0 10460 936 pts/0 S+ 22:55 0:00 grep --color=auto monit
尝试启动 monit 服务,失败
vagrant@vagrant-ubuntu-trusty-64:~$ sudo service monit start
start: Unknown job: monit
vagrant@vagrant-ubuntu-trusty-64:~$ ps aux | grep monit
vagrant 7675 0.0 0.0 10460 932 pts/0 S+ 22:56 0:00 grep --color=auto monit
更新:2016 年 9 月 3 日
我正在使用 vagrant 创建运行 ubuntu/trusty 14.04 的虚拟机。
/etc/init.d/monit start
似乎有效
vagrant@vagrant-ubuntu-trusty-64:~$ sudo /etc/init.d/monit start
* Starting daemon monitor monit /etc/monit/conf.d/postfix.conf:11: Warning: hostname did not resolve 'INSERT_THE_RELAY_HOST'
[ OK ]
更新:2016-09-04
服务名称实际上是mmonit
,不是monit
。 :)
sudo service mmonit start
作品
答案1
服务名称实际上是mmonit
,不是monit
。 :)
sudo service mmonit start
作品