Git Product home page Git Product logo

mongotail's Introduction

mongotail

CLI to tail any capped MongoDB collection - like oplog

Build status js-standard-style

Installation

npm install mongotail -g

Usage

mongotail [options] [database]

Options:

  • --database <database> or -d <database> - Specifies the database name

  • --collection <collection> or -c <collection> - Specifies the collection to tail. If not specified, the oplog will be tailed

  • --username <username> or -u <username> - Specifies a username to authenticate to the MongoDB instance

  • --password <password> or -p <password> - Specifies a password to authenticate to the MongoDB instance. If provided without a value, you'll be promted to enter a password manually

  • --host <hostname> - Specifies the host where the mongod or mongos is running to connect to as <hostname>. Defaults to localhost

  • --port <port> - Specifies the port where the mongod or mongos instance is listening. Defaults to 27017 which is the default MongoDB port

  • --pretty - Pretty print the output

Just as with the regular mongo client, you can seed mongotail with a MongoDB connection string, e.g:

mongotail myserver/mycollection

You can of cause mix with options:

mongotail myserver/mycollection -u admin -p

Gotcha

If the collection you are tailing is empty, mongotail will not be able to tail it and will exit right away. This is unfortunately a limitation of MongoDB.

Example: Tailing oplog

Given a replica set hosted on example.net with a master on port 10000 and a slave on port 10001, you could tail the oplog like so (given that myuser have permissions to access the oplog):

mongotail example.net:10000,example.net:10001/mydb -u myuser -p

Notice how we do not specify a collection. This will make mongotail fall back to using the special oplog.rs collection.

License

MIT

mongotail's People

Contributors

watson avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

mongotail's Issues

Unknown operation "killcursors"

2015-07-26 11:06:07.347 QUERY     [person] : {"type": {"$in": [2]}, "short_id": "3000000"}
2015-07-26 11:06:07.347 QUERY     [tag] : {}
2015-07-26 11:06:07.349 QUERY     [category] : {}
2015-07-26 11:06:07.351 QUERY     [size_chart] : {"deviser_id": "3000000", "type": 1}
2015-07-26 11:06:07.366 QUERY     [category] : {"$orderby": {"name.en-US": 1}, "$query": {"path": "/"}}
2015-07-26 11:06:08.799 QUERY     [size_chart] : {"type": 0, "categories": {"$in": ["fb3d0"]}}
2015-07-26 11:26:50.240 QUERY     [category] : {}
Mongotail EXCEPTION - Unknown operation "killcursors"
Dump: {"ns": "", "ts": ISODate("2015-07-26T11:26:50.240Z"), "op": "killcursors"}
Traceback (most recent call last):
  File "/usr/local/bin/mongotail", line 9, in <module>
    load_entry_point('mongotail==0.3.2', 'console_scripts', 'mongotail')()
  File "/usr/local/lib/python2.7/dist-packages/mongotail/mongotail.py", line 156, in main
    tail(client, db, args.n, args.follow)
  File "/usr/local/lib/python2.7/dist-packages/mongotail/mongotail.py", line 68, in tail
    print_obj(result)
  File "/usr/local/lib/python2.7/dist-packages/mongotail/out.py", line 129, in print_obj
    operation.upper().ljust(9), doc, query))
UnboundLocalError: local variable 'query' referenced before assignment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.