zabbix服务端安装
[[email protected] conf.d]# rpm -ivh http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm
[[email protected] conf.d]# yum install -y httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring
//安装lamp环境
[[email protected] conf.d]# yum install zabbix20 zabbix20-agent zabbix20-server zabbix20-server-mysql zabbix20-web zabbix20-web-mysql net-snmp-devel
//安装zabbix服务
[[email protected] conf.d]# /etc/init.d/zabbix-server start
[[email protected] conf.d]# /etc/init.d/zabbix-agent start
[[email protected] conf.d]# netstat -lnp |grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 8507/zabbix_agentd
tcp 0 0 :::10050 :::* LISTEN 8507/zabbix_agentd
//zabbix_server还未启动
[[email protected] conf.d]# less /var/log/zabbix/zabbix_server.log //查看日志信息
8484:20150621:155627.140 [Z3001] connection to database ‘zabbix‘ failed: [1044] Access denied for user ‘‘@‘localhost‘ to database ‘zabbix‘
8484:20150621:155627.140 Cannot connect to the database. Exiting...
//不能连接到数据库
[[email protected] conf.d]# /etc/init.d/httpd start
[[email protected] conf.d]# /etc/init.d/mysqld start
[[email protected] conf.d]# mysql -uroot -p -e "create database zabbix"
[[email protected] conf.d]# mysql -uroot -p --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/schema.sql
[[email protected] conf.d]# mysql -uroot -p --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/images.sql
[[email protected] conf.d]# mysql -uroot -p --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/data.sql
[[email protected] conf.d]# /etc/init.d/zabbix-server start
[[email protected] conf.d]# !net
netstat -lnp |grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 8507/zabbix_agentd
tcp 0 0 :::10050 :::* LISTEN 8507/zabbix_agentd
//还是只有zabbix_agentd,server未启动
[[email protected] conf.d]# tail /var/log/zabbix/zabbix_server.log
8909:20150621:160536.422 [Z3001] connection to database ‘zabbix‘ failed: [1044] Access denied for user ‘‘@‘localhost‘ to database ‘zabbix‘
8909:20150621:160536.422 Cannot connect to the database. Exiting...
//不能连接数据库
[[email protected] conf.d]# mysql -uroot -e "grant all on *.* to ‘zabbix‘@‘localhost‘ identified by ‘zabbix‘;"
[email protected] conf.d]# vim /etc/zabbix/zabbix_server.conf //查看及修改
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
[[email protected] conf.d]# ls /var/lib/mysql/mysql.sock //查看文件是否存在
/var/lib/mysql/mysql.sock
[[email protected] conf.d]# /etc/init.d/zabbix-server start
[[email protected] conf.d]# !net
netstat -lnp |grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 8507/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 9175/zabbix_server
tcp 0 0 :::10050 :::* LISTEN 8507/zabbix_agentd
tcp 0 0 :::10051 :::* LISTEN 9175/zabbix_server
[[email protected] conf.d]# ps aux |grep zabbix
//查看都已启动
现网页开始安装zabbix
[[email protected] conf.d]# /etc/init.d/httpd restart
浏览器访问192.168.137.21/zabbix进入安装页面
next
[[email protected] conf.d]# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
//修改检测未通过的选项
[[email protected] conf.d]# /etc/init.d/httpd restart
刷新页面,全部ok通过
Database name:zabbix
User :zabbix
Password:zabbix
next
name:137.23自定义
next-------finish
Username:admin
Password:zabbix
登入:zabbix默认页面
zabbix增加客户端监控
客户端
[[email protected] ~]# yum install zabbix20-agent
[email protected] ~]# vim /etc/zabbix_agentd.conf
Server=192.168.137.21 //改成服务端的IP
ServerActive=0.0.0.0:10050 //监听所有IP和10050端口
Hostname=wang
//自定义但要唯一
[[email protected] ~]# /etc/init.d/zabbix-agent start
[[email protected] ~]# ps aux |grep zabbix
//查看已启动
服务端:
服务端检测客户端hostname,能够检测出
[[email protected] conf.d]# zabbix_get -s 192.168.137.23 -p10050 -k "system.hostname"
Client
WEB页面下:
configuration------- hos--------- Create Host
Host name :137.23 (自定义)
Visible name:wang (自定义)
Agent interfaces:192.168.137.23 10050
save保存
点击Templates-----选择要监控的内容---Template OS Linux
Configuration-----Hosts-----wang-------Templates----add(添加模板)------Template OS Linux
select
点开wang,监控的内容都在里面了
zabbix设置邮件报警
服务端:
[[email protected] conf.d]# yum install -y sendmail
[[email protected] conf.d]# /etc/init.d/postfix start
[[email protected] conf.d]# mail -s "test" root </etc/passwd //给root发送test邮件
[email protected] conf.d]# mailq //查看有无未发出的邮件
/var/spool/mqueue is empty
Total requests: 0
[[email protected] conf.d]# mail //收邮件
Heirloom Mail version 12.4 7/29/08. Type ? for help.
"/var/spool/mail/root": 55 messages 1 new 55 unread
U 53 root Sun Jun 21 17:19 64/2860 "test"
打入该邮件数字打开邮件
53
Message 53:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
q退出
[[email protected] conf.d]# mkdir -p /home/zabbix/bin
[[email protected] conf.d]# vim /home/zabbix/bin/baojing.sh
#! /bin/bash
echo "$3" |/bin/mail -s "$2" $1
[[email protected] conf.d]# chmod +x /home/zabbix/bin/baojing.sh
[[email protected] conf.d]# vim /etc/zabbix_server.conf
AlertScriptsPath=/home/zabbix/bin
ExternalScripts=/home/zabbix/bin
WEB页面下
Administration-------Media types----Create media type
Description:baojing
Type:Script
Script name:baojing.sh
Enabled:√
save
创建用户:Administration------ Users-----Users-----Create User
creat action
operation---new--