Skip to main content

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.

Release files for mongostat-fdw 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongostat-fdw 0.0.1
File Size Uploaded
mongostat_fdw-0.0.1.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mongostat-fdw 0.0.1
File Interpreter ABI Platform
mongostat_fdw-0.0.1-py2-none-any.whl Python 2 none any Details

Total release size: 9.6 kB

Release files / mongostat_fdw-0.0.1.tar.gz

Download URL mongostat_fdw-0.0.1.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bd2826f5f8d64d54f5fa106965fea6994947aa075662e841903c2ff6da84b783
BLAKE2b-256 checksum
How to use checksums
487a6b4bdd38f6b8cfba42acd2ea9a48615a74a7e9f64eb51adbf990f52e7bf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / mongostat_fdw-0.0.1-py2-none-any.whl

Download URL mongostat_fdw-0.0.1-py2-none-any.whl
Size 6.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
08085b3ff6c9c6041f5230dfda044428682c2415c62322c102ef4cb031ae77bb
BLAKE2b-256 checksum
How to use checksums
9888898c4196c652624a9417293fc8d08b9bbe7d0e77b7f8e505d701679ff508
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page