Ad Widget

Collapse

Web.page.regexp username and password?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oldfox
    Junior Member
    • May 2014
    • 14

    #1

    Web.page.regexp username and password?

    Hi
    I got one question. Is there way to pass username and assword in web.page.rexep key?
    I try web.page.regexp[user[email protected],,,"(^)*.*"]

    Regards
    Pawel
  • jan.garaj
    Senior Member
    Zabbix Certified Specialist
    • Jan 2010
    • 506

    #2
    No, "user[email protected]" is CURL URL format and curl is not used on agent side. There is "pure" tcp connect only.

    But you can use Zabbix webmonitoring, where is libcurl used (it's server side).
    Or you can write your own userparameter/module for your agent.
    Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
    My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

    Comment

    • kloczek
      Senior Member
      • Jun 2006
      • 1771

      #3
      Originally posted by jan.garaj
      But you can use Zabbix webmonitoring, where is libcurl used (it's server side).
      Problem with web scenarios is that they are not fire on agent side but from zabbix server/proxy.
      It would be IMO good to have possibility to fire web scenario probes from agents as well. Zabbix agent is using libcurl and it should be quite easy to adapt existing web scenarios code to integrate this within agent.

      Next issue: you must know web.page.regexp[] is processing http reply line by line so it is not possible to use regexps to find patterns stretching across multiple lines.
      However zabbix code has implemented in internal functions finding multiple line regexps so it is only matter of changing current behavior of web.page.regexp[] or provide new agent key on top of such function (IMO it should be changed web.page.regexp[] to allow use multiline regexps because it will not break any existing monitoring).
      http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
      https://kloczek.wordpress.com/
      zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
      My zabbix templates https://github.com/kloczek/zabbix-templates

      Comment

      • jan.garaj
        Senior Member
        Zabbix Certified Specialist
        • Jan 2010
        • 506

        #4
        Good point Tomasz :-) I don't agree only with:
        Originally posted by kloczek
        Zabbix agent is using libcurl.
        Nope, Zabbix agent doesn't use libcurl. If you compile agent with option --enable-agent only, libcurl is not there:
        Code:
        root@zabbix:~/zabbix/src/zabbix_agent# ldd zabbix_agentd
                linux-vdso.so.1 =>  (0x00007fff629fe000)
                libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1cd05b0000)
                libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f1cd0395000)
                libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1ccffce000)
                /lib64/ld-linux-x86-64.so.2 (0x00007f1cd07c1000)
        Source code for key web.page.regexp - function WEB_PAGE_REGEXP
        https://www.zabbix.org/websvn/wsvn/z.../common/http.c - unfortunately, no libcurl: WEB_PAGE_REGEXP()->get_http_page()->zbx_tcp_connect()->...

        Fortunately, Zabbix provide module functionality, where you can use libcurl easily. But then you realize, that one web step check provides more than on metric in one go (response time, response code, ...), what is problem for Zabbix standard concept: one check = one metric. So I always gave it up, because these problems and I've used userparameters with curl command.
        Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
        My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

        Comment

        • kloczek
          Senior Member
          • Jun 2006
          • 1771

          #5
          Originally posted by jan.garaj
          Good point Tomasz :-) I don't agree only with:

          Nope, Zabbix agent doesn't use libcurl. If you compile agent with option --enable-agent only, libcurl is not there:
          Code:
          root@zabbix:~/zabbix/src/zabbix_agent# ldd zabbix_agentd
                  linux-vdso.so.1 =>  (0x00007fff629fe000)
                  libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1cd05b0000)
                  libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f1cd0395000)
                  libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1ccffce000)
                  /lib64/ld-linux-x86-64.so.2 (0x00007f1cd07c1000)
          I don't think that it is caused by --enable-agent

          Code:
          ]$ objdump -x /usr/sbin/zabbix_agentd | grep NEEDED
            NEEDED               libldap-2.4.so.2
            NEEDED               liblber-2.4.so.2
            NEEDED               libcurl.so.4
            NEEDED               libdl.so.2
            NEEDED               librt.so.1
            NEEDED               libresolv.so.2
            NEEDED               libc.so.6
          Above is on Linux, And the same on Solaris:
          Code:
          $ gobjdump -x /usr/sbin/zabbix_agentd | grep NEEDED
            NEEDED               libldap.so.5
            NEEDED               libcurl.so.3
            NEEDED               libsocket.so.1
            NEEDED               libnsl.so.1
            NEEDED               libm.so.2
            NEEDED               libkstat.so.1
            NEEDED               libresolv.so.2
            NEEDED               libc.so.1
          Part of my rpm spec file:
          Code:
          # Conditional build:
          #%undefine              with_pgsql              # enable PostgreSQL az zabbix DB backend
          %define                 with_mysql      yes     # enable MySQL as zabbix DB backend
          #%undefine              with_oracle             # enable Oracle as zabbix DB backend
          #%undefine              with_jabber
          #%undefine              with_java
          %ifos Linux then
          %define                 with_openipmi   yes
          %endif
          #%undefine              with_odbc
          
          [..]
          
          %build
          autoreconf --force
          %configure \
                  LDFLAGS="-Wl,--as-needed" \
                  --enable-agent \
                  --enable-ipv6 \
                  --enable-proxy \
                  --enable-server \
                  --with%{!?with_jabber:out}-jabber \
                  --%{?with_java:en}%{!?with_java:dis}able-java \
                  --with-ldap \
                  --with-libcurl \
                  --with-net-snmp \
                  --with%{!?with_openipmi:out}-openipmi \
                  --with-mysql%{?with_mysql:%{mysql_config}}%{!?with_mysql:=no} \
                  %{?with_pgsql:--with-pgsql} \
                  %{?with_oracle:--with-oracle} \
                  --with%{!?with_odbc:out}-unixodbc
          %{__sed} -i 's/\(#define ZABBIX_VERSION_PATCH\t.*\)/\1-%{release}/' include/version.h
          %{__make}
          As you see all binaries are linked with -Wl,--as-needed so really my binaries are using libcurl symbols

          Source code for key web.page.regexp - function WEB_PAGE_REGEXP
          https://www.zabbix.org/websvn/wsvn/z.../common/http.c - unfortunately, no libcurl: WEB_PAGE_REGEXP()->get_http_page()->zbx_tcp_connect()->...

          Fortunately, Zabbix provide module functionality, where you can use libcurl easily. But then you realize, that one web step check provides more than on metric in one go (response time, response code, ...), what is problem for Zabbix standard concept: one check = one metric. So I always gave it up, because these problems and I've used userparameters with curl command.
          I wrote that libcurl is generally used by the agent code so from this point of view if agent will start using libcurl in handling http connection (not regexp ) it will not add to much additional complexity to agent (agent should be as simple and robust as possible).

          And again: change behavior of WEB_PAGE_REGEXP() start using zbx_regexp_sub() on whole buffer instead repeating it on each line will not break any existing user monitoring but will open using web.page.regexp[] monitoring which needs extract values from multiple lines output like

          Code:
          $ zabbix_agentd --test web.page.get[169.254.169.254,/latest/meta-data/instance-id]
          web.page.get[169.254.169.254,/latest/meta-data/instance-id] [t|HTTP/1.0 200 OK
          Content-Type: text/plain
          Accept-Ranges: bytes
          ETag: "1619924732"
          Last-Modified: Fri, 14 Jun 2013 11:43:18 GMT
          Content-Length: 10
          Connection: close
          Date: Fri, 16 Jan 2015 09:03:17 GMT
          Server: EC2ws
          i-94292ffe]
          So in this case you must find line with "Server: EC2ws" to output i-94292ffe from next line. At the moment web.page.regexp[] cannot do this.
          http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
          https://kloczek.wordpress.com/
          zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
          My zabbix templates https://github.com/kloczek/zabbix-templates

          Comment

          • oldfox
            Junior Member
            • May 2014
            • 14

            #6
            Hi
            Thanks for all replays
            Yes I use finally external command (curl and grep) In my case I need also multiline match so even web.page.regexp was insufficient.
            Anyway I was also thinking to use web scenario and macro maybe? But how use macro from web scenario in item?

            Regards
            Pawel

            Comment

            Working...