Skip to main content

mongo databases and collections statistics fdw for postgresql

Project description

Mongo database and collection statistics foreign data wrapper for PostgreSQL written in python.

dependencies

installation

  1. install python module

  • from sources (bitbucket)

    $ git clone https://bitbucket.org/olshevskiy87/mongostat_fdw.git
    $ cd mongostat_fdw
    $ python setup.py install
  • using pip

    $ pip install mongostat_fdw
  1. create extension “multicorn” in postgresql (e.g. using psql)

    $$ create extension multicorn;
  2. create foreign servers

    $$ CREATE SERVER mongostat_fdw_db
       FOREIGN DATA WRAPPER multicorn
       OPTIONS (
           wrapper 'mongostat_fdw.MongoDBStatFDW'
       );
    $$ CREATE SERVER mongostat_fdw_coll
       FOREIGN DATA WRAPPER multicorn
       OPTIONS (
           wrapper 'mongostat_fdw.MongoCollStatFDW'
       );
  3. create foreign tables

    $$ CREATE FOREIGN TABLE mongo_db_stat (
        "avgObjSize" NUMERIC,
        collections INT,
        "dataFileVersion" JSONB, -- for Postgres 9.4+ or JSON, or (at least) TEXT
        "extentFreeList" JSONB,  -- Mongo 3.0.0+
        "dataSize" NUMERIC,
        db TEXT,
        "fileSize" NUMERIC,
        "indexSize" NUMERIC,
        indexes INT,
        "nsSizeMB" BIGINT,
        "numExtents" INT,
        objects INT,
        ok NUMERIC,
        "storageSize" NUMERIC,
        "extentFreeList" JSONB   -- for Postgres 9.4+ or JSON, or (at least) TEXT
    ) SERVER mongostat_fdw_db OPTIONS (
        -- uri 'mongodb://127.0.0.1:27017',
        host '127.0.0.1',
        port '27017',
        db 'test'
    );
    $$ CREATE FOREIGN TABLE mongo_coll_stat (
        "avgObjSize" NUMERIC,
        count INT,
        "indexSize" JSONB,
        "lastExtentSize" NUMERIC,
        nindexes INT,
        ns TEXT,
        "numExtents" INT,
        ok NUMERIC,
        "paddingFactor" NUMERIC,
        size NUMERIC,
        "storageSize" NUMERIC,
        "systemFlags" INT,
        "totalIndexSize" NUMERIC,
        "userFlags" INT
    ) SERVER mongostat_fdw_coll OPTIONS (
        db 'test'
    );

usage

  • get “test” database statistics

$$ select db, "fileSize", "dataSize", "avgObjSize", indexes, "dataFileVersion"
   from mongo_db_stat;

  db   | fileSize | dataSize |  avgObjSize   | indexes |     dataFileVersion
-------+----------+----------+---------------+---------+--------------------------
 local | 67108864 |     2840 | 405.714285714 |       1 | {"major": 4, "minor": 5}
 admin |        0 |        0 |           0.0 |       0 | {}
(2 rows)
  • get “test” database collections statistics

$$ select ns as tbl_name, size, "storageSize", count
   from mongo_coll_stat;

      tbl_name       | size | storageSize | count
---------------------+------+-------------+-------
 test.system.indexes |   72 |        4096 |     1
 test.test_coll      |  344 |        4096 |     7
(2 rows)

license

Copyright (c) 2016 Dmitriy Olshevskiy. MIT LICENSE.

See LICENSE.txt for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongostat_fdw-0.0.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

mongostat_fdw-0.0.1-py2-none-any.whl (6.0 kB view details)

Uploaded Python 2

File details

Details for the file mongostat_fdw-0.0.1.tar.gz.

File metadata

File hashes

Hashes for mongostat_fdw-0.0.1.tar.gz
Algorithm Hash digest
SHA256 bd2826f5f8d64d54f5fa106965fea6994947aa075662e841903c2ff6da84b783
MD5 67962f9ea18b2fadf40f8a0b4196d601
BLAKE2b-256 487a6b4bdd38f6b8cfba42acd2ea9a48615a74a7e9f64eb51adbf990f52e7bf7

See more details on using hashes here.

File details

Details for the file mongostat_fdw-0.0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for mongostat_fdw-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 08085b3ff6c9c6041f5230dfda044428682c2415c62322c102ef4cb031ae77bb
MD5 3e7fed72f08af602ca41b5a98bbc4b61
BLAKE2b-256 9888898c4196c652624a9417293fc8d08b9bbe7d0e77b7f8e505d701679ff508

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page