ServiceNav offers 2 service models to allow you to run your own MS-MSSQL-request-integer and MS-MSSQL-request-string SQL queries.
By default these templates work with Microsoft SQLServer and Sybase.
We will focus here on the MS-MSSQL-Request-String model.
Using the MS-MSSQL-request-string model
This template allows you to execute a query that will return a or both columns for single line.
The first column is used to perform a comparison with the string searched for when configuring the model.
The second column [optional] is used to display an output text in the operating interface.
Prerequisites for configuration :
Supervision account type MS SQL with the right to run the command on the SQL Server or Sybase instance and database.
File configuration freetds.conf. Consult the documentation : https://coservit.marquedigitale.ovh/documentation/configurer-la-supervision-pour-une-base-ms-sql-server/
Model Parameter :
- The server name: This is the name defined in the freetds.conf file: [LOGIN_NAME]
- The name of the database to be queried
- The SQL query
- The string to search in column 1 of the query result.
- The status to be displayed if the channel is present
- The status to be displayed if the channel is not present
Use Case - Controlling an Application Scenario
Objective: I have an application that manages application scenarios. As there is no model for this application in ServiceNav, it is nevertheless possible to check the scenario result directly in the database.
Using the model MS-MSSQL-request-string present in ServiceNav, create its own service model to supervise its application scenario.
From its SQL server
In the Microsoft SQL Server Management console, prepare your query to return only one row and 2 columns.
select top 1 status, webscriptname from SchedItemResult where webscriptName='ServiceNav - Demo' and DATEDIFF(minute, PollTime, getdate()) < 5 order by PollTime desc;
The result is this.
Here I have a result with the column "status" which will be used to search for the word "success" and the column "webscriptname" which will display the name of the script.
Now you just need to implement it in a ServiceNav service model.
Create a new unit service from the template MS-MSSQL-Query_String
In the Configuration Module / Services Menu / Lists
Click on the Add button
Choose Service Model
Instanciate the fields
The query will therefore return 2 columns.
The control will therefore search for the string "success" in column 1 and display the description in column 2.
Add this service on its equipment that manages scenarios.
Click on Validate and reload its configuration.
Verification of this new model in supervision
In the Supervision / Technical Operation Module
Look for its control point and check its operation.