zoukankan      html  css  js  c++  java
  • Zabbix

    Zabbix3.4.7部署
    系统环境:CentOs7.2
    1.关闭selinux
    1.1 [root@localhost ~]# setenforce 0 #临时关闭
    1.2 [root@localhost ~]# vi /etc/selinux/config #将selinux=enforcing改为SELINUX=disabled #永久关闭
     
    2.关闭防火墙
    2.1 [root@localhost ~]# systemctl stop firewalld.service #停止防火墙
    2.2 [root@localhost ~]# systemctl disable firewalld.service #禁止开机自启动
     
    3.zabbix3.4程序安装
    3.1 配置zabbix的yum源
    [root@localhost ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
    3.2安装zabbix程序包,安装mysql、zabbxi-agent
    [root@localhost ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server
    3.3启动mariadb并设置开机启动,创建数据库实例,授权
    [root@localhost ~]# systemctl start mariadb #启动mariadb
    [root@localhost ~]# systemctl enable mariadb #设置开机启动
    [root@localhost ~]# mysql #登入数据库
    MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
    #创建数据库实例
    Query OK, 1 row affected (0.00 sec)
    MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';
    #授权所有主机访问数据库实例zabbix,用户名/密码:zabbix/zabbix
    Query OK, 0 rows affected (0.00 sec)
    MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
    #授权localhost主机名访问数据库实例zabbix,用户名/密码:zabbix/zabbix
    Query OK, 0 rows affected (0.00 sec)
    MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost.localdomain identified by 'zabbix'; #授权localhost.localdomain主机访问数据库实例zabbix,用户名/密码:zabbix/zabbix
    Query OK, 0 rows affected (0.00 sec)
     
    4.导入初始模式和数据
    4.1 进入create.sql.gz所在目录
    [root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.4/
    4.2 导入出事模式
    [root@localhost zabbix-server-mysql-3.4.4]# zcat create.sql.gz |mysql -uroot zabbix
     
    5.启动zabbix-server服务
    5.1 启动zabbix-server服务
    [root@localhost zabbix-server-mysql-3.4.4]# systemctl start zabbix-server
    5.2 设置zabbix-server服务开机自启动
    [root@localhost zabbix-server-mysql-3.4.4]# systemctl enable zabbix-server
    ou
    6.编辑Apache的配置文件,消注释设置正确的时区
    [root@localhost zabbix-server-mysql-3.4.4]# vi /etc/httpd/conf.d/zabbix.conf
    php_value max_execution_time 300
    php_value memory_limit 128M
    php_value post_max_size 16M
    php_value upload_max_filesize 2M
    php_value max_input_time 300
    php_value always_populate_raw_post_data -1
    php_value date.timezone Asia/Shanghai
     
    7.启动httpd服务 ,设置开机启动httpd服务
    7.1 启动httpd服务
    [root@localhost ~]# systemctl start httpd
    7.2 设置开机启动httpd服务
    [root@localhost ~]# systemctl enable httpd
     
    8.zabbix Web网页安装
    8.1 在浏览器输入地址http://服务器ip/zabbix/setup.php,出现欢迎界面,点击下一步;
    8.2 出现必要条件检测界面,正常都是OK,点击下一步;
     
    8.3 配置DB连接,与zabbix_server.conf文件中主机、数据库名称、用户名、密码保持一致,点击下一步;
    8.4 zabbix服务器详细信息,点击下一步;
     
    8.5 安装前汇总,检查信息无误,点击下一步安装;
     
    8.6 安装成功;
    Congratulations! You have successfully installed Zabbix frontend.
    配置文件目录
    Configuration file "/etc/zabbix/web/zabbix.conf.php" created.
    8.7 在浏览器输入http://zabbix服务器ip/zabbix/index.php,输入管理员用户名Admin(区分大小写),默认密码zabbix,点击登入即可。
     
     
     
     
    解决图形界面乱码
    1. 控制面板-->字体-->选择一种中文字体 例如”楷体“ (simkai.ttf)
    2. 将我们下载好的字体上传到zabbix server端的/usr/share/zabbix/fonts目录下
    3. 修改/usr/share/zabbix/include/defines.inc.php文件中字体的配置,将里面graphfont替换成simkai
     
    4. 保存退出之后重新刷新界面即可正常显示
     
     
     
    zabbix邮件报警
    1. 安装软件包
    [root@localhost ~]# yum -y install mailx
    2. 给/bin目录下设置权限
    [root@localhost ~]# Chown -R zabbix.zabbix /bin/mail
    3. 编辑/etc/mail.rc
    [root@localhost ~]# vim /etc/mail.rc
    set from=15810060392@163.com
    set smtp=smtp.163.com
    set smtp-auth-user=15810060392@163.com #邮箱账号
    set smtp-auth-password=cheng12345 #客户端授权码
    set smtp-auth=login
    4. 测试mailx配置是否有问题
    [root@localhost ~]# echo test | mail -s "my name is chengwangan" 15810060392@163.com #此收件箱为收邮件
    5. 编辑zabbix_server.conf,配置脚本存放目录
    [root@localhost zabbix]# cd /etc/zabbix/
    [root@localhost zabbix]# vim zabbix_server.conf
    AlertScriptsPath=/usr/lib/zabbix/alertscripts #这里我选择默认目录
    6. 编辑邮件脚本
    [root@localhost zabbix]# vim /usr/lib/zabbix/alertscripts/mailx.sh
    #!/bin/bash
    messages=`echo $3 | tr ' ' ' '`
    subject=`echo $2 | tr ' ' ' '`
    echo "${messages}" | mail -s "${subject}" $1 >>/tmp/mailx.log 2>&1
    7. 增加可执行权限并测试,邮件日志可以在 /tmp/mailx.log 看到
    [root@localhost ~]# touch /tmp/mailx.log
    [root@localhost ~]# chmod 777 /tmp/mailx.log
    [root@localhost ~]# chown -R zabbix.zabbix /tmp/mailx.log
    [root@localhost ~]# chmod -x /usr/lib/zabbix/alertscripts/mailx.sh
    [root@localhost ~]# chown -R zabbix.zabbix /usr/lib/zabbix/
    8. 测试脚本邮件能否正常发送
    [root@localhost alertscripts]# sh mailx.sh 15810060392@163.com
    9. zabbix web界面配置
    管理-->报警媒介类型-->创建媒体类型
    三个必要参数:
    {ALERT.SENDTO}
    {ALERT.SUBJECT}
    {ALERT.MESSAGE}
     
    10. 用户报警配置
    管理-->用户-->Admin-->报警媒介-->添加
     
     
    11. 添加报警动作
    配置-->动作-->创建动作
    默认接收人:{TRIGGER.STATUS}: {TRIGGER.NAME}
    主机:{HOST.NAME}
    IP:{HOST.IP}
    Trigger:{TRIGGER.NAME}
    Trigger status:{TRIGGER.STATUS}
    Trigger severity:{TRIGGER.SERERITY}
    Original event ID:{EVENT.ID}
     
    恢复操作:
    默认接收人:{TRIGGER.STATUS}: {TRIGGER.NAME}
    主机:{HOST.NAME}
    IP:{HOST.IP}
    Trigger:{TRIGGER.NAME}
    Trigger status:{TRIGGER.STATUS}
    Trigger severity:{TRIGGER.SERERITY}
    Original event ID:{EVENT.ID}
     
     
    12. 测试
    我们关闭zabbix_agentd后, 看看能不能收到邮件报警
    [root@localhost alertscripts]# systemctl stop zabbix-agent.service
    这里报错了,脚本没有执行权限, 我们需要给脚本555权限
    [root@localhost alertscripts]# chmod 555 mailx.sh
    启动zabbix-agent 停留一分钟再关闭重新触发
    [root@localhost alertscripts]# systemctl start zabbix-agent.service
    [root@localhost alertscripts]# systemctl stop zabbix-agent.service
     
    邮件已经发送过来了, 我们登陆163邮箱查看
     
     
     
    zabbix-agent客户端安装
    1. 安装zabbix-agent
    #Agent端
    [root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-agent-3.0.4-1.el7.x86_64.rpm
    2. 备份并且更改zabbix-agent配置文件
    [root@localhost ~]#cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_$(date +%F)
    [root@localhost ~]# sed -i 's/Server=127.0.0.1/Server=192.168.0.125/g' /etc/zabbix/zabbix_agentd.conf
    [root@localhost ~]# sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.0.125/g' /etc/zabbix/zabbix_agentd.conf
    4. 修改zabbix-agent.conf信息
    [root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
    Server=192.168.4.182 #填写Server端IP
    ServerActive=192.168.4.182 #填写监控端IP
    Hostname=zabbix server #填写监控端创建主机时的用户名
    5. 设置开机自启动并启动zabbix客户端
    systemctl start zabbix-agent
    systemctl enable zabbix-agent
    #Server端
    1.添加被监控主机的身份信息
    界面操作:配置-->主机-->创建主机
    填写Agent端信息
    主机名必须和Agent端的Hostname一致
    Agent代理端口必须和Agent端的Server=XXX.XXX.XXX.XXX 一致
    2. 主机旁边的模板我们点进去添加如下
    Template App Zabbix Server
    Template OS Linux
     
    3. 看到ZBX变成绿色之后就代表我们已经成功监控上这台主机
    4. 监控-->图形-->选择刚才创建的主机,我们看一下它的网卡流量趋势
     
    本文来自  https://note.youdao.com/share/?id=ae959d5e9dcb4fe26ec7139f48c5b108&type=note#/
  • 相关阅读:
    js 控制页面跳转的5种方法
    js外部文件问题
    JS设置cookie,删除cookie
    JS中的输出
    转:这些年我们爱犯的弱智错误(菜鸟必看)
    JS 代码调试经验总结(菜鸟必读)
    js中err
    不理解,如果有高手看到了,请帮忙解答,谢谢啦~
    window对象和全局变量,局部变量的疑问
    看script中函数的各种不同形式的结果
  • 原文地址:https://www.cnblogs.com/98years/p/9008843.html
Copyright © 2011-2022 走看看