racker / rackspace-monitoring-agent-plugins-contrib

Contributed Rackspace Monitoring Agent plugins
71 stars 65 forks source link

Holland mysqldump fails to expand ~ causing it to fail to detect a sql credentials file that does exist. #131

Open sjafferali opened 8 years ago

sjafferali commented 8 years ago
[root@hcluster1-db2 plugins]# ./holland_mysqldump.py
status success holland checked
metric log_age int64 138
metric dump_age int64 139
metric error_count int64 0
metric first_error string none
metric last_error string none
metric sql_creds_exist string false
metric sql_ping_succeeds string true
metric sql_status_succeeds string true
[root@hcluster1-db2 plugins]#

Although, we can see my credentials file is defined as ~/my.cnf.

[root@hcluster1-db2 plugins]# grep ^defaults /etc/holland/backupsets/default.conf
defaults-extra-file = ~/.my.cnf,
[root@hcluster1-db2 plugins]#

And this file does indeed exist.

[root@hcluster1-db2 plugins]# stat ~/.my.cnf
  File: ‘/root/.my.cnf’
  Size: 87          Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 786463      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-05-18 18:06:54.239755077 -0500
Modify: 2016-05-18 18:06:54.239755077 -0500
Change: 2016-05-18 18:06:54.239755077 -0500
 Birth: -
[root@hcluster1-db2 plugins]#

Switching this to /root/.my.cnf file seems to be a good work around to make this detect the file properly.

[root@hcluster1-db2 plugins]# grep ^defaults /etc/holland/backupsets/default.conf
defaults-extra-file = /root/.my.cnf,
[root@hcluster1-db2 plugins]# ./holland_mysqldump.py
status success holland checked
metric log_age int64 335
metric dump_age int64 336
metric error_count int64 0
metric first_error string none
metric last_error string none
metric sql_creds_exist string true
metric sql_ping_succeeds string true
metric sql_status_succeeds string true
[root@hcluster1-db2 plugins]#

Although, as a more permanent solution, I ended up modifying line 144 from:

                if os.access(f, os.F_OK):

To:

                if os.access(os.path.expanduser(f), os.F_OK):

Pull request to follow.