Relocating NMIS9 and OMK logs
This is a process for moving log files/directories and editing the configuration files that utilize it. Many may have started their monitoring with a smaller disk size and added on or want to have logs in a separate place than their other files. The purpose of this process is to show what will need to be edited and some tips to do this efficiently with as little down time as possible.
This document assumes that NMIS9 and OMK are installed in the default locations.
Steps:
Stop Daemons, this will also stop the logs from being written too while you make your changes.
stop daemons
systemctl stop nmis9d systemctl stop rsyslog systemctl stop snmptrapd /usr/local/omk/bin/checkomkdaemons.sh stopCopy folders/files to new path, we are doing this recursively and also copying their permissions.
copy logs
cp -rp /usr/local/nmis9/logs /mnt/nmis9_logs cp -rp /usr/local/omk/log /mnt/omk_logsBack up current configuration files before editing
backup configurations
cp /usr/local/nmis9/conf/Config.nmis /usr/local/nmis9/conf/Config.nmis.backup1 cp /usr/local/omk/conf/opCommon.json /usr/local/omk/conf/opCommon.json.backup1 cp /etc/rsyslog.conf /etc/rsyslog.conf.backup1Edit the NMIS9 configuration file, we are using the patch tool found in nmis9/bin. This saves time and doesn't make the user open a text editor to make changes.
nmis9 patch
/usr/local/nmis9/admin/patch_config.pl /usr/local/nmis9/conf/Config.nmis /directories/\<nmis_logs\>=/mnt/nmis9_logsSame as step 4) but with the omk configuration file, omk/conf/opCommon.json.
omk patch
/usr/local/nmis9/admin/patch_config.pl /usr/local/omk/conf/opCommon.json /nmis/\<nmis9_logs\>=/mnt/nmis9_logs /usr/local/nmis9/admin/patch_config.pl /usr/local/omk/conf/opCommon.json /directories/\<omk_logs\>=/mnt/omk_logsRemove old folder to save space or you can rename or move it.
remove the old
rm -rf /usr/local/omk/log rm -rf /usr/local/nmis9/logsCreate symlink to where the old log files where, this makes it easier to follow wiki and saves the need of editing logrotate.
symlinking
ln -s /mnt/nmis9_logs /usr/local/nmis9/logs ln -s /mnt/omk_logs /usr/local/omk/logIf you are using syslog you will want to update the configuration file to match the new path. I have given an example using sed (stream editor), this was tested on ubuntu 20.04 and working. Syntax: sed -i 's:<search regex>:<replacement>:g' <input file>
I sed
sed -i 's:/usr/local/nmis9/logs:/mnt/omk_logs:g' /etc/rsyslog.confStart your Daemons
Start your daemons
systemctl start nmis9d systemctl start rsyslog systemctl start snmptrapd /usr/local/omk/bin/checkomkdaemons.sh start
NOTE: For logrotate, you do not have to change the paths as long as you did the symlink! It does honor this.