REM -------------------------------------------------------------------------
REM  #Description.............: Organices start JFProcessMonitor.exe
REM  #New.....................: 16.10.2024/J.Fes
REM  #LUp.....................: 26.11.2025/J.Fes in work not jet ready for use
REM -------------------------------------------------------------------------
REM  #EXA.....................: Call PMonManage.cmd "D:Start:Yes" "#ProcessName#" "#LogFile_NE#"
REM -------------------------------------------------------------------------
if not defined JobMgr_PMon_use set JobMgr_PMon_use=ON
if not defined JobMgr_PMon_Txt set JobMgr_PMon_Txt=%JobName%

set PMon_Action=%~1
set PMon_processName_p=%~2

if "%JobMgr_PMon_use%" equ "ON" call :PMonUseYes

goto :PMonUseNo

:PMonUseYes
REM  Call Echo2 "--# #Step:Activate PMON --------------------------------------------"
 Call Echo2 "--- #Step Start PMon:Yes" "%JobMgr_PMon_Txt%"
 Call :SetPmon "%CmdCurRoot_DP%\%JobTemp_TP%"
  if /i "%JobMgr_WIMode%" equ "Normal" (
    start "PMon Job:[%JobName%][%TcSiteId%]" %toMon%
  ) else (
    start "PMon Job:[%JobName%][%TcSiteId%]" %toMon%
  )
 goto :eof :next

:PMonUseNo
 Call Echo2 "--# #Doc:PMON Use:NO -----------------------------------------------"
 Call Echo2 "--# Setp:Start PMon:NO..........: %JobMgr_PMon_Txt%"
 goto :next

goto :eof


:SetPmon
 set temp=%~1
 set tmp=%temp%
 if not exist "%temp%" md "%temp%"

 set PMon_exeL_DPNE=%BinL_DP%\JFProcessMonitor.exe
 set PMon_SysLog_DPNE=%temp%\zzPLMPerf1_PMon_sys.log
 set PMon_ResultXml_DPNE=%temp%\zzPLMPerf2_PMon_Result.xml

	set toMon=%PMon_exeL_DPNE%
 set toMon=%toMon% --titlePrefix "JobMon:[%JobName%][Step:%JobMgr_PLMPerfStepNo%][Start:%Date%/%time:~0,8%]"
 set toMon=%toMon% --processName "%PMon_processName_p%"
 set toMon=%toMon% --waitForProcess 150000
 set toMon=%toMon% --parentProcessId 0
rem	set toMon=%toMon% --killChildProcesses
REM 	set toMon=%toMon% --killChildProcesses
 set toMon=%toMon% --fileLastWriteTime "%temp%\*.*;600"
 set toMon=%toMon% --tailTextFile "%temp%\%username%*.syslog"
 set toMon=%toMon% --duraTimeSpanIfGreaterThen 1000
 set toMon=%toMon% --tailForceMilliseconds "500"
 set toMon=%toMon% --tailTextFile_log "%PMon_SysLog_DPNE%"
	set toMon=%toMon% --saveResultsTo "%PMon_ResultXml_DPNE%"
 rem set toMon=%toMon% --runtimeLimitSeconds 600
 Call Echo2 "Perf.P.Mon use setting..........: 16.02.2024"
goto :eof

