Integración de la tecnología de Aplicación SIKULIX-SCENARIO


ServicePilot application-sikulix-scenario


# SikuliX Scenario

Overview

This package creates an object that can receive SikuliX scenario data over HTTP(S).

Description

ServicePilot can receive indicator data directly from SikuliX scenario scripts over HTTP(S). This package provides the ability to receive a SikuliX scenario execution status, message and run times each time a SikuliX scenario script is run.

Threshold and monitoring policies might need to be applied, depending on the scenarios run.

This package can be cloned and renamed to form the basis of a custom SikuliX scenario data receiver that can be tailored to the scenario parameters expected to be received. In particular if text indicator data is expected then a new package will be needed.

Requirements

  • Network Flows - It is necessary to ensure network connectivity between the SikuliX script and the ServicePilot Manager. In case of a network infrastructure with a firewall, all of the following flows must be opened:

    • ServicePilot Manager Web server access (by default TCP/80 when using HTTP or TCP/443 when using HTTPS although this port is configurable): Between SikuliX script and ServicePilot Manager
  • SikuliX scenario script - A script or program sending data to ServicePilot. Example Jython SikuliX script code is provided in this documentation to add to your SikuliX scripts to send data to ServicePilot in the correct format for this package to receive. In general data needs to sent in the following form:

    • An HTTP GET request with the URL containing http(s)://<ServicePilot Manager IP Address or FQDN>:<ServicePilot Manager Port>/SendData.html?resname=<SikuliX Scenario Resource Name>&o=<SikuliX Scenario Resource Name>&i1=<Value 1>&i2=<Value 2>...
  • ServicePilot Requirements

    • ServicePilot Manager minimum version: 9.0

Installation

Before adding a resource to monitor, make certain that all pre-requisites are in place and that ServicePilot Agent is communicating correctly with the ServicePilot Manager. Resources can be added to ServicePilot configuration using Views Configuration web interface

  1. As an administrative user of ServicePilot, open the ServicePilot web interface.
  2. Navigate to Administration. The Configuration > Views web page will open.
  3. Click on the view in which to place the new resource in the Views hierarchy on the left of the interface. The View editor section will show the existing view contents.
  4. From the Packages list on the right of the interface, click and drag the application-sikulix-scenario package into the View editor and let go.
  5. The Resource properties dialog box will open to allow resource configuration.
  6. Click OK to close the Resource properties dialog box. Note that the dialog box will not close if required parameters are not set.
  7. Click Save to apply the new resource to ServicePilot configuration.
  8. Check if the object has been created in your map and that indicators are populated after the SikuliX scenario is run.

License

Object TypeLicense object ConsumedCondition
SikuliX Scenario1

Notes

The name of the SikuliX scenario resource added is key to the data being received being placed in the correct object. Make certain that each instance of a SikuliX scenario being run has a corresponding SikuliX scenario resource, uniquely named.

If you wish to use the sp_indicator Jython method to send text data then a clone of this package will be required to receive the custom data.

Following is some Jython code that can be included in a SikuliX scenario script to send the correct type of data to ServicePilot. Be sure to set the SP_NUM_INDICATORS value to the total number of indicators that your script will produce:

import urllib2import urllibimport sslimport sys, _socketimport socketimport os############################################ ServicePilot Parameters# HTTPS URL of the ServicePilot Manager and port number if required without the trailing /SP_URL='https://10.1.1.14'# The name of the object that will receive the data in ServicePilot. This is HOSTNAME - SCRIPTNAME by defaultSP_SCN_NAME=socket.gethostname() + ' - ' + os.path.basename(sys.argv[0]).rsplit('.',1)[0]# The number of indicators to be sent to ServicePilot. The count of calls to sp_stats() and sp_indicator(string) up to a maximum of 27.SP_NUM_INDICATORS=2#########################################SP_OUTPUT_FILE='C:\Windows\Temp\\' + SP_SCN_NAME + '.sikuli.txt'print(SP_OUTPUT_FILE)SP_OUTPUT='no output defined'SP_EXITSTATE=0SP_PERFDATA=''SP_STATUSLIST=[ 'OK', 'WARNING', 'CRITICAL', 'UNKNOWN' ]OK=0WARNING=1CRITICAL=2UNKNOWN=3SP_INDICATORS=[SP_STATUSLIST[UNKNOWN], SP_OUTPUT, 0]SP_STAGE=''SP_TIMER=time.time()SP_TOTAL_TIMER=SP_TIMER#def sp_exit(nagios_code, output):   global SP_OUTPUT   global SP_EXITSTATE   global SP_TOTAL_TIMER   global SP_INDICATORS   SP_OUTPUT=output   SP_EXITSTATE=nagios_code   file = open(SP_OUTPUT_FILE, 'w+')   file.write(SP_PERFDATA)   file.write('bin_output:SCN ' + SP_STATUSLIST[SP_EXITSTATE] + ' ' + SP_OUTPUT)   file.close   SP_INDICATORS[0] = SP_STATUSLIST[SP_EXITSTATE]   SP_INDICATORS[1] = SP_OUTPUT   SP_INDICATORS[2] = round(time.time() - SP_TOTAL_TIMER, 3)   full_url = SP_URL + '/SendData.html?resname=' + urllib.quote_plus(SP_SCN_NAME) + '&o=' + urllib.quote_plus(SP_SCN_NAME) + "&a=CustomSikuliAgent"   if len(SP_INDICATORS) - 3 < SP_NUM_INDICATORS:     SP_INDICATORS.extend([''] * (SP_NUM_INDICATORS - len(SP_INDICATORS) + 3))   for index in range(len(SP_INDICATORS)):     full_url += '&i' + str(index+1) + '=' + urllib.quote_plus(str(SP_INDICATORS[index]))   ctx = ssl.create_default_context()   ctx.check_hostname = False   ctx.verify_mode = ssl.CERT_NONE   data = urllib2.urlopen(full_url, context=ctx)   exit(SP_EXITSTATE)#def sp_start_timer(stage):   global SP_STAGE   global SP_TIMER   SP_STAGE = stage   SP_TIMER = time.time()#def sp_stats():   global SP_PERFDATA   global SP_STAGE   global SP_TIMER   global SP_INDICATORS   time_elapsed = round(time.time() - SP_TIMER, 3)   SP_INDICATORS.append((time_elapsed))   SP_PERFDATA +='time_' + SP_STAGE + '_i' + str(len(SP_INDICATORS)) + ':' + str(time_elapsed) + "\n"#def sp_indicator(indicator):   global SP_PERFDATA   global SP_STAGE   global SP_INDICATORS   SP_INDICATORS.append((indicator))   SP_PERFDATA +='time_' + SP_STAGE + '_i' + str(len(SP_INDICATORS)) + ':' + str(indicator) + "\n"## See https://bugs.launchpad.net/sikuli/+bug/1464105 for issue with urlib2 re-useif _socket.NIO_GROUP.isShutdown():   _socket.NIO_GROUP = _socket.NioEventLoopGroup(2, _socket.DaemonThreadFactory("PyScan-Netty-Client-%s"))   sys.registerCloser(_socket._shutdown_threadpool)########################################### Your code here## Start a timer for a sub-section of the scenario# sp_start_timer('load-home-page')## Record the time elapsed between the last sp_start_timer and now# sp_stats()## Send Text (or numerical) indicator data to ServicePilot. A custom package will be needed to receive this data.# sp_indicator('Some text')## Send the scenario results to ServicePilot. Must be called once at the end of the script in both success or failure conditions.# sp_exit(CRITICAL,'Homepage not found') # sp_exit(OK,SP_SCN_NAME + ' SUCCESS')

Cómo podemos ayudarle ?

O llámenos a +33 2 40 60 13 30