ServiceNav offers 2 service models to allow you to execute your own SQL queries MS-MSSQL-request-integer and MS-MSSQL-request-string.
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 model allows to execute a query that will return a or two columns for one line.
The first column is used to make a comparison with the string searched during the model configuration.
The second column [optional] allows you to display an output text in the operating interface.
Configuration requirements :
Supervisory 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.com/servicenav/fr/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 query
- 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 I don't have a model for this application in ServiceNav, it is nevertheless possible to check the result of the scenario directly in the database.
Using the 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 two 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 we just need to implement it in a ServiceNav service model.
From ServiceNav
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 the Service Model
Instantiate the fields
The query will therefore return 2 columns.
So the control will look for the string "success" in column 1 and display the description in column 2.
Add this service to your equipment that manages the scenarios.
Click on Click Apply and reload its configuration.
Verification of this new model in supervision
In the Supervision / Technical Operation Module
Find its control point and check its operation.