Skip to main content

NetDoc Collector

NetDoc Collector is the discovery and data collection component used by NetDoc. It connects to network devices over SSH, Telnet, or HTTPS, runs vendor-specific commands, and stores the resulting raw data for downstream processing.

This repository uses MkDocs for documentation and MkDocstrings to generate API reference pages from the source code in src/netdoc_collector.

Installation

For local development, install the project dependencies with Poetry:

poetry install

If you want the CLI to be available immediately in your environment, install the package in editable mode:

poetry run pip install -e .

Verify that the command-line interface is available:

poetry run netdoc-collector --help

Modes

  • Stand-alone mode: read a local Ansible-style JSON inventory and collect data from the listed devices.
  • Managed mode: claim a discovery job from the NetDoc backend, collect the required data, and push the results back.

Configuration example: config.yaml

inventory: inventory.json
output: ./output
workers: 5
cmd_timeout: 240
retention: 5

backend:
  url: https://netdoc.example.com/api/v1
  timeout: 120
  token: null
  verify: true

Secrets example: secrets.yaml

Store credentials in this file for the scanner and collection logic. Keep it out of version control and protect it with restrictive file permissions.

credentials:
  - id: default
    username: admin
    password: Passw0rd!
    secret: enable_secret
  - id: readonly
    username: readonly
    password: read0nly

Inventory example: inventory.json

The collector accepts Ansible-style JSON inventory data with _meta.hostvars and host-specific connection details.

{
  "_meta": {
    "hostvars": {
      "switch1.example.com": {
        "ansible_host": "192.0.2.10",
        "ansible_user": "admin",
        "ansible_password": "Passw0rd!",
        "netmiko_device_type": "cisco_ios"
      },
      "linux-host.example.com": {
        "ansible_host": "192.0.2.20",
        "ansible_user": "ubuntu",
        "ansible_password": "secret",
        "netmiko_device_type": "linux"
      }
    }
  },
  "all": {
    "hosts": [
      "switch1.example.com",
      "linux-host.example.com"
    ]
  }
}

Usage examples

Stand-alone mode

netdoc-collector -i inventory.json -c config.yaml
netdoc-collector -i inventory.json -o ./output -w 10

Scanner mode

netdoc-collector -s -n 172.25.82.2/32

Managed mode

export NETDOC_TOKEN="<your-api-token>"
netdoc-collector --url https://netdoc.example.com --token "$NETDOC_TOKEN"

You can also provide the token directly on the command line:

netdoc-collector --url https://netdoc.example.com --token mytoken --workers 8

Output

Discovery snapshots are written to the configured output directory in timestamped folders. Each host receives its own subdirectory containing JSON payloads and raw command output files.

Developer quickstart

git clone https://github.com/NetDocLab/netdoc-collector.git
cd netdoc-collector
poetry install
pre-commit install
pre-commit install --hook-type commit-msg

Run tests

poetry run pytest

Build documentation locally

poetry run mkdocs build --strict
poetry run mkdocs serve -a 127.0.0.1:8000

Formatting and linting

poetry run ruff check .
poetry run ruff format .

Documentation

The published documentation is built from this README and the API reference pages generated from the source code.

Contributing

See CONTRIBUTING.md for contribution guidelines, branch conventions, and CI requirements.

Metadata

Release files for netdoc-collector 0.8.3

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

Source distribution (sdist)

Source distribution for netdoc-collector 0.8.3
File Size Uploaded
netdoc_collector-0.8.3.tar.gz 236.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for netdoc-collector 0.8.3
File Interpreter ABI Platform
netdoc_collector-0.8.3-py3-none-any.whl Python 3 none any Details

Total release size: 282.5 kB

Release files / netdoc_collector-0.8.3.tar.gz

Download URL netdoc_collector-0.8.3.tar.gz
Size 236.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e4c2434ad5918da4abeadfcad3751d89b1f318ae48b7d754b294294fcc6276b0
BLAKE2b-256 checksum
How to use checksums
3861130144846accea9bdf3c10cb4e25859768187148f5927a360e3a662774a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / netdoc_collector-0.8.3-py3-none-any.whl

Download URL netdoc_collector-0.8.3-py3-none-any.whl
Size 46.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a05fdcc4fdd10c02646411f7d59acd5017e1295fc437bbdd10328ff8834545de
BLAKE2b-256 checksum
How to use checksums
7619d2af0b6aec73d9e8cf35fe1c0f3b977f2bab56c2ecf4d2f268ecb3384a11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release history Release notifications | RSS feed

This release

0.8.3 This release

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

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