Postgress DB is using all available space

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Postgress DB is using all available space

Post by bosecorp »

Our development server keeps running out space because Postgress is taking all available space.

is there a way to purge old data. we dont really care about historical data since this is our development server
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Postgress DB is using all available space

Post by tgriep »

Below is the procedure for truncating the Postgres database tables. Run the following as root.

Code: Select all

service nagios stop
service ndo2db stop
service crond stop
service postgresql restart
pkill -9 -u nagios
echo "truncate table xi_events; truncate table xi_meta; truncate table xi_eventqueue;" | psql nagiosxi nagiosxi
service crond start
service ndo2db start
service nagios start
service npcd restart
Then the database should be vacuumed and there are 3 different ways to to that (Depending on the version of Postgress that is installed) the command below work on most systems. Run it as root.

Code: Select all

echo "vacuum;vacuum analyze;vacuum full;"|psql nagiosxi postgres
If it fails, let us know and I can post the other procedure for vacuuming.

If the system was upgraded and then the Postgress database started to grow, it could be that some of the tables did not get updated. If the XI install files are still on the system, you can run this to update the tables.

Code: Select all

service nagios stop
psql nagiosxi nagiosxi -f /tmp/nagiosxi/nagiosxi/nagiosxi-db/mods/pgsql/schema_01.sql
service postgresql restart
service nagios start
If all goes well, the database shouldn't grow to fill the hard drive anymore.

FYI, the Postgres database (nagiosxi) does not store historical data, mostly user info and temporary tables.
Be sure to check out our Knowledgebase for helpful articles and solutions!
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Re: Postgress DB is using all available space

Post by bosecorp »

Worked

do you know why postgres was taking all available space?
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Postgress DB is using all available space

Post by tgriep »

Glad it worked for you.
If the SQL tables did not get updated, the dbmaint script and the event handler scripts cannot remove the processed data and over time, is fills the hard drive up.
Be sure to check out our Knowledgebase for helpful articles and solutions!
bosecorp
Posts: 929
Joined: Thu Jun 26, 2014 1:00 pm

Re: Postgress DB is using all available space

Post by bosecorp »

Thank you

you can close this ticket
Locked