Ad Widget

Collapse

Help on web.page.regexp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RobertS
    Member
    • Aug 2006
    • 57

    #1

    Help on web.page.regexp

    I want to monitor my Tomcat-Server and test (every 10 sec) for a string on the returned page with web.page.regexp. I want to check "http://www.mytomcatserver.com:8080/portal/pages/Login.jsp" for the string "LOGIN"

    First try:
    Code:
    web.page.regexp[www.mytomcatserver.com,portal/pages/Login.jsp,8080,LOGIN,5]
    -> i get "not supported"
    -> the key is cut after 64 chars
    Code:
    web.page.regexp[www.mytomcatserver.com,portal/pages/Login.jsp,80
    Second try:
    Code:
    web.page.regexp[10.20.30.40,portal/pages/Login.jsp,8080,LOGIN,5]
    -> Return Value 0; but last check does not update; no change when the server is not reachable

    Question:
    What is the correct syntax for web.page.regexp in this example?
    What would be the syntax if i want to check for the occurrence of "LOGIN" and "Version" in the returned page?
    Why is it not possible to use more then 64 char for the key?

    Thank you,
    Robert
  • RobertS
    Member
    • Aug 2006
    • 57

    #2
    Hello to all,

    it seems that nobody is using web.page.regexp . Or is there someone who can help me?

    Regards, Robert

    Comment

    • alj
      Senior Member
      • Aug 2006
      • 188

      #3
      It cant monitor https anyway so I end up using custom monitor with curl getting url and grep parsing it.

      Comment

      • dorth
        Junior Member
        • Oct 2013
        • 6

        #4
        web.page.regexp examples

        I stumbled onto this page while trying to come up with some examples of using web.page.regexp. Since I'm guessing you've given up on getting an answer in the past 11 years, I'm going to add some examples which don't really address your question, but that might help someone else out who google into this forum.

        Here is what the data stream looks like that I'll be parsing:
        Code:
        {
          "cluster_name" : "elk-prod-02",
          "status" : "green",
          "timed_out" : false,
          "number_of_nodes" : 3,
          "number_of_data_nodes" : 3,
          "active_primary_shards" : 4453,
          "active_shards" : 8906,
          "relocating_shards" : 0,
          "initializing_shards" : 0,
          "unassigned_shards" : 0,
          "number_of_pending_tasks" : 0
        }
        The first example is if I want to parse the value of "status" to return green (without any quotes).

        Code:
        web.page.regexp[localhost,/my.json,80,\"status\" : \"(.*)\",,"\1"]
        In the example above, I search for "status" (with quotes which I have to escape with a backslash), followed by a space, then a colon, then quotes, my text, and then another quote. I've included a saved the match of my text using parenthesis which in this case do NOT need to be quoted. My results is returned using a backreference of \1.

        Here is what it looks like on the command line. I have to wrap the whole thing in single quotes when used on the command line:
        Code:
        :~$ zabbix_agentd -t 'web.page.regexp[localhost,/my.json,80,\"status\" : \"(.*)\",,"\1"]'
        [s|green]
        You'll quickly discover that trying to use a comma (,) in your RegEx appears to be impossible, as does using brackets []. So there are some things you'll just have to futz around with. Using the command line (zabbix_agentd -t) can be really helpful, but unfortunately will allow you to use things (ex: brackets) which can't be pasted into the UI and used.

        Now let's try getting a non-quoted integer. Remember that since this is JSON, it might or might not have a comma (,) after the value. That's just as well since I couldn't find a way to escape a comma.

        Code:
        ~# zabbix_agentd -t 'web.page.regexp[localhost,/my.json,80,\"number_of_nodes\" : (\w*),,"\1"]'
        [s|3]
        The above shows how to use a character class \w to match a non-word. I was not able to get the GNU character classes such as [:alpha:].

        Anyway, I apologize for not directly answering the question, but hopefully this might help someone else. Likely even me the next time I have to do this!

        Dave O

        Comment

        • Richard2233
          Junior Member
          • Mar 2018
          • 3

          #5
          Hi dorth ,

          Not sure if you are still active on this forum but if you are would really appreciate your thoughts on an issue I am having over on: https://www.zabbix.com/forum/zabbix-...string-changes
          Not meaning to hijack this thread but I if you have chance to have a look it would be appreciated as the example you've given above is very similar to the issue I've posted.

          Thanks in advance.

          Comment

          • kloczek
            Senior Member
            • Jun 2006
            • 1771

            #6
            Originally posted by RobertS
            it seems that nobody is using web.page.regexp . Or is there someone who can help me?
            Of course is using and it works perfectly on for example Apache 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

            Working...