• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..23-Dec-2021-

testdata/H23-Dec-2021-126

README.mdH A D23-Dec-20216 KiB144104

config.goH A D23-Dec-20211.9 KiB5822

conn.goH A D23-Dec-20217.2 KiB294200

handler_collection_stats.goH A D23-Dec-20211.5 KiB5527

handler_collection_stats_test.goH A D23-Dec-20211.7 KiB8572

handler_collections_discovery.goH A D23-Dec-20211.7 KiB7036

handler_collections_discovery_test.goH A D23-Dec-20211.7 KiB7971

handler_collections_usage.goH A D23-Dec-20211.4 KiB5627

handler_collections_usage_test.goH A D23-Dec-20211.3 KiB7160

handler_config_discovery.goH A D23-Dec-20212.3 KiB9761

handler_connPool_stats.goH A D23-Dec-20211.5 KiB5527

handler_connPool_stats_test.goH A D23-Dec-20211.8 KiB9181

handler_database_stats.goH A D23-Dec-20211.4 KiB5527

handler_database_stats_test.goH A D23-Dec-20211.8 KiB9281

handler_databases_discovery.goH A D23-Dec-20211.4 KiB5625

handler_databases_discovery_test.goH A D23-Dec-20211.2 KiB6153

handler_jumbo_chunks.goH A D23-Dec-20211.2 KiB3712

handler_oplog_stats.goH A D23-Dec-20212.7 KiB9351

handler_oplog_stats_test.goH A D23-Dec-20212 KiB9681

handler_ping.goH A D23-Dec-20211.1 KiB3611

handler_replset_config.goH A D23-Dec-20211.5 KiB5931

handler_replset_config_test.goH A D23-Dec-20211.3 KiB7260

handler_replset_status.goH A D23-Dec-20213.6 KiB163110

handler_server_status.goH A D23-Dec-20211.5 KiB5931

handler_server_status_test.goH A D23-Dec-20211.3 KiB7260

handler_shards_discovery.goH A D23-Dec-20212.2 KiB8853

metrics.goH A D23-Dec-20215.6 KiB160102

mockconn.goH A D23-Dec-20213.4 KiB191148

mongodb.goH A D23-Dec-20212.8 KiB11566

README.md

1# MongoDB plugin
2Provides native Zabbix solution for monitoring MongoDB servers and clusters (document-based, distributed database).
3It can monitor several MongoDB instances simultaneously, remotes or locals to the Zabbix Agent.
4The plugin keeps connections in the opened state to reduce network
5congestion, latency, CPU and memory usage. Best for use in conjunction with the official
6[MongoDB template.](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/mongodb)
7You can extend it or create your template for your specific needs.
8
9## Requirements
10* Zabbix Agent 2
11* Go >= 1.13 (required only to build from the source)
12
13## Supported versions
14* MongoDB, versions 4.4, 4.2, 4.0 and 3.6
15
16## Installation
17Depending on your configuration you need to create a local read-only user in the admin database:
18- *STANDALONE*: for each single MongoDB node.
19- *REPLICASET*: create the user on the primary node of the replica set.
20- *SHARDING*: for each shard in your cluster (just create the user on the primary node of the replica set).
21Also, create the same user on a mongos router. It will automatically spread to config servers.
22
23```javascript
24use admin
25
26db.auth("admin", "<ADMIN_PASSWORD>")
27
28db.createUser({
29  "user": "zabbix",
30  "pwd": "<PASSWORD>",
31  "roles": [
32    { role: "readAnyDatabase", db: "admin" },
33    { role: "clusterMonitor", db: "admin" },
34  ]
35})
36```
37
38## Configuration
39The Zabbix Agent's configuration file is used to configure plugins.
40
41**Plugins.Mongo.KeepAlive** — Sets a time for waiting before unused connections will be closed.
42*Default value:* 300 sec.
43*Limits:* 60-900
44
45**Plugins.Mongo.Timeout** — The amount of time to wait for a server to respond when first connecting and on follow up
46operations in the session.
47*Default value:* equals the global Timeout configuration parameter.
48*Limits:* 1-30
49
50### Configuring connection
51A connection can be configured using either keys' parameters or named sessions.
52
53*Notes*:
54* It is not possible to mix configuration using named sessions and keys' parameters simultaneously.
55* You can leave any connection parameter empty, a default hard-coded value will be used in the such case:
56  localhost:27017 without authentication.
57* Embedded URI credentials (userinfo) are forbidden and will be ignored. So, you can't pass the credentials by this:
58
59      mongodb.ping[tcp://user:password@127.0.0.1] — WRONG
60
61  The correct way is:
62
63      mongodb.ping[tcp://127.0.0.1,user,password]
64
65* Currently, only TCP connections supported.
66
67Examples of valid URIs:
68    - tcp://127.0.0.1:27017
69    - tcp://localhost
70    - localhost
71
72#### Using keys' parameters
73The common parameters for all keys are: [ConnString][,User][,Password]
74Where ConnString can be either a URI or session name.
75ConnString will be treated as a URI if no session with the given name found.
76If you use ConnString as a session name, just skip the rest of the connection parameters.
77
78#### Using named sessions
79Named sessions allow you to define specific parameters for each MongoDB instance. Currently, there are only three supported
80parameters: Uri, User and Password. It's a bit more secure way to store credentials compared to item keys or macros.
81
82E.g: suppose you have two MongoDB instances: "Prod" and "Test".
83You should add the following options to the agent configuration file:
84
85    Plugins.Mongo.Sessions.Prod.Uri=tcp://192.168.1.1:27017
86    Plugins.Mongo.Sessions.Prod.User=<UserForProd>
87    Plugins.Mongo.Sessions.Prod.Password=<PasswordForProd>
88
89    Plugins.Mongo.Sessions.Test.Uri=tcp://192.168.0.1:27017
90    Plugins.Mongo.Sessions.Test.User=<UserForTest>
91    Plugins.Mongo.Sessions.Test.Password=<PasswordForTest>
92
93Then you will be able to use these names as the 1st parameter (ConnString) in keys instead of URIs, e.g:
94
95    mongodb.ping[Prod]
96    mongodb.ping[Test]
97
98*Note*: sessions names are case-sensitive.
99
100## Supported keys
101**mongodb.collection.stats[\<commonParams\>[,database],collection]** — Returns a variety of storage statistics for a
102given collection.
103*Parameters:*
104database — database name (default: admin).
105collection (required) — collection name.
106
107**mongodb.cfg.discovery[\<commonParams\>]** — Returns a list of discovered config servers.
108
109**mongodb.collections.discovery[\<commonParams\>]** — Returns a list of discovered collections.
110
111**mongodb.collections.usage[\<commonParams\>]** — Returns usage statistics for collections.
112
113**mongodb.connpool.stats[\<commonParams\>]** — Returns information regarding the open outgoing connections from the
114current database instance to other members of the sharded cluster or replica set.
115
116**mongodb.db.stats[\<commonParams\>[,database]]** — Returns statistics reflecting a given database system’s state.
117*Parameters:*
118database — database name (default: admin).
119
120**mongodb.db.discovery[\<commonParams\>]** — Returns a list of discovered databases.
121
122**mongodb.jumbo_chunks.count[\<commonParams\>]** — Returns count of jumbo chunks.
123
124**mongodb.oplog.stats[\<commonParams\>]** — Returns a status of the replica set, using data polled from the oplog.
125
126**mongodb.ping[\<commonParams\>]** — Tests if a connection is alive or not.
127*Returns:*
128- "1" if a connection is alive.
129- "0" if a connection is broken (if there is any error presented including AUTH and configuration issues).
130
131**mongodb.rs.config[\<commonParams\>]** — Returns a current configuration of the replica set.
132
133**mongodb.rs.status[\<commonParams\>]** — Returns a replica set status from the point of view of the member
134where the method is run.
135
136**mongodb.server.status[\<commonParams\>]** — Returns a database’s state.
137
138**mongodb.sh.discovery[\<commonParams\>]** — Returns a list of discovered shards present in the cluster.
139
140## Troubleshooting
141The plugin uses Zabbix agent's logs. You can increase debugging level of Zabbix Agent if you need more details about
142what is happening.
143Set the DebugLevel configuration option to "5" (extended debugging) in order to turn on verbose log messages for the MGO package.
144