Allow for performance monitoring
This commit is contained in:
@@ -6,14 +6,14 @@ import axios from "axios";
|
||||
* @param debug Whether to log debug information
|
||||
* @private
|
||||
*/
|
||||
export async function sendHeartbeat(url: string, debug: boolean = false) {
|
||||
export async function sendHeartbeat(url: string, performance?: number, debug: boolean = false) {
|
||||
const useUrl = new URL(url);
|
||||
try {
|
||||
const response = await axios.get(`${useUrl.origin}/${useUrl.pathname}?status=up&msg=OK`);
|
||||
const response = await axios.get(`${useUrl.origin}/${useUrl.pathname}?status=up&msg=OK${performance ? `&ping=${performance}` : ""}`);
|
||||
if (debug)
|
||||
console.log(
|
||||
`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${response.status} ${response.statusText} - ${
|
||||
response.data
|
||||
response.data.toString()
|
||||
}`
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -27,14 +27,14 @@ export async function sendHeartbeat(url: string, debug: boolean = false) {
|
||||
* @param debug Whether to log debug information
|
||||
* @private
|
||||
*/
|
||||
export async function sendShutdownNotification(url: string, msg: string = "Shutdown",debug: boolean = false) {
|
||||
export async function sendDownNotification(url: string, msg: string = "Error",debug: boolean = false) {
|
||||
const useUrl = new URL(url);
|
||||
try {
|
||||
const response = await axios.get(`${useUrl.origin}/${useUrl.pathname}?status=DOWN&msg=${msg}`);
|
||||
if (debug)
|
||||
console.log(
|
||||
`[eu.astrogd.uptime-kuma-push-monitor] (${new Date().toISOString()}) <${url}>: ${response.status} ${response.statusText} - ${
|
||||
response.data
|
||||
response.data.toString()
|
||||
}`
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user