DualPing is a tool designed to continuously ping both your local router and an external IP. When the local router is reachable but the external IP isn't, it's indicative of an internet outage. This tool logs these outages to Google Calendar and sends notifications via Discord.
- Pings the local router and an external IP at regular intervals.
- Logs internet outages to Google Calendar.
- Sends notifications of outages to Discord.
- Easily deployable with Docker.
- Node.js environment.
- A service account with Google Calendar API permissions and its JSON key.
- A Discord webhook URL for notifications.
- Clone this repository.
- Store your Google Service Account's JSON key in the root of this repository as
google.json
. - Update environment variables in
docker-compose.yml
or use an.env
file.
- Build and run the Docker container:
docker-compose up --build
- Once running, it will continuously ping the defined IPs.
- If you're running in TTY mode (
TTY_MODE=true
), pressingt
will push a test event to Google Calendar.
Most of the configuration is done via environment variables:
Variable | Description | Default Value |
---|---|---|
TTY_MODE |
Enable/disable TTY mode. | false |
LOCAL_ROUTER |
IP of the local router to ping. | 8.8.8.8 |
INTERNET_IP |
External IP to ping to determine internet connectivity. | 1.1.1.1 |
DISCORD_WEBHOOK_URL |
The webhook URL for Discord notifications. | (Required) |
CALENDAR_ID |
Google Calendar's ID where outage events will be logged. | default |
LOCATION |
A descriptor for the location of the monitor. | New Location |
PING_COUNT |
Number of failed pings to external IP before logging. | 3 |
-
Google Cloud Console:
- Navigate to Google Cloud Console.
- If you haven't already, create a new project.
-
Enable Google Calendar API:
- In the left sidebar, navigate to
APIs & Services
>Library
. - Search for "Google Calendar API" and select it.
- Click on "Enable" to enable the Google Calendar API for your project.
- In the left sidebar, navigate to
-
Create a Service Account:
- In the left sidebar, navigate to
IAM & Admin
>Service Accounts
. - Click on "Create Service Account".
- Provide a name and description for your service account, then click "Create".
- For the role, select
Project
>Editor
. Continue to the next step. - You don't need to grant users access to this service account, so you can just click "Done".
- In the left sidebar, navigate to
-
Generate JSON Key:
- In the list of service accounts, find the one you just created and click on its name.
- Under the
Keys
tab, click on "Add Key" and selectJSON
. - A JSON key file will be automatically downloaded to your machine. Rename this file to
google.json
.
-
Share Calendar with Service Account:
- Go to Google Calendar.
- Find the calendar you want to use (or create a new one).
- Click on the three dots next to the calendar's name and choose
Settings and sharing
. - Under
Share with specific people
, click on "Add people". - Enter the email of the service account (it will look something like
[email protected]
). - Set the permission to
Make changes to events
or as per your requirement.
-
Place the JSON File:
- Move the
google.json
file to the root directory of your DualPing project.
- Move the
Now your tool is set up to communicate with the Google Calendar API!
If you prefer to run the DualPing natively without Docker, follow these steps:
- Install Node.js and npm (usually comes bundled with Node.js).
- Ensure you have
ping
utility available on your system.
- Clone the Repository:
git clone https://github.com/EpicnessTwo/DualPing cd DualPing
- Install Dependencies:
npm install
- Set Environment Variables:
Create a file named .env in the root of the project and set your environment variables like so:
TTY_MODE=false LOCAL_ROUTER=10.0.0.1 INTERNET_IP=1.1.1.1 DISCORD_WEBHOOK_URL=https://discordapp.com/api/webhooks/xxx/yyy [email protected] LOCATION=New Location Test PING_COUNT=3
- Run the Script:
npm start