zabbix_Agent 監控配置說明


Agent 監控配置說明

Linux安裝Agent

1.查看系統版本

查看系統版本

uname -a
1
根據系統版本下載對應的zabbix-agent版本安裝
下載地址:http://repo.zabbix.com/zabbix

2.安裝zabbix-agent

把下載好的rpm安裝包拷貝到主機上
運行命令安裝

rpm -ivh zabbix-agent-3.0.4-1.el7.x86_64.rpm
1
安裝完成后設置開機自動啟動

chkconfig zabbix-agent on
1
3.配置zabbix-agent

ServerActive=10.0.0.105(zabbix-server的IP地址)
Timeout=15(超時時間)
AllowRoot=1(允許以root運行)
UnsafeUserParameters=1(允許特殊字符)
UserParameter(配置自定義key)

詳細配置詳解

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

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

PidFile=/var/run/zabbix/zabbix_agentd.pid

PidFile
默認值:/tmp/zabbix_agentd.pid
PID文件名

### Option: LogType
# Specifies where log messages are written to:
# system - syslog
# file - file specified with LogFile parameter
# console - standard output
#
# Mandatory: no
# Default:
# LogType=file

LogType
指定日志消息寫入的位置
system:syslog
file:使用LogFile參數指定的文件
console:標准輸出

### Option: LogFile
# Log file name for LogType 'file' parameter.
#
# Mandatory: no
# Default:
# LogFile=

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFile
日志文件路徑
如果未配置,日志會記錄到syslog中

### Option: LogFileSize
# Maximum size of log file in MB.
# 0 - disable automatic log rotation.
#
# Mandatory: no
# Range: 0-1024
# Default:
# LogFileSize=1
LogFileSize=0

LogFileSize
取值范圍:0-1024
默認值:1
日志文件大小,單位為MB。
0 - 關閉自動輪滾.
備注:如果日志文件到達了最大值並且文件輪滾失敗,那么老日志文件會被清空掉。

### Option: DebugLevel
# Specifies debug level:
# 0 - basic information about starting and stopping of Zabbix processes
# 1 - critical information
# 2 - error information
# 3 - warnings
# 4 - for debugging (produces lots of information)
# 5 - extended debugging (produces even more information)
#
# Mandatory: no
# Range: 0-5
# Default:
# DebugLevel=3

DebugLevel
取值范圍:0-5
默認值:3
指定日志級別
0 - basic information about starting and stopping of Zabbix processes
1 - critical級別
2 - error級別
3 - warnings級別
4 - debug級別
5 - extended debugging (與級別4一樣. 只能使用runtime control 來設置.)

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

SourceIP
zabbix對外連接的出口IP地址

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

EnableRemoteCommands
默認值:0
是否運行zabbix server在此服務器上執行遠程命令
0 - 禁止
1 - 允許

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

LogRemoteCommands
默認值:0
記錄原型執行的shell命令日志,級別為warrning
0 - disabled
1 - enabled

### Option: Server
# List of comma delimited IP addresses (or hostnames) of Zabbix servers.
# Incoming connections will be accepted only from the hosts listed here.
# If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally.
#
# Mandatory: no
# Default:
# Server=

Server=10.0.0.100

Server
zabbix server的ip地址,多個ip使用逗號分隔

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

ListenPort
取值范圍:1024-32767
默認值10050
監聽端口

### Option: ListenIP
# List of comma delimited IP addresses that the agent should listen on.
# First IP address is sent to Zabbix server if connecting to it to retrieve list of active checks.
#
# Mandatory: no
# Default:
# ListenIP=0.0.0.0

ListenIP
默認值:0.0.0.0
監聽IP地址,默認為所有接口,多個ip之間使用逗號分隔

### Option: StartAgents
# Number of pre-forked instances of zabbix_agentd that process passive checks.
# If set to 0, disables passive checks and the agent will not listen on any TCP port.
#
# Mandatory: no
# Range: 0-100
# Default:
# StartAgents=3

StartAgents
取值范圍:0-100
默認值:3
zabbix啟動之后開啟被動監控的進程數量,如果設置為0,那么zabbix被動監控被禁用,並且不會監聽相應端口,也就是說10050端口不會開啟。

### Option: ServerActive
# List of comma delimited IP:port (or hostname:port) pairs of Zabbix servers for active checks.
# If port is not specified, default port is used.
# IPv6 addresses must be enclosed in square brackets if port for that host is specified.
# If port is not specified, square brackets for IPv6 addresses are optional.
# If this parameter is not specified, active checks are disabled.
# Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
#
# Mandatory: no
# Default:
# ServerActive=

ServerActive=10.0.0.100:10052

ServerActive
zabbix 主動監控server的ip地址,使用逗號分隔多IP,如果注釋這個選項,那么當前服務器的主動監控就被禁用了

### 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:
# Hostname=

Hostname
默認值:HostnameItem配置的值
主機名,必須唯一,區分大小寫。Hostname必須和zabbix web上配置的一直,否則zabbix主動監控無法正常工作。為什么呢?因為agent拿着這個主機名去問server,我有配置主動監控項 嗎?server拿着這個主機名去配置里面查詢,然后返回信息。
支持字符:數字字母、’.’、’ ‘、 ‘_’、 ‘-‘,不超過64個字符

### Option: HostnameItem
# Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.
# Does not support UserParameters or aliases.
#
# Mandatory: no
# Default:
# HostnameItem=system.hostname

HostnameItem
默認值:system.hostname
設置主機名,只有當HostMetadata沒設置,她才生效。不支持UserParameters 、aliases,支持system.run[]

### Option: HostMetadata
# Optional parameter that defines host metadata.
# Host metadata is used at host auto-registration process.
# An agent will issue an error and not start if the value is over limit of 255 characters.
# If not defined, value will be acquired from HostMetadataItem.
#
# Mandatory: no
# Range: 0-255 characters
# Default:
# HostMetadata=

HostMetadata
取值范圍:0-255 字符
僅用於主機自動注冊功能,如果當前值為定義,那么它的值默認為HostMetadataItem的值。這個選項在2.2.0之后加入,並且確保支付不能超過限制,以及字符串必須是UTF8,否則服務器無法啟動

### Option: HostMetadataItem
# Optional parameter that defines an item used for getting host metadata.
# Host metadata is used at host auto-registration process.
# During an auto-registration request an agent will log a warning message if
# the value returned by specified item is over limit of 255 characters.
# This option is only used when HostMetadata is not defined.
#
# Mandatory: no
# Default:
# HostMetadataItem=

HostMetadataItem
功能同上,如果HostMetadata值未設置,這個配置才有效。支持使用UserParameters、alias、system.run[]

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

RefreshActiveChecks
取值范圍:60-3600
默認值:120
多久時間(秒)刷新一次主動監控配置信息,如果刷新失敗,那么60秒之后會重試一次

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

BufferSend
取值范圍:1-3600
默認值:5
數據存儲在buffer中最長多少秒

### 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

BufferSize
取值范圍:2-65535
默認值:100
buffer最大值,如果buffer滿了,zabbix將會將檢索到的數據發送給zabbix server或者proxy

### 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=20

MaxLinesPerSecond
取值范圍:1-1000
默認值:20
處理監控類型為log何eventlog日志時,agent每秒最大發送的行數。默認為20行

### Option: Alias
# Sets an alias for an item key. It can be used to substitute long and complex item key with a smaller and simpler one.
# Multiple Alias parameters may be present. Multiple parameters with the same Alias key are not allowed.
# Different Alias keys may reference the same item key.
# For example, to retrieve the ID of user 'zabbix':
# Alias=zabbix.userid:vfs.file.regexp[/etc/passwd,^zabbix:.:([0-9]+),,,,\1]
# Now shorthand key zabbix.userid may be used to retrieve data.
# Aliases can be used in HostMetadataItem but not in HostnameItem parameters.
#
# Mandatory: no
# Range:
# Default:

Alias
key的別名,例如 Alias=ttlsa.userid:vfs.file.regexp[/etc/passwd,^ttlsa:.:([0-9]+),,,,\1], 或者ttlsa的用戶ID。你可以使用key:vfs.file.regexp[/etc/passwd,^ttlsa:.: ([0-9]+),,,,\1],也可以使用ttlsa.userid。

備注: 別名不能重復,但是可以有多個alias對應同一個key。

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

Timeout
默認值:1-30
默認值:3
超時時間

### 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 the user specified by the User configuration option instead.
# Has no effect if started under a regular user.
# 0 - do not allow
# 1 - allow
#
# Mandatory: no
# Default:
# AllowRoot=0
AllowRoot=1

AllowRoot
默認值:0
是否允許使用root身份運行zabbix,如果值為0,並且是在root環境下,zabbix會嘗試使用zabbix用戶運行,如果不存在會告知zabbix用戶不存在。
0 - 不允許
1 - 允許

### Option: User
# Drop privileges to a specific, existing user on the system.
# Only has effect if run as 'root' and AllowRoot is disabled.
#
# Mandatory: no
# Default:
# User=zabbix

User
默認值:zabbix
運行zabbix程序的用戶,如果AllowRoot被禁用,才有效果

### Option: Include
# You may include individual files or all files in a directory in the configuration file.
# Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
#
# Mandatory: no
# Default:
# Include=

Include=/etc/zabbix/zabbix_agentd.d/

# Include=/usr/local/etc/zabbix_agentd.userparams.conf
# Include=/usr/local/etc/zabbix_agentd.conf.d/
# Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf

nclude
包含自配置文件,不同的配置寫到不同的文件中,然后include,配置文件會顯得規范。例如: /absolute/path/to/config/files/*.conf. Zabbix 2.4.0開始支持正則表達式。

### Option: UnsafeUserParameters
# Allow all characters to be passed in arguments to user-defined parameters.
# The following characters are not allowed:
# \ ' " ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @
# Additionally, newline characters are not allowed.
# 0 - do not allow
# 1 - allow
#
# Mandatory: no
# Range: 0-1
# Default:
# UnsafeUserParameters=0
UnsafeUserParameters=1

UnsafeUserParameters
取值范圍:0,1
默認值: 0
允許所有字符的參數傳遞給用戶定義的參數(包括特殊字符)。

### Option: UserParameter
# User-defined parameter to monitor. There can be several user-defined parameters.
# Format: UserParameter=<key>,<shell command>
# See 'zabbix_agentd' directory for examples.
#
# Mandatory: no
# Default:
# UserParameter=
UserParameter=system.cpu.steal,nproc
UserParameter=dskTotal[*],python /root/disk.py $1 $2
UserParameter=ifNumber,/etc/init.d/network status |awk 'NR==4'|awk -v RS="@#$j" '{print gsub(/ /,"&")+1}'
UserParameter=ifInQLen[*],ethtool -S $1 |grep 'Tx Queue#:'|awk '{print $2 3}'
UserParameter=ifOutQLen[*],ethtool -S $1 |grep 'Rx Queue#:'|awk '{print $2 3}'
UserParameter=ifStatus[*],python /root/Net.py $1 $2

UserParameter
用戶自定義key,格式: UserParameter=,
例如:serParameter=system.test,who|wc -l

### Option: LoadModulePath
# Full path to location of agent modules.
# Default depends on compilation options.
#
# Mandatory: no
# Default:
# LoadModulePath=${libdir}/modules

LoadModulePath
模塊路徑,絕對路徑

### Option: LoadModule
# Module to load at agent startup. Modules are used to extend functionality of the agent.
# Format: LoadModule=<module.so>
# The modules must be located in directory specified by LoadModulePath.
# It is allowed to include multiple LoadModule parameters.
#
# Mandatory: no
# Default:
# LoadModule=

LoadModule
加載模塊文件,可以寫多個
格式: LoadModule=
必須配置LoadModulePath,指定模塊目錄

####### TLS-RELATED PARAMETERS #######

### Option: TLSConnect
# How the agent should connect to server or proxy. Used for active checks.
# Only one value can be specified:
# unencrypted - connect without encryption
# psk - connect using TLS and a pre-shared key
# cert - connect using TLS and a certificate
#
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:
# TLSConnect=unencrypted

### Option: TLSAccept
# What incoming connections to accept.
# Multiple values can be specified, separated by comma:
# unencrypted - accept connections without encryption
# psk - accept connections secured with TLS and a pre-shared key
# cert - accept connections secured with TLS and a certificate
#
# Mandatory: yes, if TLS certificate or PSK parameters are defined (even for 'unencrypted' connection)
# Default:
# TLSAccept=unencrypted

### Option: TLSCAFile
# Full pathname of a file containing the top-level CA(s) certificates for
# peer certificate verification.
#
# Mandatory: no
# Default:
# TLSCAFile=

### Option: TLSCRLFile
# Full pathname of a file containing revoked certificates.
#
# Mandatory: no
# Default:
# TLSCRLFile=

### Option: TLSServerCertIssuer
# Allowed server certificate issuer.
#
# Mandatory: no
# Default:
# TLSServerCertIssuer=

### Option: TLSServerCertSubject
# Allowed server certificate subject.
#
# Mandatory: no
# Default:
# TLSServerCertSubject=

### Option: TLSCertFile
# Full pathname of a file containing the agent certificate or certificate chain.
#
# Mandatory: no
# Default:
# TLSCertFile=

### Option: TLSKeyFile
# Full pathname of a file containing the agent private key.
#
# Mandatory: no
# Default:
# TLSKeyFile=

### Option: TLSPSKIdentity
# Unique, case sensitive string used to identify the pre-shared key.
#
# Mandatory: no
# Default:
# TLSPSKIdentity=

### Option: TLSPSKFile
# Full pathname of a file containing the pre-shared key.
#
# Mandatory: no
# Default:
# TLSPSKFile=

windows安裝Agent

1.下載zabbix-agent壓縮包

下載地址:http://www.zabbix.com/download

2.安裝zabbix-agent

1)在非C盤的任意盤創建zabbix文件夾(以D盤為例)
2)解壓下載的zabbix-agent文件,根據系統是64位還是32位系統,選擇對應版本(以64位為例)
3)將解壓出來的文件夾下的 bin\win64 文件夾中的文件拷貝到創建的zabbix文件夾下
4)將解壓出來的文件夾下的 conf 文件夾拷貝到創建的zabbix文件夾下
5)打開 zabbix\conf\ 下的zabbix_agentd.win.conf 修改配置(方法同上)
6)修改好后保存退出,打開終端,運行

D:\zabbix\zabbix_agentd.exe -c D:\zabbix\conf\zabbix_agentd.win.conf -i

D:\zabbix\zabbix_agentd.exe -c D:\zabbix\conf\zabbix_agentd.win.conf -s


-i 安裝
-d 卸載
-s 啟動
-x 停止
-h 幫助
-c 配置文件位置
注意: 關閉防火牆,或者開放指定端口

轉自:http://blog.csdn.net/qq_28426351/article/details/53485435


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM