mamonsu
mamonsu — a monitoring agent for collectingPostgres Pro and system metrics
Synopsis
mamonsu
agent
[agent_action
]
mamonsu
bootstrap
-M
[mamonsu_user
-c
|--config
] [-x
|--create-extensions
] [connection_options
]
mamonsu
export
{template
|config
}filename
[export_options
]
mamonsu
report
[report_options
] [connection_options
]
mamonsu
tune
[tuning_options
] [connection_options
]
mamonsu
upload
[upload_options
]
mamonsu
zabbix
dashboard
upload
template_name
mamonsu
zabbix
{template
|host
|hostgroup
}server_action
mamonsu
zabbix
item
{error
|lastvalue
|lastclock
}host_id
mamonsu
zabbix version
mamonsu
[-c
|--config
] [-d
|--daemonize
]
mamonsu
--version
mamonsu
--help
Description
mamonsu is a monitoring agent for collectingPostgres Pro and system metrics that can be visualized on theZabbix server. Unlike the nativeZabbix Agent configured to collectPostgres Pro metrics,mamonsu uses a single database connection, which allows to minimize performance impact on the monitored system.
Themamonsu agent includes the following components:
A supervisor process that monitors database and system activity.
Plugins that specify whichPostgres Pro and system metrics to collect.
Customizable configuration and template files that define which plugins to use and how to visualize the collected data.
mamonsu is an active agent, which means that it sends the data to theZabbix server once it is collected. Pre-configured to monitor multiplePostgres Pro and system metrics out of the box,mamonsu can be extended with your own custom plugins to track other metrics critical for your system.
mamonsu also provides the command-line interface for updating someZabbix server settings, as well as getting an overview of the monitored system configuration and tuningPostgres Pro and system settings on the fly. You can find the list of allmamonsu commands inthe section called “Command-Line Reference”.
Installation and Setup
Important
Before you start installation, attentively readCompatibility Considerations.
To usemamonsu, you must create aZabbix account and set up aZabbix server as explained inZabbix documentation. Naturally, you must also have aPostgres Pro instance up and running if you are going to monitorPostgres Pro metrics. If you are configuring yourPostgres Pro cluster from scratch, seeChapter 16 andSection 17.2 forPostgres Pro installation and setup instructions, respectively.
Note
Whilemamonsu can collectPostgres Pro metrics from a remote cluster, system metrics are only collected locally. If you choose to collectPostgres Pro metrics remotely, make sure to disable collection of system metrics to avoid confusion, as they will be displayed under the same host inZabbix.
A pre-builtmamonsu package is provided together withPostgres Pro Standard, but has a separate installer. Once you have installedmamonsu, complete the following steps to set up metrics collection:
Optionally, bootstrapmamonsu
If you omit this step, metrics can only be collected on behalf of a superuser, which is not recommended.
In this step, the
bootstrap
command sets themamonsu user, createsmamonsu
schema in the specified or implied database, as well as extensions and objects needed for monitoring.bootstrap
has no mandatory options. When run without options, it takes the values needed from the configuration file (/etc/mamonsu/agent.conf
by default). Below is a simple example of bootstrap:In the
[postgres]
section ofagent.conf
, specify connection parameters for thePostgres Pro cluster you are going to monitor. For more details, seeConnection Parameters.Run the following command to bootstrapmamonsu:
mamonsu bootstrap
This command will create the user
mamonsu
with the passwordmamonsu
, create monitoring functions in the database specified inagent.conf
and grant the right to execute them to themamonsu
user.
In the following example,
bootstrap
options are passed explicitly.Create a non-privileged database user formamonsu. For example:
CREATE USER mamonsu_user WITH PASSWORD 'mamonsu_password';GRANT pg_monitor TO mamonsu_user;
Create a database that will be used for connection toPostgres Pro. For example:
CREATE DATABASE mamonsu_database OWNER mamonsu_user;
Run the following command to bootstrapmamonsu:
mamonsu bootstrap -M mamonsu_user -x -c /etc/mamonsu/agent.conf -d mamonsu_database -U postgres --host myhost --port 5432
For details of the options
-M
,-x
and-c
, seebootstrap
. For details of other options, seeConnection Options. This command will create monitoring functions in themamonsu_database
and grant the right to execute them tomamonsu_user
. Thepg_buffercache extension will also be created to ensure collection of metrics on the shared buffer cache, and the path to the configuration file will be changed.
As a result, a superuser connection is no longer required. Note thatmamonsu also creates several tables in the
mamonsu
schema in the specified database. Do not delete these tables as they are required formamonsu to work.Configuremamonsu
Edit the
agent.conf
configuration file, which is located in the/etc/mamonsu/
directory by default.ConfigureZabbix-related settings. The
address
field must point to the runningZabbix server, while theclient
field must provide the name of theZabbix host. You can find the list of hosts available for your account in theZabbix web interface underConfiguration >Hosts.[zabbix]; enabled by defaultenabled =
True
client =zabbix_host_name
address =zabbix_server
By default,mamonsu will collect bothPostgres Pro and system metrics. If required, you can disable metrics collection of either type by setting the
enabled
parameter toFalse
in the[postgres]
or[system]
section of theagent.conf
file, respectively.[system]; enabled by defaultenabled = True
Note
Whilemamonsu can collectPostgres Pro metrics from a remote cluster, system metrics are only collected locally. If you choose to collectPostgres Pro metrics remotely, make sure to disable collection of system metrics to avoid confusion, as they will be displayed under the same host inZabbix.
If you are going to collectPostgres Pro metrics, specify connection parameters for thePostgres Pro cluster you are going to monitor. In the
user
,password
, anddatabase
fields, you must specify themamonsu_user
,mamonsu_password
, and themamonsu_database
used for bootstrap, respectively. If you skipped the bootstrap, specify superuser credentials and the database to connect to.[postgres]; enabled by defaultenabled = Trueuser =
mamonsu_user
database =mamonsu_database
password =mamonsu_password
port = 5432
These are the mainmamonsu settings to get started. You can also fine-tune othermamonsu settings as explained inthe section called “Configuration Parameters”.
Configure how to display metrics on theZabbix server
Generate a template that defines how to visualize the collected metrics on theZabbix server:
mamonsu export template template.xml
mamonsu generates the
template.xml
file in your current directory. By default, the name of the template that will be displayed in theZabbix account isPostgresPro-
, whereOS
OS
is the name of your operating system. To get a template with a different display name, you can run the above command with the--template-name
option.Optionally, specify yourZabbix account settings in the following environment variables on your monitoring system:
Set the
ZABBIX_USER
andZABBIX_PASSWD
variables to the login and password of yourZabbix account, respectively.Set the
ZABBIX_URL
tohttp://zabbix/
If you skip this step, you will have to add the following options to all
mamonsu zabbix
commands that you run:--url=http://zabbix/ --user=
zabbix_login
--password=zabbix_password
Upload
template.xml
to theZabbix server.mamonsu zabbix template export template.xml
Alternatively, you can upload the template through theZabbix web interface: log in to yourZabbix account and selectTemplates >Import.
Link the generated template to the host to be monitored.
In theZabbix web interface, select your host, go toTemplates >Add, select your template, and clickUpdate.
Tip
If you would like to link a template with a newZabbix host, you can do it from the command line using
mamonsu zabbix
commands. Seethe section called “ManagingZabbix Server Settings from the Command Line” for details.
When the setup is complete, startmamonsu. For example, on Linux systems, you can startmamonsu as a service with the following command:
service mamonsu start
mamonsu picks up all the parameters from themamonsu configuration file and starts monitoring your system.
Command-Line Reference
agent
Syntax:
mamonsu agent { metric-list | metric-getmetric_name
| version }
Provide information on the collected metrics from the command line. You can specify one of the following parameters:
metric-list
Show the list of metrics thatmamonsu is collecting. The output of this command provides the item key of each metric, its latest value, and the time when this value was received.
metric-get
metric_name
Check the latest value for the specified metric. You can get the list of available metrics using the
metric-list
option.version
Displaymamonsu version.
bootstrap
Syntax:
mamonsu bootstrap -Mmamonsu_user
[-c[config_file
] | --config[=config_file
]] [-x | --create-extensions] [connection_options
]
Bootstrapmamonsu. This command can take the following options:
-M
Specify a non-privileged user that will own allmamonsu processes.
-c
config_file
--config=
config_file
Specify the
agent.conf
file where the[postgres]
section contains the database name to be used if--dbname
is not specified through
.connection_options
Default:
/etc/mamonsu/agent.conf
-x
--create-extensions
Create auxiliary extensions. Thepg_buffercache extension will be created, which is no longer created by default. ForPostgres Pro 12 or higher, the
bootstrap
command will also create functions to work with thepgpro_stats extension and grant the right to execute them to the-x
mamonsu
user.connection_options
Provide optional
command-line connection parameters
.
export
Syntax:
mamonsu export configfilename
.conf [--add-plugins=plugin_directory
]mamonsu export templatefilename
.xml [--add-plugins=plugin_directory
] [--template-name=template_name
] [--application=application_name
] [--old-zabbix]
Generate a template or configuration file for metrics collection. The optional parameters to customize metrics collection are as follows:
--add-plugins=
plugin_directory
Collect metrics that are defined in custom plugins located in the specified
plugin_directory
. If you are going to use custom plugins, you must provide this option when generating both the configuration file and the template.--template-name=
template_name
Specify the name of the template that will be displayed on theZabbix server.
Default:
PostgresPro-
, whereOS
OS
is the name of your operating system--application=
application_name
Specify an identifier under which the collected metrics will be displayed on theZabbix server.
Default:
App-PostgresPro-
, whereOS
OS
is the name of your operating system--old-zabbix
Export a template forZabbix server version 4.2 or lower. By default, the template is generated in a format compatible with Zabbix 4.4 or higher.
export zabbix-parameters
Syntax:
mamonsu export zabbix-parametersfilename
.conf [--add-plugins=plugin_directory
] [--plugin-type={pg | sys | all}] [--pg-version=version
] [--config=config_file
]
Export metrics configuration for use with the nativeZabbix agent. The optional parameters to customize metrics collection are as follows:
--add-plugins=
plugin_directory
Collect metrics that are defined in custom plugins located in the specified
plugin_directory
. If you are going to use custom plugins, you must provide this option when generating both the configuration file and the template.--plugin-type={pg | sys | all}
Specify the type of metrics to collect:
pg
forPostgres Pro metrics.sys
for system metrics.all
for bothPostgres Pro and system metrics.
Default:
all
--pg-version=
version
Specify the major version of the server for which to configure metrics collection.
mamonsu
can collect metrics for all supportedPostgres Pro versions, as well asPostgreSQL versions starting from 9.5.Default:
10
--config=
config_file
Specify the
agent.conf
file to be used as the source for metrics definitions.Default:
/etc/mamonsu/agent.conf
export zabbix-template
Syntax:
mamonsu export zabbix-templatefilename
.conf [--add-plugins=plugin_directory
] [--plugin-type={pg | sys | all}] [--template-name=template_name
] [--application=application_name
] [--config=config_file
] [--old-zabbix]
Export a template for use with the nativeZabbix agent. The optional parameters to customize metrics collection are as follows:
--add-plugins=
plugin_directory
Collect metrics that are defined in custom plugins located in the specified
plugin_directory
. If you are going to use custom plugins, you must provide this option when generating both the configuration file and the template.--plugin-type={pg | sys | all}
Specify the type of metrics to collect:
pg
configuresPostgres Pro metrics.sys
configures system metrics.all
configures bothPostgres Pro and system metrics.
Default:
all
--template-name=
template_name
Specify the name of the template that will be displayed on theZabbix server.
Default:
PostgresPro-
, whereOS
OS
is the name of your operating system--application=
application_name
Specify an identifier under which the collected metrics will be displayed on theZabbix server.
Default:
App-PostgresPro-
, whereOS
OS
is the name of your operating system--config=
config_file
Specify the
agent.conf
file to be used as the source for metrics definitions.Default:
/etc/mamonsu/agent.conf
--old-zabbix
Export a template forZabbix server version 4.2 or lower. By default, the template is generated in a format compatible with Zabbix 4.4 or higher.
report
Syntax:
mamonsu report [--run-system=Boolean
] [--run-postgres=Boolean
] [--print-report=Boolean
] [--report-path=report_file
] [--disable-sudo] [connection_options
]
Generate a detailed report on the hardware, operating system, memory usage and other parameters of the monitored system, as well asPostgres Pro configuration.
The following optional parameters customize the report:
--run-system=
Boolean
Include system information into the generated report.
Default:
True
--run-postgres=
Boolean
Include information onPostgres Pro into the generated report.
Default:
True
--print-report=
Boolean
Print the report tostdout.
Default:
True
--report-path=
report_file
Save the report into the specified file.
Default:
/tmp/report.txt
--disable-sudo
Do not report data that can only be received with superuser rights. This option is only available for Linux systems.
connection_options
Provide optional
command-line connection parameters
.
tune
Syntax:
mamonsu tune [--dry-run] [--disable-sudo] [--log-level {INFO|DEBUG|WARN}] [--dont-tune-pgbadger] [--dont-reload-postgresql] [connection_options
]
OptimizePostgres Pro and system configuration based on the collected statistics. You can use the following options:
--dry-run
Display the settings to be tuned without changing the actual system andPostgres Pro configuration.
--disable-sudo
Do not tune the settings that can only be changed by a superuser. This option is only available for Linux systems.
--dont-tune-pgbadger
Do not tunepgbadger parameters.
--log-level { INFO | DEBUG | WARN}
Change the logging level.
Default:
INFO
--dont-reload-postgresql
Forbidmamonsu to run the
pg_reload_conf()
function. If you specify this option, the modified settings that require reloadingPostgres Pro configuration do not take effect immediately.connection_options
Provide optional
command-line connection parameters
.
upload
Syntax:
mamonsu upload [--zabbix-file=metrics_file
] [--zabbix-address=zabbix_address
] [--zabbix-port=port_number
] [--zabbix-client=zabbix_host_name
] [--zabbix-log-level={INFO|DEBUG|WARN}]
Upload metrics data previously saved into a file onto a Zabbix server for visualization. For details on how to save metrics into a file, seethe section called “Logging Parameters”.
This command can take the following options:
--zabbix-address=
zabbix_address
The address of theZabbix server.
Default:
localhost
--zabbix-port=
port_number
The port of theZabbix server.
Default: 10051
--zabbix-file=
metrics_file
A text file that stores the collected metrics data to be visualized, such as
localhost.log
.--zabbix-client=
zabbix_host_name
The name of theZabbix host.
Default:
localhost
--zabbix-log-level={INFO|DEBUG|WARN}
Change the logging level.
Default:
INFO
zabbix dashboard upload
Syntax:
mamonsu dashboard uploadtemplate_name
Upload aZabbix dashboard with themamonsu metrics to a template on theZabbix server version 6.0 or higher.
zabbix item
Syntax:
mamonsu zabbix item {error | lastvalue | lastclock }host_name
View the specified property of the latest metrics data received byZabbix for the specified host.
zabbix version
Syntax:
mamonsu zabbix version
Get the version of theZabbix server thatmamonsu is connected to.
zabbix host
Syntax:
mamonsu zabbix host listmamonsu zabbix host showhost_name
mamonsu zabbix host idhost_name
mamonsu zabbix host deletehost_id
mamonsu zabbix host createhost_name
hostgroup_id
template_id
mamonsu_address
mamonsu zabbix host info {templates | hostgroups | graphs | items}host_id
ManageZabbix hosts using one of the actions described inthe section called “Zabbix Server Actions”.
zabbix hostgroup
Syntax:
mamonsu zabbix hostgroup listmamonsu zabbix hostgroup showhostgroup_name
mamonsu zabbix hostgroup idhostgroup_name
mamonsu zabbix hostgroup deletehostgroup_id
mamonsu zabbix hostgroup createhostgroup_name
ManageZabbix host groups using one of the actions described inthe section called “Zabbix Server Actions”.
zabbix template
Syntax:
mamonsu zabbix template listmamonsu zabbix template showtemplate_name
mamonsu zabbix template idtemplate_name
mamonsu zabbix template deletetemplate_id
mamonsu zabbix template exportfile
ManageZabbix templates using one of the actions described inthe section called “Zabbix Server Actions”.
[--config] [--daemonize]
Syntax:
mamonsu [-cconfig_file
| --config=config_file
] [-d | --daemonize]
Start working as a monitoring agent in the foreground or in the background using configuration parameters loaded from the configuration file. If the specified or default configuration file does not exist, exit with an error. Useful for debugging. You can specify the following options:
-c
config_file
--config=
config_file
Specify the
agent.conf
file where to load the configuration parameters from.Default:
/etc/mamonsu/agent.conf
-d
--daemonize
Run in the background. Without it,mamonsu will run in the foreground.
--version
Syntax:
mamonsu --version
Displaymamonsu
version.
--help
Syntax:
mamonsu --help
Displaymamonsu
command-line help.
Connection Options
connection_options
provide command-line connection parameters for the targetPostgres Pro cluster.connection_options
can be--host
,--port
,--dbname
(-d
),--username
(-U
), and--password
(-W
). The--dbname
option should specify themamonsu_database
created for monitoring purposes. Note that the--username
(-U
) option must specify a superuser that can access the cluster.
If you omitconnection_options
,mamonsu checks the configuration file for the needed settings.
Zabbix Server Actions
Usingmamonsu, you can control some of theZabbix server functionality from the command line. Specifically, you can create or deleteZabbix hosts and host groups, as well as generate, import, and deleteZabbix templates using one of the following commands. Theobject_name
to use must correspond to the type of theZabbix object specified in the command:template
,host
, orhostgroup
.
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 the ID of the specified object, which is assigned automatically by theZabbix server.
delete
object_id
Delete the object with the specified ID.
create
hostgroup_name
create
host_name
hostgroup_id
template_id
mamonsu_address
Create a new host or a host group.
export
template_name
Generate aZabbix template.
info {templates | hostgroups | graphs | items}
host_id
Display detailed information about the templates, host groups, graphs, and metrics available on the host with the specified ID.
Configuration Parameters
Theagent.conf
configuration file is located in the/etc/mamonsu
directory by default. It provides several groups of parameters that control which metrics to collect and how to log the collected data:
All parameters must be specified in the
format.parameter
=value
Connection Parameters
[postgres]
The[postgres]
section controlsPostgres Pro metrics collection and can contain the following parameters:
enabled
Enables/disablesPostgres Pro metrics collection if set to
True
orFalse
, respectively.Default:
True
user
The user on behalf of which the cluster will be monitored. It must be themamonsu user set in bootstrap, or a superuser if
bootstrap
was not run.Default:
postgres
password
The password for the specified user.
database
The database to connect to for metrics collection.
Default:
postgres
host
The server address to connect to.
Default:
localhost
port
The port to connect to.
Default: 5432
application_name
Application name that identifiesmamonsu connected to thePostgres Pro cluster.
Default:
mamonsu
query_timeout
statement_timeout for themamonsu session, in seconds. If aPostgres Pro metric query does not complete within this time interval, it gets terminated.
Default: 10
[system]
The[system]
section controls system metrics collection and can contain the following parameters:
enabled
Enables/disables system metrics collection if set to
True
orFalse
, respectively.Default:
True
[zabbix]
The[zabbix]
section provides connection settings for theZabbix server and can contain the following parameters:
enabled
Enables/disables sending the collected metrics data to theZabbix server if set to
True
orFalse
, respectively.Default:
True
client
The name of theZabbix host.
address
The address of theZabbix server.
Default: 127.0.0.1
port
The port of theZabbix server.
Default: 10051
timeout
Maximum time to wait while connecting to theZabbix server, in seconds.
Default: 15
[agent]
The[agent]
section specifies the location ofmamonsu and whether it is allowed to access metrics from the command line:
enabled
Enables/disables metrics collection from the command line using the
agent
command.Default:
True
host
The address of the system on whichmamonsu is running.
Default: 127.0.0.1
port
The port on whichmamonsu is running.
Default: 10052
[sender]
The[sender]
section controls the queue size of the data to be sent to theZabbix server:
queue
The maximum number of collected metric values that can be accumulated locally beforemamonsu sends them to theZabbix server. Once the accumulated data is sent, the queue is cleared.
Default: 2048
Logging Parameters
[metric_log]
The[metric_log]
section enables storing the collected metrics data in text files locally. This section can contain the following parameters:
enabled
Enables/disables storing the collected metrics data in a text file. If this option is set to
True
,mamonsu creates thelocalhost.log
file for storing metric values.Default:
False
directory
Specifies the directory where log files with metrics data will be stored.
Default:
/var/log/mamonsu
max_size_mb
The maximum size of a log file, in MB. When the specified size is reached, it is renamed to
localhost.log.archive
, and an emptylocalhost.log
file is created.Default: 1024
[log]
The[log]
section specifies logging settings formamonsu and can contain the following parameters:
file
Specifies the log filename, which can be preceded by the full path.
level
Specifies the debug level. This option can take
DEBUG
,ERROR
, orINFO
values.Default:
INFO
format
The format of the logged data.
Default:
[%(levelname)s] %(asctime)s - %(name)s - %(message)s
where
levelname
is the debug level,asctime
returns the current time,name
specifies the plugin that emitted this log entry orroot
otherwise, andmessage
provides the actual log message.
Plugin Parameters
[plugins]
The[plugins]
section specifies custom plugins to be added for metrics collection and can contain the following parameters:
enabled
Enables/disables using custom plugins for metrics collection if set to
True
orFalse
, respectively.Default:
False
directory
Specifies the directory that contains custom plugins for metrics collection. Setting this parameter to
None
forbids using custom plugins.Default:
/etc/mamonsu/plugins
If you need to configure any of the plugins you add tomamonsu after installation, you have to add this plugin section to theagent.conf
file.
The syntax of this section should follow the syntax used with the examples shown below inthe section called “Individual Plugin Sections”.
Individual Plugin Sections
All built-in plugins are installed along withmamonsu. To configure a built-in plugin you should find a corresponding section below theIndividual Plugin Sections
heading and edit its parameter values.
To disable any plugin you should set theenabled
parameter toFalse
and to enable it — set it toTrue
. These values are case sensitive.
The example below shows individual plugin sections corresponding to thepreparedtransaction
and thepgprobackup
built-in plugins:
[preparedtransaction]max_prepared_transaction_time = 60interval = 60[pgprobackup]enabled = falseinterval = 300backup_dirs = /backup_dir1,/backup_dir2pg_probackup_path = /usr/bin/pg_probackup-11
[preparedtransaction]
This plugin gets age in seconds of the oldest prepared transaction and number of all transactions prepared for a two-phase commit. For additional information refer toPREPARE TRANSACTION andSection 50.77.
Themax_prepared_transaction_time
parameter specifies the threshold in seconds for the age of the prepared transaction.
Theinterval
parameter allows you to change the metrics collection interval.
The plugin collects two metrics:pgsql.prepared.count
(number of prepared transactions) andpgsql.prepared.oldest
(oldest prepared transaction age in seconds).
Ifpgsql.prepared.oldest
value exceeds the threshold specified by themax_prepared_transaction_time
parameter, a trigger with the following message is fired: "PostgreSQL prepared transaction is too old on {host}".
[pgprobackup]
This plugin usespg_probackup to track its backups' state and gets size of backup directories which store all backup files.
Please note that this plugin counts the total size of all files in the target directory. Make sure that extraneous files are not stored in this directory.
Thebackup_dirs
parameter specifies a comma-separated list of paths to directories for which metrics should be collected.
Thepg_probackup_path
parameter specifies the path topg_probackup.
Theinterval
parameter allows you to change the metrics collection interval.
By default this plugin is disabled. To enable it set theenabled
parameter toTrue
.
This plugin collects two metrics:pg_probackup.dir.size[#backup_directory]
(the size of the target directory) andpg_probackup.dir.error[#backup_directory]
(backup errors) for each specifiedbackup_directory
.
If any generated backup has bad status, likeERROR
,CORRUPT
,ORPHAN
, a trigger is fired.
Usage
Collecting and Viewing Metrics Data
Once started,mamonsu begins collecting system andPostgres Pro metrics. Theagent
command enables you to get an overview of the collected metrics from the command line in real time.
To view the list of available metrics, use theagent metric-list
command:
mamonsu agent metric-list
The output of this command provides the item key of each metric, its latest value, and the time when this value was received. For example:
system.memory[active] 7921004544 1564570818system.memory[swap_cache] 868352 1564570818pgsql.connections[idle] 6.0 1564570818pgsql.archive_command[failed_trying_to_archive] 0 1564570818
To view the current value for a specific metric, you can use theagent metric-get
command:
mamonsu agent metric-getmetric_name
wheremetric_name
is the item key of the metric to monitor, as returned by themetric-list
command. For example,pgsql.connections[idle]
.
You can view graphs for the collected metrics in theZabbix web interface under theGraphs menu. For details on working withZabbix, see its official documentation athttps://www.zabbix.com/documentation/current/manual.
If you have chosen to save all the collected metrics data into a file, as explained inthe section called “Logging Parameters”, you can later upload these metrics onto a Zabbix server for visualization using theupload command.
Adding Custom Plugins
You can extendmamonsu with your own custom plugins, as follows:
Save all custom plugins in a single directory, such as
/etc/mamonsu/plugins
.Make sure this directory is specified in your configuration file under the
[plugins]
section:[plugins]directory = /etc/mamonsu/plugins
Generate a newZabbix template to include custom plugins:
mamonsu export template template.xml --add-plugins=/etc/mamonsu/plugins
Upload the generated
template.xml
to theZabbix server as explained inthe section called “Installation and Setup”.
TuningPostgres Pro and System Configuration
Based on the collected metrics data,mamonsu can tune yourPostgres Pro and system configuration for optimal performance.
You can get detailed information about the hardware, operating system, memory usage and other parameters of the monitored system, as well asPostgres Pro configuration, as follows:
mamonsu report
To view the suggested optimizations without applying them, run thetune
command with the--dry-run
option:
mamonsu tune --dry-run
To apply all the suggested changes, run thetune
command without any parameters:
mamonsu tune
You can exclude some settings from the report or disable some of the optimizations by passing optional parameters. Seethe section called “Command-Line Reference” for the full list of parameters available forreport
andtune
commands.
ManagingZabbix Server Settings from the Command Line
mamonsu enables you to work with theZabbix server from the command line. You can upload template files toZabbix, create and deleteZabbix hosts and host groups, link templates with hosts and check the latest metric values.
To set up yourZabbix host from scratch, you can follow these steps:
Optionally, specify yourZabbix account settings in the following environment variables on your monitoring system:
Set the
ZABBIX_USER
andZABBIX_PASSWD
variables to the login and password of yourZabbix account, respectively.Set the
ZABBIX_URL
tohttp://zabbix/
If you skip this step, you will have to add the following options to all
mamonsu zabbix
commands that you run:--url=http://zabbix/ --user=
zabbix_login
--password=zabbix_password
Generate a new template file and upload it to theZabbix server:
mamonsu export template template.xmlmamonsu zabbix template export template.xml
Create a new host group:
mamonsu zabbix hostgroup create
hostgroup_name
Check the IDs for this host group and the uploaded template, which are assigned automatically by theZabbix server:
mamonsu zabbix hostgroup id
hostgroup_name
mamonsu zabbix template idtemplate_name
Create a host associated with this group and link it with the uploaded template using a single command:
mamonsu zabbix host create
host_name
hostgroup_id
template_id
mamonsu_address
where
host_name
is the name of the host,hostgroup_id
andtemplate_id
are the unique IDs returned in the previous step, andmamonsu_address
is the IP address of the system on whichmamonsu runs.
Once yourZabbix host is configured, complete the setup of your monitoring system as explained inthe section called “Installation and Setup”.
Exporting Metrics for NativeZabbix Agent
Usingmamonsu, you can convert system andPostgres Pro metrics definitions to the format supported by the nativeZabbix agent.
This feature currently has the following limitations:
You cannot export metrics if you run
mamonsu
on Windows systems.Metrics definitions for
pg_wait_sampling
and CFS features available inPostgres Pro Enterprise are not converted.
Important
To work withZabbix proxy, you must export settings to the format supported by the nativeZabbix agent.
To collect metrics provided bymamonsu using the nativeZabbix agent, do the following:
Generate a configuration file that is compatible with the nativeZabbix agent and place it under
/etc/zabbix/zabbix_agent.d/
. You can prepend the filename with the required path:mamonsu export zabbix-parameters /etc/zabbix/zabbix_agent.d/zabbix_agent.conf
For all possible options of the
export zabbix-parameters
command, seethe section called “Command-Line Reference”.Generate a template for the nativeZabbix agent:
mamonsu export zabbix-template template.xml
For all possible options of the
export zabbix-template
command, seethe section called “Command-Line Reference”.Upload the generated template to theZabbix server, as explained inthe section called “Installation and Setup”.
If you are going to collectPostgres Pro metrics, change the following macros in the template after the upload:
For
{$PG_CONNINFO}
, provide connection parameters for thePostgres Pro server to be monitored.For
{$PG_PATH}
, specifypsql installation directory.
Compatibility Considerations
If you want to upgrademamonsu to a version that is not compatible with the previous one, what you must do to continue using the application depends on whether you need to retain the metrics data collected.
If you need to retain the collected data, do the following:
Install the new version ofmamonsu.
Generate a new template for theZabbix server.
If you performed a bootstrap using the previous version ofmamonsu, run the
bootstrap
command again.Upload the new template to theZabbix server.
Rename the host for which you want to retain the collected data and leave the old template linked to that host.
Create a new host for the same system and link the new template to it.
Restartmamonsu. It will collect data for the new host. The old host will no longer be used, but the data collected will be available.
If you do not need to retain the collected data, do the following:
Install the new version ofmamonsu.
Generate a new template for theZabbix server.
If you performed a bootstrap using the previous version ofmamonsu, run the
bootstrap
command again.Upload the new template to theZabbix server.
In the settings of theZabbix host, link the new template to the host instead of the old one.
Restartmamonsu. It will start collecting data. All the data collected earlier will be lost.