How to send regular HTTP requests?
Heartbeat monitoring is a great way to monitor intranet servers/computers/devices which are connected to the internet.
And, besides that, it also allows us to monitor the health of the regular actions (cron jobs, background processes..) our website/app/system performs.
It works in an opposite way compared to the other monitoring types as it requires the monitor to send the requests so that Uptime Robot can decide if it is up or down.
And, for sending these regular HTTP requests you can setup:
- Cron jobs (Unix/Linux)
It is needed to use the
crontabcommand for creating and managing crons jobs.
In order to create/edit a cron job:
- connect to the server/computer with SSH
- select the editor of choice from the displayed list
- Append the entry like:
*/5 * * * * wget --spider "https://heartbeat.uptimerobot.com/m1616982-1d6f73e6a50d64d3491db9b3e7009b4af279d1at" >/dev/null 2>&1
by replacing the URL with the URL of the heartbeat monitor and also replacing the
/5part with the interval value of the monitor
- save and close the file (no need to restart)
- Task scheduler (Windows)
This built-in Windows feature allows triggering actions and programs every x minutes. Window's Powershell can easily send HTTP requests and they can both be used in combination to send regular HTTP requests with steps:If you encounter a problem with PowerShell command related security/permission issue – where the task is scheduled to run as an admin with highest privilege, you have to add “-NoProfile -ExecutionPolicy Bypass” in the argument. Otherwise, the task itself will run successfully, but the actual PowerShell command included in the task would fail.
- open the task scheduler app and create a new task
- make sure the task will run even if no user is logged-in:
- create a new trigger that will run every x minutes (where x must be the interval of the monitor):
- create a new action that will run Powershell to send HTTP requests and please enter the values:
- Add Arguments:
>-Command "Invoke-WebRequest https://heartbeat.uptimerobot.com/m1616982-1d6f73e6a50d64d3491db9b3e7009b4af279d1at"(by replacing this URL with the URL of the heartbeat monitor)
- click ok and save the scheduled task