Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
1a5e08ae
Commit
1a5e08ae
authored
Mar 01, 2016
by
Kevin Falcone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log collection stats for certain mongos
parent
4f8686bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
playbooks/roles/mongo_3_0/defaults/main.yml
+1
-0
playbooks/roles/mongo_3_0/templates/log-mongo-serverStatus.sh.j2
+14
-0
No files found.
playbooks/roles/mongo_3_0/defaults/main.yml
View file @
1a5e08ae
...
...
@@ -40,6 +40,7 @@ MONGO_USERS:
roles
:
readWrite
MONGO_CLUSTERED
:
!!null
MONGO_LOG_COLLECTION_STATS
:
!!null
MONGO_BIND_IP
:
127.0.0.1
MONGO_REPL_SET
:
"
rs0"
...
...
playbooks/roles/mongo_3_0/templates/log-mongo-serverStatus.sh.j2
View file @
1a5e08ae
#!/usr/bin/env bash
# Using JSON.stringify forces output of normal JSON, as opposed to Mongo's weird non-compliant extended JSON
/usr/bin/mongo
-u
{{
MONGO_ADMIN_USER
}}
--authenticationDatabase
admin
-p
'{{ MONGO_ADMIN_PASSWORD }}'
--quiet
<<<
'JSON.stringify(db.serverStatus())'
# This can generate a lot more logging, so only turn it on for environments
# where you're interested in collection-level statistics
{
%
if
MONGO_LOG_COLLECTION_STATS %
}
/usr/bin/mongo
-u
{{
MONGO_ADMIN_USER
}}
--authenticationDatabase
admin
-p
'{{ MONGO_ADMIN_PASSWORD }}'
--quiet
<<<
'
rs.slaveOk();
db.getMongo().getDBNames().forEach(function(database) {
if (/^(local|admin)/.test(database))
return;
thisdb = db.getSiblingDB(database);
thisdb.getCollectionNames().forEach(function(collection) {print(JSON.stringify(thisdb[collection].stats()))});
});
'
{
% endif %
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment