1.6. Misc API

Miscellaneous utility functions.

Functions

function getDirs()

Get ntopng directory information.

Return

table (installdir, workingdir, scriptdir, httpdocsdir, callbacksdir).

function getInfo()

Get ntopng status information.

Return

ntopng information.

function getUptime()

Get seconds from ntopng startup.

Return

ntopng uptime in seconds.

function getHttpPrefix()

Get the ntopng HTTP prefix.

The HTTP prefix is the initial part of the ntopng URL, which consists of HTTP host, port and optionally a user-defined prefix. Any URL within ntopng should include this prefix.

Return

the HTTP prefix.

function getRandomCSRFValue()

Generate a random value to prevent CSRF and XSRF attacks.

Return

the token value.

Note

Any HTTP POST request must contain a “csrf” field with a token value generated by a call to this function.

function isShutdown()

Check if ntopng is shuttind down.

Return

true if is shuttting down, false otherwise.

function getLocalNetworks()

Get the ntopng local networks list.

Return

table (network_address -> “”).

function addLocalNetwork(string network_cidr)

Add a network to the ntopng local networks list.

Parameters
  • network_cidr: the network to add in CIDR format.

function getNetworkNameById(int network_id)

Retrieves a ntopng local network by its id.

Return

the network address on success, an empty string otherwise.

Parameters
  • network_id: the local network id.

function getHostInformation()

Get information about the currest host.

Return

table (ip, instance_name).

function systemHostStat()

Get ntopng host statistics.

Return

table (cpu_load, cpu_idle, mem_total, mem_free, mem_buffers, mem_cached, mem_shmem. mem_used).

function syslog(string message, int syslog_severity)

Send a message to syslog.

Parameters
  • message: the message to send.

  • syslog_severity: an integer representing the standard syslog severity as per RFC 5424. LOG_INFO is used when severity is not specified.

function setLoggingLevel(string level)

Set ntopng logging level.

Parameters
  • level: one of “trace”, “debug”, “info”, “normal”, “warning”, “error”.

function traceEvent(string msg)

Log a message.

Note

Message will be logged with “normal” level.

Parameters
  • msg: the message to log.

function verboseTrace()

Check if verbose trace is enabled.

Return

true if verborse trace is enabled, false otherwise.

function gettimemsec()

Get the current time in milliseconds.

Return

the current miliiseconds time.

function isLoginDisabled()

Check if the ntopng gui login is disable.

Return

true if login is disabled, false otherwise.

function hasVLANs()

Check if ntopng has seen any VLAN tagged traffic.

Return

true if VLAN traffic has been seen, false otherwise.

function hasGeoIP()

Check if ntopng has Geo IP support available.

Return

true if Geo IP is available, false otherwise.

function isWindows()

Check if the operating system is Windows.

Return

true if Windows, false otherwise.

function msleep(int duration)

Sleep with milliseconds accuracy.

Parameters
  • duration: in milliseconds.

function getMacManufacturer(string mac)

Get the manufacturer name from mac address.

Return

table(short, extended) on success, nil otherwise.

Parameters
  • mac: the MAC address.