Internal documentation only
This page has been marked as draft.
Remove Logs with Future Date
Scenario Copied
Client asked if it is possible to delete future logs that they have been set manually. They accidentally typed the wrong date before updating a collector and now they have those events stuck that is causing issues with the integration between Opsview and ServiceNow Event Management.
Resolution Copied
Before proceeding with the steps below, please run an Apply Changes.
We had set a service check to a critical status and attempted to delete the critical log entry.
We found that two runtime database tables contained output related to the angge test that was configured on the check.
To access the runtime database, you may use the following command:
/opt/opsview/coreutils/utils/cx runtime
Tables:
nagios_statehistory
mysql> SELECT * FROM nagios_statehistory WHERE output LIKE '%test%';
+-----------------+---------------------+-----------------+-----------+--------------+-------+------------+-----------------------+--------------------+------------+-----------------+--------------------------+--------------------+-------------------------------+-----------+------------+-----------------+------------+
| statehistory_id | state_time | state_time_usec | object_id | state_change | state | state_type | current_check_attempt | max_check_attempts | last_state | last_hard_state | scheduled_downtime_depth | downtimehistory_id | problem_has_been_acknowledged | eventtype | host_state | host_state_type | output |
+-----------------+---------------------+-----------------+-----------+--------------+-------+------------+-----------------------+--------------------+------------+-----------------+--------------------------+--------------------+-------------------------------+-----------+------------+-----------------+------------+
| 4775 | 2025-07-25 16:43:09 | 0 | 228 | 1 | 2 | 1 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | test |
| 4778 | 2025-07-25 18:00:34 | 0 | 228 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | test2 |
| 4790 | 2025-07-25 19:22:27 | 0 | 10 | 1 | 2 | 1 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | test |
| 4801 | 2025-07-25 21:14:23 | 0 | 10 | 1 | 2 | 1 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | angge test |
+-----------------+---------------------+-----------------+-----------+--------------+-------+------------+-----------------------+--------------------+------------+-----------------+--------------------------+--------------------+-------------------------------+-----------+------------+-----------------+------------+
4 rows in set (0.02 sec)
nagios_servicechecks
mysql> SELECT * FROM nagios_servicechecks WHERE output LIKE '%test%';
+-----------------+-------------------+------------+-----------------------+--------------------+-------+------------+---------------------+-----------------+---------+---------------+----------------+---------+-------------+------------+----------+
| servicecheck_id | service_object_id | check_type | current_check_attempt | max_check_attempts | state | state_type | start_time | start_time_usec | timeout | early_timeout | execution_time | latency | return_code | output | perfdata |
+-----------------+-------------------+------------+-----------------------+--------------------+-------+------------+---------------------+-----------------+---------+---------------+----------------+---------+-------------+------------+----------+
| 754533 | 228 | 1 | 1 | 3 | 2 | 1 | 2025-07-25 16:43:09 | 0 | 60 | 0 | 0 | 0 | 2 | test | |
| 756564 | 228 | 1 | 1 | 3 | 1 | 1 | 2025-07-25 18:00:34 | 0 | 60 | 0 | 0 | 0 | 1 | test2 | |
| 758757 | 10 | 1 | 1 | 3 | 2 | 1 | 2025-07-25 19:22:27 | 0 | 60 | 0 | 0 | 0 | 2 | test | |
| 761604 | 10 | 1 | 1 | 3 | 2 | 1 | 2025-07-25 21:14:23 | 0 | 60 | 0 | 0 | 0 | 2 | angge test | |
+-----------------+-------------------+------------+-----------------------+--------------------+-------+------------+---------------------+-----------------+---------+---------------+----------------+---------+-------------+------------+----------+
4 rows in set (0.90 sec)
After identifying the entries, we manually deleted them from the table.
nagios_statehistory
mysql> DELETE FROM nagios_statehistory WHERE statehistory_id = 4801;
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM nagios_statehistory WHERE output LIKE '%test%';
+-----------------+---------------------+-----------------+-----------+--------------+-------+------------+-----------------------+--------------------+------------+-----------------+--------------------------+--------------------+-------------------------------+-----------+------------+-----------------+--------+
| statehistory_id | state_time | state_time_usec | object_id | state_change | state | state_type | current_check_attempt | max_check_attempts | last_state | last_hard_state | scheduled_downtime_depth | downtimehistory_id | problem_has_been_acknowledged | eventtype | host_state | host_state_type | output |
+-----------------+---------------------+-----------------+-----------+--------------+-------+------------+-----------------------+--------------------+------------+-----------------+--------------------------+--------------------+-------------------------------+-----------+------------+-----------------+--------+
| 4775 | 2025-07-25 16:43:09 | 0 | 228 | 1 | 2 | 1 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | test |
| 4778 | 2025-07-25 18:00:34 | 0 | 228 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | test2 |
| 4790 | 2025-07-25 19:22:27 | 0 | 10 | 1 | 2 | 1 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | test |
+-----------------+---------------------+-----------------+-----------+--------------+-------+------------+-----------------------+--------------------+------------+-----------------+--------------------------+--------------------+-------------------------------+-----------+------------+-----------------+--------+
3 rows in set (0.02 sec)
nagios_servicechecks
mysql> DELETE FROM nagios_servicechecks WHERE start_time = '2025-07-25 21:14:23';
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM nagios_servicechecks WHERE output LIKE '%test%';
+-----------------+-------------------+------------+-----------------------+--------------------+-------+------------+---------------------+-----------------+---------+---------------+----------------+---------+-------------+--------+----------+
| servicecheck_id | service_object_id | check_type | current_check_attempt | max_check_attempts | state | state_type | start_time | start_time_usec | timeout | early_timeout | execution_time | latency | return_code | output | perfdata |
+-----------------+-------------------+------------+-----------------------+--------------------+-------+------------+---------------------+-----------------+---------+---------------+----------------+---------+-------------+--------+----------+
| 754533 | 228 | 1 | 1 | 3 | 2 | 1 | 2025-07-25 16:43:09 | 0 | 60 | 0 | 0 | 0 | 2 | test | |
| 756564 | 228 | 1 | 1 | 3 | 1 | 1 | 2025-07-25 18:00:34 | 0 | 60 | 0 | 0 | 0 | 1 | test2 | |
| 758757 | 10 | 1 | 1 | 3 | 2 | 1 | 2025-07-25 19:22:27 | 0 | 60 | 0 | 0 | 0 | 2 | test | |
+-----------------+-------------------+------------+-----------------------+--------------------+-------+------------+---------------------+-----------------+---------+---------------+----------------+---------+-------------+--------+----------+
3 rows in set (0.97 sec)
After deleting both entries, the set status is successfully removed from the history tab.
Also, you may choose to filter using the start_time column instead of the output column when querying the nagios_servicechecks table and state_time column on the nagios_statehistory table.