Ad Widget

Collapse

TCP port monitoring template not working

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mcflurry
    Member
    • Jun 2022
    • 32

    #1

    TCP port monitoring template not working

    I'm trying to get this template working without success...



    I've followed discovery instructions for agent2:

    Install UserParameter for zabbix-agent2:
    echo 'UserParameter=ss.tcp.listening,netstat --tcp --listening --numeric-ports' | sudo tee /etc/zabbix/zabbix_agent2.d/ss.tcp.listening.conf

    Restart Zabbix agent
    systemctl restart zabbix-agent2

    In this section replace Key:
    system.run["ss --tcp --listening --numeric"]
    with:
    netstat.tcp.listening
    I've imported the template and added it to a Linux host and there's no update about it. Is there anyway to debug this? Am I missing something????


    Click image for larger version

Name:	1.png
Views:	1965
Size:	31.7 KB
ID:	447144

    server:/etc/zabbix/zabbix_agent2.d # ll
    total 8
    drwxr-xr-x 2 root root 4096 Jun 27 12:26 plugins.d
    -rw-r--r-- 1 root root 73 Jun 30 14:43 ss.tcp.listening.conf
    server:/etc/zabbix/zabbix_agent2.d # cat ss.tcp.listening.conf
    UserParameter=ss.tcp.listening,netstat --tcp --listening --numeric-ports
  • Answer selected by mcflurry at 14-07-2022, 10:55.
    Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    Ok, oh well. As you saw from the beginning, the template is not very high quality (the contradicting information about using system.run/ss.tcp.listening/netstat/ss/whatever). So there is a problem in Filter: "Type of calculation" was set to "And/Or" which was in this case evaluated as "Or". Set it to "And", and the filtering starts working properly.

    Click image for larger version

Name:	filter.png
Views:	1913
Size:	47.1 KB
ID:	447881

    Markku

    Comment

    • vladimir_lv
      Senior Member
      • May 2022
      • 240

      #2
      you have to use the same key in the item (ss.tcp.listening ) as described in UserParameter.

      Comment

      • mcflurry
        Member
        • Jun 2022
        • 32

        #3
        Uhm, well, i imported the template and then followed the documentation....

        You mean that this:

        Click image for larger version  Name:	1.png Views:	0 Size:	32.9 KB ID:	447229

        Should be like this:

        Click image for larger version  Name:	2.png Views:	0 Size:	33.0 KB ID:	447230

        And "Key" in "Discovery rule" has to be as it says in the documentation (as it's set in op), Key: netstat.tcp.listening
        Last edited by mcflurry; 04-07-2022, 09:22.

        Comment


        • vladimir_lv
          vladimir_lv commented
          Editing a comment
          Yes, should be like this. Is it working now?
      • mcflurry
        Member
        • Jun 2022
        • 32

        #4
        I fear not... I've added the template to a linux host and nothings happens... i guess it should discover every open port for that host, or am I wrong?

        I've tested the discovery rule of the template in Configuration -> Hosts and it returns: "Unknown metric netstat.tcp.listening"

        But if i change that to ss.tcp.listening it returns this:

        [{"{#PORT}":"25"},{"{#PORT}":"512"},{"{#PORT}":"513 "},{"{#PORT}":"514"},,{"{#PORT}":"199"},},{"{#PORT }":"21"}

        Does that means that value "Key" in the discovery rule must meet the user parameter and the key in the item???
        Last edited by mcflurry; 04-07-2022, 10:22.

        Comment

        • vladimir_lv
          Senior Member
          • May 2022
          • 240

          #5
          Does that means that value "Key" in the discovery rule must meet the user parameter and the key in the item???
          Yes, exactly!

          Comment

          • mcflurry
            Member
            • Jun 2022
            • 32

            #6
            Updated everything and it doesn't discovers any port...

            Running "zabbix_agent2 -t ss.tcp.listening" from cli returns all listening ports...
            Last edited by mcflurry; 04-07-2022, 10:57.

            Comment

            • vladimir_lv
              Senior Member
              • May 2022
              • 240

              #7
              But if i change that to ss.tcp.listening it returns this:

              [{"{#PORT}":"25"},{"{#PORT}":"512"},{"{#PORT}":" 513 "},{"{#PORT}":"514"},,{"{#PORT}":"199"},},{"{# PORT }":"21"}
              Is this result what you wish to get?

              Comment

              • mcflurry
                Member
                • Jun 2022
                • 32

                #8
                Originally posted by vladimir_lv

                Is this result what you wish to get?
                Yes, and i guess the javascript will format those ports just to display the port number.

                Comment

                • vladimir_lv
                  Senior Member
                  • May 2022
                  • 240

                  #9
                  Because the result look like:
                  Code:
                  Active Internet connections (only servers)
                  Proto Recv-Q Send-Q Local Address Foreign Address State
                  tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN
                  tcp 0 0 localhost:199 0.0.0.0:* LISTEN
                  you need to use Type of information: Text

                  Comment

                  • mcflurry
                    Member
                    • Jun 2022
                    • 32

                    #10
                    Originally posted by vladimir_lv
                    Because the result look like:
                    Code:
                    Active Internet connections (only servers)
                    Proto Recv-Q Send-Q Local Address Foreign Address State
                    tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN
                    tcp 0 0 localhost:199 0.0.0.0:* LISTEN
                    you need to use Type of information: Text
                    If I change that in the item prototype a message shows up: This type of information may not match the key.

                    This is a template, it should be configured almost oob.

                    Comment

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

                      #11
                      There is now confusion about the discovery key and the item prototype key.

                      The discovery key seems to be ss.tcp.listening. The item prototype key is something else, whatever was configured in the template, don't edit if you don't know what you are doing.

                      But please clarify this:

                      I've imported the template and added it to a Linux host and there's no update about it.
                      How long did you wait for the items to be discovered? In the screenshot you showed us the discover interval is one day. Did you wait for one day or less?

                      (I'm currently on iPad so I cannot download the yaml file to see the original setup, sorry.)

                      Markku
                      Last edited by Markku; 04-07-2022, 16:14.

                      Comment

                      • mcflurry
                        Member
                        • Jun 2022
                        • 32

                        #12
                        Originally posted by Markku
                        There is now confusion about the discovery key and the item prototype key.

                        The discovery key seems to be ss.tcp.listening. The item prototype key is something else, whatever was configured in the template, don't edit if you don't know what you are doing.

                        But please clarify this:



                        How long did you wait for the items to be discovered? In the screenshot you showed us the discover interval is one day. Did you wait for one day or less?

                        (I'm currently on iPad so I cannot download the yaml file to see the original setup, sorry.)

                        Markku
                        You were right, it took hours to update... and i didn't change a thing, just importing the template works.

                        Comment

                        • Zablab
                          Junior Member
                          • Jan 2022
                          • 28

                          #13
                          Is there a Windows equivalent version of this? Or, rather, is there a way to monitor multiple ports via single key\template? I want to be able to monitor specific Ports on various Server types, for example:

                          445 on File Server
                          1433 on SQL Server
                          80, 443 on Web Server

                          I know about net.tcp.service[tcp,,{$TCP.PORT}] but that's only a single Port, I'd like to avoid creating a ton of different Marco's or Templates.
                          It doesn't appear I can use Regex for this single Macro, it seems I need to do a discover and filter?

                          From what I gather this version does a full port discovery & then you uses Regex\Java to filter out the ports you want or don't want, this is pretty much what I want to do in Windows, but unsure how to convert this, and I can't find a Windows version.

                          Comment

                          • mcflurry
                            Member
                            • Jun 2022
                            • 32

                            #14
                            Originally posted by Zablab
                            Is there a Windows equivalent version of this? Or, rather, is there a way to monitor multiple ports via single key\template? I want to be able to monitor specific Ports on various Server types, for example:

                            445 on File Server
                            1433 on SQL Server
                            80, 443 on Web Server

                            I know about net.tcp.service[tcp,,{$TCP.PORT}] but that's only a single Port, I'd like to avoid creating a ton of different Marco's or Templates.
                            It doesn't appear I can use Regex for this single Macro, it seems I need to do a discover and filter?

                            From what I gather this version does a full port discovery & then you uses Regex\Java to filter out the ports you want or don't want, this is pretty much what I want to do in Windows, but unsure how to convert this, and I can't find a Windows version.
                            I haven't found anything for windows like this one.

                            And about this one, I can't get to filter ports. It discover every listening port, so if there are random ports listening it discovers those too... and when the process stop using those ports it complaints about those.

                            I've been playing with the filter and it does nothing.

                            Comment

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

                              #15
                              Originally posted by mcflurry
                              I've been playing with the filter and it does nothing.
                              The template documentation says that macros {$TCP.PORT.MATCHES} and {$TCP.PORT.NOT_MATCHES} (regular expressions) can be used for filtering. So, for example, to match only port 22, you could use ^22$ in {$TCP.PORT.MATCHES}. Or, ^(22|443|3306)$ matches 22, 443 or 3306.

                              ^ matches start of string, $ matches end of string. Parenthesis and pipe (|) can be used as "or" grouping.

                              If you enter just 22, it will match any string that contains 22, like 10220. Or, plain (22|443) will match 12200 and 30443.

                              Markku

                              Comment

                              Working...