• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 582
  • Last Modified:

Nagios mysql script

I have a small script that runs on a server that has mysql, then nrpe returns the output to the nagios server. I want to change this so that the nagios server runs the script by logging into the mysql db on the remote machine. Im not that good with mysql so maybe someone can look at my mysql script and tell me how to change it to loging and do its check remotely. Thanks!

#!/bin/sh

test=`mysql -P 3306 --socket=/var/mysql/mysql.sock -u mysqlid-pmysqlpw -e 'use mysql_test; show tables;' | wc -l`
echo "OK - $test tables"
0
linuxpig
Asked:
linuxpig
1 Solution
 
UmeshCommented:
This should work..

Please adjust these values

UserName - userName (which has been created on remote mysql server and which allow you to connect remotely)
SecretPassword - Password for the above user

HostName_or_IP_address - IP/Hostname of the server on which MySQL server is running

#!/bin/sh
 
test=`mysql -uUserName -pSecretPassword -hHostName_or_IP_address -e 'use mysql_test; show tables;' | wc -l`
 
echo "OK - $test tables"

Open in new window

0
 
linuxpigAuthor Commented:
Quick and accurate answer
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now