Cleanup Nagios XI Database

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
bennyboy
Posts: 157
Joined: Thu Oct 29, 2015 9:42 am

Cleanup Nagios XI Database

Post by bennyboy »

Can you run some cleanup on this db ?

Code: Select all

[root@NagiosServer mysql]# du -h
1012K   ./mysql
0       ./test
212K    ./performance_schema
6.5G    ./nagios
7.0M    ./nagiosql
14G     ./nagiosxi
21G     .
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Cleanup Nagios XI Database

Post by dchurch »

How many hosts and services are you monitoring?

Any deletions from the database will result in data loss. Data loss such as historical data being used to draw uptime graphs. If disk space is more important to you than historical data, you can delete some of the entries in those tables.

If you're really concerned about which tables are contributing the most to the size-on-disk of your database, you can run this SQL:

Code: Select all

select
    round(((data_length + index_length) / 1024 / 1024), 2) "size_in_mb",
    concat(table_schema, '.', table_name) as "table"
from information_schema.tables
where data_length is not null
order by data_length + index_length;
Here Be Dragons

Again, THIS WILL RESULT IN DATA LOSS.

To delete entries in nagios_logentries older than 90 days, connect to the ndoutils database and run the following command:

Code: Select all

select count(*) from nagios_logentries where entry_time < date_sub(now(), interval 90 day);
-- only do this if you're sure: delete from nagios_logentries where entry_time < date_sub(now(), interval 90 day);
So, from the shell it would be:

Code: Select all

mysql -undoutils -pn@gweb nagios -e 'select count(*) from nagios_logentries where entry_time < date_sub(now(), interval 90 day);'
# only do this if you're sure: mysql -undoutils -pn@gweb nagios -e 'delete from nagios_logentries where entry_time < date_sub(now(), interval 90 day);'
Replace "90 day" with an appropriate value to delete more or less data. "30 day" would delete more data, "120 day" would delete less.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.