Search code examples
triggerszabbixhttp-response-codes

How to check HTTP response code in zabbix?


I have a Zabbix server 2.2 and a few linux hosts with websites. How can I get a notification from Zabbix, if the HTTP(s) response code is not 200?

I've tried those triggers without any success:

    {owncloud:web.test.rspcode[Availability of owncloud,owncloud availability].last(,10)}#200

    {owncloud:web.test.error[Availability of owncloud].count(10,200)}<1

    {owncloud:web.test.error[Availability of owncloud].last(#1,10)}=200

But nothing works. I never got an notification, that the code is not 200 anymore even it was 404, because I have renamed the index.php of owncloud to index2.php


Solution

  • I found the issue. You need to specify the URL to check with file. For example like this in your web scenario:

        https://owncloud.example.com/index.php
    

    "Note that Zabbix frontend uses JavaScript redirect when logging in, thus first we must log in, and only in further steps we may check for logged-in features. Additionally, the login step must use full URL to index.php file." - https://www.zabbix.com/documentation/2.4/manual/web_monitoring/example

    I also used following expression as trigger:

        {owncloud:web.test.fail[Availability of owncloud].last()}>0