Where does the Problem ID data gets stored

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
yunushaikh
Posts: 176
Joined: Sat Jun 20, 2015 9:04 pm

Where does the Problem ID data gets stored

Post by yunushaikh »

Hello Experts,
Below 2 macros I am working with

$HOSTPROBLEMID$ A globally unique number associated with the host's current problem state. Every time a host (or service) transitions from an UP or OK state to a problem state, a global problem ID number is incremented by one (1). This macro will be non-zero if the host is currently a non-UP state. State transitions between non-UP states (e.g. DOWN to UNREACHABLE) do not cause this problem id to increase. If the host is currently in an UP state, this macro will be set to zero (0). Combined with event handlers, this macro could be used to automatically open trouble tickets when hosts first enter a problem state.

$LASTHOSTPROBLEMID$ The previous (globally unique) problem number that was given to the host. Combined with event handlers, this macro could be used for automatically closing trouble tickets, etc. when a host recovers to an UP state.

Where is the $LASTHOSTPROBLEMID$ stored? where is the value for this stored against a specific service. Can you please let me know this is very urgent.

Thanks,
Yunus Shaikh.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Where does the Problem ID data gets stored

Post by mcapra »

Strictly speaking, it's held within the Nagios Core process's memory. As the marcos description indicates, you'd be able to evaluate this at the execution time of your event handler.

Could you describe the use case a bit more? We might be able to offer better advice with the bigger picture available.
Former Nagios employee
https://www.mcapra.com/
yunushaikh
Posts: 176
Joined: Sat Jun 20, 2015 9:04 pm

Re: Where does the Problem ID data gets stored

Post by yunushaikh »

It should be stored somewhere in the nagios database right?

because with the use of $LASTHOSTPROBLEMID$ the tickets are marked as resolved taking the Problem id from it.

I want this Macro value just to make a record of problem id's and the timestamp from it. So we can take out number of hours of downtime of the hosts.

Sicne we get the percentage value in reports. I need it in hours.

Please let me know if there is any input.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Where does the Problem ID data gets stored

Post by tmcdonald »

I don't believe it is in the DB:

Code: Select all

mysql> select distinct TABLE_NAME from INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('last_problem_id','LASTHOSTPROBLEMID') AND TABLE_SCHEMA='nagios';
Empty set (0.00 sec)

mysql> select distinct TABLE_NAME,COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME like "%problem%" AND TABLE_SCHEMA='nagios';
+----------------------+-------------------------------+
| TABLE_NAME           | COLUMN_NAME                   |
+----------------------+-------------------------------+
| nagios_hoststatus    | problem_has_been_acknowledged |
| nagios_servicestatus | problem_has_been_acknowledged |
+----------------------+-------------------------------+
2 rows in set (0.01 sec)
I also was not able to find anything directly referencing the macro or its variable name in the codebases for Core or NDO that would have to do with inserting that value into the DB. It's possible that the field is inserted as part of a loop over the object and so the field is not mentioned by name, but then I would expect to have found a matching field in the DB.

It is however stored in status.dat as last_problem_id but this is not a real-time updated file.
Former Nagios employee
Locked