# Monocle [![Rust](https://github.com/bgpkit/monocle/actions/workflows/rust.yml/badge.svg)](https://github.com/bgpkit/monocle/actions/workflows/rust.yml) [![Crates.io](https://img.shields.io/crates/v/monocle)](https://crates.io/crates/monocle) [![Docs.rs](https://docs.rs/monocle/badge.svg)](https://docs.rs/monocle) [![License](https://img.shields.io/crates/l/monocle)](https://raw.githubusercontent.com/bgpkit/monocle/main/LICENSE) See through all BGP data with a monocle. ![](https://spaces.bgpkit.org/assets/monocle/monocle-emoji.png) ## Install ### Using `cargo` ```bash cargo install monocle ``` ### Using `homebrew` on macOS ```bash brew install bgpkit/tap/monocle ``` ### Using [`cargo-binstall`](https://github.com/cargo-bins/cargo-binstall) Install `cargo-binstall` first: ```bash cargo install cargo-binstall ``` Then install `monocle` using `cargo binstall` ```bash cargo binstall monocle ``` ## Usage Subcommands: - `parse`: parse individual MRT files - `search`: search for matching messages from all available public MRT files - `whois`: search AS and organization information by ASN or name - `country`: utility to lookup country name and code - `time`: utility to convert time between unix timestamp and RFC3339 string - `rpki`: check RPKI validation for given ASNs or prefixes Top-level help menu: ```text ➜ ~ monocle A commandline application to search, parse, and process BGP information in public sources. Usage: monocle [OPTIONS] Commands: parse Parse individual MRT files given a file path, local or remote search Search BGP messages from all available public MRT files whois ASN and organization lookup utility country ASN and organization lookup utility time Time conversion utilities rpki RPKI utilities help Print this message or the help of the given subcommand(s) Options: -c, --config configuration file path, by default $HOME/.monocle.toml is used --debug Print debug information -h, --help Print help -V, --version Print version ``` ### `monocle parse` Parsing single MRT file given a local path or a remote URL. ```text ➜ monocle git:(main) ✗ monocle parse --help Parse individual MRT files given a file path, local or remote USAGE: monocle parse [OPTIONS] ARGS: File path to a MRT file, local or remote OPTIONS: -a, --as-path Filter by AS path regex string -h, --help Print help information -j, --peer-ip Filter by peer IP address -J, --peer-asn Filter by peer ASN --json Output as JSON objects -m, --elem-type Filter by elem type: announce (a) or withdraw (w) -o, --origin-asn Filter by origin AS Number -p, --prefix Filter by network prefix --pretty Pretty-print JSON output -s, --include-super Include super-prefix when filtering -S, --include-sub Include sub-prefix when filtering -t, --start-ts Filter by start unix timestamp inclusive -T, --end-ts Filter by end unix timestamp inclusive -V, --version Print version information ``` ### `monocle search` Search for BGP messages across publicly available BGP route collectors and parse relevant MRT files in parallel. More filters can be used to search for messages that match your criteria. ```text ➜ monocle git:(main) ✗ monocle search --help Search BGP messages from all available public MRT files Usage: monocle search [OPTIONS] --start-ts --end-ts Options: --dry-run Dry-run, do not download or parse --json Output as JSON objects --pretty Pretty-print JSON output --sqlite-path SQLite output file path --mrt-path MRT output file path --sqlite-reset SQLite reset database content if exists -t, --start-ts Filter by start unix timestamp inclusive -T, --end-ts Filter by end unix timestamp inclusive -c, --collector Filter by collector, e.g. rrc00 or route-views2 -P, --project Filter by route collection project, i.e. riperis or routeviews -o, --origin-asn Filter by origin AS Number -p, --prefix Filter by network prefix -s, --include-super Include super-prefix when filtering -S, --include-sub Include sub-prefix when filtering -j, --peer-ip Filter by peer IP address -J, --peer-asn Filter by peer ASN -m, --elem-type Filter by elem type: announce (a) or withdraw (w) -a, --as-path Filter by AS path regex string -h, --help Print help -V, --version Print version ``` ### `monocle time` Convert between UNIX timestamp and RFC3339 time strings. ```text ➜ ~ monocle time --help Time conversion utilities USAGE: monocle time [TIME] ARGS: