mamonsu

mamonsu — a monitoring agent for collecting Postgres Pro and system metrics.

Synopsis

mamonsu { report | tune }

mamonsu agent action

mamonsu zabbix {template | host | hostgroup} zabbix-action

Description

mamonsu is an active monitoring agent for Postgres Pro. Based on zabbix, mamonsu provides an extensible cross-platform solution that can collect and visualize multiple Postgres Pro and system metrics.

The mamonsu agent includes the following components:

  • A supervisor process that monitors all the running threads.

  • Plugins that specify which metrics to collect, and how to visualize the collected data.

To ensure a stable connection to the monitored system, mamonsu plugins use a Postgres Pro connection pooler. If required, you can add your own custom plugins to monitor specific metrics critical for your system.

Installation and Setup

To use mamonsu, you must have a zabbix account and a zabbix server set up.

A pre-built mamonsu package is provided together with Postgres Pro Standard, but has a separate installer. Once you have installed both Postgres Pro Standard and mamonsu, complete the following steps to set up metrics collection:

  1. If you are starting from scratch, configure your Postgres Pro instance and initialize a new database. For details, see Section 17.2.

  2. Bootstrap mamonsu. You must specify the IP address of the host you are going to monitor and the first database to connect to, as well as provide the username and password of the Postgres Pro user for mamonsu to connect as. You can omit the -W option if the password is not required.

    mamonsu bootstrap --host host_ip --dbname database_name --username username -W password
    

    As a result, mamonsu creates several tables with the mamonsu prefix in the specified database. Do not delete these tables as they are required for mamonsu to work.

  3. mamonsu enables you to control some of the zabbix server functionality from the command line. You can create and delete zabbix hosts and host groups, as well as create, delete, or import zabbix templates. If you are going run zabbix-related commands, configure the following environment variables for your zabbix server:

    • Set the ZABBIX_USER and ZABBIX_PASSWD variables to the login and password of your zabbix account, respectively.

    • Set the ZABBIX_URL to http://zabbix/

    If you configure these variables, you can omit the following options in the subsequent commands:

    --url=http://zabbix/ --user=zabbix_login --password=zabbix_password
    
  4. If you do not have a zabbix host yet, create a new zabbix host group and host to use for metrics collection:

    mamonsu zabbix hostgroup create hostgroup_id
    mamonsu zabbix host create host_name hostgroup_id template_id IP_address
          
  5. Edit the agent.conf configuration file pre-installed with mamonsu. By default, agent.conf is located in the mamonsu installation directory.

    • Configure zabbix-related settings. You must set address to the zabbix server address and specify the name of the zabbix host that will receive the collected metrics. You can find the hosts available for your account in the zabbix web interface under Configuration > Hosts.

      [zabbix]
      ; enabled by default
      enabled = True
      client = zabbix_host_name
      address = zabbix_server_ip
      
    • Specify the Postgres Pro user and the database to connect to. In the example below, we connect to a postgres database as a postgres user. If the password is not required, set the password parameter to None. mamonsu will start collecting metrics starting from this database, and will try to connect to other databases available in your system. By default, mamonsu collects metrics data each 10ms. You can change the query_timeout parameter to modify this behavior. If you are using a custom port for Postgres Pro, make sure to change the port parameter accordingly.

      [postgres]
      ; enabled by default
      enabled = True
      user = postgres
      database = postgres
      ; empty password
      password = None
      port = 5432
      query_timeout = 10
      
    • By default, mamonsu will collect both Postgres Pro and system metrics. If required, you can disable metrics collection of either type by setting the enabled parameter to False in the corresponding section of the agent.conf file.

      [system]
      ; enabled by default
      enabled = True
      
  6. Export a template for zabbix:

    mamonsu export template template.xml
    

    mamonsu generates the template.xml file in your current directory.

  7. Import the template.xml into zabbix:

    mamonsu zabbix template export template.xml --url=http://zabbix/ --user=zabbix_login --password=zabbix_password
    

    To upload the template through the zabbix web interface, you can go to Templates > Import in your zabbix account.

  8. Add the template to your monitoring host. In the web interface, select your host, go to Templates, click Add, select the PostgresPro-Linux template, and click Update.

When the setup is complete, start mamonsu:

service mamonsu start

mamonsu picks up all the parameters from the configuration file and starts monitoring your system.

Options

mamonsu enables you to manage metrics collection and control some of the zabbix options from the command line. The mamonsu can take the following options.

report

Display detailed information about the used hardware and Postgres Pro settings.

tune

Optimize system configuration based on the collected information about the used hardware and Postgres Pro settings.

agent

mamonsu agent command provides access to the available metrics from the command line. You can specify one of the following actions:

version

Display mamonsu version.

metric-list

Show the list of available metrics.

metric-get metric_name

Specify the metric to monitor. You can get the list of available metrics using the metric-list option.

zabbix template

Manage the zabbix template using one of the actions described in the section called “zabbix Actions”.

zabbix host

Manage the zabbix host using one of the actions described in the section called “zabbix Actions”.

zabbix hostgroup

Manage the zabbix host group using one of the actions described in the section called “zabbix Actions”.

zabbix Actions

Using mamonsu you can control some of the zabbix server functionality from the command line. Specifically, you can create or delete zabbix hosts and host groups, as well as generate, import, and delete zabbix templates using one of the following commands. The object_name to use must correspond to the type of the zabbix object specified in the command: template, host, or hostgroup.

list

Display the list of available templates, hosts, or host groups.

show object_name

Display the details about the specified template, host, or host group.

id object_name

Show ID of the specified object.

delete object_id

Delete the specified object.

create hostgroup_name
create host_name hostgroup_id template_id ip_address

Create a new host or a host group.

export template_name

Generate a zabbix template.

info

Display detailed information about the specified host using one of the following options:

templates host_id

Display the list of templates available for the specified host.

hostgroups host_id

Display the host groups to which the specified host belongs.

graphs host_id

Display the graphs available for the specified host.

Usage

Collecting Metrics Data

To view the list of available metrics, run the following command:

mamonsu agent metric-list

To monitor a specific metric, run:

mamonsu agent metric-get metric_name

where metric_name is the name of the metric to monitor. You can view graphs for the collected metrics in the zabbix web interface under the Graphs menu.

To create a report about the used hardware and Postgres Pro settings, run:

mamonsu report

Based on the hardware information, mamonsu enables you to make a generic optimization for your system and the Postgres Pro instance:

mamonsu tune

Adding Custom Plugins

To add your own custom plugin to mamonsu, follow these steps:

  1. Make sure a plugin directory is defined in your configuration file, and put your plugin files into this directory.

    [plugins]
    directory = /etc/mamonsu/plugins
    
  2. Re-export the zabbix template:

    mamonsu -c agent.conf -e template.xml
    
  3. Upload the new template.xml to the zabbix server.