1. 程式人生 > 實用技巧 >Zabbix下檢視引數的小技巧

Zabbix下檢視引數的小技巧

我們在管理、維護Zabbix的時候,經常需要檢視配置檔案下的一些引數資訊。下面介紹一些常用的小技巧。

1:我想知道zabbix_server.conf檔案中配置了那些引數。

# grep '^[a-Z]' /etc/zabbix/zabbix_server.conf 
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=xxxxxxxx
DBSocket=/mysql_data/mysql/mysql.sock
StartPollers=15
StartTrappers=40
StartPingers=10
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
CacheSize=2048M
ValueCacheSize=128M
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

2我想知道zabbix_agentd.conf

檔案中配置了那些引數。

[root@KerryDB ~]# grep '^[a-Z]' /etc/zabbix/zabbix_agentd.conf 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
EnableRemoteCommands=1
Server=192.168.xxx.xxx
ServerActive=192.168.xxx.xxx
Hostname=getlnx14uat
Include=/etc/zabbix/zabbix_agentd.d/
UnsafeUserParameters=1
UserParameter=custom.iptables.version,/sbin/iptables --version | cut -d 'v' -f 2
[root@KerryDB ~]# cat /etc/zabbix/zabbix_agentd.conf | grep -v ^$ | grep -v ^#
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
DenyKey=system.run[*]
Server=192.168.xxx.xxx
ServerActive=192.168.xxx.xxx
Hostname=KerryDB
Include=/etc/zabbix/zabbix_agentd.d/*.conf
UserParameter=custom.iptables.version,/sbin/iptables --version | cut -d 'v' -f 2
[root@KerryDB ~]# 

3:我想檢視某個引數的值,例如CacheSize的值

# grep "^CacheSize" /etc/zabbix/zabbix_server.conf 
CacheSize=2048M
#grep -B 5 "^CacheSize" /etc/zabbix/zabbix_server.conf
#
# Mandatory: no
# Range: 128K-64G
# Default:
# CacheSize=8M
CacheSize=2048M

4:我想檢視某幾個引數的值

[root@KerryDB ~]# egrep 'LogFileSize|UserParameter' /etc/zabbix/zabbix_agentd.conf
### Option: LogFileSize
# LogFileSize=1
LogFileSize=0
# Does not support UserParameters or aliases.
### Option: UnsafeUserParameters
# UnsafeUserParameters=0
### Option: UserParameter
# Format: UserParameter=<key>,<shell command>
# UserParameter=
UserParameter=custom.iptables.version,/sbin/iptables --version | cut -d 'v' -f 2
[root@KerryDB ~]# egrep 'LogFileSize|UserParameter' /etc/zabbix/zabbix_agentd.conf | grep '^[L,U]'
LogFileSize=0
UserParameter=custom.iptables.version,/sbin/iptables --version | cut -d 'v' -f 2
[root@KerryDB ~]#