التركيب

المتطلبات

يلزم وجود قاعدة بيانات PostgreSQL مع مستخدم مسموح له بتعديل كائنات قاعدة البيانات. يجب تثبيت غلاف البيانات الخارجية على نفس مثيل الخادم الذي يعمل عليه خادم قاعدة البيانات.

مثال: إنشاء قاعدة بيانات infosim مملوكة للدور infosim:

export DB_NAME=infosim
mkdir -p /var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/tab_space/${DB_NAME} \
 /var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/idx_space/${DB_NAME} && \
 chown -R postgres:postgres /var/lib/pgsql/custom/user_tblspc
psql -Upostgres -c "CREATE ROLE $DB_NAME WITH LOGIN PASSWORD '$DB_NAME';"
psql -Upostgres -c "CREATE TABLESPACE ${DB_NAME}_tab OWNER $DB_NAME \
LOCATION '/var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/tab_space/$DB_NAME';"
psql -Upostgres -c "CREATE TABLESPACE ${DB_NAME}_idx OWNER $DB_NAME \
LOCATION '/var/lib/pgsql/custom/user_tblspc/${DB_NAME}_tblspc/idx_space/$DB_NAME';"
psql -Upostgres -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_NAME TEMPLATE template0 \
TABLESPACE ${DB_NAME}_tab ENCODING 'UTF8' LC_COLLATE 'de_CH.UTF-8' LC_CTYPE 'de_CH.UTF-8';"

التثبيت القياسي

تثبيت RPM من SKOOR Repo

dnf install eranger-stablenet-fdw

التكوين

ملف التكوين

/etc/stablenet-fdw/stablenet-fdw.conf

[global]

#accept_insecure_certificate = false
                                        # Accept insecure certificates
                                        # (self-signed, expired, etc.)
                                        # when connecting to the StableNet® API.
default_user =
                                        # Default user name for the StableNet® API.
                                        # This is used in case no authorization
                                        # is provided by the SQL client.
default_password =
                                        # Default password for the StableNet® API.
                                        # This is used in case no authorization
                                        # is provided by the SQL client.
#skoor_auth_url = http://localhost:8094
                                        # URL of the SKOOR web service
                                        # (default: http://localhost:8094)
                                        # This is used to get the StableNet®
                                        # auth tokens.
#oracle_client_lib_dir =
                                        # Path to the Oracle client library directory.
                                        # This is used to load the Oracle client library
                                        # for the Oracle database connection.
                                        # If omitted, the thin client is used which might have
                                        # problems connectiong to older Oracle databases.
#percentile_agg_max_buckets = 60
                                        # Maximum number of buckets for the percentile aggregation.
                                        # This controls the trade-off between accuracy and performance.
                                        # When changing this value you have to do a complete resync of
                                        # your measurement data.
                                        # Defaults to 60.
#percentile_agg_max_error = 0.05
                                        # Maximum allowed error for the percentile aggregation.
                                        # This controls the trade-off between accuracy and performance.
                                        # When changing this value you have to do a complete resync of
                                        # your measurement data.
                                        # Defaults to 0.05.
[history_sync]

#days = 365
                                        # Number of days the history data is loaded from the
                                        # StableNet® database when running history_sync.sh.
                                        # Defaults to 365 days.
#start_date =
                                        # Start date for the history data sync. Has to be in ISO-8601 format
                                        # (e.g. 1970-01-01). Takes precedence over days.
#end_date =
                                        # End date (inclusive) for the history data sync. Has to be in ISO-8601 format
                                        # (e.g. 2038-01-19).
                                        # Defaults to today (exclusive).
[database]

#host = localhost
                                        # Hostname of the PostgreSQL database
#port = 5432
                                        # Port of the PostgreSQL database
#database = infosim
                                        # Name of the PostgreSQL database
#user = infosim
                                        # User name of the PostgreSQL database
#password = infosim
                                        # Password of the PostgreSQL database
#schema = stablenet
                                        # Schema of the PostgreSQL database
                                        # (default: stablenet)
#measurement_data_table = stablenet_measurement_data
                                        # Name of the measurement data table
                                        # (default: stablenet_measurement_data)

[retention_days]

#raw = 1
#minutely = 1
#5_minutely = 14
#15_minutely = 31
                                        # ~1 month
#hourly = 93
                                        # ~3 months
#daily = 365
                                        # ~1 years
#weekly = 365
                                        # ~1 years
#monthly = 1825
                                        # ~5 years
#quarterly = 1825
                                        # ~5 years
#yearly = 3650
                                        # ~10 years

[webservice]                            # use te form werbservice_<server_id>
                                        # to configure multiple StableNet® servers
                                        # (see below).

url =
                                        # URL of the StableNet® API
#oauth_token_url =
                                        # URL of the OAuth2 token endpoint.
                                        # Currently, only password grant type is supported.
                                        # As soon as this is set, OAuth2 authentication is used, any provided StableNet
                                        # tokens and default_username/default_password configuration are ignored.
#oauth_client_id =
                                        # OAuth2 client ID.
#oauth_client_secret =
                                        # OAuth2 client secret (sometimes optional).
#oauth_username =
                                        # OAuth2 username.
#oauth_password =
                                        # OAuth2 password.
database_connection =
                                        # Connection string to the StableNet® database.
                                        # This is used for the measurement data sync.
                                        # The connection string must be in the format:
                                        # MySQL: mysql+pymysql://<user>:<password>@<host>:3306/<database>
                                        # Oracle: oracle+oracledb://<user>:<password>@<host>:1521/?service_name=<service>
                                        # Connection info can be found on the StableNet server in
                                        # /opt/stablenet/snmw/wildfly/standalone/configuration/standalone.xml (<datasources>).
                                        # It's usually a good idea to use a different user and service than the one used by StableNet.
#sync_ping_data = true
                                        # Sync ping measurement data from the StableNet® database.
                                        # Defaults to true.
#sync_snmp_data = true
                                        # Sync SNMP measurement data from the StableNet® database.
                                        # Defaults to true.
#sync_usrscript_data = true
                                        # Sync usrscript measurement data from the StableNet® database.
                                        # Defaults to true.
#ping_measurement_filter =
                                        # Filter for the ping measurement.
#snmp_measurement_filter =
                                        # Filter for the SNMP measurement.
#snmp_indexes =
                                        # List of SNMP indexes to be used for the SNMP measurement.
                                        # This is the number part of the metric key, e.g. #1234 -> 1234
#usrscript_measurement_filter =
                                        # Filter for the usrscript measurement.
#usrscript_indexes =
                                        # List of usrscript indexes to be used for the usrscript measurement.
                                        # This is the number part of the metric key, e.g. #1234 -> 1234
#ping_data_table = sn_ping_data
                                        # Name of the ping measurement table in the StableNet® database.
#snmp_data_table = sn_snmp_data
                                        # Name of the SNMP measurement table in the StableNet® database.
#usrscript_data_table = sn_usrscript_data
                                        # Name of the SNMP measurement table in the StableNet® database.

#[webservice_<server_id>]
                                        # Optional, if multiple StableNet® servers
                                        # are used. Replace <server_id> with a unique
                                        # identifier for the StableNet® server.
                                        # Only alphanumeric lowercase characters are allowed.
                                        # Please note, that every webservice section
                                        # must have a unique identifier if multiple
                                        # StableNet® servers are used. if the server_id
                                        # changes, a resync of the measurement data is needed
                                        # because the measurement ID change (<measurment_id>@<server_id>).
                                        # If you have already a webservice configured without server_id,
                                        # then it's recommended to leave the existing webservice without
                                        # server_id and add a new webservice with server_id. This avoids
                                        # a resync of the measurement data.

#server_name =
                                        # Unique name of the connected StableNet®
                                        # server. This should be a human readable
                                        # name, not a technical identifier.
                                        # Defaults to server_id if omitted.
#url =
                                        # URL of the StableNet® the web service

يمكن أيضًا توفير الخيارات بواسطة متغيرات البيئة باستخدام البادئة STABLENET_FDW_WEBSERVICE_ واسم الخيار بأحرف كبيرة (على سبيل المثال STABLENET_FDW_WEBSERVICE_URL). بالنسبة لإعدادات global، يجب حذف GLOBAL من مفتاح ENV (على سبيل المثال STABLENET_FDW_DEFAULT_USER).

url هو عنوان URL الأساسي لخدمة الويب StableNet® API. وعادةً ما يكون على الشكل https://<host>:5443/api/1.

يمكن تعريف مثيلات StableNet® متعددة باستخدام أقسام webservice متعددة مع لاحقات server_id فريدة. يتم استخدام server_id كمعرف داخلي للحصول على سلسلة التفويض المطابقة من SKOOR Auth على سبيل المثال. يجب تعيين server_name مناسب يستخدم لتعريف الخادم في الجداول الخارجية والمجمعة. يمكن أيضًا تكوين هذا باستخدام متغيرات البيئة (على سبيل المثال STABLENET_FDW_WEBSERVICE_URL_TEST ، STABLENET_FDW_WEBSERVICE_SERVER_NAME_TEST).

بعد تغيير التكوين، يجب إعادة تشغيل خادم PostgreSQL.

systemctl restart postgresql-13

تهيئة الجداول الخارجية

تهيئة الجداول الخارجية المطلوبة بواسطة غلاف البيانات الخارجية.

/opt/stablenet-fdw/init-foreign-tables.sh -h <host> -p <port> -d <database> -U <user> -o <owner>

على سبيل المثال

/opt/stablenet-fdw/init-foreign-tables.sh -U postgres -h localhost -p 5432 -d infosim -o infosim

يجب تنفيذ هذا الأمر بعد كل تحديث لـ eranger-stablenet-fdw للحصول على تعريفات الجداول الجديدة.

اختبار الاتصال

psql -h localhost -p 5432 -U infosim -d infosim -c "SELECT * from stablenet.stablenet_info;"

يجب أن يعرض هذا الأمر عدد الأجهزة في مثيل StableNet® المتصل.