Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL监控直接运行脚本传参能获取数据而zabbix_get获取报错。 #40

Closed
i0668 opened this issue May 17, 2018 · 5 comments
Closed

Comments

@i0668
Copy link

i0668 commented May 17, 2018

你好,我在命令行使用如下:

[root@s1 scripts]# python mysql_all.py -k threads_connected
1

在zabbix_get下无返回:

[root@jn53 bin]# ./zabbix_get -s 163.com -p 10050 -k "mysql.item[threads_connected]"

tmp下面的log以及txt已经全部777权限,zabbix_get调用报错如下:

[2018-05-17 16:18:01] INFO
     msg: Try To Get From Cache File: /tmp/.zabbix_mysql_variables_slave_status_3306_by_zabbix.txt
     key: threads_connected
   value: None

[2018-05-17 16:18:01] ERROR
Traceback (most recent call last):
  File "/etc/zabbix/scripts/mysql_all.py", line 47, in get_mysql_cmd_output
    if os.path.isfile(p):
  File "/usr/lib64/python2.7/genericpath.py", line 29, in isfile
    st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, NoneType found

[2018-05-17 16:18:01] ERROR
Traceback (most recent call last):
  File "/etc/zabbix/scripts/mysql_all.py", line 193, in main
    value = mysql.get_item_tval(key)
  File "/etc/zabbix/scripts/mysql_all.py", line 116, in get_item_tval
    val = self.get_value(key)
  File "/etc/zabbix/scripts/mysql_all.py", line 110, in get_value
    self._file_cache.save_to_cache_file(content)
  File "/etc/zabbix/scripts/qiueer/python/filecache.py", line 86, in save_to_cache_file
    fd.write(content)
TypeError: expected a character buffer object

另一个关联的log里面只有一串数字,没有那堆json数据,而命令行执行脚本的时候是有的。

[root@s1 tmp]# cat .zabbix_mysql_variables_slave_status_3306_by_zabbix.txt
1526545591
@qiueer
Copy link
Owner

qiueer commented May 23, 2018

zabbix用户能使用mysql命令吗
 bp = which("mysql")  -- 应该这里的问题

@wddphero
Copy link

File "mysql_perf.py", line 38
port = port if port else self._port
^
SyntaxError: invalid syntax

@wddphero
Copy link

python mysql_func.py
File "mysql_func.py", line 37
hostname = hostname if hostname else self._iphost
^
SyntaxError: invalid syntax

@wddphero
Copy link

zabbix监控mysql的 python脚本。都有报错。

@qiueer
Copy link
Owner

qiueer commented May 17, 2019

@wddphero dos2unix转化下格式看看,如果下载后没有打开或编辑过,应该没有问题。可百度下python语法格式要求

@qiueer qiueer closed this as completed May 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants