Page 1 of 1

Where does the Problem ID data gets stored

Posted: Fri Feb 24, 2017 5:33 am
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.

Re: Where does the Problem ID data gets stored

Posted: Fri Feb 24, 2017 2:32 pm
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.

Re: Where does the Problem ID data gets stored

Posted: Thu Mar 02, 2017 12:25 am
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.

Re: Where does the Problem ID data gets stored

Posted: Thu Mar 02, 2017 12:37 pm
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.