Nagios mysql script

Posted on 2008-11-18
Last Modified: 2012-05-05
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!


test=`mysql -P 3306 --socket=/var/mysql/mysql.sock -u mysqlid-pmysqlpw -e 'use mysql_test; show tables;' | wc -l`
echo "OK - $test tables"
Question by:linuxpig
    LVL 26

    Accepted Solution

    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
    test=`mysql -uUserName -pSecretPassword -hHostName_or_IP_address -e 'use mysql_test; show tables;' | wc -l`
    echo "OK - $test tables"

    Open in new window


    Author Closing Comment

    Quick and accurate answer

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
    All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now