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.
Stop Daemons, this will also stop the logs from being written too while you make your changes.
Code Block language bash title stop daemons
systemctl stop nmis9d
systemctl stop rsyslog
systemctl stop snmptrapd
Copy folders/files to new path, we are doing this recursively and also copying their permissions.
Code Block language bash title copy logs
cp -rp /usr/local/nmis9/logs /mnt/nmis9_logs
cp -rp /usr/local/omk/log /mnt/omk_logs
Back up current configuration files before editing
Code Block language bash title 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.backup1
Edit 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.
Code Block language bash title nmis9 patch
/usr/local/nmis9/admin/patch_config.pl /usr/local/nmis9/conf/Config.nmis /directories/\<nmis_logs\>=/mnt/nmis9_logs
Same as step 4) but with the omk configuration file, omk/conf/opCommon.json.
Code Block language bash title 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_logs
Remove old folder to save space or you can rename or move it.
Code Block language bash title remove the old
rm -rf /usr/local/omk/log
rm -rf /usr/local/nmis9/logs
Create symlink to where the old log files where, this makes it easier to follow wiki and saves the need of editing logrotate.
Code Block language bash title symlinking
ln -s /mnt/nmis9_logs /usr/local/nmis9/logs
ln -s /mnt/omk_logs /usr/local/omk/log
If 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>
Code Block language bash title I sed
sed -i 's:/usr/local/nmis9/logs:/mnt/omk_logs:g' /etc/rsyslog.conf
- Start Daemons
Start your Daemons
Code Block language bash title 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.