Ad Widget

Collapse

Failed to fetch nginx stub status page

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • EHRETic
    Member
    • Jan 2021
    • 45

    #1

    Failed to fetch nginx stub status page

    Hi there,

    I'm new to Zabbix (started a week ago with the 5.2) and it's my very first post here.

    I'm starting installing slowly but surelly Zabbix agent on all my VMs. It's in my lab so there is no panic, but I always wanted an overview of what is going on in my infra as it's start to be quite large for a homelab...
    I've a few VMs that use NGINX as a https web proxy for different services that use a web console (Zabbix is one of them BTW), I find NGINX quite convenient for that. Of course I'd like to monitor it.

    So I've attached the template "Nginx by Zabbix agent" to the necessary hosts and straight away, I got "Service is down" alerts.
    I've solved this one by replacing the key in some of the items (solution was provided here: https://www.zabbix.com/forum/zabbix-...ervice-is-down) but the despite that change, the alert "Nginx: Failed to fetch stub status page (or no data for 30m)" is still popping up. Also, I don't know if it is "right" to change it as the problem might have another source.

    The changes are in yellow, changing the red one didn't help :

    Click image for larger version

Name:	2021-01-19 14_56_01-Configuration of items.png
Views:	9964
Size:	82.3 KB
ID:	417017

    Issue is the same if I use "Nginx by HTTP" template.

    Any idea where I should start? Thanks in advance
  • Answer selected by EHRETic at 03-03-2022, 14:21.
    EHRETic
    Member
    • Jan 2021
    • 45

    Hi there,

    After a lot of other things to do, I was today going back at that one. So I've tried all mentioned above (and my server is also migrated to 6.0 LTS), but it didn't work.

    So I looked further and I found out that you HAVE TO publish at some point the NGINX status page in order to read (sorry, but I had to learn that).
    In my case, I choose to create a dedicated server listening on 127.0.0.1 so I would not disturb any running configuration.

    So I added the following configuration block on my NGINX servers and reconfigured the template accordingly, {$NGINX.STUB_STATUS.PATH} remained empty.

    NGINX server block:

    Code:
    # NGINX monitoring
    server {
        listen 8080;
        server_name 127.0.0.1;
    
        location / {
            stub_status on;
            allow 127.0.0.1;
            deny all;
        }
    }
    Thanks all for you help anyway, I hope this will serve to others!

    Comment

    • dereitz
      Junior Member
      • Feb 2021
      • 1

      #2
      Were you able to resolve this?

      I'm also new to Zabbix. I'm running both the Zabbix server and the agent in Docker containers which has added to the complexity.

      In any case, I cannot seem to get either the NGINX via HTTP or the NGINX via Zabbix agent templates working while inside the Docker container. Has anyone had success with this? I'd appreciate any tips!!!

      Comment

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

        #3
        "Nginx by Zabbix agent" does provide these macros... So that info in that other page you linked, is wrong... no need to change anything in keys.
        {$NGINX.STUB_STATUS.HOST}","{$NGINX.STUB_STATUS.PA TH}","{$NGINX.STUB_STATUS.PORT}" default values in template are localhost, basic_status and 80. So agent does locally a web.get from same host. Maybe your nginx is not configured to provide that page to localhost? Can you get it on command line with curl or wget?

        "Nginx by HTTP" solves same with http call to {$NGINX.STUB_STATUS.SCHEME}://{HOST.CONN}:{$NGINX.STUB_STATUS.PORT}/{$NGINX.STUB_STATUS.PATH} basically http://<your host>:80/basic_status by default. Is there something answering on that port, is the port reachable from server/proxy? FW-s open? Again, you can test from server/proxy with wget/curl...

        Comment

        • tariver
          Junior Member
          • Apr 2021
          • 4

          #4
          Sorry for necroposting, but this is the first result that comes on Google for "Zabbix Nginx Service status down" query.

          Have the same problem, turned out that Zabbix agent uses IPv6 to connect to nginx and my nginx were not using IPv6.
          To check if this item works locally:
          Code:
          zabbix_agentd -t net.tcp.service[http,localhost,80]
          The output should be
          Code:
          net.tcp.service[http,localhost,80]            [u|1]
          If the last part is [u|0] then something is wrong.

          To check if nginx is listening on IPv6
          Code:
          $ sudo netstat -tnlp | grep nginx
          There should be a line that reads something to this:
          Code:
          tcp        0      0 :::80                       :::*                        LISTEN      7815/nginx
          If there is no such a line then your nginx doesn't.

          How to fix it: add the following line to server configuration where the basic_statusis is defined.
          Code:
          listen [::]:80;
          or this line if you want nginx to listen to IPv6 only on localhost
          Code:
          listen [::1]:80;
          After that check your nginx configuration with
          Code:
          nginx -t
          and then reload config (doesn't affect users)
          Code:
          nginx -s reload

          Comment


          • RonaldBag
            RonaldBag commented
            Editing a comment
            I found a simpler solution: Change the macro to use 127.0.0.1 instead of localhost.
        • EHRETic
          Member
          • Jan 2021
          • 45

          #5
          Hi there,

          After a lot of other things to do, I was today going back at that one. So I've tried all mentioned above (and my server is also migrated to 6.0 LTS), but it didn't work.

          So I looked further and I found out that you HAVE TO publish at some point the NGINX status page in order to read (sorry, but I had to learn that).
          In my case, I choose to create a dedicated server listening on 127.0.0.1 so I would not disturb any running configuration.

          So I added the following configuration block on my NGINX servers and reconfigured the template accordingly, {$NGINX.STUB_STATUS.PATH} remained empty.

          NGINX server block:

          Code:
          # NGINX monitoring
          server {
              listen 8080;
              server_name 127.0.0.1;
          
              location / {
                  stub_status on;
                  allow 127.0.0.1;
                  deny all;
              }
          }
          Thanks all for you help anyway, I hope this will serve to others!

          Comment

          Working...