Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
silviugd committed Oct 31, 2018
1 parent ece7bb3 commit c95bd44
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 15 deletions.
32 changes: 32 additions & 0 deletions configure.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@echo off

SET /P serverkey=Enter Server Key:
SET /P gateway=Enter Gateway Address:

goto check_Permissions

:check_Permissions

net session >nul 2>&1
if %ERRORLEVEL% == 0 (


echo Removing previous nMon Agent Service
net stop "nMon Agent"
%~dp0nodejs\node.exe %~dp0service.js --remove


echo Configuring nMon Agent Service
%~dp0nodejs\node.exe %~dp0service.js --add %serverkey% %gateway%

echo Starting nMon Agent Service
net start "nMon Agent"

echo Done

) else (
echo Failure: Administrative permissions required.
echo Right click on this file and select "Run as administrator".
)

pause >nul
1 change: 0 additions & 1 deletion gateway.txt

This file was deleted.

Binary file added icon.ico
Binary file not shown.
10 changes: 6 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ function intervalFunc() {
post_data = post_data + "{agent_version}" + agent_version + "{/agent_version}";

// serverkey
serverkey_file = fs.readFileSync(path.join(__dirname, 'serverkey.txt'));
serverkey = serverkey_file.toString();
//serverkey_file = fs.readFileSync(path.join(__dirname, 'serverkey.txt'));
//serverkey = serverkey_file.toString();
serverkey = process.argv[2];
post_data = post_data + "{serverkey}" + serverkey + "{/serverkey}";

// gateway
gateway_file = fs.readFileSync(path.join(__dirname, 'gateway.txt'));
gateway = gateway_file.toString();
//gateway_file = fs.readFileSync(path.join(__dirname, 'gateway.txt'));
//gateway = gateway_file.toString();
gateway = process.argv[3];
post_data = post_data + "{gateway}" + gateway + "{/gateway}";

// time #TBD
Expand Down
1 change: 0 additions & 1 deletion nmon-agent.log

This file was deleted.

23 changes: 23 additions & 0 deletions remove.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@echo off

goto check_Permissions

:check_Permissions

net session >nul 2>&1
if %ERRORLEVEL% == 0 (

echo Stopping nMon Agent Service
net stop "nMon Agent"

echo Removing nMon Agent Service
%~dp0nodejs\node.exe %~dp0service.js --remove

echo Done

) else (
echo Failure: Administrative permissions required.
echo Right click on this file and select "Run as administrator".
)

pause >nul
1 change: 0 additions & 1 deletion serverkey.txt

This file was deleted.

2 changes: 0 additions & 2 deletions service-add.cmd

This file was deleted.

2 changes: 0 additions & 2 deletions service-remove.cmd

This file was deleted.

7 changes: 3 additions & 4 deletions service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
** Change to the examples directory so this program can run as a service.
**/

process.chdir(__dirname);

var fs = require ("fs");
Expand All @@ -19,8 +17,9 @@ if (process.argv[2] == "--add") {
name: "nMon Agent",
nodePath: path.join(__dirname, "nodejs", "node.exe"),
programPath: path.join(__dirname, "main.js"),
programArgs: [process.argv[3], process.argv[4]]



};

service.add ("nMon Agent", options, function(error) {
Expand Down

0 comments on commit c95bd44

Please sign in to comment.