zabbix-agent安装及脚本
- 格式:docx
- 大小:18.32 KB
- 文档页数:3
Zabbix 手册目录Ⅰ Zabbix简介 (1)一、Zabbix介绍 (1)二、Zabbix系统架构 (4)1.Zabbix架构: (4)2.Zabbix架构说明: (5)Ⅱ Zabbix安装 (8)一、Zabbix安装 (8)1、安装基础包 (8)2、启动httpd、mysql (9)3、配置防火墙 (9)4、配置PHP参数 (9)5、修改httpd 的FQDN 错误 (10)6、下载zabbix-3.0.3tar.gz (10)7、添加zabbix 用户和组 (11)8、安装zabbix-server (11)9、创建zabbix 数据库以及相关表 (11)10、配置软连接和启动文件信息 (12)11、修改/etc/init.d 目录下的zabbix_server 和zabbix_agentd 启动文件(配置server和agent) (12)12、通过web 站点配置zabbix (14)二、Zabbix 监控机配置 (19)1. 登录 (19)2. 添加主机(Hosts) (20)3. 创建模板 (26)4.添加告警动作(Actions) (28)5.添加告警方式(Medias) (29)6.添加用户(Users) (30)Ⅲ Zabbix配置 (32)一、Client端配置 (32)二、zabbix_server.conf 配置文件详解 (33)三、zabbix_agentd.conf 配置文件详解 (41)ⅠZabbix简介一、Zabbix介绍Zabbix是一个分布式监控系统,支持多种采集方式和采集客户端,有专用的Agent(代理),也支持SNMP、IPMI、JMX、Telnet、SSH等多种协议,它将采集到的数据存放到数据库,然后对其进行分析整理,达到条件触发告警.其灵活的扩展性和丰富的功能是其他监控系统所不能比的。
相对来说,它的总体功能做得非常优秀,其界面如图1-1、图1-2。
如何使用Zabbix进行服务器监控服务器是现代网络应用的核心组件,它需要提供稳定、高效、安全的服务。
但是,服务器在运行过程中可能会出现各种问题。
例如,服务器可能会暂停服务,可能会出现磁盘空间不足的情况,可能会出现 CPU 使用率过高的情况等等。
这时,我们需要一种工具来监控服务器的运行情况,以便及时发现并解决问题。
Zabbix就是这样一种工具。
本文将介绍如何使用Zabbix 进行服务器监控。
一、安装 Zabbix安装 Zabbix 的过程有点复杂,这里不再详细说明,读者可以参考 Zabbix 的官方文档进行安装。
在安装完成之后,需要进行以下配置:1. 启动 Zabbix Server 和 Zabbix Agent。
在启动之前,需要检查Zabbix 的配置文件是否正确。
例如,检查 Zabbix Server 是否配置了正确的数据库信息,检查 Zabbix Agent 是否配置了正确的Server。
2. 配置监控主机。
在 Zabbix 中,需要通过监控主机来监控服务器。
每个监控主机都有一个唯一的Hostname。
在配置监控主机时,需要注意:a. 首先,需要在监控主机上安装 Zabbix Agent,并配置Agent 的 Server 变量。
b. 其次,需要在Zabbix Server 上配置监控主机的Hostname。
3. 配置监控项。
监控项是用来监控服务器指标的,例如 CPU使用率、磁盘空间等等。
每个监控项都有一个唯一的名称和一个采集间隔。
在配置监控项时,需要注意:a. 需要选择正确的监控项类型。
例如,CPU 使用率的监控项类型是 "Zabbix Agent (Active)",而磁盘空间的监控项类型是"Zabbix Agent (Passive)"。
b. 需要配置正确的监控项参数。
例如,CPU 使用率的监控项需要设置 CPU 核数,而磁盘空间的监控项需要设置磁盘挂载点。
zabbix监控mysql的⽅法zabbix部署完之后zabbix-agent操作1.监控mysql,⾸先要先安装mysql[root@localhost ~]# yum -y install mariadb mariadb-server2.编写mysql监控项的脚本在zabbix-agent先授权个⽤户不然测试时没有权限[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 33Server version: 5.5.65-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> grant all on *.* to 'check'@'localhost' identified by '123';Query OK, 0 rows affected (0.00 sec)mysql监控的内容主要有主从的状态 (得先配置主从在下⾯)流量检测发送,接受常规操作增删改查某个库、某个表的⼤⼩tps(每秒查询处理的事务数)qps(每秒能处理多少次请求数)[root@localhost ~]# mkdir /etc/zabbix/scipts[root@localhost ~]# cd /etc/zabbix/scipts/[root@localhost scipts]# vim mysql.sh#!/bin/bashmysql="mysql -ucheck -p123"case $1 in# mysql主从状态slave_status)$mysql -e "show slave status\G" |grep "Yes" |wc -l;;# mysql流量接受Bytes_received)mysqladmin extended-status |grep "Bytes_received" |awk '{print $4}';;# mysql流量发送Bytes_sent)mysqladmin extended-status |grep "Bytes_sent" |awk '{print $4}';;# mysql常规操作增Com_insert)mysqladmin extended-status |grep -w "Com_insert" |awk '{print $4}';;# mysql常规操作删Com_delete)mysqladmin extended-status |grep -w "Com_delete" |awk '{print $4}';;# mysql常规操作改Com_update)mysqladmin extended-status |grep -w "Com_update" |awk '{print $4}';;# mysql常规操作查Com_select)mysqladmin extended-status |grep -w "Com_select" |awk '{print $4}';;# mysql tpstps)mysqladmin status |awk '{print $6/$2}';;# mysql qps=(rollback+commit)/uptimeqps)rollback=$(mysqladmin extended-status |grep -w "Com_rollback" |awk '{print $4}')commit=$(mysqladmin extended-status |grep -w "Com_commit" |awk '{print $4}')uptime=$(mysqladmin status |awk '{print $2}')count=$[$rollback+$commit]echo "$count $uptime" > /tmp/a.txtcat /tmp/a.txt |awk '{print $1/$2}';;# 库⼤⼩我们这⾥拿mysql库举例db)$mysql -e "select sum(data_length) from information_schema.tables where table_schema='mysql'" |sed -n '2p';;# 表⼤⼩我们这⾥拿mysql下⾯的user表举例tb)$mysql -e "select sum(data_length) from information_schema.tables where table_schema='mysql' and table_name='user'" |sed -n '2p';;esac3.⾃定义键值key 重启zabbix-agent[root@localhost scipts]# cd /etc/zabbix/zabbix_agentd.d/[root@localhost zabbix_agentd.d]# vim mysql.confUserParameter=mysql[*],/etc/zabbix/scipts/mysql.sh $1[root@localhost zabbix_agentd.d]# systemctl restart zabbix-agent4.在zabbix-server测试先安装zabbix-get[root@localhost ~]# yum -y install zabbix-get[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[slave_status]2[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Bytes_received]850970[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Bytes_sent]224906[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_insert]3001[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_delete]135[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_update]128[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[Com_select]19[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[qps]0.864842[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[tps]1.92936[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[db]555118[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[tb]420报错处理[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[slave_status]sh: /etc/zabbix/scipts/mysql.sh: 权限不够脚本执⾏权限不够去zabbix-agent 加权限[root@localhost zabbix_agentd.d]# chmod +x /etc/zabbix/scipts/mysql.sh[root@localhost ~]# zabbix_get -s 192.168.27.137 -k mysql[slave_status]ERROR 1227 (42000) at line 1: Access denied; you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation 是因为⽤户没有权限查看去zabbix-agent 授权个⽤户在脚本⾥⾯加上[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 33Server version: 5.5.65-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> grant all on *.* to 'check'@'localhost' identified by '123';Query OK, 0 rows affected (0.00 sec)[root@localhost scipts]# vim mysql.sh#!/bin/bashmysql="mysql -ucheck -p123"case $1 in# mysql主从状态slave_status)$mysql -e "show slave status\G" |grep "Yes" |wc -l;;zabbix页⾯上添加监控项和图形查看mysql流量数据查看mysql qps tps查看mysql主从状态查看mysql常规操作查看mysql库表⼤⼩mysql主从配置⼀.zabbix-server端[root@localhost ~]# vim /etc/f[root@localhost ~]# systemctl restart mariadb[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 7Server version: 5.5.65-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show master status;+------------------+----------+--------------+------------------+| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |+------------------+----------+--------------+------------------+| mysql-bin.000001 | 175170 | | |+------------------+----------+--------------+------------------+1 row in set (0.00 sec)MariaDB [(none)]> grant all on *.* to 'tom'@'%' identified by '123'; Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> flush privileges;Query OK, 0 rows affected (0.00 sec)⼆.zabbix-agent端[root@localhost ~]# vim /etc/f[root@localhost ~]# systemctl restart mariadb[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 2Server version: 5.5.65-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> change master to-> master_host='192.168.27.136',-> master_user='tom',-> master_password='123',-> master_log_file='mysql-bin.000001',-> master_log_pos=175170;Query OK, 0 rows affected (0.01 sec)MariaDB [(none)]> start slave;Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> show slave status \G;*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.27.136Master_User: tomMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 175170Relay_Log_File: mysql-relay.000004Relay_Log_Pos: 529Relay_Master_Log_File: mysql-bin.000001Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 1146Last_Error: Error 'Table 'zabbix.history_uint' doesn't exist' on query. Default database: 'zabbix'. Query: 'insert into history_uint (itemid,clock,ns,value) values (23287,1602301747,810415730,1)'Skip_Counter: 0Exec_Master_Log_Pos: 173424Relay_Log_Space: 2565Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: NULLMaster_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 1146Last_SQL_Error: Error 'Table 'zabbix.history_uint' doesn't exist' on query. Default database: 'zabbix'. Query: 'insert into history_uint (itemid,clock,ns,value) values (23287,1602301747,810415730,1)' Replicate_Ignore_Server_Ids:Master_Server_Id: 11 row in set (0.00 sec)ERROR: No query specified报错处理[root@localhost ~]# vim /etc/f[root@localhost ~]# systemctl restart mariadb[root@localhost ~]# mysqlWelcome to the MariaDB monitor. Commands end with ; or \g.Your MariaDB connection id is 4Server version: 5.5.65-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show slave status \G;*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.27.136Master_User: tomMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000001Read_Master_Log_Pos: 199126Relay_Log_File: mysql-relay.000006Relay_Log_Pos: 3950Relay_Master_Log_File: mysql-bin.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 199126Relay_Log_Space: 4240Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 11 row in set (0.00 sec)到此这篇关于zabbix 监控mysql的⽅法的⽂章就介绍到这了,更多相关zabbix 监控mysql内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。
Zabbix添加windows主机监控zabbix监控windows主机1、官⽹下载zabbix的windows-agent(选择相应版本):2、将下载的agent包解压到windows主机相应路径下:3、在conf\zabbix_agentd.win.conf⽂件中修改⼀下配置:LogRemoteCommands=1 #执⾏远程命令是否保存操作⽇志LogFile=d:\zabbix\zabbix_agentd.log #⽇志⽂件存储位置EnableRemoteCommands=1 #允许在本地执⾏远程命令Server=103.218.3.xx,103.218.3.xx/25,103.218.3.xxx #填zabbix服务器IP地址(注,如果zabbix-agent是跨⽹段连接的话需将远程zabbix_server主机所有的ip地址以及⽹关加上)Hostname=yisu-5d327127b488f #zabbix_agent即windows主机名称(被监控主机名称)ServerActive=103.218.3.xx,103.218.3.xx/25,103.218.3.xxx #填写zabbix服务器IP地址(同Server)4、在windows控制台cmd下执⾏以下命令:d:cd zabbix\bin#安装agent zabbix_agentd.exe -c c:\zabbix\conf\zabbix_agentd.win.conf -i#启动agent zabbix_agentd.exe -c c:\conf\zabbix_agentd.win.conf -s注释:-c:指定配置⽂件位置-i:安装agent-s:启动-x:停⽌agent-d:卸载agent(注:在安装时可能提⽰缺少⼀些dll包,可⽤dll-helper⼯具依次解决)5、agent启动成功后,即可在zabbix页⾯添加windows:添加主机: 添加模板: 添加完成即可查看。
zabbix监控服务部署脚本搭建平台脚本:1 #!/bin/bash2 #zabbix监控服务部署3 #脚本使⽤前提:yum搭建,nginx-1.12.2源码包,zabbix-3.4.4源码包,要求源码包尽量在单⼀⽬录下,最好在默认管理员家⽬录下4 #数据库主机,名称,账户,密码,⽇志为默认,不可修改5 #选择部署和⼀键部署的选择需要注释脚本操作,默认为选择部署;⼀键部署将选择部署的1和2合并6 source /root/moudle.sh7while :8do9echo"############################__menu__################################"10echo"1.环境部署"11echo"2.安装监控平台"12echo"3.启动监控服务"13echo"4.部署被监控主机(在被监控主机上)"14echo"5.exit"15echo"####################################################################"16 read -p "请输⼊您要部署的服务:选择部署(1|2|3|4|5);⼀键部署(1|2|3|4):"select1718 #选择部署19if [ "$select" == "1" ];then20 install_nginx21elif [ "$select" == "2" ];then22 install_zabbix23elif [ "$select" == "3" ];then24 start_zabbix25elif [ "$select" == "4" ];then26 install_zabbix_webx27elif [ "$select" == "5" ];then28 exit29else30echo"I AM SORRY"31fi3233 #⼀键部署34#if [ $select == "1" ];then35 # install_nginx;install_zabbix36#elif [ $select == "2" ];then37 # start_zabbix38#elif [ $select == "3" ];then39 # install_zabbix_webx40#elif [ "$select" == "4" ];then41 # exit42#else43 # echo"I AM SORRY"44 #fi45done执⾏脚本:/root/moudle.sh1 #!/bin/bash2 #函数定义3 install_nginx()4 {5yum -y install gcc pcre-devel zlib-devel openssl-devel67if [ -f */nginx-1.12.2.tar.gz ];then8find / -name "nginx-1.12.2.tar.gz" > /1.txt && sed -i 's/\/nginx-1.12.2.tar.gz//' /1.txt9 cd `cat /1.txt`10tar -xf nginx-1.12.2.tar.gz11 cd nginx-1.12.212 ./configure --with-http_ssl_module13make && make install14else15echo"没有nginx源码包"16 exit 117fi1819yum -y install php php-mysql mariadb mariadb-server mariadb-devel php-fpm2021sed -i '65,68s/#//' /usr/local/nginx/conf/nginx.conf22sed -i '70,71s/#//' /usr/local/nginx/conf/nginx.conf23sed -i '/fastcgi/,70s/_params/.conf/' /usr/local/nginx/conf/nginx.conf2425 systemctl start mariadb26 systemctl start php-fpm27 /usr/local/nginx/sbin/nginx28 ss -untlp | grep :80 >/dev/null29if [ $? -eq 0 ];then30echo"环境部署完毕,请进⾏监控平台安装"31else32echo"部署失败,请检查!"33fi34 }3536 install_zabbix()37 {38yum -y install net-snmp-devel curl-devel libevent-devel3940if [ -f */zabbix-3.4.4.tar.gz ];then41find / -name "zabbix-3.4.4.tar.gz" > /1.txt ; sed -i '2,100d' /1.txt ; sed -i '1s/\/zabbix-3.4.4.tar.gz//' /1.txt42 cd `cat /1.txt`43tar -xf zabbix-3.4.4.tar.gz44 cd zabbix-3.4.445 ./configure \46 --enable-server --enable-proxy --enable-agent \47 --with-mysql=/usr/bin/mysql_config \48 --with-net-snmp --with-libcurl49make install50else51echo"没有zabbix源码包"52 exit 253fi5455 cd frontends/php/56cp -a * /usr/local/nginx/html/57chmod -R 777 /usr/local/nginx/html/*5859 sed -i "/keepalive_timeout 65;/a fastcgi_buffers 8 16k;\nfastcgi_buffer_size 32k;\nfastcgi_connect_timeout 300;\nfastcgi_send_timeout 300;\nfastcgi_read_timeout 300;" /usr/local/nginx/conf/nginx.conf60 /usr/local/nginx/sbin/nginx -s stop61 /usr/local/nginx/sbin/nginx6263 echo "开始数据库配置,请耐⼼等待......"64 mysql -e "create database zabbix character set utf8"65 mysql -e "grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix'"66 cd `cat /1.txt`67 cd zabbix-3.4.4/database/mysql/68 mysql -uzabbix -pzabbix zabbix < schema.sql69 mysql -uzabbix -pzabbix zabbix < images.sql70 mysql -uzabbix -pzabbix zabbix < data.sql7172 cd /root/73 yum -y install php-gd php-xml php-ldap php-bcmath php-mbstring7475 sed -i '/;date.timezone/s/;date.timezone =/date.timezone = Asia\/Shanghai/' /etc/php.ini76 sed -i '/max_exe/s/30/300/' /etc/php.ini77 sed -i '/post_max/s/8/32/' /etc/php.ini78 sed -i '/^max_input/s/60/300/' /etc/php.ini7980 systemctl restart php-fpm81 ip=`ifconfig eth1 | awk '/inet/ {print $2}'`82 echo "请访问http://$ip/index.php进⾏监控平台配置"83}8485start_zabbix()86{87 sed -i '/^# DBHost/s/#//' /usr/local/etc/zabbix_server.conf88 sed -i '/^# DBPassword/s/# DBPassword=/DBPassword=zabbix/' /usr/local/etc/zabbix_server.conf89 useradd zabbix90 zabbix_server91 netstat -utnlp | grep :10051 &>/dev/null92 if [ $? -eq 0 ];then93 echo "监控启动成功"94 else95 echo "失败,请检查"96 fi97}9899install_zabbix_webx()100{101 yum -y install gcc pcre-devel102103 if [ -f */zabbix-3.4.4.tar.gz ];then104find / -name "zabbix-3.4.4.tar.gz" > /1.txt ; sed -i '2,100d' /1.txt ; sed -i '1s/\/zabbix-3.4.4.tar.gz//' /1.txt105 cd `cat /1.txt`106tar -xf zabbix-3.4.4.tar.gz107 cd zabbix-3.4.4108 ./configure --enable-agent109make install110else111echo"没有zabbix源码包"112 exit 3113fi114115 read -p "请输⼊监控平台主机IP:" ip116sed -i "/^server=/s/127.0.0.1/127.0.0.1,$ip/" /usr/local/etc/zabbix_agentd.conf117sed -i "/^serveractive/s/127.0.0.1/$ip:10051/" /usr/local/etc/zabbix_agentd.conf118echo"正在开启,请耐⼼等待......"119 useradd zabbix120 zabbix_agentd121 ss -untlp | grep :10050 &>/dev/null122if [ $? -eq 0 ];then123echo"监控启动成功"124else125echo"失败,请检查"126fi127 }。
服务器IP:192.168.30.199A.关闭SELINUX#vi /etc/selinux/configSELINUX=enforcing #注释掉SELINUXTYPE=targeted #注释掉SELINUX=disabled #增加:wq #保存退出#setenforce 0#使配置立即生效B.关闭iptables#chkconfig iptables off#service iptables stopC.卸载系统自带的mysql和http服务#rpm -e --nodeps mysql httpd1.安装lnmp环境#yum install gcc gcc-c++ make mysql-server mysql-devel libcurl-devel net-snmp-devel php php-ldap php-gd php-xml php-mysql php-bcmath httpd fping php-mbstring说明:/etc/httpd/conf/httpd.conf #apache配置文件路劲/usr/sbin/apachectl #apache的运行路劲/var/www/html #web目录/usr/bin/mysql #mysql的运行路径/var/lib/mysql #mysql数据库文件的存放路径/usr/lib/mysql #mysql的安装路径/etc/php.ini #PHP配置文件路劲#rpm -ql httpd mysql php #查看安装文件都在哪#service httpd start #开启http服务#service mysqld start#开启mysql服务#chkconfig httpd on #添加开机自动启动#chkconfig mysqld on #添加开机自动启动修改MySQL 配置文件,增加如下#vi /etc/fcharacter-set-server=utf8 #设置字符集为utf8innodb_file_per_table=1 #让innodb的每个表文件单独存储2.安装Zabbix1)添加zabbix用户和组#useradd zabbix -s /sbin/nologin #创建用户zabbix,不允许登陆系统2)安装zabbixcd /opt/zabbix-2.4.5#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-net-snmp --with-libcurl --enable-proxy --with-mysql=/usr/bin/mysql_config#make && make install说明:--enable-server 启用zabbix-server服务--enable-agent 启用zabbix-agent客户端--with-net-snmp 支持SNMP服务--with-libcurl 支持web界面管理--enable-proxy 启用zabbix-proxy代理服务3)创建zabbix数据库,创建zabbix账号#mysql -u root -p #进入mysql控制台,密码为空create database zabbix character set utf8; #创建数据库zabbix,并且数据库编码使用utf8grant all on zabbix.* to 'zabbix'@'localhost' identified by '123456' with grant option;#创建新账号zabbix,密码为:123456。
zabbix监控windows(zabbixwindows客户端安装详解)zabbix监控windows(zabbix windows客户端安装详解)本例版本为zabbix-1.8.2版本,但⼏乎所有版本安装基本⼀致!拷贝主程序到c:\⽬录下(zabbix_agentd.exe zabbix_get.exe zabbix_sender.exe)主程序放置在zabbix-1.8.2\zabbix-1.8.2\bin\win32下,其他版本⽬录⼀致或者直接下载然后拷贝配置⽂件到c:\ linux和windows配置⽂件⼀致,可相互拷贝(zabbix_agentd.conf)配置⽂件放置在zabbix-1.8.2\zabbix-1.8.2\misc\conf1.修改配置⽂件zabbix_agentd.conf:Server=192.168.0.163 zabbix 服务断IP地址Hostname=Zabbix_windows 本地主机名ListenIP=192.168.0.219 本地ipLogFile=c:\zabbix_agentd.log log⽂件位置,此处切记⼀定修改,默认是linux的⽬录结构2.安装在运⾏中cmd进⼊c盘根⽬录注:如果 zabbix_agentd.conf不在根⽬录下,则必须使⽤config参数,具体如下:c:/win32/zabbix_agentd.exe --config <zabbix_agentd.conf的⽬录> install 。
例如:C:\win32>zabbix_agentd.exe -i -c C:\zabbix\zabbix_agentd.conf#-i install#-c 指定配置⽂件services.msc -->检查zabbix server服务是否启动netstat -an|findstr 10050 查看运⾏状态。
centos上docker部署zabbix环境centos7,docker,zabbix-server5.4,zabbix-agent4.0⼀、zabbix-server1. 安装mysqldocker run --name mysql-server -t \-e MYSQL_DATABASE="zabbix" \-e MYSQL_USER="zabbix" \-e MYSQL_PASSWORD="4242587f*" \-e MYSQL_ROOT_PASSWORD="4242587ff*" \-d mysql:5.7 \--character-set-server=utf8 --collation-server=utf8_bin2. 安装java监控docker run --name zabbix-java-gateway -t \-d zabbix/zabbix-java-gateway:latest3. 安装zabbix-server(内核centos版)docker pull zabbix/zabbix-server-mysql:centos-latest # 拉取centos版镜像docker run --privileged=true -v /home/zabbix-server:/etc/zabbix -v /usr/lib/zabbix/alertscripts:/home/alertscripts --name zabbix-server-mysql -t \-e DB_SERVER_HOST="mysql-server" \-e MYSQL_DATABASE="zabbix" \-e MYSQL_USER="zabbix" \-e MYSQL_PASSWORD="4242587f*" \-e MYSQL_ROOT_PASSWORD="4242587ff*" \-e ZBX_JAVAGATEWAY="zabbix-java-gateway" \--link mysql-server:mysql \--link zabbix-java-gateway:zabbix-java-gateway \-p 10051:10051 \-d zabbix/zabbix-server-mysql:centos-latest**ps:第⼀个-v对应配置⽂件,本地需要提前创建好⽬录和放好zabbix_server.conf;第⼆个-v为脚本放置位置与本机映射。
标题:Zabbix Agent配置指标一、简介Zabbix是一个开源的网络监控系统,能够监控各种网络服务、服务器硬件及网络资源。
Zabbix Agent是Zabbix监控系统中的一个关键组件,用于在被监控设备上收集各种指标数据,并将其发送至Zabbix Server。
本文将介绍Zabbix Agent的配置指标,帮助用户更好地了解和使用Zabbix Agent。
二、配置Zabbix Agent1. 安装Zabbix AgentZabbix Agent可以在各个操作系统上进行安装,如在Linux系统上可以通过包管理工具进行安装,而在Windows系统上则可以从Zabbix 全球信息湾下载安装包进行安装。
安装完成后,需要根据实际环境进行配置。
2. 配置Zabbix Agent参数Zabbix Agent的配置文件为zabbix_agentd.conf,可以在安装目录下找到。
用户可以根据自己的需求对配置文件进行修改,比如设置Server的IP位置区域、日志文件路径、监听端口等参数。
三、Zabbix Agent的常用配置指标1. Hostname在zabbix_agentd.conf文件中,可以通过配置Hostname参数设置被监控设备的主机名。
这样在Zabbix Server上就可以清晰地区分不同设备的监控数据,方便管理和查看。
2. ServerServer参数用于设置Zabbix Server的IP位置区域,这样Zabbix Agent就知道将采集到的监控数据发送至哪个服务器。
用户可以将多个Zabbix Server的IP位置区域配置在这里,用逗号分隔。
3. ListenPortListenPort参数用于设置Zabbix Agent的监听端口,默认为10050。
用户可以根据需要进行修改,但需要保证和Zabbix Server上配置的一致。
4. LogFileLogFile参数用于设置Zabbix Agent的日志文件路径,用户可以根据自己的需求设置。
zabbix agent 标准参数一、概述Zabbix是一款功能强大的开源监控系统,它提供了包括警报、告警机制、历史记录等功能。
其中,Zabbix代理(Agent)是Zabbix系统中的重要组成部分,用于收集各类系统信息并发送给Zabbix服务器。
为了使Zabbix代理能够正常工作,我们需要了解并正确配置其标准参数。
二、参数说明1.主机名(Hostname):这是Zabbix代理的主机名称,用于标识代理所在的主机。
2.用户名(Username):这是用于与Zabbix服务器进行身份验证的用户名。
3.密码(Password):这是用于与Zabbix服务器进行身份验证的密码。
4.版本(Version):Zabbix代理的版本号,用于确定代理与Zabbix服务器的兼容性。
5.有效时间(Validity):该参数指定了Zabbix代理的有效期,通常为一年。
6.更新间隔(Updateinterval):该参数指定了Zabbix代理定期更新自身信息的频率,单位为秒。
7.数据源(Datasource):该参数指定了Zabbix代理从何处获取数据,如SNMP、IPMI等。
8.最大响应时间(Maxresponsetime):该参数指定了Zabbix代理等待数据返回的最大时间,单位为秒。
9.心跳超时时间(Heartbeattimeout):该参数指定了Zabbix代理与Zabbix服务器之间的心跳超时时间,以确保代理与服务器之间的连接正常。
三、配置方法1.在安装Zabbix代理时,系统会要求您输入上述参数,请确保正确填写。
2.在Zabbix代理的配置文件中,您需要修改或添加上述参数。
常见配置文件位置为/etc/zabbix/zabbix_agentd.conf。
3.在修改或添加参数后,您需要重启Zabbix代理,使更改生效。
四、注意事项1.确保您填写的用户名和密码是正确的,且具有足够的权限与Zabbix服务器进行通信。
详解zabbix中文版安装部署2011-07-13 13:07:30标签:监控zabbix原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处、作者信息和本声明。
否则将追究法律责任。
/1068039/609990一、zabbix简介(摘自百度百科)zabbix是一个基于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主动接收监视数据(trapping方式),同时还可被动接收zabbix agent发送的数据(trapping方式)。
另外zabbix server还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。
zabbix的主要特点:- 安装与配置简单,学习成本低- 支持多语言(包括中文)- 免费开源- 自动发现服务器与网络设备- 分布式监视以及WEB集中管理功能- 可以无agent监视- 用户安全认证和柔软的授权方式- 通过WEB界面设置或查看监视结果- email等通知功能等等Zabbix主要功能:- CPU负荷- 内存使用- 磁盘使用- 网络状况- 端口监视- 日志监视由于zabbix是基于web界面将存储在数据库中的数据成图表显示出来,所以zabbix需要运行在web和数据库的平台上,在这里我们使用lemp环境。
zabbix添加你需要监控的主机步骤详解添加监控主机主机192.168.179.104添加进zabbix监控项(在192.168.179.104安装上zabbix-agent)#添加监控主机,注意zabbix版本要和server端⼀致[root@localhost ~]# yum install zabbix40-agent -y --被监控的主机192.168.179.104安装上agent[root@localhost ~]# rpm -qc zabbix40-agent/etc/zabbix/zabbix_agentd.confServer=192.168.179.103 --要将数据给到103,zabbix server端的地址#ServerActive=127.0.0.1Hostname=192.168.179.104 --主机ip启动zabbix-agent服务[root@localhost ~]# systemctl start zabbix-agent[root@localhost ~]# netstat -tpln | grep 100tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 15386/zabbix_agentdtcp6 0 0 :::10050 :::* LISTEN 15386/zabbix_agentd在zabbix当中添加你需要监控的主机为你的主机添加zabbix为我们提供⾃带监控模板当变为蓝⾊代表监控主机成功如果你的监控没有成功过去latest.data⾥⾯看看graph有没有数据过来,图像⾥⾯有曲线代表正常总结到此这篇关于zabbix 添加你需要监控的主机的⽂章就介绍到这了,更多相关zabbix 监控主机内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。
zabbixagent配置详解(windows)客户端操作标注:监控zabbix_agentd客户端安装对象是win server 2008操作系统 64位。
1、下载zabbix_agentd监控客户端软件安装包(windows操作系统客户端)2、关闭监控主机windows server 2008防⽕墙或防⽕墙⼊放⾏zabbix_agentd客户端⼝号 10050 (TPC/UDP)。
3、下载后解压zabbix_agents_3.2.0.win.zip 压缩包,⾥⾯有两个⽂件夹,⼀个是bin⽂件夹,另⼀个是conf⽂件夹。
Bin⽂件夹⾥⾯有两个⽂件夹,⼀个是win32⽂件夹⾥存放zabbix_agentd安装程序应⽤于windows 32位操作系统,⼀个是win64⽂件夹⾥存放zabbix_agentd安装程序应⽤于windows 64位操作系统。
Conf⽂件夹⾥存放是配置⽂件zabbix_agentd.win.conf4、在windows server 2008 操作系统 C盘⽬录下创建⼀个zabbix⽂件夹,把刚下载的zabbix_agentd压缩包⾥的win64位⽂件夹的zabbix.agentd.exe安装程序和conf⽂件夹zabbix_agentd.win.conf复制到windows server 2008操作系统C盘创建的zabbix⽂件夹⾥。
(⽂件夹创建路径可以⾃定义,但后⾯zabbix_agentd客户端运⾏安装命令需要根据创建的路径运⾏)5、右键以⽂本格式编辑zabbix_agentd.win.conf 配置⽂件。
修改下⾯⼏项EnableRemoteCommands=1 #允许在本地执⾏远程命令LogRemoteCommands=1 #执⾏远程命令是否保存操作⽇志Server = 10.8.9.155 #填写zabbix服务器IP地址Hostname=wintest01 #zabbix_agent客户端计算机名 (被监控主机)6、桌⾯ ---- 开始 ---- 运⾏ ----- 输⼊cmd 打开DOS命令窗⼝---- 输⼊以下两条命令进⾏zabbix客户端安装。
一 简介zabbix 是一个基于WEB 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案zabbix 能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题zabbix 由2部分构成,zabbix server 与可选组件zabbix agentzabbix 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 方式)(注:以上简介参考至百度百科)二 关闭selinux1 2 [root@app01 ~]# setenforce 0[root@app01 ~]# getenforce三 LNMP 环境配置MySQL5.6安装1 [root@prx02 ~]# cd /usr/local/src (1)配置依赖以及卸载旧版本的mariadb-server : 1 23 [root@prx02 src]# yum install java-1.8.0-openjdk[root@prx02 src]# rpm -qa | grep mariadb-server[root@prx02 src]# rpm -e --nodeps mariadb-server-5.5.47-1.el7_2.x86_64(2)安装MySQL :1 2 3 4 [root@prx02 src]# rpm -ivh /get/mysql-community-rel ease-el6-5.noarch.rpm[root@prx02 src]# yum install mysql-server -y[root@prx02 src]# yum install mysql-devel -y1 [root@prx02 php-5.6.20]# vim /etc/f修改:[mysqld]innodb_file_per_table1 [root@nmp01 nginx]# chkconfig mysqld on1 2 [root@prx02 src]# service mysqld startStarting mysqld (via systemctl): [ OK ](3)设置root 密码及其他安全选项:1 [root@prx02 src]# mysql_secure_installation(4)创建zabbix 数据库:1 [root@prx02 src]# mysql -uroot -p 1 23456789 1mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'password';mysql> flush privileges ;mysql> show databases;+--------------------+| Database |+--------------------+| information_schema |0 11 12 13 141516| mysql || performance_schema || zabbix |+--------------------+4 rows in set (0.00 sec)mysql> quit;PHP-5.6.20的源码安装(1)下载地址:/get/php-5.6.20.tar.gz/from/a/mirror(2)安装依赖包:1 2 3 4 5 [root@nmp01 libgd-2.1.1]# yum -y install freetype-devel[root@nmp01 libgd-2.1.1]# yum -y install libXpm-devel[root@nmp01 php-5.6.20]# yum install libxml2[root@nmp01 php-5.6.20]# yum install libxml2-devel -y[root@nmp01 php-5.6.20]# yum install -y curl curl-devel安装yasm :下载地址:/projects/yasm/releases/yasm-1.2.0.tar.gz 1 2 3 4 5 [root@nmp01 src]# cd /usr/local/src[root@nmp01 src]# tar -zxvf yasm-1.2.0.tar.gz[root@nmp01 yasm-1.2.0]# cd yasm-1.2.0[root@nmp01 yasm-1.2.0]# ./configure[root@nmp01 yasm-1.2.0]# make && make install安装libmcrypt :下载地址:/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.t ar.gz1 2 3 [root@nmp01 src]# tar -zxvf libmcrypt-2.5.8.tar.gz[root@nmp01 src]# cd libmcrypt-2.5.8[root@nmp01 libmcrypt-2.5.8]# ./configure4 [root@nmp01 libmcrypt-2.5.8]# make && make install 安装libvpx :下载地址:https:///files/libvpx-v1.3.0.tar.bz21 2 3 4 [root@nmp01 src]# tar -jxvf libvpx-v1.3.0.tar.bz2[root@nmp01 src]# cd libvpx-v1.3.0[root@nmp01 libvpx-v1.3.0]# ./configure --prefix=/usr/local/libvpx --en able-shared --enable-vp9[root@nmp01 libvpx-v1.3.0]# make && make install 安装tiff :下载地址:/libtiff/tiff-4.0.3.tar.gz1 2 3 4 [root@nmp01 tiff-4.0.3]# tar -zxvf tiff-4.0.3.tar.gz[root@nmp01 tiff-4.0.3]# cd tiff-4.0.3[root@nmp01 tiff-4.0.3]# ./configure --prefix=/usr/local/tiff --enable-shared[root@nmp01 tiff-4.0.3]# make && make install 安装libpng :下载地址:/projects/libpng/1 2 3 4 [root@nmp01 src]# tar -zxvf libpng-1.6.23.tar.gz[root@nmp01 libpng-1.6.23]# cd libpng-1.6.23[root@nmp01 libpng-1.6.23]# ./configure --prefix=/usr/local/libpng --en able-shared[root@nmp01 libpng-1.6.23]# make && make install 安装freetype :下载地址:/projects/freetype/1 2 3 4 [root@nmp01 src]# tar zxvf freetype-2.6.4.tar.gz[root@nmp01 src]# cd freetype-2.6.4/[root@nmp01 freetype-2.6.4]# ./configure --prefix=/usr/local/freetype --enable-shared[root@nmp01 freetype-2.6.4]# make && make install安装Jpeg :下载地址:/1 2 3 4 [root@nmp01 src]# tar -zxvf jpegsrc.v9b.tar.gz[root@nmp01 src]# cd jpeg-9b/[root@nmp01 jpeg-9b]# ./configure --prefix=/usr/local/jpeg --enable-sh ared[root@nmp01 jpeg-9b]# make && make install 安装libgd :下载地址:https:///libgd/gd-libgd/downloads 1 2 3 4 [root@nmp01 libgd-2.1.1]# tar -zxvf libgd-2.1.1.tar.gz[root@nmp01 libgd-2.1.1]# cd libgd-2.1.1[root@nmp01 libgd-2.1.1]# ./configure --prefix=/usr/local/libgd --enabl e-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --wit h-freetype=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx[root@nmp01 libgd-2.1.1]# make && make install安装t1lib :下载地址:ftp:///pub/Linux/libs/graphics/t1lib-5.1.2.tar.gz 1 2 3 4 5 [root@nmp01 t1lib-5.1.2]# tar -zxvf t1lib-5.1.2.tar.gz[root@nmp01 t1lib-5.1.2]# cd t1lib-5.1.2[root@nmp01 t1lib-5.1.2]# ./configure --prefix=/usr/local/t1lib --enabl e-shared[root@nmp01 t1lib-5.1.2]# make without_doc[root@nmp01 t1lib-5.1.2]# make install(3)php 源码安装:1 2 3 [root@prx02 src]# cd /usr/local/src[root@prx02 src]# tar -zxvf php-5.6.20.tar.gz[root@prx02 php-5.6.20]# cd php-5.6.20/注:如果系统是64位,请执行以下两条命令,否则安装php 会出错(32位系统不需要执行)1 2 [root@prx02 php-5.6.20]# \cp -frp /usr/lib64/libltdl.so* /usr/lib/ [root@prx02 php-5.6.20]# \cp -frp /usr/lib64/libXpm.so* /usr/lib/ 1 2 3 [root@prx02 php-5.6.20]# export LD_LIBRARY_PATH=/usr/local/libgd/lib[root@nmp01 ~]# ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib/li4 5 6 bmysqlclient.so[root@nmp01 ~]# cd /usr/lib[root@nmp01 lib]# mkdir mysql[root@nmp01 lib]# cp /usr/lib64/mysql/* /usr/lib/mysql/1 2 3 [root@prx02 php-5.6.20]# ./configure --prefix=/usr/local/php --with-con fig-file-path=/usr/local/php/etc --with-mysql=/usr --with-mysqli=/usr/b in/mysql_config --with-pdo-mysql --with-gd --with-png-dir=/usr/local/li bpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/fre etype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zli b-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enab le-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable -fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-opens sl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --wit h-curl --enable-ctype[root@prx02 php-5.6.20]# make && make install(4)配置php :1 2 3 4 5 6 7 8 9 10 11 [root@prx02 php-5.6.20]# cd /usr/local[root@prx02 local ]# ln -s php-5.6.20/ php[root@prx02 local ]# cp /usr/local/src/php-5.6.20/php.ini-production /u sr/local/php/etc/php.ini[root@prx02 local ]# cp /usr/local/src/php-5.6.20/sapi/fpm/php-fpm.conf .in /usr/local/php/etc/php-fpm.conf[root@prx02 local ]# ln -s /usr/local/php/sbin/* /usr/sbin/[root@nmp01 php-5.6.20]# ln -s /usr/local/php/etc/php.ini /etc/php.ini [root@nmp01 php-5.6.20]# ln -s /usr/local/php/etc/php-fpm.conf /etc/ph p-fpm.conf(5)修改php.ini :修改:post_max_size = 16Mmax_execution_time = 300max_input_time = 300date.timezone = PRC #设置时区mbstring.func_overload = 0always_populate_raw_post_data = -1expose_php = Off #禁止显示php 版本的信息short_open_tag = ON #支持php 短标签opcache.enable=1 #php 支持opcode 缓存opcache.enable_cli=0 #php 支持opcode 缓存 在最后一行添加:zend_extension=opcache.so #开启opcode 缓存功能附:禁止部分函数的执行(也可以不添加这步配置):修改:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_s tatus,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepa ssthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr ,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_ge t_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posi x_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit, posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttynam e,posix_uname(6)配置和启动php-fpm :1 [root@prx02 mysql]# vim /usr/local/php-5.6.20/etc/php-fpm.conf修改:request_terminate_timeout = 300user = wwwgroup = wwwpid = run/php-fpm.pid #取消前面的分号添加php-fpm 自启动脚本:1 2 3 4 5 6 [root@prx02 ~]# cp /usr/local/src/php-5.6.20/sapi/fpm/init.d.php-fpm /e tc/init.d/php-fpm[root@prx02 init.d]# chmod a+x /etc/init.d/php-fpm[root@prx02 ~]# chkconfig php-fpm on7 8 [root@prx02 local ]# php-fpm或:[root@prx02 local ]# service php-fpm start1 [root@prx02 local ]# netstat -anp | grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN出现上面的提示则说明php-fpm 已经启动起来了注:php-fpm 重启关闭命令:# 启动service php-fpm start# 关闭service php-fpm stop# 重启service php-fpm restart# 重载service php-fpm reloadnginx 的安装和配置安装略修改nginx 配置文件,添加server ,用于访问zabbix 的web 页面(1)修改/usr/local/nginx/conf/nginx.conf :1 2 3 4 5 6 7 8 9 10 11 12 1server {listen 80;server_name localhost;access_log /usr/local/nginx/logs/zabbix.access.log;index index.php index.html index.html;root /usr/local/nginx/html/zabbix;location /{try_files $uri $uri/ /index.php?$args;}3 14 15 16 17 18 19 20 21222324252627location ~ .*\.(php)?${expires -1s;try_files $uri =404;fastcgi_split_path_info ^(.+\.php)(/.+)$;include fastcgi_params;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi _script_name;fastcgi_pass 127.0.0.1:9000;}}(2)测试nginx 中的php 访问:1 [root@prx02 local ]# mkdir -p /usr/local/nginx/html/zabbix1 [root@prx02 local ]# vim /usr/local/nginx/html/zabbix/info.php内容:<?phpphpinfo();?>浏览器中访问:http://127.0.0.1/info.php四 zabbix 服务端的安装和配置下载地址:https:///projects/zabbix/(1)安装:1 2 3 4 5 6 7 8 9 10 11 [root@prx02 ~]# groupadd zabbix[root@prx02 ~]# useradd zabbix -g zabbix -s /bin/false[root@prx02 ~]# cd /usr/local/src[root@prx02 src]# tar -zxvf zabbix-3.0.3.tar.gz[root@prx02 zabbix-3.0.3]# cd zabbix-3.0.3/[root@prx02 zabbix-3.0.3]# yum install -y net-snmp-devel[root@prx02 zabbix-3.0.3]# ./configure --prefix=/usr/local/zabbix --ena ble-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --enable-java [root@prx02 zabbix-3.0.3]# make && make install(2)导入数据库文件:1 [root@nmp01 zabbix-3.0.3]# mysql -uzabbix -p1 2 3 4 5 6 7 8 mysql> use zabbix;mysql> source /usr/local/src/zabbix-3.0.3/database/mysql/schema.sql;mysql> source /usr/local/src/zabbix-3.0.3/database/mysql/images.sql;mysql> source /usr/local/src/zabbix-3.0.3/database/mysql/data.sql;mysql> quit;(3)添加系统软连接:1 2 [root@prx02 zabbix-3.0.3]# ln -s /usr/local/zabbix/sbin/* /usr/local/s bin/[root@prx02 zabbix-3.0.3]# ln -s /usr/local/zabbix/bin/* /usr/local/bi n/(4)添加zabbix 服务对应的端口:1 [root@prx02 mysql]# vim /etc/services在文件末尾添加:# Zabbixzabbix-agent 10050/tcp # Zabbix Agentzabbix-agent 10050/udp # Zabbix Agentzabbix-trapper 10051/tcp # Zabbix Trapperzabbix-trapper 10051/udp # Zabbix Trapper(5)修改zabbix 配置文件: 1 [root@prx02 mysql]# vim /usr/local/zabbix/etc/zabbix_server.conf 修改以下几处: DBName=zabbixDBUser=zabbix DBPassword=zabbix,123. AlertScriptsPath==/usr/local/zabbix/share/zabbix/alertscripts #zabbix 运行脚本存放目录DBPort=33061 [root@prx02 mysql]# vim /usr/local/zabbix/etc/zabbix_agentd.conf 修改:Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/ UnsafeUserParameters=1 #启用自定义key (6)添加开机启动脚本:服务端:1 [root@prx02 mysql]# cp /usr/local/src/zabbix-3.0.3/misc/init.d/fedora/c ore/zabbix_server /etc/rc.d/init.d/zabbix_server客户端:1 [root@prx02 mysql]# cp /usr/local/src/zabbix-3.0.3/misc/init.d/fedora/c ore/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd1 2 3 4 [root@prx02 mysql]# chmod a+x /etc/rc.d/init.d/zabbix_*[root@prx02 mysql]# chkconfig zabbix_server on[root@prx02 mysql]# chkconfig zabbix_agentd on修改zabbix 开机启动脚本中的zabbix 安装目录:1 [root@prx02 mysql]# vim /etc/rc.d/init.d/zabbix_server修改以下内容:BASEDIR=/usr/local/zabbix/1 [root@prx02 mysql]# vim /etc/rc.d/init.d/zabbix_agentd修改以下内容:BASEDIR=/usr/local/zabbix/(7)复制zabbix 的web 站点文件到nginx :1 [root@prx02 mysql]# cp -r /usr/local/src/zabbix-3.0.3/frontends/php/* /usr/local/nginx/html/zabbix/(8)启动:1 2 3 [root@prx02 mysql]# systemctl daemon-reload[root@prx02 mysql]# service zabbix_server start[root@prx02 mysql]# service zabbix_agentd start 查看zabbix_server 相关进程:1 [root@prx02 ~]# ps -eaf|grep zabbix_server五 zabbix 的web 页面设置在zabbix 服务端访问:http://127.0.0.1然后按提示完成zabbix 的web 站点安装,最后再进行登录,默认账号密码:Admin zabbix修改页面语言:页面右上角用户 –> 语言注:如果出现检查PHP 环境时一直缺少某些库,可以尝试删掉php 的源码,然后重新编译安装单独的zabbix 客户端安装请参考我的这篇文章:/575.html。
ZabbixAgent端配置⽂件说明由于⼯作中经常接触到zabbix,所以将agent配置整理⼀下,⽅便⽇常查看。
# This is a config file for the Zabbix agent daemon (Unix)# To get more information about Zabbix, visit ############ GENERAL PARAMETERS #################### Option: PidFile# Name of PID file.## Mandatory: no# Default:#pidFile=PID路径#说明:指定程程序PIDFILE路径,可修改到其它路径,但SNC不建议修改PidFile=/smp/sncmon/zabbix_agentd.pid### Option: LogFile# Name of log file.# If not set, syslog is used.## Mandatory: no# Default:# LogFile=#LogFile=路径#说明:客户端AGENT运⾏产⽣的⽇志⽂件路径,可修改到其它路径,如/var/log/zabbix_agnetd.log,视具体情况修改,也可保持默认LogFile=/smp/sncmon/zabbix_agentd.log### Option: LogFileSize# Maximum size of log file in MB.# 0 - disable automatic log rotation.## Mandatory: no# Range: 0-1024# Default:#LogFileSize=数字#说明:AGENT产⽣⽇志⼤⼩控制,默认1M,若为0,则表⽰不产⽣任何⽇志,数字范围(1-1024M)不建议关闭⽇志功能,建议保持默认LogFileSize=1### Option: DebugLevel# Specifies debug level# 0 - no debug ⽆⽇志级别# 1 - critical information 灾难信息级别# 2 - error information ⼀般错误信息级别# 3 - warnings 警告级别# 4 - for debugging (produces lots of information) 调试级别#说明:0~4级别,⽇志产⽣量在相同单位时间,⽣成的⽇志量为递增,即0级别⽇志量最少,4级别最多,默认3级别,建议视具体情况,⾃⾏把握## Mandatory: no# Range: 0-4# Default:DebugLevel=3### Option: SourceIP# Source IP address for outgoing connections.## Mandatory: no# Default:#SourceIP=IP地址#说明:当系统设置有多个IP时,需要指定⼀个IP与⼆级代理或服务端通信,若系统只有⼀个IP,也建议指定⼀个IPSourceIP=192.168.1.3### Option: EnableRemoteCommands# Whether remote commands from Zabbix server are allowed.# 0 - not allowed 不允许# 1 - allowed 允许## Mandatory: no# Default:#EnableRemoteCommands=0或1#说明:是否允许在本地执⾏远程命令,建议设置为“允许”,因为SNC对命令下发功能进⾏了⼆次开发,功能强⼤,极⼤的⽅便⽇志运维⼯作EnableRemoteCommands=1### Option: LogRemoteCommands# Enable logging of executed shell commands as warnings.# 0 - disabled 不产⽣⽇志# 1 - enabled 产⽣⽇志## Mandatory: no# Default:#LogRemoteCommands=1或0#说明:在参数EnableRemoteCommands=1的情况下,执⾏远程命令是否保存操作⽇志,若已设置EnableRemoteCommands=1#建议LogRemoteCommands=1,以便⽇后查证。