From 8371523e2819118ca3a9b314b4403443723c4830 Mon Sep 17 00:00:00 2001 From: nmc Date: Sun, 15 Jan 2023 14:39:39 -0500 Subject: [PATCH] Cleanup + Update Actions --- .env.dist | 2 + .github/workflows/DockerBuildAndPush.yml | 10 +- main.py | 117 +---------------------- 3 files changed, 8 insertions(+), 121 deletions(-) create mode 100644 .env.dist diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000..bc55a89 --- /dev/null +++ b/.env.dist @@ -0,0 +1,2 @@ +MODEM_HOST=192.168.1.1 +MODEM_PASS=***password**** \ No newline at end of file diff --git a/.github/workflows/DockerBuildAndPush.yml b/.github/workflows/DockerBuildAndPush.yml index a19510c..6f89740 100644 --- a/.github/workflows/DockerBuildAndPush.yml +++ b/.github/workflows/DockerBuildAndPush.yml @@ -10,16 +10,16 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -32,7 +32,7 @@ jobs: # password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: . file: ./Dockerfile diff --git a/main.py b/main.py index 2667d37..49e3169 100644 --- a/main.py +++ b/main.py @@ -23,7 +23,7 @@ class NetgearLTEMetrics: self.app_port = app_port self.polling_interval_seconds = polling_interval_seconds - #NetgearLTE + #Netgear LTE self.rx_level = Gauge("netgear_lte_rx_level", "RX Level") self.tx_level = Gauge("netgear_lte_tx_level", "TX Level") self.radio_quality = Gauge("netgear_lte_radio_quality", "Radio Quality") @@ -53,10 +53,6 @@ class NetgearLTEMetrics: new values. """ - # Fetch raw status data from the application - # resp = requests.get(url=f"http://localhost:{self.app_port}/status") - # status_data = resp.json() - jar = aiohttp.CookieJar(unsafe=True) websession = aiohttp.ClientSession(cookie_jar=jar) @@ -67,7 +63,6 @@ class NetgearLTEMetrics: await websession.close() - self.rx_level.set(result.rx_level) self.tx_level.set(result.tx_level) self.radio_quality.set(result.radio_quality) @@ -88,106 +83,6 @@ class NetgearLTEMetrics: await websession.close() -# async def get_information(): -# """Example of printing the current upstream.""" -# jar = aiohttp.CookieJar(unsafe=True) -# websession = aiohttp.ClientSession(cookie_jar=jar) - -# try: -# modem = eternalegypt.Modem(hostname=os.getenv("MODEM_HOST"), websession=websession) -# await modem.login(password=os.getenv("MODEM_PASS")) - -# result = await modem.information() -# # if len(sys.argv) == 3: -# print("serial_number: {}".format(result.serial_number)) -# print("usage: {}".format(result.usage)) -# print("upstream: {}".format(result.upstream)) -# print("wire_connected: {}".format(result.wire_connected)) -# print("mobile_connected: {}".format(result.mobile_connected)) -# print("connection_text: {}".format(result.connection_text)) -# print("connection_type: {}".format(result.connection_type)) -# print("current_nw_service_type: {}".format(result.current_nw_service_type)) -# print("current_ps_service_type: {}".format(result.current_ps_service_type)) -# print("register_network_display: {}".format(result.register_network_display)) -# print("roaming: {}".format(result.roaming)) -# print("radio_quality: {}".format(result.radio_quality)) -# print("rx_level: {}".format(result.rx_level)) -# print("tx_level: {}".format(result.tx_level)) -# print("current_band: {}".format(result.current_band)) -# print("cell_id: {}".format(result.cell_id)) -# # else: -# # key = sys.argv[3] -# # print("{}: {}".format(key, result.items.get(key))) - -# await modem.logout() -# except eternalegypt.Error: -# print("Could not login") - -# await websession.close() - -# async def debugStuff(): -# jar = aiohttp.CookieJar(unsafe=True) -# websession = aiohttp.ClientSession(cookie_jar=jar) - -# modem = eternalegypt.Modem(hostname="xxx", websession=websession) -# await modem.login(password="xxx") -# await modem.delete_sms(sms_id=0) -# await modem.delete_sms(sms_id=1) -# await modem.delete_sms(sms_id=2) -# await modem.sms(message="Thisisatest",phone="xxx") -# await modem.logout() - - - -# @autologin -# async def information(self): -# """Return the current information.""" -# url = self._url('model.json') -# async with self.websession.get(url) as response: -# data = json.loads(await response.text()) - -# try: -# result = self._build_information(data) -# _LOGGER.debug("Did read information: %s", data) -# except KeyError as ex: -# _LOGGER.debug("Failed to read information (%s): %s", ex, data) -# raise Error() - -# self._sms_events(result) - -# return result - -# data['sms']['unreadMsgs'] -# data['sms']['msgCount'] -# data['general']['appVersion'] - -# result.serial_number -# result.usage -# result.upstream -# result.wire_connected -# result.mobile_connected -# result.connection_text -# result.connection_type -# result.current_nw_service_type -# result.current_ps_service_type -# result.register_network_display -# result.roaming -# result.radio_quality -# result.rx_level -# result.tx_level -# result.current_band -# result.cell_id - -# async def login(): -# jar = aiohttp.CookieJar(unsafe=True) -# websession = aiohttp.ClientSession(cookie_jar=jar) - -# modem = eternalegypt.Modem(hostname="xxx", websession=websession) -# await modem.login(password="xxx") - - -# await websession.close() -# return modem def main(): """Main entry point""" @@ -196,16 +91,6 @@ def main(): app_port = int(os.getenv("APP_PORT", "80")) exporter_port = int(os.getenv("EXPORTER_PORT", "9877")) - # asyncio.get_event_loop().run_until_complete(get_information()) - - # modem = asyncio.get_event_loop().run_until_complete(login()) - - # asyncio.get_event_loop().run_until_complete(debugStuff()) - - # while(True): - # asyncio.get_event_loop().run_until_complete(get_information()) - # time.sleep(2) - app_metrics = NetgearLTEMetrics( app_port=app_port, polling_interval_seconds=polling_interval_seconds