Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Relocating NMIS9 and OMK logs
Summary:
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:

  1. Stop Daemons, this will also stop the logs from being written too while you make your changes.

    Code Block
    languagebash
    titlestop daemons
    systemctl stop nmis9d

...

  1. 
    systemctl stop rsyslog

...

  1. 
    systemctl stop snmptrapd

...

  1. 
    /usr/local/omk/bin/checkomkdaemons.sh stop 


  2. Copy folders/files to new path, we are doing this recursively and also copying their permissions.

    Code Block
    languagebash
    titlecopy logs
    cp -rp /usr/local/nmis9/logs /mnt/nmis9_logs

...

  1. 
    cp -rp /usr/local/omk/log /mnt/omk_logs 


  2. Back up current configuration files before editing

    Code Block
    languagebash
    titlebackup configurations
    cp /usr/local/nmis9/conf/Config.nmis /usr/local/nmis9/conf/Config.nmis.backup1

...

  1. 
    cp /usr/local/omk/conf/opCommon.json /usr/local/omk/conf/opCommon.json.backup1

...

  1. 
    cp /etc/rsyslog.conf /etc/rsyslog.conf.backup1 


  2. 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
    languagebash
    titlenmis9 patch
    /usr/local/nmis9/admin/patch_config.pl /usr/local/nmis9/conf/Config.nmis /directories/\<nmis_logs\>=/mnt/nmis9_logs 


  3. Same as step 4) but with the omk configuration file, omk/conf/opCommon.json.

    Code Block
    languagebash
    titleomk patch
    /usr/local/nmis9/admin/patch_config.pl /usr/local/omk/conf/opCommon.json /nmis/\<nmis9_logs\>=/mnt/nmis9_logs

...

  1. 
    /usr/local/nmis9/admin/patch_config.pl /usr/local/omk/conf/opCommon.json /directories/\<omk_logs\>=/mnt/omk_logs 


  2. Remove old folder to save space or you can rename or move it.

    Code Block
    languagebash
    titleremove the old
    rm -rf /usr/local/omk/log

...

  1. 
    rm -rf /usr/local/nmis9/logs


  2. 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
    languagebash
    titlesymlinking
    ln -s /mnt/nmis9_logs /usr/local/nmis9/logs

...

  1. 
    ln -s /mnt/omk_logs /usr/local/omk/log 


  2. 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>

...

  1. Code Block
    languagebash
    titleI sed
    sed -i 's:/usr/local/nmis9/logs:/mnt/omk_logs:g' /etc/rsyslog.conf

...

  1. Start Daemons

...


  1. Start your Daemons

    Code Block
    languagebash
    titleStart 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.