标签:需要 utf-8 emc ase rac 自定义模板 nat 出现 汇报
服务端配置
安装zabbix源,官网下载地址www.zabbix.com/download
[root@localhost ~]# wget https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
[root@localhost ~]# rpm -ivh zabbix-release-4.0-2.el7.noarch.rpm
安装zabbix
[root@localhost ~]# yum install -y zabbix-agent zabbix-get zabbix-server-mysql zabbix-web-mysql
mysql配置
[root@localhost ~]# vim /etc/my.cnf
character_set_server = utf8
[root@localhost ~]# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘password‘;
mysql> quit
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
zabbix配置
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
DBPassword=password
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
[root@localhost ~]# systemctl start zabbix-server zabbix-agent httpd
[root@localhost ~]# systemctl enable zabbix-server zabbix-agent httpd
浏览器输入ip/zabbix,初始化zabbix
用户名Admin 密码zabbix
进入后台第一件事情就是修改密码
客户端配置
安装zabbix源,官网下载地址www.zabbix.com/download
[root@localhost ~]# wget https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
[root@localhost ~]# rpm -ivh zabbix-release-4.0-2.el7.noarch.rpm
安装zabbix
[root@localhost ~]# yum install -y zabbix-agent
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.32.10 //定义服务端的ip(被动模式)
ServerActive=192.168.32.10 //定义服务端的ip(主动模式)
Hostname=aming-01 //这是自定义的主机名,一会还需要在web界面下设置同样的主机名
[root@localhost ~]# systemctl start zabbix-agent
[root@localhost ~]# systemctl enable zabbix-agent
[root@localhost ~]# mysql -u root -p
mysql> use zabbix;
mysql> update users set passwd=md5(‘newpasswd’) where alias=‘Admin’;
添加主机群组
添加主机
添加模板
取消链接,让原先模板的内容保留
删除我们不需要的应用集、监控项、触发器、图形、自动发现、web监测,保留以下监控项即可
设置为中文后,zabbix图形的中文文字会显示小方框,这是因为在zabbix的字体库中没有中文字体
需要从windows上借用一个过来,windows字体路径为“C:\Windows\Fonts”,上传到linux的/usr/share/zabbix/fonts/,并重新软连接
[root@localhost ~]# cd /usr/share/zabbix/fonts
[root@localhost fonts]# ll
total 17788
lrwxrwxrwx. 1 root root 33 Oct 20 20:46 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r--. 1 root root 18214472 Oct 21 21:37 simsun.ttc
[root@localhost fonts]# mv graphfont.ttf graphfont.ttf.bak
[root@localhost fonts]# ln -s simsun.ttc graphfont.ttf
[root@localhost fonts]# ll
total 17788
lrwxrwxrwx. 1 root root 10 Oct 21 21:38 graphfont.ttf -> simsun.ttc
lrwxrwxrwx. 1 root root 33 Oct 20 20:46 graphfont.ttf.bak -> /etc/alternatives/zabbix-web-font
-rw-r--r--. 1 root root 18214472 Oct 21 21:37 simsun.ttc
修改一下自动发现规则
在图形中就会自动出现
客户端配置
[root@localhost ~]# vim /usr/local/sbin/estab.sh
#!/bin/bash
##获取80端口并发连接数
netstat -ant |grep ‘:80 ‘ |grep -c ESTABLISHED
[root@localhost ~]# chmod 755 /usr/local/sbin/estab.sh
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
UnsafeUserParameters=1
UserParameter=my.estab.count[*],/usr/local/sbin/estab.sh
[root@localhost ~]# systemctl restart zabbix-agent
服务端验证
[root@localhost ~]# zabbix_get -s 192.168.133.132 -p 10050 -k ‘my.estab.count‘
0
服务端配置
添加监控项、图形,有需要可以配置触发器
web创建邮件告警
{ALERT.SENDTO} ,{ALERT.SUBJECT},{ALERT.MESSAGE}
创建mail.py脚本
[root@localhost ~]# vim /usr/lib/zabbix/alertscripts/mail.py
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
import os,sys
reload(sys)
sys.setdefaultencoding(‘utf8‘)
import getopt
import smtplib
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
from subprocess import *
def sendqqmail(username,password,mailfrom,mailto,subject,content):
gserver = ‘smtp.163.com‘
gport = 25
try:
# msg = MIMEText(unicode(content).encode(‘utf-8‘)) //如果发送的邮件有乱码,可以尝试把这行改成如下:
msg = MIMEText(content,‘plan‘,‘utf-8‘)
msg[‘from‘] = mailfrom
msg[‘to‘] = mailto
msg[‘Reply-To‘] = mailfrom
msg[‘Subject‘] = subject
smtp = smtplib.SMTP(gserver, gport)
smtp.set_debuglevel(0)
smtp.ehlo()
smtp.login(username,password)
smtp.sendmail(mailfrom, mailto, msg.as_string())
smtp.close()
except Exception,err:
print "Send mail failed. Error: %s" % err
def main():
to=sys.argv[1]
subject=sys.argv[2]
content=sys.argv[3]
sendqqmail(‘test@163.com‘,‘aaaaaaaaaa‘,‘test@163.com‘,to,subject,content)
if __name__ == "__main__":
main()
[root@localhost ~]# chmod 755 /usr/lib/zabbix/alertscripts/mail.py
web修改用户组权限
创建用户
创建动作
标签:需要 utf-8 emc ase rac 自定义模板 nat 出现 汇报
原文地址:https://www.cnblogs.com/2KP2/p/9829175.html