FortiMonitor
FortiMonitor is a holistic, SaaS-based digital experience and network performance monitoring solution which combines monitoring, network incident management, automation, and network configuration management into a single source of truth
MR_B
Staff
Staff
Article Id 294911
Description This article describes how to create a custom plugin for FortiMonitor to monitor multiple Redis processes running on different ports on a single server instance.
Scope FortiMonitor.

Solution

  • Review documentation Metrics and Incidents and Custom Plugins for Linux for general information on how custom metrics work.
  • Review documentation Metric Management to change the metadata values for custom metrics if needed.
  • Copy the /usr/lib/fm-agent/plugins/redis.py plugin to /usr/lib/fm-agent/plugins/redis2.py and make the following changes to the redis2.py file.
    • Change the textkey value from textkey=”redis” to textkey=”redis2”
      • Changing this textkey value will create a separate set of metadata in the web interface for redis2
    • Look for the following lines of code in both the execute_query function and the execute_simple_query function that define the hostname and password to be used by the functions.

 

cmd = agent_util.which("redis-cli")

if config.get("hostname"):
cmd += " -h %s" % config["hostname"]
if config.get("password"):
cmd += " -a '%s'" % config["password"]

 

  • Insert the following code just below to define the port for the function.

 

if config.get("port"):
cmd += " -p %s" % config["port"]

 

  • Update the agent config file as mentioned here, however the values now need to be defined for the new plug redis2.
    • In addition to defining the password to be used the port for the plugin must also be defined as in the example below:

 

[redis2]
password = xxxxx
port = xxxxx

 

  • To create plugins for additional Redis processes running on other ports on the same server, copy the process above providing a different name for the Redis plugin (such as redis3.py), change the name of the textkey value, and add a section to the agent config file defining the new password and port to be used by the plugin.