4

Using Centos 6.4, using a yum installed Monit 5.5.

I have 2 servers with monit installed - same version, same config - but one binds on all addresses and the other only binds on the localhost.

Problem server:

# service monit restart
Stopping monit:                                            [  OK  ]
Starting monit: Starting monit daemon with http interface at [localhost:8080]
                                                           [  OK  ]

Good server:

# service monit restart
Stopping monit:                                            [  OK  ]
Starting monit: Starting monit daemon with http interface at [*:8080]
                                                           [  OK  ]

The config is this:

set httpd port 8080
  allow fofo:sdad
  allow fdgdfg:dsfsdf
  SSL ENABLE
  PEMFILE  /var/certs/monit.pem
  signature disable

I am guessing the issue is some network misconfiguration of the problem server - hence it cant bind on the external port - but then other things are working ok - http, ssh etc...

UPDATE Some more info - thanks for the comments: Problem box:

# rpm -qi monit
Name        : monit                        Relocations: (not relocatable)
Version     : 5.5                               Vendor: Dag Apt Repository, http://dag.wieers.com/apt/
Release     : 1.el6.rf                      Build Date: Wed 20 Mar 2013 02:09:54 PM WET
Install Date: Sat 04 May 2013 09:30:54 PM WEST      Build Host: lisse.hasselt.wieers.com
Group       : Applications/Internet         Source RPM: monit-5.5-1.el6.rf.src.rpm
Size        : 716992                           License: GPLv3
Signature   : DSA/SHA1, Wed 20 Mar 2013 03:59:25 PM WET, Key ID a20e52146b8d79e6
Packager    : Steve Huff <shuff@vecna.org>
URL         : http://mmonit.com/monit/
Summary     : Process monitor and restart utility
Description :
Monit is an utility for monitoring daemons or similar programs running on
a Unix system. It will start specified programs if they are not running
and restart programs not responding.

Working box:

# rpm -qi monit
Name        : monit                        Relocations: (not relocatable)
Version     : 5.5                               Vendor: Dag Apt Repository, http://dag.wieers.com/apt/
Release     : 1.el6.rf                      Build Date: Wed 20 Mar 2013 02:09:54 PM WET
Install Date: Fri 22 Mar 2013 04:02:32 AM WET      Build Host: lisse.hasselt.wieers.com
Group       : Applications/Internet         Source RPM: monit-5.5-1.el6.rf.src.rpm
Size        : 716992                           License: GPLv3
Signature   : DSA/SHA1, Wed 20 Mar 2013 03:59:25 PM WET, Key ID a20e52146b8d79e6
Packager    : Steve Huff <shuff@vecna.org>
URL         : http://mmonit.com/monit/
Summary     : Process monitor and restart utility
Description :
Monit is an utility for monitoring daemons or similar programs running on
a Unix system. It will start specified programs if they are not running
and restart programs not responding.

/etc/hosts looks pretty similar between them, like this:

cat /etc/hosts
# Automatically generated by ptisp cloud
127.0.0.1       localhost
x.x.x.x             [hostname]

Problem box:

# netstat -tln | grep ":8080"
tcp        0      0 127.0.0.1:8080              0.0.0.0:*                   LISTEN

Working box:

# netstat -tln | grep ":8080"
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN

Also ran 'ip addr' and its output looks pretty similar between a working and non-working box.

UPDATE 2

Just added M/monit to the mix tonight and this box strangely shows up twice, once inactive. I am thinking this is because the m/monit server cannot ping the client back...

Thanks in advance for any ideas. Chris

Chris Kimpton
  • 713
  • 9
  • 18
  • 1
    You may have already done so but just in case: Try doing `sudo ip addr` and make sure that the interface is up. – Belmin Fernandez May 07 '13 at 17:47
  • 1
    Just out of curiosity, is there any difference between the /etc/hosts files on the two systems? – Zoredache May 16 '13 at 17:18
  • 1
    What output of command `netstat -tln | grep ":8080"`? – cuonglm May 16 '13 at 17:31
  • 1
    Please provide the version from `rpm -qi monit` – ewwhite May 16 '13 at 17:53
  • 2
    Check that `~/.monit.conf` does not exist — this location is searched before `/etc/monit.conf` even for root. (Upstream version of Monit uses `~/.monitrc` and `/etc/monitrc`, but this particular package uses different config file names.) – Sergey Vlasov May 16 '13 at 20:58
  • Thanks @SergeyVlasov - that was it - the /etc/monit.conf file specified a localhost only webservice :). My config in /etc/monit.d/ was then being ignored :( - strangely, I dont remember altering this on the other box... - feel free to make this an answer and I'll give you the bounty :). – Chris Kimpton May 17 '13 at 12:25
  • 1
    Posted an answer with a more complete description of the search order (strange, I did not see your comment in my inbox). Also note the part about the postinstall script — it might explain your problems if you had `/etc/monitrc` there for some reason. – Sergey Vlasov May 18 '13 at 20:02

2 Answers2

4

If the Monit behavior does not match what is written in the configuration file, one possible cause may be that Monit actually uses a different configuration file.

The /etc/rc.d/init.d/monit script in the monit-5.5-1.el6.rf package starts monit without specifying the configuration file name, therefore Monit tries to find the configuration file in several places and uses the first one that is found. Another important thing is that the default configuration file name in this package is different from the one used by the unmodified upstream version of Monit — upstream uses monitrc, but the package from RepoForge uses monit.conf.

The search order used for the configuration file is as follows:

  1. ~/.monitrc in the upstream version of Monit, or ~/.monit.conf in the RepoForge package (the home directory of the user which started monit is used; if Monit is started from the init script, the user is root). The home directory is read using getpwuid(geteuid()) (i.e., from /etc/passwd or any other NSS database), not from the HOME environment variable.

  2. /etc/monitrc in the upstream version of Monit, or /etc/monit.conf in the RepoForge package. If the RepoForge package is used, /etc/monit.conf initially contains an uncommented include line, which causes Monit to read additional configuration files from the /etc/monit.d directory:

    include /etc/monit.d/*
    

    In the upstream sources the example monitrc file has this line commented out, therefore no additional configuration files are used by default.

    Note also that the RepoForge package has a postinstall script:

    # Moving old style configuration file to conf standard location
    if [ -f /etc/monitrc ]; then
        mv -f /etc/monitrc /etc/monit.conf
    fi
    

    Therefore, if the /etc/monitrc file exists before the package installation or upgrade, this file will be renamed to /etc/monit.conf, silently overwriting it.

  3. $SYSCONFDIR/monitrc in the upstream version of Monit, where $SYSCONFDIR is the value of the --sysconfdir=... option passed to the configure script when compiling the source (the default value of this option is $prefix/etc, as usual with Autoconf-generated configure scripts, and the default prefix is /usr/local, so the configuration file name becomes /usr/local/etc/monitrc). In the RepoForge package this file name becomes /etc/monit.conf, making it redundant.

  4. /usr/local/etc/monitrc in the upstream version of Monit, or /usr/local/etc/monit.conf in the RepoForge package. Here the /usr/local/etc directory is hardcoded and does not depend on any configure options.

  5. ./monitrc in the upstream version of Monit, or ./monit.conf in the RepoForge package (when starting from the init script, the current directory is likely to be /).

Sergey Vlasov
  • 6,088
  • 1
  • 19
  • 30
  • Wow - thanks for the great reply, was only expecting a copy/paste of the comment :) And the point about the post-install script. – Chris Kimpton May 19 '13 at 11:27
1

Check that ~/.monit.conf does not exist — this location is searched before /etc/monit.conf even for root. (Upstream version of Monit uses ~/.monitrc and /etc/monitrc, but this particular package uses different config file names.)

Scott Pack
  • 14,717
  • 10
  • 51
  • 83
Joel E Salas
  • 5,562
  • 15
  • 25