zabbix監控mysql :Warning: Using a password on the command line interface can be insecure.
阿新 • • 發佈:2019-01-04
使用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命令測試下:
修改之前:
[[email protected]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
修改之後:
[[email protected]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”進行處理,因為問題已經解決了,就沒有去嘗試了。