/usr/share/doc/ntopng/README.nagios is in ntopng-data 3.2+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | ntopng can now be used by nagios as a source of data. For instance you can query ntopng via the HTTP interface and extract JSON-based traffic information
Now you can create nagios plugins that can query ntopng periodically and implement alerting on traffic.
Below you can find an example of what a ntop-nagios plugin looks like
================================================================================
#!/bin/bash
################################################################################
# Nagios plugin to get info about a host from a terminal running ntopng #
# ntopng (C) 2015 #
################################################################################
VERSION="0.1"
AUTHOR="ntopng (C) 2015"
# Exit codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
function print_help {
# Print detailed help information
echo "$AUTHOR - Get host info from ntopng instance"
/bin/cat <<__EOT
Options:
-h
-?
Print detailed help screen
-n HNAME
Name of the host ntopng is running on.
-i INTEGER
Interface to check the host on.
-H HNAME
Name of host to get info for.
-p INTEGER
Port ntopng is listening on the host specified with -h.
-u USER
ntopng user for Nagios checks.
-c PASSWD
Password for ntopng user for Nagios checks.
__EOT
}
NTOPNG_HOST=
NTOPNG_PORT=
NTOPNG_USER=
NTOPNG_PASS=
CHECK_HOST=
CHECK_INTF=
# Parse command line options
while [ "$1" ]; do
case "$1" in
-h | --help)
print_help
exit $STATE_OK
;;
-H | --host)
CHECK_HOST=$2
shift 2
;;
-i | --interface)
CHECK_INTF=$2
shift 2
;;
-n | --ntopng)
NTOPNG_HOST=$2
shift 2
;;
-p | --port)
NTOPNG_PORT=$2
shift 2
;;
-u | --user)
NTOPNG_USER=$2
shift 2
;;
-c | --password)
NTOPNG_PASS=$2
shift 2
;;
-?)
print_help
exit $STATE_OK
;;
*)
echo "$0: Invalid option '$1'"
print_help
exit $STATE_UNKNOWN
;;
esac
done
if [[ "$NTOPNG_HOST" == "" ]] || [[ "$NTOPNG_PORT" == "" ]] ||
[[ "$NTOPNG_USER" == "" ]] || [[ "$NTOPNG_PASS" == "" ]] ||
[[ "$CHECK_HOST" == "" ]] || [[ "$CHECK_INTF" == "" ]]; then
echo "$0: all parameters are compulsory"
print_help
exit $STATE_WARNING
fi
RESULT_JSON=`curl -s -u ${NTOPNG_USER}:${NTOPNG_PASS} 'http://'${NTOPNG_HOST}':'${NTOPNG_PORT}'/lua/host_get_json.lua?ifname='${CHECK_INTF}'&host='${CHECK_HOST}`
# Handle result and return appropriate status
echo $RESULT_JSON
if [[ "$RESULT_JSON" == "" ]]; then
exit $STATE_CRITICAL
fi
#wget --auth-no-challenge -mk --user $NTOPNG_USER --password $NTOPNG_PASS 'http://'${NTOPNG_HOST}':'${NTOPNG_PORT}'/lua/host_get_json.lua?ifname='${CHECK_INTF}'&host='${CHECK_HOST}
exit $STATE_OK
================================================================================
|