`
sillycat
  • 浏览: 2486836 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts

 
阅读更多
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts

We can visit the page URL on all the instances
http://rancher-home:2812/

Get some XML feed back as follow:
http://rancher-home:2812/_status?format=xml

Run the command as sudo/root
cat haproxy
check process haproxy with pidfile /opt/haproxy/haproxy.pid
  start program = "/bin/sh -c '/opt/haproxy/sbin/haproxy -f /opt/haproxy/conf/haproxy.conf'" with timeout 20 seconds
  stop program = "/usr/bin/kill haproxy"
  if changed pid then restart

Email Configuration
set mailserver smtp.gmail.com port 587
    username "luohuazju@gmail.com" password “xxxxxxxxxx"
    using tlsv1
    with timeout 30 seconds
set alert luohuazju@gmail.com

set mail-format {
   from: luohuazju@gmail.com
   subject: monitor alert - [$SERVICE] $EVENT
   message:
          [$SERVICE] $EVENT
          Date: $DATE
          Action: $ACTION
          Host: $HOST
          Description: $DESCRIPTION
   Best regards.
                            from Monitor
}

Reload the service
> sudo monit reload

Exception
[CDT Oct 17 20:05:46] error    : Mail: Mailserver response error -- 534-5.7.9 Application-specific password required. Learn more at
[CDT Oct 17 20:05:46] error    : SMTP: Mailserver response error -- 534 5.7.9  https://support.google.com/mail/?p=InvalidSecondFactor v10sm1094726otk.17 - gsmtp
[CDT Oct 17 20:05:46] error    : Aborting event

Solution:
Go to google account [Security] —> [Signing to Google] —> [Password] —> [App password] generate one for MAC Server

Check the logging
> tail -f /var/log/monit.log

We can manually kill the haproxy to see the alert emails.

Check this UI Tool
https://github.com/adriaaah/monit-dashboard

> sudo yum install epel-release
> sudo yum install python-pip
> sudo pip install --upgrade pip
> sudo pip install web.py
> sudo yum install python-requests python-xmltodict python-simplejson

> git clone https://github.com/adriaaah/monit-dashboard
> cd monit-dashboard/
> cp conf/servers.json.example conf/servers.json

> ./bin/monit-dashboard.py
It seems not working because of the Python Version

Since we want to migrate all the things to Python3, install and prepare python3
Install PYENV from the latest github
> git clone https://github.com/pyenv/pyenv.git ~/.pyenv

Add to the PATH
> vi ~/.bash_profile
PATH=$PATH:$HOME/.pyenv/bin
eval "$(pyenv init -)"
> . ~/.bash_profile

Check installation
>  pyenv -v
pyenv 1.2.14-5-g68a77df

Install the Python3 and Python2
> pyenv install 3.6.0
> pyenv install 2.7.10


Check all the versions, latest is 3.7.4, install some other versions
https://www.python.org/downloads/
> sudo yum install libffi-devel
>sudo yum install sqlite-devel
> sudo yum install bzip2-devel

>  pyenv install 3.8.0

> pyenv versions
* system (set by /home/carl/.pyenv/version)
  3.8.0

> pyenv global 3.8.0

>  python -V
Python 3.8.0


> pip install web.py
> pip install requests
> pip install xmltodict
> pip install simplejson
> python ./bin/monit-dashboard.py
http://0.0.0.0:8080/

Not working at all, I may need to do something similar here myself.
http://webpy.org/install
https://github.com/adriaaah/monit-dashboard

References:
https://imil.net/blog/2016/03/16/Fetch-monit-status-in-JSON/
http://webpy.org/
https://github.com/adriaaah/monit-dashboard
https://serverfault.com/questions/432053/monit-http-based-api/764226
https://serverfault.com/questions/709931/monit-cant-restart-nginx

email
https://my.oschina.net/HeAlvin/blog/918177
https://gist.github.com/jcdarwin/fa9235dd48276f348cc7
https://serverfault.com/questions/635139/how-to-fix-send-mail-authorization-failed-534-5-7-14
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics