Mongo values reporting from an incorrect section when also asking for repllication stats
Opened this issue · 0 comments
GoogleCodeExporter commented
: Please delete the following text from your bug report.
s/following/preceding/ ;)
Version:
1.1.8 with repl patches.
Problem:
Cacti graphs for MongoDB commands, when run against a mongodb server with
replication enabled, only show counters for replica commands, not
client-originated queries.
The problem is in the output of the mongodb stats query when also asking for
replication stats:
db._adminCommand({serverStatus:1, repl:2})
{
...
"opcountersRepl" : {
"insert" : 4728067,
"query" : 0,
"update" : 2055551,
"delete" : 23362,
"getmore" : 0,
"command" : 1
},
"opcounters" : {
"insert" : 0,
"query" : 21212983,
"update" : 99691,
"delete" : 83,
"getmore" : 159272,
"command" : 36233378
},
...
}
php's preg_match in ss_get_by_ssh.php will match the first instance of "insert"
(in "opcountersRepl"), and not the one from the "opcounters" section. If the
mongodb command is db._adminCommand({serverStatus:1}), the "opcounterRepl"
section is not printed,
To return the graphs to showing the counters for client insert/queries/etc, I
grabbed the "opcounters" section of the output, and matched the
insert/query/update/delete/getmore/command strings from that.
ss_get_by_ssh.php / mongodb_parse:
1298c1301,1306
< preg_match('/"insert" : ([0-9]+)/', $output, $matches);
---
> # Grab the 'opcounters' section.
> preg_match('/"opcounters"\s*:\s*{([^}]*)}/msU', $output, $matches);
> $opcounters = $matches[1];
> # $opcounters = $output;
>
> preg_match('/"insert" : ([0-9]+)/', $opcounters, $matches);
1300c1308
< preg_match('/"query" : ([0-9]+)/', $output, $matches);
---
> preg_match('/"query" : ([0-9]+)/', $opcounters, $matches);
1302c1310
< preg_match('/"update" : ([0-9]+)/', $output, $matches);
---
> preg_match('/"update" : ([0-9]+)/', $opcounters, $matches);
1304c1312
< preg_match('/"delete" : ([0-9]+)/', $output, $matches);
---
> preg_match('/"delete" : ([0-9]+)/', $opcounters, $matches);
1306c1314
< preg_match('/"getmore" : ([0-9]+)/', $output, $matches);
---
> preg_match('/"getmore" : ([0-9]+)/', $opcounters, $matches);
1308c1316
< preg_match('/"command" : ([0-9]+)/', $output, $matches);
---
> preg_match('/"command" : ([0-9]+)/', $opcounters, $matches);
--
Original issue reported on code.google.com by b...@brandaffinity.net
on 30 Nov 2011 at 7:47