- 论坛徽章:
- 6
|
打算配置zabbix监控mysql
使用zabbix-agent默认用户参数文件
UserParameter=mysql.status,echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'
UserParameter=mysql.size,echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema='$1'")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name='$2'");" | HOME=/var/lib/zabbix mysql -N
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V
由于采用mysql直接启动 所以需要读取到cnf 看到只能针对用户进行cnf的设定 这样最安全
为什么不设定在etc下面呢 由于需要配置账号密码 这样如果放在用户目录下是最好的
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file,
except for login file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#
Also read groups with concat(group, suffix)
--login-path=# Read this path from the login file.
然后配置cnf
[mysql]
host=localhost
user=root
password=***
socket=/var/lib/mysql/mysql.sock
问题是我应该把cnf放在哪里
/var/lib/zabbix/.my.cnf
放在这里的时候
发现依然不对啊无法读取到啊
|
|