由zabbix监控某关注的指明:
host group --> host --> item(存储于MySQL) --> graph(zabbix-web) --> trigger(触发器) --> action(conditon+operation)
application:把功能相近的一组item归类在一起统一进行管理组件:

Zabbix完整的监控配置流程大体上由如下步骤组成:
Host group --> Hosts --> Applications --> Items --> Trigger --> Events --> Actions --> User groups --> Users --> Medias

    graph, screen,

    依赖关系:
        Host --> Item --> Trigger --> Action --> Notice, Command

    添加主机到zabbix server:
    discovery, auto_registrion
            low level discovery

    模板:
        template:
        item, application, trigger, graph, action

主机组:
机器用途、系统版本、应用程序、地理位置

Item:
默认的Items有多种类型:
Zabbix-agent:
工作模式:passive,active

            网卡流量相关:
                net.if.in[if,]
                        if:接口,如eth0
                            mode:bytes,packets,errors,dropped
                    net.if.out[if,]
                    net.if.total[if,]

            端口相关:
                net.tcp.listen[port]
                    net.tcp.port[,port]
                    net.tcp.service[service,,]
                    net.udp.listen[port]

            进程相关:
                kernel.maxfiles
                    kernel.maxproc

            CPU相关:
                system.cpu.inter
                system.cpu.load[,]
                    system.cpu.num[]
                    system.cpu.switches
                    system.cpu.util[,,]

            磁盘IO或文件系统相关:
                vfs.dev.read[,,]
                    vfs.dev.write[,,]
                    vfs.fs.inode[fs,]

用户可自定义item:
关键:选取一个唯一的key;
命令:收集数据的命令或脚本;

Trigger:
状态:
OK
PROBLEM:有事件发生;

    zabbix server每次接收到items的新数据时,就会对Item的当前采样值进行判断,即与trigger的表达式进行比较;

    一个trigger只能属于一个Item,但一个Item可以有多个trigger;

 Severity:
     Not classifled:未知级别,灰色;
         Information:一般信息,亮绿;
         Warning:警告信息,×××;
         Average:一般故障,橙色;
         High:高级别故障,红色;
         Dister:致命故障,亮红;

Action:
触发条件一般为事件:
Trigger events:OK --> PROBLEM
Discovery events:zabbix的network discovery工作时发现主机;
Auto registration events:主动模式的agent注册时产生的事件;
Internal events:Item变成不再支持,或Trigger变成未知状态;

Operation的功能:
动作:
send message
Remote command

    配置send message:
        (1)定义好Media;
            (2)定义好用户;
            (3)配置要发送的消息;

实验环境:
主机名称:node1.smoke.com master
操作系统:CentOS 6.5
内核版本:2.6.32-504.el6.x86_64
网卡1:vmnet0 172.16.100.6
网卡2:vmnet8 dhcp
主机名称:node2.smoke.com
操作系统:CentOS 6.5
内核版本:2.6.32-504.el6.x86_64
网卡1:vmnet0 172.16.100.7
网卡2:vmnet8 dhcp
主机名称:node3.smoke.com
操作系统:Windows xp
网卡1:172.16.100.8

系统配置:
node1:zabbix-server

[root@node1 ~]# hostname
node1.smoke.com
[root@node1 ~]# ip addr show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:99:d9:9e brd ff:ff:ff:ff:ff:ff
    inet 172.16.100.6/24 brd 172.16.100.255 scope global eth0
    inet6 fe80::20c:29ff:fe99:d99e/64 scope link
       valid_lft forever preferred_lft forever
3: eth1:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:99:d9:a8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.243.145/24 brd 192.168.243.255 scope global eth1
    inet6 fe80::20c:29ff:fe99:d9a8/64 scope link
       valid_lft forever preferred_lft forever
[root@node1 ~]# ip route show
172.16.100.0/24 dev eth0  proto kernel  scope link  src 172.16.100.6
192.168.243.0/24 dev eth1  proto kernel  scope link  src 192.168.243.145
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003
default via 192.168.243.2 dev eth1
[root@node1 ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate time.nist.gov &> /dev/null
[root@node1 ~]# vim /etc/hosts
172.16.100.6   node1.smoke.com node1
172.16.100.7   node2.smoke.com node2
172.16.100.8   node3.smoke.com node3

node2:linux-agent

[root@node2 ~]# hostname
node2.smoke.com
[root@node2 ~]# ip addr show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:d6:6a:92 brd ff:ff:ff:ff:ff:ff
    inet 172.16.100.7/24 brd 172.16.100.255 scope global eth0
    inet6 fe80::20c:29ff:fed6:6a92/64 scope link
       valid_lft forever preferred_lft forever
3: eth1:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:d6:6a:9c brd ff:ff:ff:ff:ff:ff
    inet 192.168.243.146/24 brd 192.168.243.255 scope global eth1
    inet6 fe80::20c:29ff:fed6:6a9c/64 scope link
       valid_lft forever preferred_lft forever
[root@node2 ~]# ip route show
172.16.100.0/24 dev eth0  proto kernel  scope link  src 172.16.100.7
192.168.243.0/24 dev eth1  proto kernel  scope link  src 192.168.243.146
169.254.0.0/16 dev eth0  scope link  metric 1002
169.254.0.0/16 dev eth1  scope link  metric 1003
default via 192.168.243.2 dev eth1
[root@node2 ~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate time.nist.gov &> /dev/nulll
[root@node2 ~]# vim /etc/hosts
172.16.100.6   node1.smoke.com node1
172.16.100.7   node2.smoke.com node2
172.16.100.8   node3.smoke.com node3

node3:windows-agent

安装mariadb:

node1:zabbix-server
[root@node1 ~]# tar xf cmake-2.8.8.tar.gz
[root@node1 ~]# cd cmake-2.8.8
[root@node1 cmake-2.8.8]# ./bootstrap
[root@node1 cmake-2.8.8]# make && make install
[root@node1 cmake-2.8.8]# cd
[root@node1 ~]# groupadd -g 306 -r mysql
[root@node1 ~]# useradd -u 306 -g mysql -r -s /sbin/nologin mysql
[root@node1 ~]# mkdir /mydata/data -pv
[root@node1 ~]# yum -y install readline-devel zlib-devel openssl-devel
[root@node1 ~]# tar xf mariadb-10.0.10.tar.gz
[root@node1 ~]# cd mariadb-10.0.10
[root@node1 mariadb-10.0.10]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/mydata/data \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DWITH_SSL=system \
> -DWITH_ZLIB=system \
> -DWITH_LIBWRAP=0 \
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci
[root@node1 mariadb-10.0.10]# make && make install
[root@node1 mariadb-10.0.10]# cd /usr/local/mysql/
[root@node1 mysql]# chgrp mysql ./*
[root@node1 mysql]# chown mysql:mysql /mydata/data
[root@node1 mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
[root@node1 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@node1 mysql]# chmod +x /etc/rc.d/init.d/mysqld
[root@node1 mysql]# chkconfig --add mysqld
[root@node1 mysql]# mv /etc/my.cnf /etc/my.cnf.bak
[root@node1 mysql]# cp support-files/my-large.cnf /etc/my.cnf
[root@node1 mysql]# vim /etc/my.cnf
log-bin=/mydata/binlogs/master-bin
innodb_file_per_table = ON
[root@node1 mysql]# mkdir -pv /mydata/binlogs/
[root@node1 mysql]# chown -R mysql.mysql /mydata/binlogs/
[root@node1 mysql]# service mysqld start
[root@node1 mysql]# vim /etc/profile.d/mysqld.sh
export PATH=/usr/local/mysql/bin:$PATH
[root@node1 mysql]# . /etc/profile.d/mysqld.sh
[root@node1 mysql]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.0.10-MariaDB-log Source distribution

Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use mysql
Database changed
MariaDB [mysql]> SELECT user,host,password FROM user;
+------+-----------------+----------+
| user | host            | password |
+------+-----------------+----------+
| root | localhost       |          |
| root | node1.smoke.com |          |
| root | 127.0.0.1       |          |
| root | ::1             |          |
|      | localhost       |          |
|      | node1.smoke.com |          |
+------+-----------------+----------+
6 rows in set (0.00 sec)

MariaDB [mysql]> DROP USER ""@'localhost';
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> DROP USER ""@'node1.smoke.com';
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> \q
Bye

安装zabbix:
node1:zabbix-server

[root@node1 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.0.10-MariaDB-log Source distribution

Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE zabbix CHARACTER SET utf8;
Query OK, 1 row affected (0.06 sec)

MariaDB [(none)]> GRANT ALL on zabbix.* TO 'zbxuser'@'172.16.%.%' IDENTIFIED BY 'zbxpass';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL on zabbix.* TO 'zbxuser'@'node1.smoke.com' IDENTIFIED BY 'zbxpass';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> \q
Bye
[root@node1 ~]# cd zabbix-2.4.5/
[root@node1 zabbix-2.4.5]# ls
zabbix-2.4.5-1.el6.x86_64.rpm               zabbix-proxy-pgsql-2.4.5-1.el6.x86_64.rpm    zabbix-web-2.4.5-1.el6.noarch.rpm
zabbix-agent-2.4.5-1.el6.x86_64.rpm         zabbix-proxy-sqlite3-2.4.5-1.el6.x86_64.rpm  zabbix-web-japanese-2.4.5-1.el6.noarch.rpm
zabbix-get-2.4.5-1.el6.x86_64.rpm           zabbix-sender-2.4.5-1.el6.x86_64.rpm         zabbix-web-mysql-2.4.5-1.el6.noarch.rpm
zabbix-java-gateway-2.4.5-1.el6.x86_64.rpm  zabbix-server-2.4.5-1.el6.x86_64.rpm         zabbix-web-pgsql-2.4.5-1.el6.noarch.rpm
zabbix-proxy-2.4.5-1.el6.x86_64.rpm         zabbix-server-mysql-2.4.5-1.el6.x86_64.rpm
zabbix-proxy-mysql-2.4.5-1.el6.x86_64.rpm   zabbix-server-pgsql-2.4.5-1.el6.x86_64.rpm
[root@node1 zabbix-2.4.5]# yum -y install zabbix-server-2.4.5-1.el6.x86_64.rpm zabbix-server-mysql-2.4.5-1.el6.x86_64.rpm zabbix-get-2.4.5-1.el6.x86_64.rpm zabbix-2.4.5-1.el6.x86_64.rpm zabbix-web-2.4.5-1.el6.noarch.rpm zabbix-web-mysql-2.4.5-1.el6.noarch.rpm zabbix-agent-2.4.5-1.el6.x86_64.rpm zabbix-sender-2.4.5-1.el6.x86_64.rpm

安装报错:

Error: Package: zabbix-server-2.4.5-1.el6.x86_64 (/zabbix-server-2.4.5-1.el6.x86_64)
           Requires: fping
Error: Package: zabbix-server-mysql-2.4.5-1.el6.x86_64 (/zabbix-server-mysql-2.4.5-1.el6.x86_64)
           Requires: libiksemel.so.3()(64bit)
Error: Package: zabbix-server-2.4.5-1.el6.x86_64 (/zabbix-server-2.4.5-1.el6.x86_64)
           Requires: iksemel
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
[root@node1 ~]# ls *.rpm
fping-2.4b2-10.el6.x86_64.rpm  iksemel-1.4-2.el6.x86_64.rpm  iksemel-devel-1.4-2.el6.x86_64.rpm
[root@node1 ~]# yum -y localinstall iksemel-1.4-2.el6.x86_64.rpm iksemel-devel-1.4-2.el6.x86_64.rpm fping-2.4b2-10.el6.x86_64.rpm

配置zabbix:

node1:zabbix-server
[root@node1 ~]# service httpd start
[root@node1 ~]# cd /usr/share/doc/zabbix-server-mysql-2.4.5/create/
[root@node1 create]# ls
data.sql  images.sql  schema.sql
[root@node1 create]# mysql zabbix < schema.sql    #导入数据库要有顺序,先schema、images、data;
[root@node1 create]# mysql zabbix < images.sql
[root@node1 create]# mysql zabbix < data.sql
[root@node1 ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=172.16.100.6
DBUser=zbxuser
DBPassword=zbxpass
DBSocket=/tmp/mysql.sock
[root@node1 ~]# service zabbix-server start
Starting Zabbix server:                                    [  OK  ]
[root@node1 ~]# ss -tnl
State       Recv-Q Send-Q                            Local Address:Port                              Peer Address:Port
LISTEN      0      128                                          :::22                                          :::*
LISTEN      0      128                                           *:22                                           *:*
LISTEN      0      128                                          :::10051                                       :::*
LISTEN      0      128                                           *:10051                                        *:*
LISTEN      0      128                                           *:3306                                         *:*
LISTEN      0      128                                          :::80                                          :::*
[root@node1 ~]# vim /etc/php.ini
date.timezone = Asia/Chongqing
[root@node1 ~]# service httpd restart

配置zabbix-web:
通过windows的浏览器输入172.16.100.6/zabbix;
Zabbix监控(四)_第1张图片

点击next,所有检查通过,点击next,配置数据库连接,数据库主机172.16.100.6、数据库用户zbxuser、密码zbxpass,点击next;
Zabbix监控(四)_第2张图片

配置zabbix主机地址172.16.100.6,name为node1.smoke.com,点击next,到finish,自动跳转到zabbix登录界面;
Zabbix监控(四)_第3张图片

默认账号admin,密码zabbix;
Zabbix监控(四)_第4张图片

zabbix-server监控自己:
node1:zabbix-server

[root@node1 ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,172.16.100.6
ServerActive=127.0.0.1,172.16.100.6
Hostname=node1.smoke.com
[root@node1 ~]# service zabbix-agent start
[root@node1 ~]# ss -tnl
State       Recv-Q Send-Q                            Local Address:Port                              Peer Address:Port
LISTEN      0      128                                          :::22                                          :::*
LISTEN      0      128                                           *:22                                           *:*
LISTEN      0      128                                          :::10050                                       :::*
LISTEN      0      128                                           *:10050                                        *:*
LISTEN      0      128                                          :::10051                                       :::*
LISTEN      0      128                                           *:10051                                        *:*
LISTEN      0      128                                           *:3306                                         *:*
LISTEN      0      128                                          :::80                                          :::*

在zabbix-web上面启用对node1.smoke.com的监控,点击Configuration--Hosts,默认zabbix-server已经把自己监控了,点击Disable启用本机监控;
Zabbix监控(四)_第5张图片

zabbix-server监控linux-agent:
node2:linux-agent

[root@node2 ~]# cd zabbix-2.4.5/
[root@node2 zabbix-2.4.5]# yum -y install zabbix-2.4.5-1.el6.x86_64.rpm zabbix-agent-2.4.5-1.el6.x86_64.rpm zabbix-sender-2.4.5-1.el6.x86_64.rpm   
[root@node2 zabbix-2.4.5]# vim /etc/zabbix/zabbix_agentd.conf
Server=172.16.100.6
ServerActive=172.16.100.6
Hostname=node2.smoke.com
[root@node2 zabbix-2.4.5]# service zabbix-agent start

修改zabbix-web字体:
在Windows目录C:\Windows\Fonts复制新宋体到zabbix-server的/usr/share/zabbix/fonts目录;
node1:zabbix-server
[root@node1 ~]# cd /usr/share/zabbix/fonts/
[root@node1 fonts]# ls
graphfont.ttf  simsun.ttc

创建主机组:
点击Configuration -- Host groups -- Create host group,填写完成,点击Add;
Zabbix监控(四)_第6张图片

定义主机:
点击Configuration -- Hosts -- Create Host,填写完成,点击Add;
Zabbix监控(四)_第7张图片

在node2主机上点击Applications -- Create application,填写完成点击Add;
Zabbix监控(四)

再点击Create application,填写完成点击Add;
Zabbix监控(四)

点击Configuration -- Hosts,点击node2上面的Items -- Create item,填写完成点击Add;
Zabbix监控(四)_第8张图片

点击Configuration -- Hosts,点击node2上面的Applications -- Create application,填写完成点击Add;
Zabbix监控(四)

点击Configuration -- Hosts,点击node2上面的Items -- Create item,填写完成点击Add;
Zabbix监控(四)_第9张图片

点击Configuration -- Hosts,点击node2上面的Items -- Create item,填写完成点击Add;
Zabbix监控(四)_第10张图片

点击Configuration -- Hosts,点击node2上面的Graphs -- Create graph,填写完成点击Add;
Zabbix监控(四)_第11张图片

点击Configuration -- Hosts,点击node2上面的Triggers -- Create Triggers,填写完成点击Add;
Zabbix监控(四)_第12张图片

点击Configuration -- Hosts,点击node2上面的Graphs -- Traffic Stats -- Preview;
Zabbix监控(四)_第13张图片

点击Monitoring -- Events,Group选择test group,Host选择node2,Source选择Trigger;
Zabbix监控(四)

点击Administration -- Media types -- Create media type,填写完成点击Add;
Zabbix监控(四)_第14张图片

点击Administration -- Users,选择Users,点击Create user,User菜单;
Zabbix监控(四)_第15张图片

Media菜单,填写完成点击Add;
Zabbix监控(四)

点击Administration -- Users,选择User groups,点击Zabbix administratos -- Permissions,点击Read-write下面的Add,全部选择,点击Update;
Zabbix监控(四)_第16张图片

点击Configuration -- Actions -- Create Action,选择Operations菜单,点击Add;
Zabbix监控(四)_第17张图片

点击Conditions菜单;
Zabbix监控(四)_第18张图片

点击Action菜单,填写完成点击Add;
Zabbix监控(四)_第19张图片

node1:zabbix-server

[root@node1 ~]# service zabbix-server restart
[root@node1 ~]# mail
[root@node1 ~]# yum -y install sendmail
[root@node1 ~]# service sendmail start