Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial work on webhook option. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Initial work on webhook option. #1

wants to merge 1 commit into from

Conversation

nvwx
Copy link

@nvwx nvwx commented Jul 16, 2024

Description

Feature Added:

This pull request adds a feature to retrieve new client connections from Meraki networks within the last 24 hours and send the data to a specified webhook endpoint.

Main Changes:

  1. Fetching Network IDs:

    • Implemented get_network_ids to retrieve network IDs, names, and time zones for the specified organization.
  2. Fetching New Clients:

    • Implemented get_new_clients to fetch clients connected to each network in the last 24 hours based on Unix epoch timestamps.
    • Converted firstSeen timestamps to human-readable format for the JSON output.
  3. Sending Data to Webhook:

    • Implemented send_to_webhook to send the client data to a specified webhook endpoint in JSON format.
  4. Scheduling the Job:

    • Implemented job and main functions to run the process every 15 minutes using the schedule library.

Testing:

  1. Unit Tests:

    • Created unit tests for get_network_ids, get_new_clients, and send_to_webhook using the unittest library.
    • Mocked Meraki Dashboard API calls to ensure the correctness of the implemented functions.
  2. Test Coverage:

    • Verified that timestamps are handled correctly as Unix epoch values and comparisons are done accurately.
    • Ensured that the data sent to the webhook is in the correct format.

Motivation and Context

Why is this feature needed?

  • This feature automates the process of monitoring new client connections to Meraki networks and sending alerts to a specified webhook. This can be useful for network administrators to keep track of new devices connecting to their network in real-time.

What issues does this PR address?

  • Automates the detection and alerting of new client connections to Meraki networks.
  • Provides a structured and automated approach to network monitoring.

Unit Testing:

  • Implemented unit tests to ensure that:
    • Network IDs are correctly retrieved and formatted.
    • New clients are correctly identified based on Unix epoch timestamps.
    • Data sent to the webhook is correctly formatted as JSON.

Manual Testing:

  • Ran the script in a test environment and verified the correct operation by checking the output. I didn't perform an actual request as this is just for training.

Types of Changes:

  • New feature (non-breaking change which adds functionality)
  • Testing (unit tests for the new feature)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant