Posted by:
努力记

努力记,通过记录,计划,让自己的努力可以触碰彩虹!

7,844

Zabbix:分布式监控系统

  • 2014-09-26
  • 暂无评论
Zabbix由3部分构成:
  • zabbix server:用于提供web界面的监控服务器,并且存放监控数据
  • zabbix agent(可选组件):用于从被监控主机中收集数据,提供zabbix server获取监控数据
  • zabbix proxy(可选组件):在分布式监控中,用来局部代替server接收监控数据,并统一提交给zabbix server
相对于Cacti,可以明显的看出agent及proxy就是为了分布式而存在的,分担server的监控负载
内部的实际操作和Cacti类似,但提供了相对可控的划分
  • Host:被监控主机
  • Host groups:对被监控主机进行分组
  • items:一项监控信息
  • applications:对items进行分组
  • triggers:触发器,对一组逻辑表达式进行判断,执行trigger event
  • events:事件,分为4种
    • trigger events:触发器事件
    • discovery events:主机或服务发现或丢失事件
    • auto registraion events:agent注册事件
    • internal events:对于内部的item、discovery及trigger进入或退出不可知状态的事件
  • graphs:图形话数据,对于item进行汇总展示
  • network map:进行主机的网络拓扑的制作
建立template:items,triggers,graphs,applications,screens
安装agent:
可以在被监控主机上直接使用yum或apt安装
# yum install zabbix-agent
# apt-get install zabbix-agent
编辑配置文件/usr/local/etc/zabbix_agentd.conf
# This is a config file for Zabbix Agent (Unix) 
# To get more information about Zabbix, visit http://www.zabbix.com 

############ GENERAL PARAMETERS ################# 

### Option: PidFile 
# Name of PID file. 
# 
# Mandatory: no 
# Default: 
# PidFile=/tmp/zabbix_agentd.pid 

### Option: LogFile 
# Name of log file. 
# If not set, syslog is used. 
# 
# Mandatory: no 
# Default: 
# LogFileLogFile= 

LogFile=/tmp/zabbix_agentd.log 

### Option: LogFileSize 
# Maximum size of log file in MB. 
# 0 - disable automatic log rotation. 
# 
# Mandatory: no 
# Range: 0-1024 
# Default: 
# 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) 
# 
# Mandatory: no 
# Range: 0-4 
# Default: 
# DebugLevel=3 

### Option: SourceIP 
# Source IP address for outgoing connections. 
# 
# Mandatory: no 
# Default: 
# SourceIP= 

### Option: EnableRemoteCommands 
# Whether remote commands from Zabbix server are allowed. 
# 0 - not allowed 
# 1 - allowed 
# 
# Mandatory: no 
# Default: 
EnableRemoteCommands=1 

### Option: LogRemoteCommands 
# Enable logging of executed shell commands as warnings. 
# 0 - disabled 
# 1 - enabled 
# 
# Mandatory: no 
# Default: 
LogRemoteCommands=1 

##### Passive checks related 

### Option: Server 
# List of comma delimited IP addresses (or hostnames) of Zabbix servers. 
# No spaces allowed. First entry is used for receiving list of and sending active checks. 
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally. 
# 
# Mandatory: yes 
# Default: 
# ServerServer= 

Server=192.168.1.1 

### Option: Hostname 
# Unique, case sensitive hostname. 
# Required for active checks and must match hostname as configured on the server. 
# Value is acquired from HostnameItem if undefined. 
# 
# Mandatory: no 
# Default: 
# HostnameHostname= 

Hostname=IP131 

### Option: HostnameItem 
# Item used for generating Hostname if it is undefined. 
# Ignored if Hostname is defined. 
# 
# Mandatory: no 
# Default: 
# HostnameItem=system.hostname 

### Option: ListenPort 
# Agent will listen on this port for connections from the server. 
# 
# Mandatory: no 
# Range: 1024-32767 
# Default: 
# ListenPort=10050 

### Option: ListenIP 
# List of comma delimited IP addresses that the agent should listen on. 
# 
# Mandatory: no 
# Default: 
# ListenIP=0.0.0.0 

### Option: DisablePassive 
# Disable passive checks. The agent will not listen on any TCP port. 
# Only active checks will be processed. 
# 0 - do not disable 
# 1 - disable 
# 
# Mandatory: no 
# Default: 
# DisablePassive=0 

##### Active checks related 

### Option: DisableActive 
# Disable active checks. The agent will work in passive mode listening for server. 
# 
# Mandatory: no 
# Default: 
# DisableActive=0 

### Option: ServerPort 
# Server port for retrieving list of and sending active checks. 
# 
# Mandatory: no 
# Default: 
# ServerPort=10051 

### Option: RefreshActiveChecks 
# How often list of active checks is refreshed, in seconds. 
# 
# Mandatory: no 
# Range: 60-3600 
# Default: 
# RefreshActiveChecks=120 

### Option: BufferSend 
# Do not keep data longer than N seconds in buffer. 
# 
# Mandatory: no 
# Range: 1-3600 
# Default: 
# BufferSend=5 

### Option: BufferSize 
# Maximum number of values in a memory buffer. The agent will send 
# all collected data to Zabbix Server or Proxy if the buffer is full. 
# 
# Mandatory: no 
# Range: 2-65535 
# Default: 
# BufferSize=100 

### Option: MaxLinesPerSecond 
# Maximum number of new lines the agent will send per second to Zabbix Server 
# or Proxy processing 'log' and 'logrt' active checks. 
# The provided value will be overridden by the parameter 'maxlines', 
# provided in 'log' or 'logrt' item keys. 
# 
# Mandatory: no 
# Range: 1-1000 
# Default: 
# MaxLinesPerSecond=100 

### Option: AllowRoot 
# Allow the agent to run as 'root'. If disabled and the agent is started by 'root', the agent 
# will try to switch to user 'zabbix' instead. Has no effect if started under a regular user. 
# 0 - do not allow 
# 1 - allow 
# 
# Mandatory: no 
# Default: 
AllowRoot=1 

############ ADVANCED PARAMETERS ################# 

### Option: Alias 
# Sets an alias for parameter. It can be useful to substitute long and complex parameter name with a smaller and simpler one. 
# 
# Mandatory: no 
# Range: 
# Default: 

### Option: StartAgents 
# Number of pre-forked instances of zabbix_agentd that process passive checks. 
# 
# Mandatory: no 
# Range: 1-100 
# Default: 
# StartAgents=3 

### Option: Timeout 
# Spend no more than Timeout seconds on processing 
# 
# Mandatory: no 
# Range: 1-30 
# Default: 
Timeout=10 

### Option: Include 
# You may include individual files or all files in a directory in the configuration file. 
# 
# Mandatory: no 
# Default: 
# Include= 

# Include=/etc/zabbix/zabbix_agentd.userparams.conf 
# Include=/etc/zabbix/zabbix_agentd/ 

####### USER-DEFINED MONITORED PARAMETERS ####### 

### Option: UnsafeUserParameters 
# Allow all characters to be passed in arguments to user-defined parameters. 
# 0 - do not allow 
# 1 - allow 
# 
# Mandatory: no 
# Range: 0-1 
# Default: 
#UnsafeUserParameters=0 

### Option: UserParameter 
# User-defined parameter to monitor. There can be several user-defined parameters. 
# Format: UserParameter=<key>,<shell command> 
# Note that shell command must not return empty string or EOL only. 
# See 'zabbix_agentd' directory for examples. 
# 
# Mandatory: no 
# Default: 
# UserParameter= 

#used for monitor disk io 
UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$4}' 
UserParameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$7}' 
UserParameter=custom.vfs.dev.write.ops[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$8}' 
UserParameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$11}' 
UserParameter=custom.vfs.dev.io.active[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$12}' 
UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$13}' 
UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$6}' 
UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | grep $1 | head -1 | awk '{print $$10}' 

#used for monitor iptables iptstat 
UserParameter=iptstate.tcp,/etc/zabbix/scripts/net-tcp 
UserParameter=iptstate.tcp.syn,/etc/zabbix/scripts/net-syn 
UserParameter=iptstate.tcp.timewait,/etc/zabbix/scripts/net-time-wait 
UserParameter=iptstate.tcp.established,/etc/zabbix/scripts/net-established 
UserParameter=iptstate.tcp.close,/etc/zabbix/scripts/net-close 
UserParameter=iptstate.udp,/etc/zabbix/scripts/net-udp 
UserParameter=iptstate.icmp,/etc/zabbix/scripts/net-icmp
启动:agent是以xinetd模式运行的守护进程,agentd则是传统的守护进程模式
编辑/etc/services,添加
zabbix_agent 10050/tcp
zabbix_trap 10051/tcp
# zabbix_agentd
安装server:
Requirement Description
OpenIPMI Required for IPMI support.
libssh2 Required for SSH support. Version 1.0 or higher.
fping Required for ICMP ping items.
libcurl Required for web monitoring.
libiksemel Required for Jabber support.
net-snmp Required for SNMP support.
从源码安装:
# tar -zxvf zabbix-2.2.0.tar.gz
# groupadd zabbix
# useradd -g zabbix -M -s /sbin/nologin zabbix
# cd zabbix-2.2.0
# ./configure --prefix=/usr/local/zabbix --enable-server --with-mysql -enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
# make install

 

修改配置文件/usr/local/etc/zabbix_server.conf
ListenPort=10051
LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/var/run/zabbix/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

 

#扩展配置

 

StartPollers = 50
StartIPMIPollers=3
StartPollersUnreachable=10
StartTrappers=50
StartPingers=40
StartDiscoverers=10
StartHTTPPollers=20
StartTimers=20
StartVMwareCollectors=5
VMwareFrequency=45
VMwareCacheSize=256M
StartSNMPTrapper=1
HousekeepingFrequency=6
MaxHousekeeperDelete=10000
SenderFrequency=5
CacheSize=1G
CacheUpdateFrequency=60
StartDBSyncers=50
HistoryCacheSize=1G
TrendCacheSize=1G
HistoryTextCacheSize=1G
ValueCacheSize=512M
Timeout=30
UnavailableDelay=30
LogSlowQueries=3000
StartProxyPollers=10
AllowRoot=1 #让 zabbix 进程以root用户运行,可避免一些权限不足的问题
建立数据库及数据库角色(在mysql命令行中执行):
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
flush privileges
导入数据库:
# mysql -u<username> -p zabbix < database/mysql/schema.sql
# mysql -u<username> -p zabbix < database/mysql/data.sql
# mysql -u<username> -p zabbix < database/mysql/images.sql
配置zabbix:
# cp misc/init.d/redhat/zabbix_server /etc/init.d/zabbix-server
# mkdir /etc/zabbix
# cp /usr/local/zabbix/etc/zabbix_server.conf /etc/zabbix/
# mkdir /var/log/zabbix
# mkdir /var/run/zabbix
# chown zabbix:zabbix /var/log/zabbix
# chown zabbix:zabbix /var/run/zabbix
# chmod +x /etc/init.d/zabbix-server
# chkconfig zabbix-server on
frontend需要服务器安装php+mysql+web service(Apache,Nginx)
修改php配置:
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_execution_time = 300
max_input_time = 300
session.auto_start = 0  ??

 

php的扩展支持:
PHP extensions:
gd 2.0 PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir).
bcmath
php-bcmath (--enable-bcmath)
ctype
php-ctype (--enable-ctype)
libXML 2.6.15 php-xml or php5-dom, if provided as a separate package by the distributor.
xmlreader
php-xmlreader, if provided as a separate package by the distributor.
xmlwriter
php-xmlwriter, if provided as a separate package by the distributor.
session
php-session, if provided as a separate package by the distributor.
sockets
php-net-socket (--enable-sockets). Required for user script support.
mbstring
php-mbstring (--enable-mbstring)
gettext
php-gettext (--with-gettext). Required for translations to work.
ibm_db2
Required if IBM DB2 is used as Zabbix backend database.
mysqli
Required if MySQL is used as Zabbix backend database.
oci8
Required if Oracle is used as Zabbix backend database.
pgsql
Required if PostgreSQL is used as Zabbix backend database.
sqlite3
Required if SQLite is used as Zabbix backend database.
设定frontend:
将webservice设定web访问路径frontends/php/
可以复制到有web权限的目录下
# cp -r ./frontends/php/* /var/www/zabbix/
重新启动web service
访问web进行配置操作
默认的用户名密码:Admin<zabbix>
乱码问题:
上传C:\Windows\Fonts\simkai.ttf到frontends/fonts目录下(实际的前端目录)
vi frontends/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'simkai');
define('ZBX_FONT_NAME', 'simkai');

 



back up ↑

无觅相关文章插件,快速提升流量