zabbix
- zabbix([`z?biks])是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
- zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
- zabbix由2部分构成,zabbix server与可选组件zabbix agent。
- zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
安装使用
zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。zabbix agent可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD, OS X, Tru64/OSF1, Windows NT4.0, Windows (2000/2003/XP/Vista)等系统之上。 zabbix server可以单独监视远程服务器的服务状态;同时也可以与zabbix agent配合,可以轮询zabbix agent主动接收监视数据(agent方式),同时还可被动接收zabbix agent发送的数据(trapping方式)。
zabbix词汇
- zabbix server,服务端,收集数据,写入数据
- zabbix agent,部署在被监控的机器上,是一个进程,和zabbix server进行交互,以及负责执行命令
- Host, 服务器的概念,指zabbix监控的实体, 服务器,交换机等
- Hosts, 主机组
- Applications, 应用
- Events, 事件
- Media, 发送通知的通道
- Remote command,远程命令
- Template, 模板
- Item, 对于某一个指标的监控,称之为Items, 如某台服务器的内存使用状况,就是一个item监控项
- Trigger, 触发器,定义报警的逻辑,有正常,异常,未知三个状态
- Action, 当Trigger符合设定值后,zabbix指定的动作,如发个邮件给运维,说服务器有问题了
安装部署zabbix 5.0
需求 zabbix server 192.168.20.11 zabbix client 192.168.20.22
[root@localhost ~]
[root@localhost ~]
[root@server ~]
获取https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.YVusdK: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...
正在升级/安装...
1:zabbix-release-5.0-1.el7
[root@server ~]
[root@server ~]
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras updates zabbix zabbix-non-supported
Cleaning up list of fastest mirrors
[root@server ~]
[root@server ~]
[root@server ~]
[root@server ~]
[zabbix-frontend]
enabled=1 //0改为1表示开启这里的参数
[root@server ~]
[root@server ~]
Enter password:
mysql> create database zabbix character set utf8 collate utf8_bin; //创建zabbix数据库 设置编码
Query OK, 1 row affected (0.00 sec)
mysql> create user zabbix@localhost identified by '123'; //创建zabbix用户
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost; //授权
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; //刷新权限表
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@server ~]
Enter password:
[root@server ~]
mysql: [Warning] Using a password on the command line interface can be insecure.
t.
mysql> use zabbix;
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| config_autoreg_tls |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| host_tag |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| interface_snmp |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| item_rtdata |
| items |
| items_applications |
| lld_macro_path |
| lld_override |
| lld_override_condition |
| lld_override_opdiscover |
| lld_override_operation |
| lld_override_ophistory |
| lld_override_opinventory |
| lld_override_opperiod |
| lld_override_opseverity |
| lld_override_opstatus |
| lld_override_optag |
| lld_override_optemplate |
| lld_override_optrends |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| media_type_message |
| media_type_param |
| module |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_data |
| task_remote_command |
| task_remote_command_result |
| task_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
166 rows in set (0.00 sec)
mysql> exit
Bye
[root@server ~]
[root@server ~]
php_value[date.timezone] = Asia/Shanghai
[root@server ~]
[root@server ~]
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/rh-php72-php-fpm.service to /usr/lib/systemd/system/rh-php72-php-fpm.service.
[root@localhost ~]
[root@client ~]
[root@client ~]
31 Aug 22:24:12 ntpdate[97101]: adjust time server 203.107.6.88 offset -0.001576 sec
您在 /var/spool/mail/root 中有新邮件
[root@client ~]
[root@client ~]
[root@client ~]
获取https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.qAR3nc: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中...
正在升级/安装...
1:zabbix-release-5.0-1.el7
[root@client ~]
[root@client ~]
[root@client ~]
Server=192.168.20.11 //指定server ip
ServerActive=192.168.20.11 //同上
Hostname=Zabbix-agent01 //修改name多台的话不可重复
[root@localhost ~]
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=192.168.20.11
ServerActive=192.168.20.11
Hostname=Zabbix-agent01
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
[root@client ~]
[root@server ~]
[root@server ~]
client
[root@server~]
1 //表示成功
- 可创建主机然后监控
|