Skip to content

Commit

Permalink
fix labels and add logs for ping
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Jun 6, 2023
1 parent c931698 commit 05199ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dashboard/src/Components/Monitor/MonitorSteps/MonitorStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ const MonitorStepElement: FunctionComponent<ComponentProps> = (
fields = [
{
key: 'monitorDestination',
title: 'Ping URL',
title: 'Ping Hostname or IP Address',
description:
'URL of the resources you would like us to ping.',
'Hostname or IP Address of the resource you would like us to ping.',
fieldType: FieldType.Text,
placeholder: 'No data entered',
},
Expand Down
10 changes: 10 additions & 0 deletions Probe/Utils/Monitors/MonitorTypes/PingMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import URL from 'Common/Types/API/URL';
import IPv4 from 'Common/Types/IP/IPv4';
import IPv6 from 'Common/Types/IP/IPv6';
import PositiveNumber from 'Common/Types/PositiveNumber';
import logger from 'CommonServer/Utils/Logger';
import ping from 'ping';

// TODO - make sure it work for the IPV6
Expand Down Expand Up @@ -30,6 +31,8 @@ export default class PingMonitor {
hostAddress = host.toString();
}

logger.info("Pinging host: " + hostAddress);

try {
const res: ping.PingResponse = await ping.promise.probe(
hostAddress,
Expand All @@ -40,13 +43,20 @@ export default class PingMonitor {
}
);

logger.info("Pinging host "+hostAddress+" success: ");
logger.info(res);

return {
isOnline: res.alive,
responseTimeInMS: res.time
? new PositiveNumber(Math.ceil(res.time as any))
: undefined,
};
} catch (err) {

logger.info("Pinging host "+hostAddress+" error: ");
logger.info(err);

if (!retry) {
retry = 0; // default value
}
Expand Down

0 comments on commit 05199ef

Please sign in to comment.