Ad Widget

Collapse

Using Web monitoring to inspect string changes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Richard2233
    Junior Member
    • Mar 2018
    • 3

    #1

    Using Web monitoring to inspect string changes

    Hi guys,

    I apologize in advance if this has already been covered but I have tried searching the forums and I have looked at the documentation, but maybe I am not understanding something. I am fairly new to Zabbix....

    I have an application which outputs a JSON page for each active application. Which looks like the following:
    applicationInstanceStatus
    0
    autoRestartSuspended false
    autoRestartSuspendedForApp false
    autoRestartableApp false
    instance
    active true
    applicationDisplayName "ApplicationOne"
    applicationName "ApplicationOne"
    custom false
    id 2
    name 1
    serverName "MickeyMouseServer.com"
    lastStartTime "2018-03-22 17:53:37"
    status "RUNNING"

    Is it possible to setup the web monitor to report on the "RUNNING" status so if it turn to "STOPPED", it will then flag up?

    Any help or pointers are greatly received!
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    You should be able to use item web.page.regexp[host,<path>,<port>,<regexp>,<length>,<output>]. Look at the source for the web page and search for the 'status "RUNNING"' string, your regex has to extract data to return. I don't think I've used this item type late, I think the host is just a zabbix-agent that will initiate the curl (probably) to fetch the data, so you could probably use the server or proxy if the web server isn't monitored by Zabbix.
    Last edited by LenR; 23-03-2018, 04:13. Reason: corrected use of item

    Comment

    • Richard2233
      Junior Member
      • Mar 2018
      • 3

      #3
      Hi,
      Thanks for responding.

      Would the this go into the "Required String" section?

      Something like
      Code:
      web.page.regexp[https://MickeyMouseServer.com:9553/systemconsole/admsvc/monitoring/status/appInstanceStatus/ApplicationOne/ApplicationOne.json,9443,RUNNING,7]

      Comment

      • dorth
        Junior Member
        • Oct 2013
        • 6

        #4
        It's probably useful to post the exact JSON output of your web page since that is what web.page.regexp will be looking at. However, looking at your expression above, I think that it *should* work. It also matches the example from the documentation (https://www.zabbix.com/documentation...s/zabbix_agent)

        As you noted, I had posted a year back (see: https://www.zabbix.com/forum/zabbix-...eb-page-regexp) but using more complex Regex for some reason. I'm not sure if that was because I couldn't get the simple stuff to work.

        Did you try your example (using zabbix_agentd -t to see if it is working? I somehow remember this was a colossal pain in the behind.

        Comment


        • Richard2233
          Richard2233 commented
          Editing a comment
          Hey,
          cheers for coming back to me.

          The raw data extract is as follows:

          {
          "applicationInstanceStatus": [
          {
          "autoRestartSuspended": false,
          "autoRestartSuspendedForApp": false,
          "autoRestartableApp": false,
          "instance": {
          "active": true,
          "applicationDisplayName": "ApplicationOne",
          "applicationName": "ApplicationOne",
          "custom": false,
          "id": 2,
          "name": 1,
          "serverName": "MickeyMouseServer.com"
          },
          "lastStartTime": "2018-03-22 17:53:37",
          "status": "RUNNING"
          }
          ]
          }

          I did try my example without much success. Sound stupid but I'm also not 100% sure I am putting it in the right place. I've tried putting it in "Required String" as well as playing around with varibles etc through the GUI. All with no success.

          I'm open to ideas but like you say, it seems to be a massive pain in the backside to get working....
      • dorth
        Junior Member
        • Oct 2013
        • 6

        #5
        OK, I appear to have it working with a simple case. Here's where I think you've gone wrong. The field for "host" is ONLY FOR THE HOST - not "https://" as this will mess you up. You have the port # to specify if it's 80 or 443 or in your case, 9553. If you want to be sure that you're getting the correct data to parse, then try the same command but using the web.page.regexp along with the zabbix_agentd -t - like this:

        zabbix_agentd -t 'web.page.get[MickeyMouseServer.com,/systemconsole/admsvc/monitoring/status/appInstanceStatus/ApplicationOne/ApplicationOne.json,9553]'

        That should return the entire json structure (including headers, which are also parsed by the .regexp). If you're not getting your JSON back, then there's something else wrong.

        Here are examples copied and pasted from experimentation:

        ± |master ✗| → zabbix_agentd -t 'web.page.get[3v225.cv.hp.com,_cluster/health?pretty,9200]'
        web.page.get[3v225.cv.hp.com,_cluster/health?pretty,9200] [t|HTTP/1.1 200 OK
        content-type: application/json; charset=UTF-8
        content-length: 491
        Connection: close

        {
        "cluster_name" : "elk-prod",
        "status" : "red",
        "timed_out" : false,
        "number_of_nodes" : 8,
        "number_of_data_nodes" : 3,
        "active_primary_shards" : 6343,
        "active_shards" : 6345,
        "relocating_shards" : 0,
        "initializing_shards" : 12,
        "unassigned_shards" : 19403,
        "delayed_unassigned_shards" : 0,
        "number_of_pending_tasks" : 609,
        "number_of_in_flight_fetch" : 0,
        "task_max_waiting_in_queue_millis" : 2927465,
        "active_shards_percent_as_number" : 24.631211180124225
        }]


        I've also found that the field for "length - maximum number of characters to return" doesn't appear to work. At least as far as I can tell. If I leave it blank, or set it to '2', or to '100' - no change in the response.

        ± |master ✗| → zabbix_agentd -t 'web.page.regexp[3v225.cv.hp.com,_cluster/health?pretty,9200,status,,]'
        web.page.regexp[3v225.cv.hp.com,_cluster/health?pretty,9200,status,1,] [s|status]



        ± |master ✗| → zabbix_agentd -t 'web.page.regexp[3v225.cv.hp.com,_cluster/health?pretty,9200,status,2,]'
        web.page.regexp[3v225.cv.hp.com,_cluster/health?pretty,9200,status,1,] [s|status]


        Comment

        Working...