check_mysql_health - 如何检查非数字输出

时间:2016-09-20 15:04:26

标签: mysql nagios icinga

我正在尝试检查mysql查询输出,并将结果与​​我的Nagios服务检查的某些值进行比较 可能有更好的方法来解决这个问题(如果是这样的话 - 请分享:))... 现在,我正在尝试这种方法:

./check_mysql_health --username root --password MyPassw0rd --mode sql --name 'show variables like 'max_connections'' --name2 "max_connections 4096"

PS:我的max_connections是4096

mysql -Bse "show variables like 'max_connections';"
max_connections 4096

输出结果为:

Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health line 1237.
    Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health line 1238.
    OK - max_connections 4096:

如果我将name2中的值更改为不等于“max_connections 4096”的值,如“G1Li”,则输出返回OK状态。

    ./check_mysql_health --username root --password MyPassw0rd --mode sql --name 'show variables like 'max_connections'' --name2 "G1Li" 
Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health 

line 1237.
    Use of uninitialized value $value in numeric gt (>) at ./check_mysql_health line 1238.
    OK - g1li:
# echo $?
0

有什么想法吗?

吉利

1 个答案:

答案 0 :(得分:0)

我也是新手,这可能有所帮助,

./check_mysql_health --username root --password MyPassw0rd --mode sql \
--name 'show 1,variables like 'max_connections'' --name2 "status max_connections 4096"

我们正在将此用于Oracle。我不确定这个状态,但是1是正确的。

或者您可以自定义,如添加更多模式(有两个主要部分,一个是远程/本地执行sql查询,另一个是解析nagios / icinga的结果数据),你想要的插件!这将是一个更好的解决方案。

相关问题