UNPKG

5.09 kBJavaScriptView Raw
1/**
2 * Created by bala on 10/7/15.
3 */
4
5
6const WebSocket = require('ws');
7
8const https = require('https');
9const fs = require('fs');
10
11const server1 = https.createServer({
12// ssl: true,
13 // cert: fs.readFileSync('/home/netstorm/work/nsecom/node_modules/netjsagent/lib/cert.pem'),
14 //key: fs.readFileSync('/home/netstorm/work/nsecom/node_modules/netjsagent/lib/key.pem')
15}).listen(80);
16
17var HOST = 'localhost';
18var PORT = '80';
19
20var server = new WebSocket.Server({server : server1});
21
22console.log('Server listening');
23 server.on('error', function(err) {
24 console.log("@@Error here ---",err)
25 });
26server.on('connection', function(sock) {
27 // console.log(EventEmitter)
28 ;
29 console.log('connected client :' + sock.remoteAddress + 'port' + sock.remotePort);
30
31 sock.send('nd_ctrl_msg_rep:result=Ok;status=NOT_RUNNING;\n');
32 // other stuff is the same from here
33
34 /* setTimeout(function(){
35 sock.write("nd_meta_data_req:action=get_thread_dump;Tier=T1;Server=Server1;Instance=ins1;");
36 },10000);*/
37 sock.on('error', function(err) {
38 console.log("Error here ---",err)
39 })
40 // Add a 'data' event handler to this instance of socket
41 sock.on('message', function(data) {
42
43 console.log('DATA ' + sock.remoteAddress + ': ' + data);
44 if(data.indexOf('nd_ctrl_msg_req:appName=')> -1) {
45 sock.send("nd_control_req:action=start_instrumentation;status=starting;nsWDir=/home/netstorm/work;testIdx=6934;nsStartTimeStamp=1433485149;appName=CAV-NODE;appID=2;tierName=NodeJS;tierID=1;ndAppServerHost=Mew;ndAppServerID=1;ndlPort=0;ndAgentPort=0;ndCollectorIP=10.10.60.6;ndCollectorPort=7892;ndVectorSeparator=>;cavEpochDiff=1388534400;ndFlowpathMasks=0x4000400000000000%200x3fffffffff%208%200xff;instrLog4J=0;collectIndependentQuery=0;NDAppLogFile=NA;ndGenLogCaptureFileList=NA;genNewSQLRecords=1;AppLogTraceLevel=0;instrCPUTime=0;dumpSQLQuery=1;flushInterval=100;bciDataBuffIncreament=0;bciDataBufferMaxCount=512;bciDataBufferMaxSize=32768;socketBufferSize=128;bciUriLogLevel=1;bciUriMaxLength=1024;urlLength=1024;uriQueryLength=1024;bciInstrSessionPct=100;logNonNSFlowpath=0;logNonNSUrlAndQueryRecord=0;bciMaxNonServiceMethodsPerFP=50000;bciMaxServiceMethodsPerFP=5000;logLevelOneFpMethod=1;entryMethodMaxDepth=9999;ctrlConnIdleTimeMaxCount=10;instrProfileContentMaxIdleTime=1;enableBciDebug=4;enableBciError=3;InstrTraceLevel=0;SQLTraceLevel=0;SQLPreparedQueryFilter=SELECT 1 FROM DUAL;SQLNonPreparedQueryFilter=SELECT 1 FROM DUAL;captureHttpTraceLevel=0;captureHTTPReqL1Fp=0;captureHTTPReqFullFp=0;captureHTTPRespL1Fp=0;captureHTTPRespFullFp=0;captureHTTPReqBodyL1Fp=0;captureHTTPReqBodyFullFp=0;captureHTTPRespBodyL1Fp=0;captureHTTPRespBodyFullFp=0;hdrListForValueAsId=Content-Encoding,Host,Server,Transfer-Encoding;NDHTTPReqHdrCfgListFullFp=NA;NDHTTPReqHdrCfgListL1Fp=NA;NDHTTPRepHdrCfgListFullFp=NA;NDHTTPRepHdrCfgListL1Fp=NA;ndHttpHdrCaptureFileList=NA;ASSampleInterval=40;ASThresholdMatchCount=5;ASReportInterval=10000;ASReportDumpMode=1;ASStateReport=1;ASStackComparingDepth=10;enableBackendMonitor=0;enableBTMonitor=0;ASStackCompareOption=1;ASDoNotFilterBlocked=0;ASPositiveThreadFilters=NA;ASNegativeThreadFilter=NA;ASDepthFilter=10;ASTraceLevel=0;ASDataBufferSize=64000;ASDataBufferMaxCount=256;ASDataBufferMinCount=16;ASEnableFPSummaryReport=2;ASResumeDataBuffFreePct=25;ASAllocateDataBuffOnFailure=0;ndMethodMonList=NA;ndMonitorInterval=10000;threadCleanUpCount=5;ndMethodMonTraceLevel=0;HTTPStatsCondCfg=NA;ndHttpCondMonFileList=NA;captureExceptionTraceLevel=0;instrExceptions=1%201%201%209999%201;ndExceptionMonList=NA;ndExceptionFilterList=java.io.InvalidClassException,java.beans.IntrospectionException,weblogic.utils.encoders.CEStreamExhausted,java.security.PrivilegedActionException,weblogic.servlet.jsp.AddToMapException,java.lang.String,atg.core.util.IntStack,atg.beans.DynamicPropertyConverterImpl,java.io.ObjectStreamClass,java.util.Hashtable$Enumerator,java.io.StringReader,java.lang.ClassLoader,atg.service.scheduler.CalendarSchedule,weblogic.utils.encoders.BASE64Decoder,atg.vfs.zip.ZipVirtualFile,java.beans.PropertyDescriptor,weblogic.utils.classloaders.GenericClassLoader,java.lang.Class,com.sun.el.parser.ELParser,sun.misc.FloatingDecimal,com.sun.el.parser.SimpleCharStream,com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException,atg.repository.rql.RqlParser$LookaheadSuccess,java.util.EmptyStackException,java.lang.NoSuchMethodException;setCavNVCookie=1%20CavNV;generateExceptionInMethod=100%20atg.commerce.pricing.priceLists.PriceListManager.getPrice(Latg/repository/RepositoryItem%3BLatg/repository/RepositoryItem%3BLatg;enableNDSession=1%200%201%201%20CavNV%20-%206%2020;nodeServerMonitor=0;enableHSLongStack=2;nodeAsyncEventMonitor=1;corelateEventCallback=1%1")
46 sock.send("\n");
47 }
48 // Write the data back to the socket, the client will receive it as data from the server
49
50 /*setTimeout(function(){
51 sock.write("nd_control_req:action=stop_instrumentation;status=stopping;");
52 },10000);*/
53
54 });
55
56});
57
58exports.module = server;
59
60