Skip to content

Housekeeping

Housekeeping

If you have a nice number of devices combined with a long running time of Observium, you're sure to have a gigantic database of event log, syslog and performance timing information. Some of you have resorted to periodically truncating tables - fear no more, housekeeping.php is here!

You have a choice of specifying either -a for all modules or -s, -e, -r, -p -b , -i, -l and/or -t for specific things. Apart from that, there are options in the configuration to set before most of these things actually do anything.

Observium will notify you if you don't run housekeeping periodically.

Running via CRON

We recommend running housekeeping via cron, daily or weekly (yes, even though the age is set in seconds, I don't recommend running it every minute ;), but only after you've run it manually once. It'll take quite a while the first time to clean up large databases. The "check for invalid RRD files" is probably quite I/O heavy on large installations.

Add the following lines to your /etc/cron.d/observium file to run housekeeping at reasonably sane intervals

# Run housekeeping script daily for syslog, eventlog and alert log
13 5 * * * root /opt/observium/housekeeping.php -sel >> /dev/null 2>&1
# Run housekeeping script daily for rrds, ports, orphaned entries in the database and performance data
47 4 * * * root /opt/observium/housekeeping.php -rptb >> /dev/null 2>&1

Modules

Syslog

-s Cleans up syslog data, based on the age of the entries.

$config['housekeeping']['syslog']['age'] = 0;

Maximum age of syslog entries in seconds; 0 to disable (i.e. 7*86400 for 7 days.)

Event Log

-e Cleans up event log data, based on the age of the entries.

$config['housekeeping']['eventlog']['age'] = 0;

Maximum age of event log entries in seconds; 0 to disable (i.e. 30*86400 for 30 days.)

Alert Log

-l Clean up alert log

$config['housekeeping']['alertlog']['age'] = 0;

Maximum age of alert log entries in seconds; 0 to disable (i.e. 30*86400 for 30 days.)

Inventory entries

-i Clean up deleted inventory entries

$config['housekeeping']['inventory']['age'] = 0;

Maximum age of deleted inventory entries in seconds; 0 to disable (i.e. 30*86400 for 30 days.)

RRD Files

-r Cleans up RRD files, there are 2 options here:

Cleanup of RRD files with a modification time of a certain age. Ports that are gone, sensors that are gone, erroneaously created RRD files due to bugs or hardware changes, etc.

$config['housekeeping']['rrd']['age'] = 0;

Maximum age of unused rrd files in seconds before automatically purging; 0 to disable (i.e. 90*86400 for 90 days.)

  • Cleanup of invalid RRD files. Runs over all .rrd files to see if they are identified as RRDTool Databases. They can sometimes get corrupted (0 bytes, half a file) when your disk/ramdrive is full. When they exist, they are not recreated even if they're invalid. Consequently RRDtool refuses to add data into them as they are not valid RRD database files. This scripts deletes any .rrd file not identified as RRDTool. Delete .rrd files that are not valid RRD files (eg created with a full disk)

Note: this defaults to true currently. Handle with care.

$config['housekeeping']['rrd']['invalid'] = TRUE;
  • Cleanup RRD dirrectories for deleted devices (devices removed from observium db but keeped rrd dirs).

    $config['housekeeping']['rrd']['deleted'] = FALSE;

Note: this defaults to false currently.

  • Cleanup RRD dirrectories for disabled devices (devices disabled in web ui, but still remaining in the database).

    $config['housekeeping']['rrd']['disabled'] = FALSE;

Note: this defaults to false currently.

Stale Database Entries

-b Cleans up stale entries in the database. Sometimes entries get left behind when devices are removed, this will clean them up.

Ports

-p Cleans up deleted ports. You can do this manually by using the purge button in the web interface, but one could probably safely assume if a port has not returned after 30 days it really is gone. Shorter could be useful in your environment, mine is set to 7 days.

$config['housekeeping']['deleted_ports']['age'] = 0;

Maximum age of deleted ports in seconds before automatically purging; 0 to disable (i.e. 30*86400 for 30 days.)

Logging

Housekeeping logs to housekeeping.log in $config['log_dir'] which defaults to the logs directory in your Observium root.