- edited description
Docker container HOST is 127.0.0.1, how to get to run the container in the real IP address?
Event:
Event: Content match
Service: US_dgateway_log_alert
Date: Thu, 09 Mar 2017 10:27:53
Action: alert
Host: 127.0.0.1
Description: content match:
Comments (12)
-
repo owner -
repo owner - edited description
-
repo owner Please can you provide more details?:
- Monit configuration
- network interfaces on the docker host
- describe what exactly you need to monitor
-
set daemon 30 with start delay 1 set logfile /var/log/monit/monit.log set pidfile /opt/monit/pid/monit.pid set idfile /opt/monit/id/.monit.id set statefile /opt/monit/state/.monit.state set ssl { verify : enable, # verify SSL certificates (disabled by default but STRONGLY RECOMMENDED) selfsigned : allow # allow self signed SSL certificates (reject by default) } set mailserver smtp.gmail.com port 587 username "gogogo" password "zzzzzzzzzzzzzzzz" using ssl,smtp.163.com port 465 username "gogogo" password "xxxxxxxxxxxxxxx" using SSLAUTO with timeout 15 seconds using hostname "163.com" set eventqueue basedir /opt/monit/event/monit slots 200 set mail-format { from: Monit <monitservice@gmail.com> subject: monit alert -- $EVENT $SERVICE message: :) Event: $EVENT Service: $SERVICE Date: $DATE Action: $ACTION Host: $HOST Description: $DESCRIPTION } check file monit_config_file path /opt/monit/conf/monitrc if changed sha1 checksum then exec "/opt/monit/bin/monit -c /opt/monit/conf/monitrc reload" check system $HOST group system if loadavg (1min) > 4 for 2 cycles then alert if loadavg (5min) > 2 for 2 cycles then alert if memory usage > 80% for 5 cycles then alert if swap usage > 65% then alert if cpu usage (user) > 95% for 4 times within 5 cycles then alert if cpu usage (system) > 85% for 4 times within 5 cycles then alert if cpu usage (wait) > 65% for 4 times within 5 cycles then alert check filesystem root with path / group system if space usage > 85% for 5 times within 15 cycles then alert check network public with interface eth0 if failed link then alert if changed link then alert if saturation > 90% then alert if download > 20 MB/s then alert if total upload > 100 GB in last hour then alert include /opt/monit/monit.s/*
-
Here's what I'm doing in the docker back to the details:
root@c6f6e22d5081:~# hostname -f c6f6e22d5081 root@c6f6e22d5081:~# hostname -i 172.10.0.6
As I understand, the monit variable $HOST should not be the result of the hostname -f return; and the response is the result of the hostname -i return.
-
repo owner Thank you for data.
Monit expands the $HOST to a name, which should match output of "hostname" command-line utility with no options.
When alert is triggered, the hostname is mapped to a FQDN name using getaddrinfo().
Please can you provide output of following commands?:
hostname hostname --all-fqdns grep c6f6e22d5081 /etc/hosts
-
from docker container, the output of following:
root@4c481dc8ed0b:~# hostname 4c481dc8ed0b root@4c481dc8ed0b:~# hostname --all-fqdns 4c481dc8ed0b root@4c481dc8ed0b:~# grep 4c481dc8ed0b /etc/hosts 172.10.0.5 4c481dc8ed0b root@4c481dc8ed0b:~#
-
repo owner -
I have been test, this issue not fix.
In fact, my idea is very simple, that is, in the docker container, when the alarm, Host docker IP, there are host IP.
Such as the host IP is: 10.0.4.9, started three docker, docker ip were 172.18.1.4, 172.18.1.5, 172.18.1.6
At this point when the docker container monit alarm, Host should be:
Host: 10.0.4.9_172.18.1.4 or Host: 10.0.4.9_172.18.1.5 or Host: 10.0.4.9_172.18.1.6
So that in a cluster environment it is easy to know which physical machine that a Docker alarm
-
repo owner adding custom hostname to monit configuration is simple, just use string instead of "$HOST" macro in "check system", for example:
check system "10.0.4.9_172.18.1.4"
-
OK, thanks
-
repo owner - changed status to resolved
- Log in to comment