Zabbix monitors mongodb
1. Configure zabbix to customize the user key
Vim/usr/local/zabbix/etc/zabbix_agentd.conf
UserParameter = MongoDB. status [*],/bin/echo "db. serverStatus (). $1 "|/usr/local/mongodb/bin/mongo admin | grep" \ <$2 \> "| awk-F: '{print $2}' | awk-F, '{print $1 }'
The preceding figure uses db. serverStatus () to obtain the server status.
$1 indicates the first parameter.
When grep $2, you must add the anchor "\ <" and "\>", because some object names may be partially the same
Restart zabbix client
2. Use custom commands to test the obtained results.
[Root @ mongodb bin] # echo "db. serverStatus (). opcounters" | mongo admin
MongoDB shell version: 2.6.3
Connecting to: admin
{
"Insert": 6,
"Queries": 138,
"Update": 1,
"Delete": 1,
"Getmore": 0,
"Command": 9884
}
Bye
3. Test whether the custom key has taken effect.
./Zabbix_get-s 127.0.0.1-k MongoDB. Status [opcounters, query]
4. Add monitoring on zabbix
Create a template
Add metric
Monitor the command and collect the number of all commands, including insert, delete, query, update, and other commands. The value is obtained every 10 seconds.
Insert, query, update, delete, getmore, and command all use the same settings.
Monitoring memory, virtual is virtual memory, resident is regardless of memory
Monitoring Network. bytesIN indicates inbound traffic, bytesOut indicates outbound traffic, and numRequests indicates the number of requests.
Number of monitored connections. available indicates the number of available connections and current indicates the number of current connections.
Monitor the number of times data is written to the hard disk
Defines the mapped project in MB.
5. Monitor the locks project. Some projects are multi-dimensional arrays and cannot be obtained using the custom user key. You need to create a dedicated key.
[Root @ mongodb bin] # echo "db. serverStatus (). locks" | mongo admin
MongoDB shell version: 2.6.3
Connecting to: admin
{
".":{
"TimeLockedMicros ":{
"R": NumberLong (572504 ),
& Quot; W & quot;: NumberLong (480751)
},
"TimeAcquiringMicros ":{
"R": NumberLong (480946 ),
& Quot; W & quot;: NumberLong (70198)
}
},
"Admin ":{
"TimeLockedMicros ":{
"R": NumberLong (142364 ),
"W": NumberLong (0)
},
"TimeAcquiringMicros ":{
"R": NumberLong (15018 ),
"W": NumberLong (0)
}
},
"Local ":{
"TimeLockedMicros ":{
"R": NumberLong (271651 ),
& Quot; w & quot;: NumberLong (271)
},
"TimeAcquiringMicros ":{
"R": NumberLong (120699 ),
"W": NumberLong (5)
}
},
"Test ":{
"TimeLockedMicros ":{
"R": NumberLong (93725 ),
& Quot; w & quot;: NumberLong (114935)
},
"TimeAcquiringMicros ":{
"R": NumberLong (67411 ),
"W": NumberLong (41)
}
}
}
Bye
Create a custom key
UserParameter = MongoDB. status. locks [*],/bin/echo "db. serverStatus (). locks. $1. $2. $3 "|/usr/local/mongodb/bin/mongo admin |/usr/bin/tail-n 2 |/usr/bin/head-n 1 | awk-F' (''{print $2} '| awk-f ') ''{print $1 }'