Ad Widget

Collapse

Is there a status page for Zabbix Server itself?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DenisBY
    Member
    • Jul 2006
    • 44

    #1

    Is there a status page for Zabbix Server itself?

    I would like to monitor Zabbix Server via external monitoring, i.e. with simple `curl` command. Is there a page, like `zabbix.example.com/status` with, i.e., 'DB connection', 'Server is running', etc.?
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    #2
    Yeah, the eternal problem: how to monitor the monitoring system.

    One way is to use Zabbix API to query some known data from Zabbix (from a specific host etc). If that call works, it means that
    • Zabbix frontend is working (API uses the same web server as GUI)
    • database is working (the host data is retrieved from the database)
    • Zabbix monitoring process is working (if you use the history API to get the latest value and compare its timestamp to current time you can see if the data is being collected correctly)
    Markku

    Comment

    • Markku
      Senior Member
      Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
      • Sep 2018
      • 1781

      #3
      Another way to monitor the system would be to create an item and a trigger that triggers regularly (for example by using cron and zabbix sender), and an action that sends the result (= heartbeat) to an external monitoring system. If the heartbeat is missing for some time, your external system can raise an alarm because Zabbix monitoring is then not working.

      Markku​

      Comment

      • DenisBY
        Member
        • Jul 2006
        • 44

        #4
        I would like to use a simple `curl` or something like this instead of installing a full monitoring system.

        Comment

        • Markku
          Senior Member
          Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
          • Sep 2018
          • 1781

          #5
          Originally posted by DenisBY
          I would like to use a simple `curl` or something like this instead of installing a full monitoring system.
          Yes, simple it shall be:

          Originally posted by Markku
          One way is to use Zabbix API to query some known data from Zabbix
          See also an example: https://blog.zabbix.com/zabbix-api-s...-and-jq/12434/

          Note that since Zabbix 5.4 you don't have to login (and logout) to the API with username+password, you can create the token manually and then use it statically in your curl command.

          Markku

          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4807

            #6
            You need one simple php script. It should do 2 things. Test DB connection and test server connection (just like your frontend does it by connecting to server:10051) and report back OK/NOK for those checks.

            Comment

            • DenisBY
              Member
              • Jul 2006
              • 44

              #7
              I couldn't find any API call or item to monitor if zabbix-server process is running.

              Comment

              • DenisBY
                Member
                • Jul 2006
                • 44

                #8
                Here is a simple script I created. I placed it to zabbix ui directory with other zabbix php files:

                PHP Code:
                <?php

                require_once dirname(__FILE__).'/conf/zabbix.conf.php';

                $timeout 5;

                function 
                check_connection($address$port) {

                   
                $connection = @fsockopen($address$port$errno$errstr5);

                   if (
                is_resource($connection))
                   {
                       
                fclose($connection);
                       return 
                'OK';
                   }
                   else
                   {
                       return 
                'ERROR';
                   }
                }


                $server_status check_connection($ZBX_SERVER$ZBX_SERVER_PORT);

                if (
                $DB['PORT'] == "0")
                {
                   switch (
                $DB['TYPE']) {
                       case 
                'MYSQL':
                           
                $port "3306";
                           break;
                       case 
                'POSTGRESQL':
                           
                $port "5432";
                           break;
                   }
                }
                else
                {
                   
                $port $DB['PORT'];
                }

                $db_status check_connection($DB['SERVER'], $port);

                header('Content-Type: application/json; charset=utf-8');
                $data = ['server' => $server_status'db' => $db_status];
                echo 
                json_encode$data );

                ?>

                Comment

                Working...