JSON filters to acknowledge all services on one host

This forum was archived to /woltlab and is now in read-only mode.
  • I am trying to setup a script to issue acknowledgments of alerts from tools we use in-house. I can acknowledge a specific check with no problem, but when I try and modify the JSON to use a filter and match all service on a host, all I get back is 404 no objects found. I changed my script to do a GET using just the filter on /v1/objects/services and it returns everything I would expect it to. Not sure what I am doing wrong here.

    So first off, I am using Perl (I am an old school SysAdmin). Here is a sample of my test script that works and will acknowledge alerts.

    Like I said it works with no problem.

    So I changed to use a filter instead so I could pickup all services on that host. Below is just the body of my post.

    1. $req = '{"type":"service","filter":"match(\"dummy-0009*\",host.name) && service.state!=ServiceOK", "author":"icingaweb2","comment":"Test from API Script","notify":false,"sticky": true,"persistent": true }';

    Not sure what I am doing wrong here. I am sure I am missing something simple but just can't put my finger on it right now. I have dug into all the documentation and done some googling to try and nail this down already... Any help would be appreciated. Thanks,

  • I am an old school sys admin as well, let us do it step by step

    First the curl version that is in the docs using *my* filter, then using *your* filter

    both of these reflect our ack in the icingaweb2.

    Now paste that stuff into your script and run it:

    and run it:

    1. root@debian88:~# perl t.pl
    2. {"results":[{"code":200.0,"status":"Successfully acknowledged problem for object 'sat4.local!WinProc'."},{"code":200.0,"status":"Successfully acknowledged problem for object 'sat4.local!LoadWin'."}]}

    So, moving the type=service part seems to do the trick.

    The post was edited 2 times, last by sru ().