Ad Widget

Collapse

Monitor MySQL Database on agent - Not supported

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vintagegamingsystems
    Member
    • Jun 2013
    • 57

    #16
    What do these lines do? How do they work?

    UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'
    When I put mysql -N | awk '{print $$3}', I get an access denied error for mysql.


    UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive

    If I put the code mysqladmin ping | grep -c alive in the command it returns 1. I assume that to mean that the mysql server is running, because when I stop mysqld, the code returns 0. But what does the "HOME=/var/lib/zabbix" part do?
    I know that the mysql.ping is the key for the item that we want to monitor.

    Comment

    • tchjts1
      Senior Member
      • May 2008
      • 1605

      #17
      Originally posted by vintagegamingsystems
      But what does the "HOME=/var/lib/zabbix" part do?
      At the very top of that file, it tells you exactly what the HOME= command is:
      # For all the following commands HOME should be set to the directory that has my.cnf file

      Also, as I pointed out earlier, in your zabbix_agentd.conf file, there has to be an "Include=" statement calling your <path>/userparameter_mysql.conf file.
      Show me that portion. That may be where your problem is. I believe by default that statement is:

      Include=/usr/local/etc/userparameter_mysql.conf
      Which doesn't appear to reflect your configuration.

      I think you are only glancing through my replies instead of thoroughly reading them, and I am having to retype this information. I suggest you go back to the beginning and re-read this stuff.

      Comment

      • vintagegamingsystems
        Member
        • Jun 2013
        • 57

        #18
        The mysql.version and mysql.ping keys are working, sort of...

        I appreciate all your helpful advice tchjts1. I found that there was a file in the /usr/local/etc/ directory called zabbix_agentd.conf. I had never seen that file before.

        So I added the line to the file:
        Code:
        Include=/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
        I am now getting the mysql.version and the mysql.ping to sort of work. I need edit these lines for my keys to work.
        Code:
        UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'
        UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
        
        UserParameter=mysql.version,mysql -V
        I will play around them and see if I can get them to report.

        Comment

        • vintagegamingsystems
          Member
          • Jun 2013
          • 57

          #19
          THANKS.It is now working. Here is the contents of the userparameters_mysql.conf file.

          It is working now. The problem was that the I needed to have the correct username and password in my /etc/my.cnf file along with the Include in the /usr/local/etc/zabbix_agentd.conf file.

          If you type enter the command:
          Code:
          strings /etc/init.d/zabbix_agentd
          You will see the default zabbix_agentd.conf file, which is /usr/local/etc/zabbix_agentd.conf . I am not sure why I had the file /etc/zabbix/zabbix_agentd.conf where it was.

          But everything is working now!!!!

          Here is a copy of my userparameters_mysql.conf file. It looks just like the one you showed me.
          Code:
          UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/etc mysql -N | awk '{print $$2}'

          Comment

          • vintagegamingsystems
            Member
            • Jun 2013
            • 57

            #20
            Here is the other part of the userparameters_mysql.conf file.

            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=/etc mysqladmin ping | grep -c alive
            UserParameter=mysql.version,mysql -V [/CODE]

            Comment

            • tchjts1
              Senior Member
              • May 2008
              • 1605

              #21
              You're welcome.

              Comment

              • vintagegamingsystems
                Member
                • Jun 2013
                • 57

                #22
                Solved

                This is one SOLVED problem. I love it. It's cool.

                Comment

                • Spoonman
                  Member
                  • Aug 2013
                  • 45

                  #23
                  Originally posted by vintagegamingsystems
                  This is one SOLVED problem. I love it. It's cool.
                  I'm sorry, I followed the instructions exactly, but my ZABBIX still gives MySQL as status "Down"
                  And furthermore, the zabbix-agent will not start anymore after I changed the files as described...
                  (CentOS 6.4 32bit, ZABBIX 2.0.8)
                  Last edited by Spoonman; 04-09-2013, 20:23.

                  Comment

                  • vintagegamingsystems
                    Member
                    • Jun 2013
                    • 57

                    #24
                    Check your log files for the zabbix agent

                    Run the following command to check your log files for your zabbix agent.

                    # cat /var/log/zabbix/zabbix_agentd.log

                    See if there is an error that is occuring. Let me know. It is pretty easy to get a database monitored via Zabbix once you have done it a few times.
                    Last edited by vintagegamingsystems; 04-09-2013, 20:59.

                    Comment

                    • Spoonman
                      Member
                      • Aug 2013
                      • 45

                      #25
                      Originally posted by vintagegamingsystems
                      Run the following command to check your log files for your zabbix agent.

                      # cat /var/log/zabbix/zabbix_agentd.log

                      See if there is an error that is occuring. Let me know. It is pretty easy to get a database monitored via Zabbix once you have done it a few times.
                      these are my errorlogs :

                      mysqladmin: connect to server at 'localhost' failed
                      error: 'Access denied for user 'zabbix'@'localhost' (using password: NO)'

                      ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: NO)

                      Comment

                      • vintagegamingsystems
                        Member
                        • Jun 2013
                        • 57

                        #26
                        Changing the my.cnf file might help.

                        Make sure your /etc/my.cnf file has contents similar to this.

                        [client]
                        user=zabbix
                        password=password
                        port=3306
                        [mysqld]
                        bind-address=127.0.0.1
                        port=3306
                        datadir=/var/lib/mysql
                        socket=/var/lib/mysql/mysql.sock
                        user=mysql
                        # Disabling symbolic-links is recommended to prevent assorted security risks
                        symbolic-links=0

                        [mysqld_safe]
                        log-error=/var/log/mysqld.log
                        pid-file=/var/run/mysqld/mysqld.pid


                        Also, make the /etc/my.cnf file group owner "zabbix" and change the permissions to "640". That way the file is not world readable.
                        Last edited by vintagegamingsystems; 18-10-2013, 18:32.

                        Comment

                        • maxmouse
                          Junior Member
                          • Aug 2013
                          • 2

                          #27
                          I had no problems getting this to work on CentOS 6 but CentOS 5 seems to ignore the "HOME=/var/lib/zabbix" item in userparameter_mysql.conf.

                          I had a .my.cnf in /var/lib/zabbix but it kept trying to connect as the "zabbix" user without a password which resulted in access denied:

                          error: 'Access denied for user 'zabbix'@'localhost' (using password: NO)'

                          It wasn't until I put the client info in /etc/my.cnf that it worked on CentOS 5, even though the configuration specifically says to use /var/lib/zabbix/.my.cnf for client info.

                          Comment

                          • rohan_king2003
                            Junior Member
                            • Feb 2014
                            • 3

                            #28
                            Multiple database in a single server

                            How will I setup or write a script to monitor multiple database in a single server? I have successfully connect the main database server itself, but how about a specific database?

                            Comment

                            • Balaraju
                              Member
                              • Jun 2016
                              • 40

                              #29
                              Monitor MySQL Database on agent - Not supported

                              HI team,

                              I want to monitor remote mysql server.

                              Can you explain step by step process on remote host. I did not understand above conversation. Can u please explain step by step process its very urgent for me.

                              Comment

                              • yujin777
                                Junior Member
                                • Jul 2017
                                • 7

                                #30
                                When Mysqld is down - it doesn't display status

                                Hi !

                                My zabbix can't trigger when MYSQLD is down.

                                Running zabbix_get command on ZS shows that:
                                Code:
                                [root@zabbix-server etc]# zabbix_get -s mysql_host -k mysql.ping
                                1

                                When server is down - it display a lot of extra information:
                                Code:
                                [root@zabbix-server etc]# zabbix_get -s mysql_host -k mysql.ping
                                mysqladmin: connect to server at 'localhost' failed
                                error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
                                Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
                                0


                                In ZS GUI - exist MYSQL Template.
                                In that Template exist item mysql.ping - inside a comment:
                                Code:
                                It requires user parameter mysql.ping, which is defined in userparameter_mysql.conf.
                                
                                0 - MySQL server is down
                                1 - MySQL server is up
                                So, it doesn't return 0 - when server is down.

                                Please help.
                                Last edited by yujin777; 20-07-2017, 15:34.

                                Comment

                                Working...