summaryrefslogtreecommitdiff
path: root/wininstall/script/nmsclient_shouhu.bat
blob: 3f1e108c5a2dd3a12bc9d5958887eb43525c205f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@ECHO OFF
rem ---------------------------------------------------------------------------
rem Start ShouHu Script for the NMS Client
rem ---------------------------------------------------------------------------

rem Guess NMSCLIENT_HOME if not defined
set "PRG_DIR=%~dp0"


if not "%NMSCLIENT_HOME%" == "" goto gotHome

set "NMSCLIENT_HOME=%PRG_DIR%"
if exist "%NMSCLIENT_HOME%\bin\NMSClient.exe" goto okHome
cd /d %PRG_DIR%\..
set "NMSCLIENT_HOME=%cd%"
cd "%PRG_DIR%"

:gotHome
if exist "%NMSCLIENT_HOME%\bin\NMSClient.exe" goto okHome
echo The NMSCLIENT_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end

:okHome

set "NC_TASKDIR=%1"
set "log_file=%NMSCLIENT_HOME%\temp\job.log"
echo start shouhu at: %DATE% %TIME% NC_TASKDIR:"%NC_TASKDIR%" >> "%log_file%"

:topLoop
			ping -n 50 127.0.0.1>nul
			set procExist=0
			wmic process where name="NMSClient.exe" get name |findstr "NMSClient.exe">nul &&set /a procExist+=1
			echo procExist: "%procExist%"
			if not "%procExist%" == "0" goto toPing
			
			echo Down at: %DATE% %TIME% >> "%log_file%"
			
			:: ---------- handler agent upgrade result
			if not "%NC_TASKDIR%" == "" (
					if exist "%NC_TASKDIR%" (
							cd /d %NC_TASKDIR%
							ren *.upgrade *.result >>"%log_file%" 2>&1
							cd /d %NMSCLIENT_HOME%\bin
					)
			)

			:: ---------- start NC
			echo start NMSClient ... >> "%log_file%"
			net start NMSClient
						
			:toPing
			ping -n 3 127.0.0.1>nul
goto topLoop





rem set XMS_VALUE=32
rem set XMX_VALUE=128
rem if exist "%NMSCLIENT_HOME%\bin\jvm.ini" (
rem		cd /d "%NMSCLIENT_HOME%\bin"
rem		for /f "tokens=1,2 delims==" %%a IN (jvm.ini) Do (
rem			rem echo "Xms"=="%%a"
rem			if "Xms"=="%%a" (
rem		  		set XMS_VALUE=%%b
rem			)
rem			if "Xmx"=="%%a" (
rem					set XMX_VALUE=%%b
rem			)
rem		)
rem	)
rem	set /a XMS_VALUE=%XMS_VALUE%*(1024*1024)
rem	set /a XMX_VALUE=%XMX_VALUE%*(1024*1024)
			
rem	start "" "%NMSCLIENT_HOME%\bin\NMSClient.exe" -Jinitialheap=%XMS_VALUE% -Jmaxheap=%XMX_VALUE%