Services

Services are scripts or programs executed within a Logscape App. The Service descriptor in the bundle xml file describes

  • Where - the Service will run. On which Logscape component it will execute on
  • When - The Service Descriptor describes what schedule the script or application will execute on.
  • What - will be executed and what arguments will be used. Arguments can be supplied in the bundles xml file or can come from a properties file.

Writing a bundle file

Here are a few examples of how to write a bundle file using the following code as a template

 	<Service>
                <name>UNIX_VMStat_wHOST_wTSTAMP
                       <resourceSelection>osName notContains WINDOWS
               <fork>true
               <background>true
                       <instanceCount>-1
                       <pauseSeconds>60
               <script>bin/vmstat.sh
       </Service>

This service is configured to execute the contents of the script tag every 60s. The number of instances running in the environment can be unlimited and the process will be forked before execution.

Running a Script

Any script can be executed here depending on the operating system being used. On windows, powershell and vbscripts can be used and on Unix like environments the scripts will depend on the installed shell.

<script>bin/vmstat.sh >/script>

Running a Groovy Script

Any groovy script supplied here will be compiled before being executed.

<script>bin/myGroovy.groovy >/script>

Running a Java Program

Java programs of a few lines can also be included in the script tag using a CDATA section.

<script> 
<![CDATA[
	import diff.*
	import com.pushtechnology.diffusion.api.*
	println "\n************************** Starting DiffClientStatsLogger **************************"
	diffHost = (diffHost == null) ? "192.168.71.56" : diffHost
	diffPort = (diffPort == null) ? "3097" : diffPort
      processMaker.java "-cp:lib/diffClient.jar:lib/diffusion.jar" ,  "diff.ClientApplication", diffHost, diffPort, "-Dlog4j.configuration=log4j.properties",  "-Dlog4j.filename=../../work/PushDiffusionApp-1.0/clientStats.log", "-Dlog4j.debug"
	def propertyMissing(String name) {return null}
]]> 
</script>