How to write the js function to monitor the Servlet


In this article, I will show / share the demo js code that will be used to monitor the Service Manager servlet, this script was from one Service Manager page: https://www.facebook.com/hpsmbest/?fref=ts

 

function Find(host, port){
var Processes = system.functions.processes(“SYSTEM”)
var PortPattern = new RegExp(“ThreadControllerId-“+port, “g”)
var HostPattern = new RegExp(host, “g”)
for (i=0;i<system.functions.lng(Processes);i++){
var CurrentProcess = Processes[i].toString()
if (CurrentProcess.match(PortPattern) && CurrentProcess.match(HostPattern)){
CurrentProcess=CurrentProcess.split(“, “)
PID = CurrentProcess[5]
return PID
}
}
return false
}
function Kill(host, port){
PID = Find(host,port)
var RetCode
if (PID != false){
paramVals = new SCDatum()
argNames = new SCDatum()
argVals = new SCDatum()

paramVals.setType(8)
argNames.setType(8)
argVals.setType(8)
argNames.push(“name”)
argNames.push(“values”)
argNames.push(“boolean1”)
paramVals.push(“-shutdown”)
paramVals.push(“-PID:”+PID)
argVals.push(“\”E:/Program Files (x86)/HP/Service Manager 9.21/Server/RUN/sm.exe\””)
argVals.push(paramVals)
argVals.push(false)
system.functions.rtecall(“callrad”, RetCode, “us.launch.external.NEW”, argNames, argVals, false)
}
}
function Start(host, port){
Found = Find(host, port)
var RetCode
if (Found==false){
paramVals = new SCDatum()
argNames = new SCDatum()
argVals = new SCDatum()
paramVals.setType(8)
argNames.setType(8)
argVals.setType(8)
argNames.push(“name”)
argNames.push(“values”)
argNames.push(“boolean1”)
paramVals.push(“-httpPort:”+port)
paramVals.push(“-httpsPort:”+(port+1))
paramVals.push(“-debugnode:1”)
paramVals.push(“-soap12binding:0”)
paramVals.push(“-log:../logs/”+host+”.sm_”+port+”.log”)
argVals.push(“\”E:/Program Files (x86)/HP/Service Manager 9.21/Server/RUN/sm.exe\””)
argVals.push(paramVals)
argVals.push(false)
system.functions.rtecall(“callrad”, RetCode, “us.launch.external.NEW”, argNames, argVals, false)
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s