标签 zabbix 下的文章

Zabbix Web场景监控小记

页面或接口直接请问失败或打不开监控项表达式:主机端口宕掉时会会触发·

{sso-git-zull-c:web.test.fail[Zuul网关接口_134].last()}<>0   #对应Failed step of scenario "Zuul网关接口_134"

页面或接口请求状态非200表达式:

{sso-git-zull-c:web.test.rspcode[Zuul网关接口_134,zuul网关_134].last()}<>200  #对应Response code for step "zuul网关_134" of scenario "Zuul网关接口_134"

页面或接口请求缓慢表达式:

{sso-git-zull-c:web.test.time[Zuul网关接口_134,zuul网关_134,resp].last()}>10 #对应Response time for step "zuul网关_134" of scenario "Zuul网关接口_134".

zabbix3.x中文图片乱码终极解决

zabbix-logo.png
Zabbix乱码是由于默认使用DejaVuSan.ttf字体,该字体不支持中文,切换语言成中文Zh_cn后,在图表上中文出现乱码,如下图:
lm.png

解决zabbix乱码方法如下:
找到本地C:WindowsFontsmsyh.ttf(微软雅黑)上传到服务器zabbix网站目录fonts目录下
修改includedefines.inc.php中的DejaVuSans为msyh

define('ZBX_GRAPH_FONT_NAME',        'msyh');
define('ZBX_FONT_NAME', 'msyh');

再次刷新即可正常;
tb.png

如果还乱码,就需要检查数据库编码是否是utf8编码了

show create database zabbixdb; #查看数据库创建编码
root@monitor-db 09:23:05 [(none)]>show create database zabbixdb;
+----------+-------------------------------------------------------------------+
| Database | Create Database                                                   |
+----------+-------------------------------------------------------------------+
| zabbixdb | CREATE DATABASE `zabbixdb` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+-------------------------------------------------------------------+
1 row in set (0.00 sec)

若数据库是utf8编码,但还乱码,就需要继续盘查,php编译参数中是否编译了jpeg、png、freetype等组件,
编译顺序如下:

安装libmcrypt:
cd /opt
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install

安装 jpeg6

 mkdir /usr/local/jpeg6
 mkdir /usr/local/jpeg6/bin
 mkdir /usr/local/jpeg6/lib
 mkdir /usr/local/jpeg6/include
 mkdir /usr/local/jpeg6/man
 mkdir /usr/local/jpeg6/man/man1
cd /opt
tar zxf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config/config.sub .
cp /usr/share/libtool/config/config.guess .
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make && make install

安装png

cd /opt
tar zxvf libpng-1.6.10.tar.gz
./configure --prefix=/usr/local/png --enable-shared
make && make install

安装freetype

cd /opt
tar zxvf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure --prefix=/usr/local/freetype --enable-shared
make && make install

最后编译php参数如下:

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql --with-mysqli=/usr/bin/mysql_config --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr/local/png --with-freetype-dir=/usr/local/freetype --with-mcrypt=/usr/local/libmcrypt --enable-maintainer-zts --with-ldap=shared --without-gdbm 
make -j 8
make install

Zabbix housekeeper processes more than 75% busy

收到Zabbix housekeeper processes more than 75% busy 报警,
问题原因
为了防止数据库持续增大,zabbix有个自动删除历史数据的机制,就是housekeeper,而mysql数据库删数据的时候,性能会降低,就会报这个错误,
解决方法如下:
调整HousekeepingFrequency参数,设置为3小时执行一次

vim /usr/local/zabbix/etc/zabbix_server.conf
HousekeepingFrequency=3            #间隔时间
MaxHousekeeperDelete=3000       #最大删除量

重新启动zabbix_server生效:

/etc/init.d/zabbix_server restart

查看log发现删除时已经带上了最大3000行

tail -f /tmp/zabbix_server.log
 10622:20181109:162644.037 resuming Zabbix agent checks on host "ETS-DB": connection restored
 10005:20181109:162646.629 slow query: 6.579011 sec, "delete from history_uint where itemid=40531 limit 3000"
 10005:20181109:162659.356 slow query: 4.364114 sec, "delete from history_uint where itemid=40399 limit 3000"
 10024:20181109:162701.359 item "dbnode1:uptime" became not supported: Unsupported item key.
 10033:20181109:162713.585 item "OA-DB:uptime" became not supported: Unsupported item key.
 10676:20181109:162718.903 cannot send list of active checks to "192.168.255.148": host [PingAn-Bank] not found
 10005:20181109:162722.824 slow query: 23.467607 sec, "delete from history_uint where itemid=40510 limit 3000"
 10680:20181109:162724.601 cannot send list of active checks to "192.168.255.132": host [WINN5F1QHDELEP] not found
 10038:20181109:162735.390 item "dbnode1_zs:uptime" became supported
 10005:20181109:162745.124 slow query: 22.299782 sec, "delete from history_uint where itemid=40515 limit 3000"
 10025:20181109:162757.104 item "dbnode1_zs:uptime" became not supported: Unsupported item key.
 10005:20181109:162806.766 slow query: 21.642425 sec, "delete from history_uint where itemid=40505 limit 3000"
 10005:20181109:162812.225 slow query: 5.458863 sec, "delete from history_uint where itemid=40511 limit 3000"
 10016:20181109:162817.036 item "dbnode1_zs:uptime" became supported
 10005:20181109:162818.444 slow query: 6.217885 sec, "delete from history_uint where itemid=40516 limit 3000"
 10005:20181109:162824.287 slow query: 5.843189 sec, "delete from history_uint where itemid=40506 limit 3000"

Zabbix3.4.11使用Orabbix插件监控Oracle 11g R2

Orabbix简介
Orabbix是设计用来为zabbix监控Oracle的数据库的插件,它提供多层次的监控,包括可用性和服务器性能的指标。
ORABBIX.png
Orabbix监控的内容:

1. 数据库版本

2. 归档文件

3. 等待的事件(如文件的I/O,单块的读,多块的读,直接读,SQLNet消息,控制文件I/O,日志写等)

4. HitRatio(监控Hit Ratio的触发,表/存储过程,SQLArea,Body)

5. 逻辑I/O(当前读操作,持续的读操作,块的更改)

6. PGA

7. SGA(固定的缓冲,JAVApool,Large Pool,Log Buffer,Shared Pool,Buffer Cache)

8. 物理I/O(重写操作,数据文件写操作,数据文件读操作)

9. SharePool(PoolDictionary Cache, Pool Free Memory, Library Cache,Sql Area ,Misc.)

10. Pin Hit Ratio(monitor Hit Ratio on Trigger, Tables/Procedures, SQLArea,Body)

11. Session/Processes(monitor Sessions and processes)

12. Session (ActiveSession, Inactive Sessions, System Session)

安装步骤如下:
1、JAVA环境配置
若是没有java 需要安装JDK环境:
jdk官方下载地址 http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz

mkdir /usr/lib/jvm/
tar -xvf jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm/
echo "export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_80" >>  /etc/profile
source /etc/profile
echo "export JRE_HOME=${JAVA_HOME}/jre" >>  /etc/profile
source /etc/profile
echo "export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib" >>  /etc/profile
echo "export PATH=${JAVA_HOME}/bin:$PATH" >>  /etc/profile
source /etc/profile
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_80/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_80/bin/javac 300

安装完毕查看版本:

[root@dbnode1 opt]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

2、Orabbix插件的下载安装
http://www.smartmarmot.com/product/orabbix/download/
也可以直接搜索下载,目前最新版本为1.2.3

创建一个目录作为orabbix的源地址:
mkdir -p /usr/local/orabbix
解压缩插件:
unzip -n orabbix-1.2.3.zip -d /usr/local/orabbix/

3、更改配置文件:

cd /usr/local/orabbix/
cp conf/config.props.sample conf/config.props
添加系统启动脚本:
cp init.d/orabbix /etc/init.d/orabbix
并修改路径:
vim /etc/init.d/orabbix
orabbix=/usr/local/orabbix

给启动脚本加执行权限

chmod +x /usr/local/orabbix/run.sh
chmod +x /etc/init.d/orabbix

修改配置文件内如如下

cat /usr/local/orabbix/conf/config.props | grep -v "^$"|grep -v "^#"

ZabbixServerList=ZabbixServer1

ZabbixServer1.Address=192.168.3.209
ZabbixServer1.Port=10051


OrabbixDaemon.PidFile=./logs/orabbix.pid
OrabbixDaemon.Sleep=300
OrabbixDaemon.MaxThreadNumber=100

DatabaseList=dbnode1

DatabaseList.MaxActive=10
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1

dbnode1.Url=jdbc:oracle:thin:@192.168.2.110:1521:ORCL
dbnode1.User=zabbix
dbnode1.Password=xxxxxxxx
dbnode1.MaxActive=10
dbnode1.MaxWait=100
dbnode1.MaxIdle=1
dbnode1.QueryListFile=./conf/query.props

4、使用DBA账号登陆oracle控制台,创建zabbix用户并赋权

CREATE USER ZABBIX IDENTIFIED BY ZABBIX2018 DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;

GRANT ALTER SESSION TO ZABBIX;
GRANT CREATE SESSION TO ZABBIX;
GRANT CONNECT TO ZABBIX;
GRANT RESOURCE TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;
GRANT SELECT ON V_$INSTANCE TO ZABBIX;
GRANT SELECT ON DBA_USERS TO ZABBIX;
GRANT SELECT ON V_$LOG_HISTORY TO ZABBIX;
GRANT SELECT ON V_$PARAMETER TO ZABBIX;
GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO ZABBIX;
GRANT SELECT ON V_$LOCK TO ZABBIX;
GRANT SELECT ON DBA_REGISTRY TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$SYSSTAT TO ZABBIX;
GRANT SELECT ON V_$LATCH TO ZABBIX;
GRANT SELECT ON V_$PGASTAT TO ZABBIX;
GRANT SELECT ON V_$SGASTAT TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$PROCESS TO ZABBIX;
GRANT SELECT ON DBA_DATA_FILES TO ZABBIX;
GRANT SELECT ON DBA_TEMP_FILES TO ZABBIX;
GRANT SELECT ON DBA_FREE_SPACE TO ZABBIX;
GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX;
GRANT SELECT ANY TABLE TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;
GRANT UNLIMITED TABLESPACE TO ZABBIX;

以下授权需要使用sysdba账号登陆
GRANT SELECT ON V_$LOG_HISTORY TO ZABBIX;
GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON DBA_DATA_FILES TO ZABBIX;
GRANT SELECT ON DBA_TEMP_FILES TO ZABBIX;
GRANT SELECT ON DBA_FREE_SPACE TO ZABBIX;
GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX;
GRANT SELECT ON V_$SESSION TO ZABBIX; 
exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description => 'resolve acl', principal =>'ZABBIX', is_grant => true, privilege => 'resolve');
exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*');
COMMIT;

5、启动orabbix服务、加入开机启动:

/etc/init.d/orabbix start
chkconfig orabbix on

6、查看日志

tail -f /usr/local/orabbix/logs 
 2018-07-17 11:36:36,662 [pool-1-thread-1] ERROR Orabbix - Error on DBEnquiry on query=archive on database=dbnode1 Error returned is java.lang.IllegalArgumentException: null value for key 'archive'
 2018-07-17 11:36:36,664 [pool-1-thread-1] WARN  Orabbix - Error while executing ->audit- on database ->dbnode1- Exception received ORA-00942: table or view does not exist

 2018-07-17 11:36:36,665 [pool-1-thread-1] WARN  Orabbix - Error while executing ->dbblockgets- on database ->dbnode1- Exception received ORA-00942: table or view does not exist

 2018-07-17 11:36:36,665 [pool-1-thread-1] ERROR Orabbix - Error on DBEnquiry on query=dbblockgets on database=dbnode1 Error returned is java.lang.IllegalArgumentException: null value for key 'dbblockgets
'
 2018-07-17 11:36:36,666 [pool-1-thread-1] WARN  Orabbix - Error while executing ->dbconsistentgets- on database ->dbnode1- Exception received ORA-00942: table or view does not exist

 2018-07-17 11:36:36,666 [pool-1-thread-1] ERROR Orabbix - Error on DBEnquiry on query=dbconsistentgets on database=dbnode1 Error returned is java.lang.IllegalArgumentException: null value for key 'dbcons
istentgets'
 2018-07-17 11:36:36,667 [pool-1-thread-1] WARN  Orabbix - Error while executing ->dbhitratio- on database ->dbnode1- Exception received ORA-00942: table or view does not exist

 2018-07-17 11:36:36,667 [pool-1-thread-1] ERROR Orabbix - Error on DBEnquiry on query=dbhitratio on database=dbnode1 Error returned is java.lang.IllegalArgumentException: null value for key 'dbhitratio'
 2018-07-17 11:36:36,668 [pool-1-thread-1] WARN  Orabbix - Error while executing ->dbphysicalread- on database ->dbnode1- Exception received ORA-00942: table or view does not exist

 2018-07-17 11:36:36,668 [pool-1-thread-1] ERROR Orabbix - Error on DBEnquiry on query=dbphysicalread on database=dbnode1 Error returned is java.lang.IllegalArgumentException: null value for key 'dbphysic
alread'
 2018-07-17 11:36:36,670 [pool-1-thread-1] WARN  Orabbix - Error while executing ->dbversion- on database ->dbnode1- Exception received ORA-00942: table or view does not exist

如果有以上类似的报错,基本都是zabbix用户权限不够导致,参考赋权;
正常log如下:

 2018-07-20 17:06:16,915 [pool-1-thread-47] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 18537 ms
 2018-07-20 17:06:58,428 [pool-1-thread-48] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 48 ms
 2018-07-20 17:08:16,967 [pool-1-thread-49] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 18586 ms
 2018-07-20 17:08:58,418 [pool-1-thread-50] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 35 ms
 2018-07-20 17:10:17,033 [pool-1-thread-51] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 18648 ms
 2018-07-20 17:10:58,418 [pool-1-thread-52] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 31 ms
 2018-07-20 17:12:17,225 [pool-1-thread-53] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 18836 ms
 2018-07-20 17:12:58,426 [pool-1-thread-54] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 35 ms
 2018-07-20 17:14:17,013 [pool-1-thread-55] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 18621 ms
 2018-07-20 17:14:58,429 [pool-1-thread-56] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 35 ms
 2018-07-20 17:16:17,087 [pool-1-thread-57] INFO  Orabbix - Done with dbJob on database dbnode1 QueryList elapsed time 18691 ms

/usr/local/orabbix下面有个template目录,里面是zabbix模板,将这些模板copy到本地机器上,然后登陆zabbix,把模板导入进去,就可以配置机器了,zabbix是3.x以上版本的话直接导入不进去,只能先导入2.x版本,然后再导出,然后导入3.x
或者直接用修改后Zabbix3.x可以直接使用的模板
zabbix_oracle_orabbix.zip
导入,并添加对应模板即可,完成以后效果如下:
1.png
2.png
3.png
4.png
5.png
10.png
VIA: http://www.smartmarmot.com/wiki/index.php?title=Orabbix
https://blog.csdn.net/tianhua79658788/article/details/77969426

zabbix 客户端执行netstat -p 报错

zabbix_get执行的脚本中含有netstat -lantup命令报错,原因是-p参数需要root用户才能使用

zabbix_get执行脚本时报错:

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.

解决该问题的办法有两种:

通过配置vi /etc/sudoers 

Cmnd_Alias MONITORING = /bin/netstat,/sbin/sudo   
%monitor        ALL=(root) NOPASSWD:MONITORING

然后在修改userparameter_script.conf文件,利用sudo执行脚本即可

通过在执行的脚本中执行

chmod +s /bin/netstat

chmod +s 的意思是
为了方便普通用户执行一些特权命令,SUID/SGID程序允许普通用户以root身份暂时执行该程序,并在执行结束后再恢复身份

最新

分类

归档

评论

其它