달력

11

« 2018/11 »

  •  
  •  
  •  
  •  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  •  

'Monitoring'에 해당되는 글 2

  1. 2018.10.10 리눅스 서버 모니터링 - 모니터릭스 monitorix
  2. 2017.02.28 Nagios - WeChat 연동

리눅스 서버 모니터링 - 모니터릭스 https://www.monitorix.org/




레드헷 계열 : EPEL (Extra Packages for Enterprise Linux) 에서 설치.
 

yum install -y htop iotop iptraf vmstat strace wget cpan

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum install --enablerepo=epel -y rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-MIME-Lite perl-CGI perl-DBI perl-XML-Simple perl-Config-General perl-HTTP-Server-Simple perl-IO-Socket-SSL


cd /usr/local/src
wget http://www.monitorix.org/monitorix-3.10.1-1.noarch.rpm
rpm -ivh monitorix-3.10.1-1.noarch.rpm
service monitorix start


chkconfig --level 35 monitorix on


/etc/monitorix/monitorix.conf 파일에서 사용 포트 수정.

아이디/비번 팝업 설정. 
mysql 이 있다면 사용하도록 수정.


서비스 시작.
 

service monitorix start



----------------------


우분투 계열
 

apt-get update
apt-get install rrdtool perl libwww-perl libmailtools-perl libmime-lite-perl librrds-perl libdbi-perl libxml-simple-perl libhttp-server-simple-perl libconfig-general-perl libio-socket-ssl-perl
wget http://www.monitorix.org/monitorix_3.10.1-izzy1_all.deb
dpkg -i monitorix_3.10.1-izzy1_all.deb


CPU Load 


MySQL Statistics


Netstat Statistics



참고 :
https://www.tecmint.com/monitorix-a-lightweight-system-and-network-monitoring-tool-for-linux/
https://www.monitorix.org/

Posted by 멋지다마라송
2017.02.28 13:03

Nagios - WeChat 연동 Tech/Linux2017.02.28 13:03

나기오스 - 위챗 연동.


Nagios 整合微信订阅号报警

环境:rhel6.5 selinux 和 iptables 关闭。要求能上外网的(虚拟机亲测可用)
以下是nagios服务与微信订阅号的整合过程,最终实现当服务或主机出现故障,自动调用微信报警。
重点讲述如何配置微信公众平台私有接口,至于nagios服务的配置请大家参照nagios官方文档进行,此处不再赘述。(www.nagios.org

1. 下载微信公众平台私有接口
# yum install -y git
# git clone https://github.com/lealife/WeiXin-Private-API

2. 修改微信公众平台私有接口代码,以配合nagios报警

# cp -r WeiXin-Private-API /usr/local/nagios/libexec/weixin
# chown -R nagios.nagios /usr/local/nagios/libexec/weixin
# cd /usr/local/nagios/libexec/weixin

修改config.php文件:

$G_CONFIG["weiXin"] = array(

        'account' => '微信公众平台登录帐号',#填写你注册的微信订阅号的帐号和密码

        'password' => '微信公众平台登录密码',

修改test.php文件,只保留如下几行即可:

<?php
require "config.php";
require "include/WeiXin.php";

$weiXin = new WeiXin($G_CONFIG['weiXin']);

$testFakeId = "$argv[1]";#微信好友ID号,这里通过nagios传入

$msg = `cat /usr/local/nagios/var/nagios.msg`;#要发送的报警信息,由nagios传入

print_r($weiXin->send($testFakeId, "$msg"));#给微信好友发送信息

3. 整合nagios和微信公共平台私有接口

1) 增加微信报警选项: templates.cfg

修改 /usr/local/nagios/etc/objects/templates.cfg

在 define contact{...} 部分,将以下两行:
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email

改为:

host_notification_commands notify-host-by-email,notify-host-by-weixin
service_notification_commands notify-service-by-email,notify-service-by-weixin


2) 增加调用命令: commands.cfg

修改 /usr/local/nagios/etc/objects/commands.cfg

在该文件的最后增加以下部分:

##### notify-host-by-weixin command definition
define command{
command_name notify-host-by-weixin
command_line
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" > /usr/local/nagios/var/nagios.msg && /usr/bin/php /usr/local/nagios/libexec/weixin/test.php $CONTACTADDRESS1$  &>/dev/null
}

##### notify-service-by-weixin command definition
define command{
command_name notify-service-by-weixin
command_line
/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" > /usr/local/nagios/var/nagios.msg && /usr/bin/php /usr/local/nagios/libexec/weixin/test.php $CONTACTADDRESS1$  &> /dev/null

3) 修改联系人选项: contact.cfg

修改 /usr/local/nagios/etc/objects/contact.cfg
在 define contact{...} 部分增加如下一行

address     11206***#微信好友ID,登录微信公众平台网页版,在用户管理中点击你要发微信的好友,此时在地址上显示的fakeid就是微信好友的ID。

4) 重载nagios配置

# service nagios reload


'Tech > Linux' 카테고리의 다른 글

nmap 옵션  (0) 2017.08.24
Dshield, Grafana - DDos Defender  (0) 2017.03.17
centos nagios 설치  (0) 2017.03.14
bash 배시 자주 사용하는 함수 - 날짜함수, 변수 입력받기 등  (0) 2017.03.08
Nagios - WeChat 연동  (0) 2017.02.28
리눅스 구버전 php 다운로드  (0) 2017.02.20
Posted by 멋지다마라송


티스토리 툴바