From 2e7ea183e63657fcfcc7cfee8f27a27e2ec5d4c4 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Tue, 9 Apr 2024 12:38:56 +0100 Subject: [PATCH] Add InfrastructureAgent files to .gitignore and update daemon management logic in Index.ts --- .gitignore | 7 ++++++- InfrastructureAgent/Index.ts | 13 +++++++++++-- InfrastructureAgent/Jobs/MonitorInfrastructure.ts | 2 +- InfrastructureAgent/README.md | 12 ++++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 56ee656966..aba949a8e3 100644 --- a/.gitignore +++ b/.gitignore @@ -102,4 +102,9 @@ Examples/otel-dotnet/obj/* InfrastructureAgent/sea-prep.blob InfrastructureAgent/InfrastructureAgent -InfrastructureAgent/build/* \ No newline at end of file +InfrastructureAgent/build/* + + +InfrastructureAgent/err.log +InfrastructureAgent/out.log +InfrastructureAgent/daemon.pid \ No newline at end of file diff --git a/InfrastructureAgent/Index.ts b/InfrastructureAgent/Index.ts index f567b32685..5d8b11d8b7 100755 --- a/InfrastructureAgent/Index.ts +++ b/InfrastructureAgent/Index.ts @@ -52,8 +52,8 @@ const returnValue: demandOption: false, }); }, - async (y: any) => { - const argv: ArgumentType = y.argv as ArgumentType; + async (y: yargs.ArgumentsCamelCase) => { + const argv: ArgumentType = y as ArgumentType; // add secrt key and oneuptime url @@ -146,6 +146,15 @@ const returnValue: 'Show status of daemon', () => {}, () => { + // check if daemon.pid file exists + + const doesFileExist: boolean = fs.existsSync('./daemon.pid'); + + if (!doesFileExist) { + Logger.info('OneUptime Infrastructure Agent is not running'); + return; + } + const pid: string | number = fs .readFileSync('./daemon.pid', 'utf-8') .trim(); diff --git a/InfrastructureAgent/Jobs/MonitorInfrastructure.ts b/InfrastructureAgent/Jobs/MonitorInfrastructure.ts index 6e0c7cf699..a4fb8e2863 100644 --- a/InfrastructureAgent/Jobs/MonitorInfrastructure.ts +++ b/InfrastructureAgent/Jobs/MonitorInfrastructure.ts @@ -75,7 +75,7 @@ export default class MonitorInfrastructure { }; Logger.info('Server Monitor Response'); - Logger.info(JSON.stringify(serverMonitorResponse)); + Logger.info(JSON.stringify(serverMonitorResponse, null, 2)); // now we send this data back to server. diff --git a/InfrastructureAgent/README.md b/InfrastructureAgent/README.md index 8fe366ef8a..5856ca3c83 100755 --- a/InfrastructureAgent/README.md +++ b/InfrastructureAgent/README.md @@ -22,6 +22,18 @@ Once its up and running you should see the metrics on the OneUptime Dashboard. oneuptime-infrastructure-agent stop ``` +## Check the status of the agent + +``` +oneuptime-infrastructure-agent status +``` + +## Logs + +``` +oneuptime-infrastructure-agent logs +``` + ## Uninstalling the agent ```