# What state to use to get the status of a check?

**URL:** <https://community.icinga.com/t/what-state-to-use-to-get-the-status-of-a-check/12942>\
**Category:** Icinga 2\
**Created:** [November 22, 2023, 7:49am UTC](https://community.icinga.com/t/what-state-to-use-to-get-the-status-of-a-check/12942 "2023-11-22T07:49:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris1980](https://community.icinga.com/letter_avatar_proxy/v4/letter/c/8edcca/32.png) [@Chris1980](https://community.icinga.com/u/Chris1980)\
**Post date:** [November 22, 2023, 7:49am UTC](https://community.icinga.com/t/what-state-to-use-to-get-the-status-of-a-check/12942/1 "2023-11-22T07:49:57Z")

</div>

I am building some checks - but I am not sure which state to use that represents the result of the check.

I marked the states of my sample-result with comments below (AAA, BBB, … EEE) to identify it.

```auto
{
      "attrs": {
        "last_check_result": {
          "active": true,
          "check_source": "MyHost",
          "command": [
            "/usr/lib/nagios/plugins/check_ping",
            "-H",
            "192.168.1.111",
            "-c",
            "5000,100%",
            "-w",
            "3000,80%"
          ],
          "execution_end": 1700638780.905078,
          "execution_start": 1700638750.898157,
          "exit_status": 2, // AAA
          "output": "PING CRITICAL - Packet loss = 100%",
          "performance_data": [
            "rta=5000.000000ms;3000.000000;5000.000000;0.000000",
            "pl=100%;80;100;0"
          ],
          "schedule_end": 1700638780.905165,
          "schedule_start": 1700638750.897758,
          "state": 2, // BBB
          "ttl": 0,
          "type": "CheckResult",
          "vars_after": {
            "attempt": 1,
            "reachable": true,
            "state": 2, // CCC       
            "state_type": 1
          },
          "vars_before": {
            "attempt": 1,
            "reachable": true,
            "state": 2, // DDD
            "state_type": 1
          }
        },
        "state": 1 // EEE
      },
      "joins": {},
      "meta": {},
      "name": "MyHost",
      "type": "Host"
    }

```

Is it AAA, …, EEE that should be used? I did not find infos in the REST API I am using.  
Thanks!

---

<div class="post-metadata">

**Author:** ![rivad](https://community.icinga.com/user_avatar/community.icinga.com/rivad/32/5852_2.png) [@rivad](https://community.icinga.com/u/rivad)\
**Post date:** [November 22, 2023, 8:49am UTC](https://community.icinga.com/t/what-state-to-use-to-get-the-status-of-a-check/12942/2 "2023-11-22T08:49:05Z")

</div>

IMHO, it’s EEE as the others are internal details relating to the check command and its runs. But the state could be set via the DSL or the REST-API as well and would not necessarily be reflected the same way under “last\_check\_result”.

---

<div class="post-metadata">

**Author:** ![Chris1980](https://community.icinga.com/letter_avatar_proxy/v4/letter/c/8edcca/32.png) [@Chris1980](https://community.icinga.com/u/Chris1980)\
**Post date:** [November 22, 2023, 8:54am UTC](https://community.icinga.com/t/what-state-to-use-to-get-the-status-of-a-check/12942/3 "2023-11-22T08:54:40Z")

</div>

I thought about BBB or EEE - but they are not equal…

---

<div class="post-metadata">

**Author:** ![rivad](https://community.icinga.com/user_avatar/community.icinga.com/rivad/32/5852_2.png) [@rivad](https://community.icinga.com/u/rivad)\
**Post date:** [November 22, 2023, 9:14am UTC](https://community.icinga.com/t/what-state-to-use-to-get-the-status-of-a-check/12942/4 "2023-11-22T09:14:15Z")

</div>

Hosts have a state of [up|down|unknown|pending] but the check for the host state reports the usual [ok|warn|crit|unknown|pending].
