zabbix监控mysql :Warning: Using a password on the command line interface can be insecure.

使用zabbix自带模板对mysql进行监控时,发现mysql5.6以上版本在使用mysqladmin时会发出警告:

“Warning: Using a password on the command line interface can be insecure.” 。

这样zabbix服务端获取数值的时候,会带有该字符串,导致报错。

解决办法试了很多,包括:

1、使用grep -v Warning result进行过滤。

2、使用mysql_config_editor进行无密码操作。

3、修改my.conf配置文件,将mysqladmin用户名密码写入配置文件。

4、在zabbix服务端寻找过滤返回值的操作。

但是以上方法都未凑效,很是尴尬。

最后实验成功的方法是:将mysqladmin的警告信息重定向到/dev/null,忽略掉告警信息。

Com_update)
    result=`/usr/bin/mysqladmin -u$MYSQL_USER -h$MYSQL_HOST -p${MYSQL_PWD} -S $MYSQL_SOCK extended-status  2>/dev/null|grep -w "Com_update"|cut -d"|" -f3`
    echo $result ;;

在原有命令中加上2>/dev/null 就行了。

使用服务端的zabbix_get命令测试下:

修改之前:

[root@VM-4ecd-7f03-4bf-9a bin]# ./zabbix_get -s xx.xx.xx.xx -p 10050 -k mysql.status[Uptime]
Warning: Using a password on the command line interface can be insecure.
159486

修改之后:

[root@VM-4ecd-7f03-4bf-9a bin]# ./zabbix_get -s xx.xx.xx.xx -p 10050 -k mysql.status[Uptime]
159496

mysql告警信息不见了。

另:有人告诉我可以通过“mysqladmin –defaults-extra-file=/etc/my.cnf”进行处理,因为问题已经解决了,就没有去尝试了。

猜你喜欢

转载自blog.csdn.net/u012599988/article/details/81026253
今日推荐