Skip to main content
Version: Next

Working with NFO Service

Working with NFO service depends on OS type it installed on. Below are the methods can be used to start, stop, restart the service or get its status.

Working with NFO service depends on OS type it installed on. Below are the methods that can be used to start, stop, restart the underlying Tomcat service or get its status. To manage the NetFlow Optimizer (NFO) server process directly, you must use REST API requests.

Managing the Tomcat Service

OS Which Does Not Support systemd

/etc/init.d/tomcat_nfo start|stop|restart|status

Command status reports the state of the service (running or not) and its PID, if it is running.

OS Which Supports systemd

systemctl start|stop|kill|restart|status tomcat_nfo.service

Command status gives a verbose info about the service. To find the line with info in the style of OS which does not support systemd, you may use option -l:

systemctl -l status tomcat_nfo.service

This option prevents from replacing trailing portion of long strings by ellipsis.

Command systemctl provides more features compared to other methods. For details, see the documentation for this command.

Universal Method

service tomcat_nfo start|stop|restart|status

This method works on both types of OS but it is deprecated on OS which supports systemd. Actually, the service command is translated to the above commands depending on OS type.

Managing the NFO Server Process

To start, stop, or restart the NFO server process directly, you must send REST API requests. A sample script, nfo_svr_ctrl.sh, is provided for convenience:

#!/bin/bash

# NFO host
NFO_HOST=localhost
# NFO port
NFO_PORT=8443
# NFO admin account password
NFO_ADMIN_PASSWORD=changeme

# -----------------------------
# If NFO version >= 2.11.1, the CSRF token is required
# for HTTP request types: POST, PUT, PATCH, and DELETE.
# For exampe:
# -H 'X-XSRF-TOKEN:QQA=' --cookie 'XSRF-TOKEN=A'
# -----------------------------

# loging
LOCATION=$(curl -sid "j_username=admin&j_password=${NFO_ADMIN_PASSWORD}" \
-H 'X-XSRF-TOKEN:QQA=' --cookie 'XSRF-TOKEN=A' \
-c cookies \
--insecure \
"https://${NFO_HOST}:${NFO_PORT}/j_security_check" \
| grep -i "Location:" | awk '{print $2}' | tr -d '\r')

if [ "$LOCATION" != "/" ]; then
echo "Invalid credentials"
exit 1
fi

# start/stop/restart NFO server
curl -X POST \
-H 'Accept:application/json' \
-H 'X-XSRF-TOKEN:QQA=' --cookie 'XSRF-TOKEN=A' \
-b cookies \
--insecure \
"https://${NFO_HOST}:${NFO_PORT}/nfirapi/server/control/$1"

# logout if NFO < 2.11.1
#curl -b cookies --insecure "https://${NFO_HOST}:${NFO_PORT}/logout"

# logout if NFO >= 2.11.1
curl --insecure -X POST -H 'X-XSRF-TOKEN:QQA=' --cookie 'XSRF-TOKEN=A' -b cookies "https://${NFO_HOST}:${NFO_PORT}/logout"

echo ""

# remove cookies file
rm cookies

Usage:

./nfo_svr_ctrl.sh start|stop|restart
note

This script uses cURL to send the necessary REST API requests to the NFO server. Ensure cURL is installed and the NFO server is accessible.