{"id":26678316,"url":"https://github.com/telexintegrations/telex_network_alerts","last_synced_at":"2025-03-26T05:15:27.194Z","repository":{"id":278356568,"uuid":"934789540","full_name":"telexintegrations/telex_network_alerts","owner":"telexintegrations","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-22T17:16:55.000Z","size":21941,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T18:23:59.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telexintegrations.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-18T12:07:59.000Z","updated_at":"2025-02-22T17:16:59.000Z","dependencies_parsed_at":"2025-02-22T18:24:08.838Z","dependency_job_id":null,"html_url":"https://github.com/telexintegrations/telex_network_alerts","commit_stats":null,"previous_names":["samueloshin/telex_network_alerts","telexintegrations/telex_network_alerts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex_network_alerts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex_network_alerts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex_network_alerts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Ftelex_network_alerts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telexintegrations","download_url":"https://codeload.github.com/telexintegrations/telex_network_alerts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245591533,"owners_count":20640692,"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":[],"created_at":"2025-03-26T05:15:26.308Z","updated_at":"2025-03-26T05:15:27.180Z","avatar_url":"https://github.com/telexintegrations.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Network Downtime Alerts\n\n## Overview\nThis application monitors network connectivity by periodically checking the availability of a specified target URL. It sends real-time alerts to Telex if the connection fails, ensuring prompt awareness of network downtime.\n\n## Features\n- Periodically checks server or endpoint availability.\n- Sends real-time alerts to Telex on downtime.\n- Configurable check interval via Cron expression.\n- Lightweight solution without a database.\n\n## Requirements\n- Python 3.8+\n- Django\n- `requests` library\n- A valid Telex webhook URL\n\n## Installation\n1. Clone the repository:\n   ```sh\n   git clone https://github.com/yourusername/network-downtime-alerts.git\n   cd network-downtime-alerts\n   ```\n2. Create and activate a virtual environment:\n   ```sh\n   python -m venv venv\n   source venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\n   ```\n3. Install dependencies:\n   ```sh\n   pip install -r requirements.txt\n   ```\n4. Configure environment variables in `.env`:\n   ```env\n   TARGET_URL=https://your-server-url.com\n   TELEX_WEBHOOK_URL=https://your-telex-webhook-url.com\n   ```\n5. Run the Django development server:\n   ```sh\n   python manage.py runserver\n   ```\n\n## API Endpoints\n### 1. Check Network Status\n- **Endpoint:** `/alerts/check/`\n- **Methods:** `GET`, `POST`\n- **Description:** Checks connectivity to the target URL and updates the status.\n- **Response:**\n  ```json\n  { \"status\": \"up\", \"message\": \"Reached https://your-server-url.com\" }\n  ```\n\n### 2. Handle Telex JSON\n- **Endpoint:** `/alerts/integration.json`\n- **Methods:** `GET`\n- **Description:** Returns JSON metadata for Telex integration.\n\n### 3. Configure Webhook\n- **Endpoint:** `/alerts/configure/`\n- **Methods:** `POST`\n- **Description:** Allows dynamic configuration of the target URL.\n- **Request Body:**\n  ```json\n  { \"target_url\": \"https://new-server-url.com\" }\n  ```\n- **Response:**\n  ```json\n  { \"status\": \"success\", \"message\": \"Target URL configured successfully\" }\n  ```\n\n### 4. Interval Settings for Cron Job\n- **Cron Job Endpoint:** `/tick/`\n- **Methods:** `GET`\n- **Description:** Triggers the `check_network_status` function at defined intervals using a cron job.\n- **Functionality:** The cron job will call this endpoint based on the specified schedule to ensure periodic network status checks.\n- **Implementation:** The `/tick/` endpoint executes `check_network_status`, ensuring continuous monitoring. The cron job should be configured to hit this endpoint at the desired interval to automate the network status verification process.\n\n## Testing the Integration\nTo test the integration, you can use **Postman** or `curl` to send requests to the API endpoints:\n\n### Using Postman:\n1. **Open Postman** and create a new request.\n2. **Select `POST`** as the request type.\n3. **Enter the URL**:\n   ```\n   https://telex-network-alerts.onrender.com/alerts/configure/\n   ```\n4. **Go to the \"Headers\" tab** and add:\n   - **Key:** `Content-Type`\n   - **Value:** `application/json`\n5. **Go to the \"Body\" tab**:\n   - Select **raw**\n   - Choose **JSON**\n   - Enter the following JSON data:\n     ```json\n     {\n       \"target_url\": \"https://example.com\"\n     }\n     ```\n6. **Click \"Send\"** to execute the request.\n7. **Expected Response:**\n   ```json\n   {\n     \"status\": \"success\",\n     \"message\": \"Target URL configured successfully\"\n   }\n   ```\n\n### Using `curl`:\nTo test using `curl`, run the following command:\n```sh\ncurl -X POST \"https://telex-network-alerts.onrender.com/alerts/configure/\" \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\"target_url\": \"https://example.com\"}'\n```\n\n### Checking Network Status\nTo manually check the network status, send a `GET` request to:\n```sh\ncurl -X GET \"https://telex-network-alerts.onrender.com/alerts/check/\"\n```\n**Expected Response:**\n```json\n{\n  \"status\": \"up\",\n  \"message\": \"Reached https://your-server-url.com\"\n}\n```\n\n## Deployment\nFor production deployment, configure a WSGI server like Gunicorn:\n```sh\npip install gunicorn\n```\nRun the server:\n```sh\ngunicorn --bind 0.0.0.0:8000 project.wsgi:application\n```\n\n## Author\n- **Name:** Bobbysam\n- **Category:** Monitoring \u0026 Logging\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Ftelex_network_alerts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelexintegrations%2Ftelex_network_alerts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Ftelex_network_alerts/lists"}