Is it possible to change WARNING to CRITICAL after X days if unchanged?

  • Hi,


    first of, sorry if this is a copy of this thread, I wasn't sure if the intention is the same.


    I'm currently using apt_check to check for critical security updates and I'd like to change the WARNING to CRITICAL if the updates are not installed after a certain amount of time, as this would indicate that the automated patch mechanism didn't work. Any idea


    • if that's possible in Icinga2
    • if it can be done using the Director
    • or if not, how I would go about doing that.


    One suggestion in the other thread was to use API + scripting. If that's the way to go, any pointers where to begin looking? I'm new to the API, aside from setting up an API user for Director.


    Thanks!

  • 1. That does not have anything to do with icinga2 but with the plugin. Icinga2 will just take the return value of the plugin and operate on that.


    2. Sure. After you have a working plugin.


    3. Modify the plugin or wrap it in a script of your favorite language. What language would be your choice to provide an API example ?


    Here is a starting point:

    Code
    1. curl -k -s -u 'root:yourpassword' -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services' -d '{ "attrs": [ "__name", "last_state_warning", "last_state_ok" ]}''' | python -m json.tool
    2. ...
    3. "attrs": {
    4. "__name": "sat4.local!loadtmp",
    5. "last_state_ok": 1501020737.369773,
    6. "last_state_warning": 1501020682.360461
    7. },
    8. ...

    The post was edited 1 time, last by sru ().

  • First of, sorry for the delayed response, second, thanks for the info.

    It helped quite a lot, unfortunately other tasks got in the way of finishing the script. If I get around to it (hopefully soon), I will add a link to the source here, in case others need it as well. :)