Description

This article provides information on how to use a script to monitor the SRX status every day/hour/minute/second.

Symptoms

In many scenarios, customers need to periodically check the performance of the SRX device. This helps customers in debugging and troubleshooting.

Solution

Cron is a tool which is used for periodically executing commands in the FreeBsd system. We can create a script, which includes certain monitor commands for SRX, and use a crontab to periodically run the scripts. Here is an example to run a script every minute:

  1. Create a montor script for auto-run in /var/tmp as test.sh echo:

    echo `date "+%Y-%m-%d %H:%M:%S"`

    echo
    echo "cli show security monitoring fpc 1: "
    /usr/sbin/cli show security monitoring fpc 1

    echo
    echo "cprod -A node1.fpc1.pic0 -c show usp flow session summary: "
    /usr/sbin/cprod -A node1.fpc1.pic0 -c "show usp flow session summary"
  2. Add the execute attribute for this script:

    chmod +x /var/tmp/test.sh
    ls -l test.sh
    -rwxr-xr-x 1 root wheel 417 Aug 8 03:41 test.sh


  • Edit the crontab to auto-run the script every minute and write the log file:

    crontab -e
    */1 * * * * sh /var/tmp/test.sh >> /var/tmp/test.log        ---->*/1 means 1 minute interval, 2nd * means every hour, 3rd * means which day in a month, 4th * means which month, 5th * means which week day in a week.