0% found this document useful (0 votes)
0 views

CPS - Database with MS SQL Server Manual_20191126_EN

The document is a manual for configuring and managing a Conteg Pro Server (CPS) with an external SQL database. It covers preliminary steps for SQL Server setup, including remote access configuration, firewall settings, and enabling SQL authentication. Additionally, it provides instructions for CPS installation, backup and restore procedures, and explanations of database tables related to sensors.

Uploaded by

hola
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

CPS - Database with MS SQL Server Manual_20191126_EN

The document is a manual for configuring and managing a Conteg Pro Server (CPS) with an external SQL database. It covers preliminary steps for SQL Server setup, including remote access configuration, firewall settings, and enabling SQL authentication. Additionally, it provides instructions for CPS installation, backup and restore procedures, and explanations of database tables related to sensors.

Uploaded by

hola
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

CPS – extrernal SQL DB

Conteg Pro Server manual

DATABASE MANUAL EN
Table of Contents
Preliminary steps ..................................................................................................................................... 3
Configuring SQL Server 2008 R2 Express Edition for remote access....................................................... 3
Firewall configuration.......................................................................................................................... 9
Configure the required firewall ports................................................................................................ 12
Configuration options for SQL Server Reporting Services ................................................................. 15
Enabling SQL authentication and sa user for database login ................................................................ 21
To Change the Authentication Mode: ............................................................................................... 21
Notes for SQL Server 2012 and later versions....................................................................................... 26
CPS Installation with MS SQL database ................................................................................................. 27
Backup and restore of the CPS database with MS SQL Server .............................................................. 30
Backing up ......................................................................................................................................... 30
Restoring ........................................................................................................................................... 32
Used ports information ......................................................................................................................... 37
CPS database tables’ explanation for sensors ....................................................................................... 39
Finding sensor data in the CPS database .............................................................................................. 45

2 CPS - DATABASE MANUAL


Preliminary steps
1. Configure SQL Server (including Express Editions) for remote access: enable TCP/IP
protocol and the SQL Server Browser service.
2. Add exceptions in the Windows Firewall for sqlservr.exe and its ports.

We’ll cover these steps below, using this blog as the source for information:

http://akawn.com/blog/2012/01/configuring-sql-server-2008-r2-express-edition-for-remote-
access/

Configuring SQL Server 2008 R2 Express Edition for remote access


Below are the steps to allow remote access to a SQL Server 2008 R2 x64 Express Edition instance
after the default install steps where performed.

Also included are the additional configuration steps for SQL Server 2008 R2 x64 Express Edition with
Advanced Services.

The steps were performed on Windows Server 2008 R2 64bit.

Start the SQL Server Configuration Manager from the Start menu, and choose Services.

CPS - DATABASE MANUAL 3


Find the SQL Server Browser service and set its Start Mode to Automatic, then start it.

4 CPS - DATABASE MANUAL


Next go to Protocols in the Network Configuration, and find TCP/IP.

Below you can see that by default, SQL Server Express allocates a Dynamic port when SQL Server
starts.

You can either keep this setting or change SQL Server to listen on a fixed TCP port e.g. TCP 1433. This
can be achieved by removing 0 from all the ‘TCP Dynamic Ports’ rows and placing the fixed TCP port
you want to use on all the ‘TCP Port’ rows below it.

For this demo we will keep SQL Server allocating a Dynamic port on start-up and therefore we
have not changed anything on this tab.

CPS - DATABASE MANUAL 5


Enable the protocol.

6 CPS - DATABASE MANUAL


Finally, restart the SQL Server service to apply the changes.

Next, open the SQL Server Management Studio.

Connect to SQL Server Express on the server you installed it.

As below you can see the instance when SQL Server Express is installed is called SQLEXPRESS if you
did not change it.

Right click on the server, and select Properties.

The below should already be enabled, but if it isn’t, then enable it and restart the SQL Server service.

CPS - DATABASE MANUAL 7


Check that Allow remote connections to this server is enabled

8 CPS - DATABASE MANUAL


Firewall configuration
If you have the Windows Firewall turned on, you’ll need to do the following steps.

Start the Windows Firewall with Advanced Services configuration:

Add a new rule:

CPS - DATABASE MANUAL 9


Choose the sqlservr.exe

10 CPS - DATABASE MANUAL


Select the network profiles where this rule applies.

Finally, give it a name.

CPS - DATABASE MANUAL 11


Configure the required firewall ports

Choose Port

12 CPS - DATABASE MANUAL


The default port is UDP 1434

CPS - DATABASE MANUAL 13


14 CPS - DATABASE MANUAL
Configuration options for SQL Server Reporting Services
The Firewall Port rule below is required only if you installed SQL Server Express with Advanced
Services and selected the SQL Server Reporting Services feature.

If you changed the HTTP TCP port from the default on 80, then you should enter the port you are
using here.

CPS - DATABASE MANUAL 15


16 CPS - DATABASE MANUAL
These steps show you how to give a user access to Reporting Services.

CPS - DATABASE MANUAL 17


As below, make sure you use localhost and not the name of the SQL Server.

Add the relevant windows user with the permissions they require.

18 CPS - DATABASE MANUAL


Now test that you are able to connect from a remote computer.

CPS - DATABASE MANUAL 19


Below shows a remote connection to Reporting Services. Above we used localhost when on the SQL
Server, but remotely you should use the SQL Server name.

20 CPS - DATABASE MANUAL


Enabling SQL authentication and sa user for database login
For security reasons, the SQL authentication method, and the database administrator sa user is
disabled by default on newer SQL installations.

You have to manually enable them if you wish to use them.

We’ll follow the instructions from this blog entry:

https://sudeeptaganguly.wordpress.com/2010/04/20/how-to-enable-sa-account-in-sql-server/

When you install the SQL Server using Windows Authentication mode, by default, the “sa” account is
disabled. Sometimes, due to users/customers request, you may need to enable the sa account. You
need to change the authentication mode for SQL server from Windows Authentication Mode to SQL
Server and Windows Authentication Mode to use the sa account.

To Change the Authentication Mode:


Follow the steps mentioned below to change the authentication mode from Windows
Authentication to SQL Server and Windows Authentication.

You need to remember that, the SQL Server service needs to restart to make this change effective.

1. Login to the SQL server instance using SQL Server Management Studio.

Right-click on the database instance, and go to Properties.

CPS - DATABASE MANUAL 21


2. On the Server Properties page, Click on Security.

Click on the radio button next to SQL Server and Windows Authentication mode, and click on OK to
close the Server Properties page.

3. Once you clicked on the Ok button, we will get the following screen:

As discussed earlier, we need to restart the SQL Server service to make this change effective.

After restarting the SQL Server, the authentication mode will be changed to SQL Server and Windows
Authentication mode.

22 CPS - DATABASE MANUAL


Enable the sa Login:

1. Connect to the SQL Server instance using SSMS and go to Security. Expand Security, go to Logins.

2. You can see the sa account is disabled when you install SQL Server using Windows Authentication
mode.

3. Right-click on the sa account and go to Login Properties.

Specify a complex password for the sa account.

By default, the Enforce password policy is checked. (if you don’t want to provide a complex password
for the sa account, you can uncheck this option. However, this is not recommended.)

CPS - DATABASE MANUAL 23


4. Click on the Status page.

By default, the sa account will be disabled.

Click on the Enabled button to enable the sa account.

Click on Ok to close the sa Login Properties.

24 CPS - DATABASE MANUAL


Thus, sa account is enabled and you will be able to login to the SQL instance using the sa account.

If you want to use a script to enable the sa account, you can use the script mentioned below:

1: USE [master]
2: GO
3: ALTER LOGIN [sa] WITH PASSWORD=N'z43VGYT@Iu*60i'
4: GO
5: ALTER LOGIN [sa] ENABLE
6: GO

CPS - DATABASE MANUAL 25


Notes for SQL Server 2012 and later versions
SQL Server 2012 only

The configuration process for SQL Server 2012 is the same as with the 2008R2 version, except that
the SQL Server Configuration Manager is not added to the Start menu (in the 2014 version, it’s
added again).

To run it, type SQLServerManager11.msc and proceed with the configuration.

SQL Server 2012 and later

Microsoft has further hardened the permissions of SQL Server, hence the SYSTEM user has less rights
in a default configuration. This can result in the CPS service unable to start automatically.

More information on this link: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/94ff47eb-


a0e0-4441-9799-b56b5ce3712b/sql-server-2012-ntauthoritysystem-sysadmin-is-not-checked-by-
default

As a fix, modify the user’s rights that run the CPS service (by default the SYSTEM user) to include the
sysadmin right:

1. Open the SQL Server Management Studio and login as an SQL administrator.

2. Open the Security/Logins branch.

3. Find the user that runs the CPS service. By default this is the NT AUTHORITY\SYSTEM user.

4. Open the properties, go to the Server Roles page, and click the sysadmin privilege, then press OK.

26 CPS - DATABASE MANUAL


CPS Installation with MS SQL database
Upon installing CPS, at the Database Settings part, choose the External RDBMS option and specify
the following:

RDBMS Name: SQL_SERVER

Server Name: [SERVER_NAME]\[INSTANCE_NAME]

Important: if you’re not using the default DB instance but a named instance, you must specify it,
otherwise the connection will fail!

In our test machine, the SERVER_NAME is Win2008R2 and the INSTANCE_NAME is SQLEXPRESS as
we’ve used the Express version.

Authentication: Windows or SQL. This setting depends on your installed SQL server; by default newer
versions are using the Windows authentication method as default.

Note: if you use SQL authentication, the ODBC connection’s user and password will be saved
(encrypted) in the CPS configuration file server.xml.

Click Next and allow CPS installation to proceed as normal.

Consult the CPS Installation Manual if you need further help.

You can verify that the CPS database has been created in SQL Management Studio, the CPS database
is named “server”:

CPS - DATABASE MANUAL 27


28 CPS - DATABASE MANUAL
The CPS installer creates a 32-bit ODBC system connector. You can verify that this has been created
using the 32-bit ODBC manager: start the ODBC Data Sources (32-bit) from Administrative Tools, or
find the program manually:

On a 64-bit OS, start odbcad32.exe from C:\Windows\SysWOW64; the file in the System32 directory
is the 64-bit version, which can’t show the 32-bit connectors on Windows Server 2008 and R2.

Note: On Windows Server 2012 and up, you will be able to see the data source but can’t modify it
using the 64-bit ODBC manager.

The data source will be added as a System DSN

CPS - DATABASE MANUAL 29


Backup and restore of the CPS database with MS SQL Server
CPS provides the built-in backup/restore function only with the Internal Database option.

If you choose external DB then you’ll have to use that software’s backup/restore functions.

Below we’ll cover the instructions for MS SQL (manual method only).

Backing up

To get a consistent state of the backup, it’s recommended to first stop the CPS services using the
CONTEG Pro Server Manager.

30 CPS - DATABASE MANUAL


Next, start the SQL Management Studio and connect to the DB instance which stores the CPS
databases (server and syslog).

Choose the server DB from the list, and select Tasks / Back Up…

You could modify the backup file’s target, by default it goes to the SQL Server’s Backup directory.

Repeat the same process for the syslog DB.

CPS - DATABASE MANUAL 31


Restoring
Prior to restoring you need to first stop the CPS services using the CPS Server Manager:

Start the SQL Management Studio and connect to the DB instance which stores the CPS databases
(server and syslog).

Right click on the Databases folder tree and select Restore Database…

32 CPS - DATABASE MANUAL


If you’ve made a backup before, you can directly select it from the list.

CPS - DATABASE MANUAL 33


If the server has been reinstalled and there’s no backup history, you’ll need to locate the backup files
manually.

34 CPS - DATABASE MANUAL


Optionally you can relocate the DB files to another directory during the restore, under the Files page.

If you’re just doing a normal restore then this is not needed.

After the DBs have been restored, you can start the CPS service again.

Important note: Renaming the DB instance and the server is not supported! If you attempt to do so,
you’ll get the following error and CPS cannot start:

CPS - DATABASE MANUAL 35


If you need to change the server’s name or the instance name, you’ll need to:

- remove the ODBC connector and uninstall CPS

- remove the existing CPS databases from the SQL server

- reinstall CPS cleanly and reconfigure it

36 CPS - DATABASE MANUAL


Used ports information
The port used for communication between the SQL server and CPS could be checked in the ODBC
connector’s configuration under Control Panel (the 32-bit ODBC app), and choose the CONTEGPro
connector:

The connector is under the System DSN tab. Click on Configure… then Next and choose Client
Configuration…

By default the port is dynamic.

CPS - DATABASE MANUAL 37


The generic CPS port that is used to communicate with Intelligent RAMOS devices is by default 5000
(TCP and UDP).

You can check and change this in the CPS Server Manager program, or under the CPS client Settings
menu / Server Options / Connections.

38 CPS - DATABASE MANUAL


CPS database tables’ explanation for sensors
Below, we’ll explain the database tables in the CPS database which are dealing with sensors.

Note: In MS SQL database, these table names have a prefix dbo. for example: dbo.host

Note 2: We’ve only included the listed reserved/unused values in case you encounter a very old DB
that still has these values; it's not an error if you see them.

Note 3: If the DB has some columns where the data type mismatches with the types written in this
manual (INTEGER or VARCHAR, and length), that could mean you have a DB Sync issue or some other
DB error.

1. host - contains all the network devices (including non- Intelligent RAMOS) under
Monitoring/Sensors in CPS.

hostid (INTEGER, primary key) - CPS DB sequence number, unique for each device

hostuid (INTEGER) - reserved/unused

mac (VARCHAR, 20)- the device’s MAC ID

type (INTEGER) - the device’s type, see below for possible values

name (VARCHAR, 4000)- the device’s IP address or DNS name

port (INTEGER) - SNMP monitoring port - note: the default port is also added for non-SNMP devices

username (VARCHAR, 4000)- SNMP username for the device

community (VARCHAR, 4000) - SNMP community (encoded) for the device

enable (INTEGER) - enabled (1) or disabled (0) device

deleted (INTEGER) - deleted device (1) or live device (0)

Host type possible values:

0 = Unknown Device

1 = Network Device

3 = Ramos Optima

6 = Axis Camera

7 = reserved/unused

8 = reserved/unused

9 = IP Camera

10 = Ramos Ultra

CPS - DATABASE MANUAL 39


13 = Ramos Ultra ACS

14 = Onvif Compatible Camera

15 = Quaddrix IP Camera

16 = reserved for future product

17 = reserved/unused

18 = Template Device

40 CPS - DATABASE MANUAL


2. hostprop - contains the network devices’ property string values, such as device name and
firmware version

hostid (INTEGER, primary key) - matches the hostid in the host table, per unique device

name (VARCHAR, primary key) - each device (hostid) can have multiple properties, these are listed
here - for example: httpport, dhcp_enable, syscontact, firmware_version

value (VARCHAR, 4000) - the string value for each “name” field - following the previous example in
order: 80, 0, System Contact, SEC-MX25V405a

Example:

name value
httpport 80
dhcp_enable 0
syscontact System Contact
firmware_version SEC-MX25V405a

3. board - contains all board devices for each network device (every Intelligent RAMOS device that
has at least a base board) and expansion boards

hostid (INTEGER) - matches the hostid in the host table, per unique device

boardid (INTEGER, primary key) - CPS DB sequence number, unique for each board

board prop id (INTEGER) - remote board id; the boardid in a device's own database, its value will
match the board_ref_id property string in the boardprop table

deleted (INTEGER) - deleted board (1) or live board (0)

property update id (INTEGER) - used for checking that a board’s property is modified or not; it will be
1 for the first time when you add an Intelligent RAMOS device to CPS, and increment when you edit a
board- or sensor’s setting

4. boardprop - contains the boards’ property string values, such as expansion board name and type

boardid (INTEGER, primary key) - matches the boardid in the board table, per unique board

name (VARCHAR, 30, primary key) - each board (boardid) can have multiple properties, these are
listed here - for example: desc, board_enable, type, revision

value (VARCHAR, 4000) - the string value for each “name” field - following the previous example in
order: Main Module, 1, 8, 2

CPS - DATABASE MANUAL 41


Example:

name value
desc Main Module
board_enable 1
type 8
revision 2

Board type possible values:

1 = EX-I8 board

3 = EX-O16 board

4 = 8 sensors base board for Ramos Ultra

8 = Ramos Ultra ACS board

9 = RDU board

10 = EX-D64 board

11 = EX-D128 board

12 = EX-D192 board

5. service - contains information about sensors

hostid (INTEGER) - matches the hostid in the host table, per unique device

serviceid (INTEGER, primary key) - CPS DB sequence number, unique for each sensor

enable (INTEGER) - enabled (1) or disabled (0) sensor

interval (INTEGER) - sensor polling interval (in seconds)

type (INTEGER) - the sensor’s type, see below for possible values

port (INTEGER) - the sensor’s port on a device; it can be physical or virtual, also for daisy chained
sensors

deleted (INTEGER) - deleted sensor (1) or live sensor (0)

boardid (INTEGER) - matches the boardid in the board table, per unique board

rboardid (INTEGER) - remote board id; references the boardid on a remote device and matches the
board_prop_id in the board table, it is used when CPS communicates with an Intelligent RAMOS
device - CPS Server and CPS Client uses the boardid for communication

42 CPS - DATABASE MANUAL


rsensorid (INTEGER) - remote sensor id; references the serviceid on a remote device’s database, it is
used when CPS communicates with an Intelligent RAMOS device - CPS Server and CPS Client uses the
serviceid for communication

mode of reader (INTEGER) - reserved/unused

CPS Server <--> CPS Client uses boardid / sensorid for communication

Device (SEC) <--> CPS Server uses rboardid / rsensorid for communication

Sensor type possible values:

2 = 4-20 mA

3 = Humidity

4 = Water Detector

5 = Digital Voltmeter

6 = Security

8 = Airflow

9 = Siren & Strobe Light

10 = Dry Contact

12 = AC Voltage

13 = Relay

14 = Motion Detector

15 = unused/reserved

16 = External Dry Contact

20 = unused/reserved

21 = unused/reserved

23 = Thermostat

24 = Smoke Detector

25 = Power

26 = RMS Current

27 = RMS Voltage

28 = Watt Meter

CPS - DATABASE MANUAL 43


29 = External Relay

30 = Virtual Sensors

32 = Watt-Hour Meter

33 = Temperature Array

34 = Liquid Rope

35 = Fuel Level - deprecated

36 = Ultrasonic Fuel Level

37 = Door

39 = Reader

40 = Probe Switch

41 = Time Tracking

42 = Tamper

43 = Thermocouple

44 = Dry Contact expander

45 = Vibration

46 = Power Voltage

47 = 5 Input Dry Contact

128 = Sound Detector

129 = Software Motion Detector

132 = No Video Signal

134 = Power Meter

144 = Camera

61696 = Host Status

61697 = SNMP Get

61698 = Custom Script

44 CPS - DATABASE MANUAL


61699 = Multiple Sensors

61701 = Software Motion Detector - deprecated

61702 = Map

61703 = Recording

61704 = Modbus TCP

61706 = Host on Map

6. serviceprop - contains the sensors’ property string values, such as status description and sensor
unit

serviceid (INTEGER, primary key) - matches the serviceid in the service table, per unique sensor

name (VARCHAR, 30, primary key) - each sensor (serviceid) can have multiple properties, these are
listed here - for example: desc, on_desc, normalstate, ping_method

value (VARCHAR, 4000) - the string value for each “name” field - following the previous example in
order: Host Status, Unreachable, 0, 0

Example:

name value
desc Host Status
on_desc Unreachable
normalstate 0
ping_method 0

Finding sensor data in the CPS database


In this example below, we’ll find a test RAMOS OPTIMA unit’s temperature/humidity sensors in the
database.

We’ll use the default SQLite DB format and the SQLite Database Browser program for demonstration
purposes (downloadable from http://sqlitebrowser.org/).

This requires checking 3 database tables: hostid (devices), service (sensor IDs), and serviceprop
(sensor properties).

Note: the default CPS SQLite database is stored at C:\ProgramData\CONTEG\CONTEG Pro


Server\server.db

1. Open server.db file with the browser, and look through the host table to find the RAMOS OPTIMA
device (we looked for its IP address in the name field):

CPS - DATABASE MANUAL 45


Its hostid is 24. Next we’ll look through the service table and find the entries with hostid 24.

46 CPS - DATABASE MANUAL


2. Browse the service table and look for hostid 24:

This hostid has 3 serviceid values: 355, 356, 357. We’ll look for these in the serviceprop table.

3. Browse the serviceprop table and look for the serviceid values:

CPS - DATABASE MANUAL 47


There are multiple matches found for these sensors. These are all the values for the T/HS sensor
connected to this RAMOS OPTIMA.

Based on this information, you can get the serviceid value for a given sensor.

More entries would be present if more sensors are attached to a device.

48 CPS - DATABASE MANUAL


CONTEG, spol. s r.o.
Headquarters: Production plant:
Na Vitezne plani 1719/4 K Silu 2179
140 00 Prague 4 393 01 Pelhrimov
Czech Republic Czech Republic
Tel.: +420 261 219 182 Tel.: +420 565 300 300
[email protected]
www.conteg.com

verze

You might also like