25.01.2015 Views

Caché Monitoring Guide - InterSystems Documentation

Caché Monitoring Guide - InterSystems Documentation

Caché Monitoring Guide - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Monitoring</strong> <strong>Caché</strong> Using Web Services<br />

SAMPLES>zn "%sys"<br />

%SYS>Set client=##class(SYS.WSMon.Client).%New()<br />

%SYS>Set client.Location="http://localhost:57799/csp/sys/SYS.WSMon.Service.cls"<br />

%SYS>Set myroutinestats=client.GetRoutine()<br />

%SYS>Write myroutinestats.RtnCallsLocal<br />

19411581<br />

%SYS>Write myroutinestats.RtnCallsRemote<br />

0<br />

%SYS>Write myroutinestats.RtnCommands<br />

432764817<br />

%SYS><br />

More typically, you create and use the client programmatically, perhaps to retrieve data for display in a user interface.<br />

Note:<br />

Remember that the SYS.WSMon package is available only in %SYS namespace, which means that you must be<br />

in that namespace to perform the steps described here.<br />

D.6 Processing Events<br />

<strong>Caché</strong> provides a sample web service (SYS.WSMon.EventSink) that can receive and process events sent by any <strong>Caché</strong><br />

<strong>Monitoring</strong> Web Service. You can use this web service or create and use your own.<br />

D.6.1 Using the Sample Event Sink Web Service<br />

SYS.WSMon.EventSink is a sample <strong>Caché</strong> web service that can receive and process events.<br />

For a given <strong>Caché</strong> instance, the <strong>Caché</strong> <strong>Monitoring</strong> Web Service is available at the following URL:<br />

http://server:port/csp/sys/SYS.WSMon.EventSink.cls<br />

Where server is the server on which <strong>Caché</strong> is running and port is the port that the <strong>Caché</strong> web server uses.<br />

This web service has one method:<br />

CacheEventSink()<br />

Method CacheEventSink(event As SYS.WSMon.wsEvent) As %Integer<br />

On Windows platforms, this sample method displays a popup window when an event occurs; for other platforms,<br />

it adds an entry to ^SYS("MONITOR","WSMON","EVENT_RECEIVED",$h).<br />

This method always returns 1.<br />

To subscribe this sample service so that it will receive events from the <strong>Monitoring</strong> Web Service, do the following in the<br />

Terminal:<br />

SER>zn "%sys"<br />

%SYS>Set client=##class(SYS.WSMon.Client).%New()<br />

%SYS>Set eventsinklocation="http://localhost:57772/csp/sys/SYS.WSMon.EventSink.cls"<br />

%SYS>Set subscriptionid=client.EventSubscribe(eventsinklocation)<br />

%SYS>Write subscriptionid<br />

CacheEventSubscription_2<br />

Here eventsinklocation is the URL for the event sink web service that will process events.<br />

128 <strong>Caché</strong> <strong>Monitoring</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!