Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

nsm_sensor_ps-restart should wait for process to gracefully terminate before rotating the log file #217

Closed
GoogleCodeExporter opened this issue Mar 24, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

nsm_sensor_ps-restart should wait for process to gracefully terminate before 
rotating the log file

Original issue reported on code.google.com by doug.bu...@gmail.com on 2 Feb 2012 at 1:14

@GoogleCodeExporter
Copy link
Author

The process_restart() function in /usr/local/lib/nsmnow/lib-nsm-common-utils 
now looks like this:


process_restart()
{
    # grab input variables with sane defaulting
    APP=${1:-}
    APP_OPTIONS=${2:-}
    PID_FILE=${3:-}
    LOG_FILE=${4:-}
    APP_DESC=${5:-}

    # Pull the PID out of the PID_FILE
    # This must be done before process_stop since it deletes PID_FILE
    PID=$(cat $PID_FILE)
    # Ask the process to shut down
    process_stop "$APP" "$PID_FILE" "$APP_DESC"
    # Wait for the process to terminate gracefully
    while [ `ps aux |grep $PID |grep -v grep |wc -l` -eq 1 ] ; do sleep 1; done
    # Rotate the log file and keep a maximum of 10  
    mv "$LOG_FILE" "$LOG_FILE".`date +%Y%m%d%H%M%S`
    [ `ls "$LOG_FILE".* |wc -l` -gt 10 ] && ls "$LOG_FILE".* |head -1 |xargs rm -f
    # Start the process
    process_start "$APP" "$APP_OPTIONS" "$PID_FILE" "$LOG_FILE" "$APP_DESC"
}

Original comment by doug.bu...@gmail.com on 2 Feb 2012 at 1:22

  • Changed state: Started
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Packaged:
/usr/local/lib/ruby/gems/1.9.1/gems/fpm-0.3.11/bin/fpm -s dir -t deb -n 
securityonion-nsmnow-admin-scripts -v 20120202 /etc/init.d/nsm* 
/usr/share/nsmnow/ /usr/local/sbin/nsm* /usr/local/lib/nsmnow/ 
/etc/cron.d/sensor-* /etc/cron.d/nsm* /etc/cron.d/bro* 
/etc/init/securityonion.conf

Original comment by doug.bu...@gmail.com on 2 Feb 2012 at 1:23

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Added the following to security-onion-upgrade.sh:

sed -i 's| |=|g' $CONF
source $CONF
if [ "$VERSION" = "20120125" ]; then
        NEW="20120202"
        echo "**********************************************"   | $LOGGER
        echo "* Upgrading from $VERSION to $NEW."               | $LOGGER
        echo "**********************************************"   | $LOGGER
        DIR="/nsm/backup/$NEW"
        mkdir -p $DIR                                           | $LOGGER
        cd $DIR

    echo "* Installing new NSM scripts"         | $LOGGER
    FILE=securityonion-nsmnow-admin-scripts_"$NEW"_i386.deb
    wget -q http://sourceforge.net/projects/security-onion/files/$NEW/$FILE -O $FILE | $LOGGER
    dpkg -i $FILE                       | $LOGGER

        sed -i "s|VERSION=$VERSION|VERSION=$NEW|g" $CONF        | $LOGGER
        echo "* Upgrade to $NEW complete."                      | $LOGGER
        echo 
fi

Original comment by doug.bu...@gmail.com on 2 Feb 2012 at 1:24

  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Published:
http://securityonion.blogspot.com/2012/02/security-onion-20120202-now-available.
html

Original comment by doug.bu...@gmail.com on 2 Feb 2012 at 1:42

  • Changed state: Verified
  • Added labels: ****
  • Removed labels: ****

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant