brontide / aioedgeos

Async version of code to interact with EdgeOS API and streaming statistics daemon.
37 stars 8 forks source link

how do you install this #1

Closed daniel2029 closed 3 years ago

tbabula commented 4 years ago

The repository lacks documentation on it. The easiest way to get it working is to try using docker-composer with parameters to launch it in detached mode and set it to always autorestart. If you are learning about docker, there is a few good free tutorials on the web how to do it. Of course you also need influxdb and grafana and there are tutorials on installing and setting them on the web. There are out of box docker images that have both indluxdb and grafana such as samuelebistoletti/docker-statsd-influxdb-grafana. Then you when you deploy brontinde's docker, you point it to IP address of your influxdb and use his json file to add dashboard to grafana.

Also make sure you have enabled traffic analysis enabled at least on host level.

daniel2029 commented 3 years ago

sorry for the late response. gave up on trying because life got in the way. thanks for your response mate👍

daniel2029 commented 3 years ago

hi i am trying to set this up using docker and when i comment the line ROUTER_SSL in settings.env it says

edge2influx_1 | 2020-11-05 00:59:15,141:ERROR:root:Run of stay_logged_in raised exception edge2influx_1 | Traceback (most recent call last): edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 60, in run edge2influx_1 | await self.call(*self.args, *self.kwargs) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 95, in stay_logged_in edge2influx_1 | await edgeos.login() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 170, in login edge2influx_1 | async with self.session.post(f'{self.url}', edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in aenter edge2influx_1 | self._resp = await self._coro edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request edge2influx_1 | break edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 596, in exit edge2influx_1 | raise asyncio.TimeoutError from None edge2influx_1 | asyncio.exceptions.TimeoutError edge2influx_1 | Traceback (most recent call last): edge2influx_1 | File "/app/influx.py", line 339, in edge2influx_1 | asyncio.run(main_loop()) edge2influx_1 | File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run edge2influx_1 | return loop.run_until_complete(main) edge2influx_1 | File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete edge2influx_1 | return future.result() edge2influx_1 | File "/app/influx.py", line 241, in main_loop edge2influx_1 | router = await stack.enter_async_context( edge2influx_1 | File "/usr/local/lib/python3.8/contextlib.py", line 568, in enter_async_context edge2influx_1 | result = await _cm_type.aenter(cm) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 145, in aenter edge2influx_1 | await self.setup() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 134, in setup edge2influx_1 | await self.stack.enter_async_context(TaskEvery(stay_logged_in, self, interval=300)) edge2influx_1 | File "/usr/local/lib/python3.8/contextlib.py", line 568, in enter_async_context edge2influx_1 | result = await _cm_type.aenter(cm) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 77, in aenter edge2influx_1 | await self.run() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 60, in run edge2influx_1 | await self.call(self.args, **self.kwargs) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 95, in stay_logged_in edge2influx_1 | await edgeos.login() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 170, in login edge2influx_1 | async with self.session.post(f'{self.url}', edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in aenter edge2influx_1 | self._resp = await self._coro edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request edge2influx_1 | break edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 596, in exit edge2influx_1 | raise asyncio.TimeoutError from None edge2influx_1 | asyncio.exceptions.TimeoutError edge2influx_1 | 2020-11-05 00:59:15,161:ERROR:asyncio:Unclosed client session edge2influx_1 | client_session: <aiohttp.client.ClientSession object at 0x7f1558c16190>

and if i uncomment the line and put the fingerprint obtained from chrome for my router it says edge2influx_1 | Traceback (most recent call last): edge2influx_1 | File "/app/influx.py", line 69, in edge2influx_1 | raise Exception(f"ROUTER_SSL {ROUTER_SSL} is invalid") edge2influx_1 | Exception: ROUTER_SSL (my hash) is invalid

ewarnke commented 3 years ago

Leave the ROUTER_SSL out and then use the fingerprint printed in the output of the failed container.

daniel2029 commented 3 years ago

Leave the ROUTER_SSL out and then use the fingerprint printed in the output of the failed container.

hi thanks for your response except i tried this already. the out put below i completely removed the ROUTER_SSL entry in .env. can u help me find where fingerprint is among the printed output? (see below)

Starting influx_edge2influx_1 ... done Attaching to influx_edge2influx_1 edge2influx_1 | edge2influx_1 | ================================================ edge2influx_1 | ROUTER_TAGNAME = get hostname from system config edge2influx_1 | ROUTER_USERNAME = ubnt edge2influx_1 | ROUTER_PASSWORD = HIDDEN edge2influx_1 | ROUTER_URL = https://192.168.0.1/ edge2influx_1 | ROUTER_SSL = ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff edge2influx_1 | - ssl_check -> <aiohttp.client_reqrep.Fingerprint object at 0x7ff9e12f8f40> edge2influx_1 | INFLUX_HOST = 192.168.0.2 edge2influx_1 | INFLUX_PORT = 8086 edge2influx_1 | INFLUX_DB = edgeos edge2influx_1 | INFLUX_USERNAME = None edge2influx_1 | INFLUX_PASSWORD = HIDDEN edge2influx_1 | PING_TARGET = 1.1.1.1 edge2influx_1 | PING_COUNT = 3 edge2influx_1 | PING_SIZE = 50 edge2influx_1 | PING_INTERVAL = 120 edge2influx_1 | ================================================ edge2influx_1 | edge2influx_1 | 2020-11-09 00:18:01,962:INFO:root:CONNECTING TO ROUTER https://192.168.0.1/ with user ubnt edge2influx_1 | 2020-11-09 00:18:33,010:ERROR:root:Run of stay_logged_in raised exception edge2influx_1 | Traceback (most recent call last): edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 60, in run edge2influx_1 | await self.call(*self.args, *self.kwargs) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 95, in stay_logged_in edge2influx_1 | await edgeos.login() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 170, in login edge2influx_1 | async with self.session.post(f'{self.url}', edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in aenter edge2influx_1 | self._resp = await self._coro edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request edge2influx_1 | break edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 596, in exit edge2influx_1 | raise asyncio.TimeoutError from None edge2influx_1 | asyncio.exceptions.TimeoutError edge2influx_1 | Traceback (most recent call last): edge2influx_1 | File "/app/influx.py", line 339, in edge2influx_1 | asyncio.run(main_loop()) edge2influx_1 | File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run edge2influx_1 | return loop.run_until_complete(main) edge2influx_1 | File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete edge2influx_1 | return future.result() edge2influx_1 | File "/app/influx.py", line 241, in main_loop edge2influx_1 | router = await stack.enter_async_context( edge2influx_1 | File "/usr/local/lib/python3.8/contextlib.py", line 568, in enter_async_context edge2influx_1 | result = await _cm_type.aenter(cm) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 145, in aenter edge2influx_1 | await self.setup() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 134, in setup edge2influx_1 | await self.stack.enter_async_context(TaskEvery(stay_logged_in, self, interval=300)) edge2influx_1 | File "/usr/local/lib/python3.8/contextlib.py", line 568, in enter_async_context edge2influx_1 | result = await _cm_type.aenter(cm) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 77, in aenter edge2influx_1 | await self.run() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 60, in run edge2influx_1 | await self.call(self.args, **self.kwargs) edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 95, in stay_logged_in edge2influx_1 | await edgeos.login() edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aioedgeos/api.py", line 170, in login edge2influx_1 | async with self.session.post(f'{self.url}', edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in aenter edge2influx_1 | self._resp = await self._coro edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request edge2influx_1 | break edge2influx_1 | File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 596, in exit edge2influx_1 | raise asyncio.TimeoutError from None edge2influx_1 | asyncio.exceptions.TimeoutError edge2influx_1 | 2020-11-09 00:18:33,034:ERROR:asyncio:Unclosed client session edge2influx_1 | client_session: <aiohttp.client.ClientSession object at 0x7ff9df406070>

whats very strange is i tried to go to the files located at /usr/local/lib/python3.8/ and they were not there?

brontide commented 3 years ago

It's a lot of errors but it's saying that the web interface isn't accessible, it's also the reason it isn't spitting out the fingerprint.

Can you access the EdgeMax interface at https://192.168.0.1/ ?

Please tell me you've at least changed the password for the default user?

daniel2029 commented 3 years ago

It's a lot of errors but it's saying that the web interface isn't accessible, it's also the reason it isn't spitting out the fingerprint.

Can you access the EdgeMax interface at https://192.168.0.1/ ?

Please tell me you've at least changed the password for the default user?

its a privilege to have you helping me mr brontide. yes dont worry i have changed the password and i can access it from my pc. thanks for providing the information, i will now check if the docker is able to access my network with the hopes that it cannot and thats why it doesnt work. thanks for your help. i will try later tonight

daniel2029 commented 3 years ago

after troubleshooting all this time, i have found the issue. this does not work on macOS :( as it works perfectly fine on my ubuntu VM.