{"id":28205735,"url":"https://github.com/robwdwd/lg","last_synced_at":"2025-06-18T15:35:40.800Z","repository":{"id":154632666,"uuid":"630403296","full_name":"robwdwd/lg","owner":"robwdwd","description":"Network Looking Glass","archived":false,"fork":false,"pushed_at":"2024-12-18T10:51:38.000Z","size":343,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-17T10:08:25.401Z","etag":null,"topics":["bgp","ip","lg","looking-glass","network","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robwdwd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-20T09:57:19.000Z","updated_at":"2024-12-18T10:51:32.000Z","dependencies_parsed_at":"2023-12-04T15:24:17.011Z","dependency_job_id":"a6062fb7-eed0-4543-80a1-f9976090b30b","html_url":"https://github.com/robwdwd/lg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robwdwd%2Flg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robwdwd%2Flg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robwdwd%2Flg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robwdwd%2Flg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robwdwd","download_url":"https://codeload.github.com/robwdwd/lg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robwdwd%2Flg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259255509,"owners_count":22829484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bgp","ip","lg","looking-glass","network","python","python3"],"created_at":"2025-05-17T10:08:25.040Z","updated_at":"2025-06-11T11:31:45.778Z","avatar_url":"https://github.com/robwdwd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Looking Glass\n\nPython Network Looking Glass\n\n## Install\n\nDownload either source or release file and put somewhere on your filesystem.\n\n### Build Virtual environment\n\nPoetry is used to build the virtual environment although\nany other venv tools can be used to build it. Pipx is a good way to [install\npoetry](https://python-poetry.org/docs/#installing-with-pipx) although you\ncan use any of the install methods listed\n[here](https://python-poetry.org/docs/#installation)\n\n```console\npoetry install --nodev\n```\n\n### Install NPM Packages\n\n```console\nnpm install\n```\n\n### Configuration\n\nCopy the [examples/env.example](examples/env.example) to `.env` in lg\nroot folder (not in the package folder.)\n\nMake sure to change the `SECRET_KEY` and `CSRF_SECRET` in the `.env` file\nand also set `DEBUG=False` for a production environment.\n\n### Location and command configuration\n\nCopy the [examples/config.yml.example](examples/config.yml.example) to config.yml in\nthe lg root folder (not in the package folder.) The path to this file can be changed\nby changing CONFIG_FILE in the .env file.\n\nThe config file contains the list of cities, devices and cli commands\nto run on each device type.\n\nAny device type supported by scrapli is supported by the looking glass.\nTo find all the device types look\n[here](https://carlmontanari.github.io/scrapli/user_guide/basic_usage/)\n\nEvery location needs a device (hostname), the device type, the full name of the\nlocation, a region and a source interface or ip address (for traceroute and\nping commands).\n\n```console\nlocations:\n  AMS:\n    name: Amsterdam\n    region: Western Europe\n    device: router.ams.example.net\n    type: cisco_iosxr\n    source: loopback999\n```\n\nThe config.yml file also contains the commands to run on each device type.\nIn each command the string IPADDRESS is substituted for the IP Address or CIDR\nthe user enters on the form and SOURCE is substiuted for the source in the location\nconfiguration. IOS-XR and JunOS commands are in the example but you can add more\nsupport for other devices provided netmiko supports that device type.\n\n### Community maps\n\nCommunity maps convert the community output in the bgp command to be more human\nfriendly. Copy [examples/communities.txt](examples/communities.txt) to the mapsdb folder.\nThis is then read at start up and saved to a sqlite database for access. Making any\nchanges to the communities.txt file requires a server restart.\n\n### Change permissions\n\nChange the group permissions of the mapsdb folder to the group of your web server\nand add group sticky bit. Make the .env file readable to the web server.\n\n```console\nchgrp www-data mapsdb .env\nchmod g+s mapsdb\n```\n\n## Running development server\n\nRun the helper app directly. Use poetry or another virtual environment.\n\n```console\npoetry shell\npython3 app.py\n```\n\nWith uvicorn.\n\n```console\npoetry shell\nuvicorn --reload --log-level debug --port 8010 lg:app\n```\n\nWith gunicorn through the uvicorn worker class, this will use gunicorn\ndefault listen address and port. Use `-b \u003cLISTEN\u003e:\u003cPORT\u003e` to change that.\n\n```console\n gunicorn -k lg.workers.CustomWorker lg:app\n```\n\n## Systemd service\n\nCreate a systemd unit file to start the lg service at startup.\nAn example unit file [examples/lg.service](examples//lg.service)\ncan be used and edited as needed.\n\n```console\ncp examples/lg.service /etc/systemd/system/lg.service\n```\n\nEdit the file and change the following as needed `WorkingDirectory`,\n`User`, `Group`. Also alter `PATH` and `VIRTUAL_ENV`\nEnvironment variables to match your install location.\n\nMake the log directory used by the service (gunicorn logs). Set `LOG_DIR` in\nthe `.env` file to change this if required and change the username to the\nsame user and group as in the unit file.\n\n```console\nmkdir /var/log/lg/\nchown www-data.www-data /var/log/lg/\n```\n\nBy default it runs on port 8010 and listens only on localhost. Change\nthis in the `.env` file.\n\nFinally enable the service\n\n```console\nsystemctl daemon-reload\nsystemctl enable lg.service\nsystemctl start lg.service\n```\n\n## Nginx configuration\n\nA reverse proxy via Nginix is optional but recommeded step. If the pages are\nserved under a sub path modify the `ROOT_PATH` in `.env`\nto match for example `ROOT_PATH=/lg`\n\nSee [examples/nginx.conf](examples/nginx.conf) and\n[examples/nginx-subpath.conf](examples/nginx-subpath.conf) configuration for\na base to get started.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobwdwd%2Flg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobwdwd%2Flg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobwdwd%2Flg/lists"}