From: ktimoney Date: Fri, 18 Aug 2023 08:08:04 +0000 (+0100) Subject: Add pmlog to RANPM docker-compose X-Git-Tag: 1.1.0~21 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F50%2F11650%2F1;p=nonrtric%2Fplt%2Franpm.git Add pmlog to RANPM docker-compose Issue-ID: NONRTRIC-903 Change-Id: I2ca916c4474b66e973f8c6188341e7fb845acc80 Signed-off-by: ktimoney --- diff --git a/docker-proj/README.md b/docker-proj/README.md index 4ecffd1..1a6cf9e 100644 --- a/docker-proj/README.md +++ b/docker-proj/README.md @@ -42,6 +42,19 @@ If the script fails, make sure to clean the setup before attempting a new setup. In addition, a `docker system prune` might be needed now and then. +### PM Influx Logger +Additionally you can install PM influx logger. + +Example cmd: \ +`./pmlog-setup.sh` + +To remove run: +`./pmlog-tear-down.sh` + +To update the filter edit and run: +`./update-pmlog.sh` + + ### Tools for monitoring Open browser to redpanda (kafka gui) - watch topics, messages etc\ diff --git a/docker-proj/config/https/template-files/pm-template.xml.gz b/docker-proj/config/https/template-files/pm-template.xml.gz new file mode 100644 index 0000000..517be24 Binary files /dev/null and b/docker-proj/config/https/template-files/pm-template.xml.gz differ diff --git a/docker-proj/config/pmlog/application.yaml b/docker-proj/config/pmlog/application.yaml new file mode 100644 index 0000000..7e9fbc5 --- /dev/null +++ b/docker-proj/config/pmlog/application.yaml @@ -0,0 +1,109 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +spring: + profiles: + active: prod + main: + allow-bean-definition-overriding: true + aop: + auto: false +management: + endpoints: + web: + exposure: + # Enabling of springboot actuator features. See springboot documentation. + include: "loggers,logfile,health,info,metrics,threaddump,heapdump,shutdown" + endpoint: + shutdown: + enabled: true +lifecycle: + timeout-per-shutdown-phase: "20s" +springdoc: + show-actuator: true +logging: + # Configuration of logging + level: + ROOT: WARN + org.apache.kafka: WARN + org.springframework: ERROR + org.springframework.data: TRACE #ERROR + org.springframework.web.reactive.function.client.ExchangeFunctions: TRACE #ERROR + org.oran.pmlog: TRACE #DEBUG + pattern: + console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger{20} - %msg%n" + file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger{20} - %msg%n" + + file: + name: /var/log/pmlog-service/application.log +server: + # Configuration of the HTTP/REST server. The parameters are defined and handeled by the springboot framework. + # See springboot documentation. + port : 8436 + http-port: 8084 + ssl: + key-store-type: JKS + key-store-password: policy_agent + key-store: /opt/app/pmlog-service/etc/cert/keystore.jks + key-password: policy_agent + key-alias: policy_agent + shutdown: "graceful" +app: + webclient: + # Configuration of the trust store used for the HTTP client (outgoing requests) + # The file location and the password for the truststore is only relevant if trust-store-used == true + # Note that the same keystore as for the server is used. + trust-store-used: false + trust-store-password: policy_agent + trust-store: /opt/app/pmlog-service/etc/cert/truststore.jks + # Configuration of usage of HTTP Proxy for the southbound accesses. + # The HTTP proxy (if configured) will only be used for accessing NearRT RIC:s + http.proxy-host: + http.proxy-port: 0 + kafka: + # KAFKA boostrap servers. + # several redundant boostrap servers can be specified, separated by a comma ','. + # bootstrap-servers and input-topic is overriden if defined in deliveryInfo in config/jobDefinition.json + bootstrap-servers: kafka-1:9097 + input-topic: + # The maximum number of records returned in a single call to poll() (default 100) + max-poll-records: 500 + group-id: kafkaGroupId + client-id: kafkaClientId + # Configues if oath2 tokens shall be used. If set to true, auth-token-file must also be configured + use-oath-token: true + ssl: + key-store-type: PEM + key-store-location: + # key password is needed if the private key is encrypted + key-store-password: + trust-store-type: PEM + trust-store-location: + influx: + url: http://influxdb2-0:8086 + # Override by env var + access-token: + bucket: pm-logg-bucket + org: est + # The user, password and database can be blank if the access-token is defined + user: + password: + database: + ics-base-url: http://ics:8083 + consumer-job-id: "pmlog" + # If the file name is empty, no authorization token is used + auth-token-file: /token-cache/jwt.txt diff --git a/docker-proj/config/pmlog/jobDefinition.json b/docker-proj/config/pmlog/jobDefinition.json new file mode 100644 index 0000000..517332d --- /dev/null +++ b/docker-proj/config/pmlog/jobDefinition.json @@ -0,0 +1,23 @@ +{ + "info_type_id": "PmData", + "job_owner": "console", + "job_definition": { + "filter": { + "sourceNames": [], + "measObjInstIds": [], + "measTypeSpecs": [ + { + "measuredObjClass": "NRCellDU", + "measTypes": [ + "pmCounterNumber108" + ] + } + ], + "measuredEntityDns": [] + }, + "deliveryInfo": { + "topic": "pmreports", + "bootStrapServers": "kafka-1:9097" + } + } +} diff --git a/docker-proj/config/pmlog/token-cache/jwt.txt b/docker-proj/config/pmlog/token-cache/jwt.txt new file mode 100644 index 0000000..e69de29 diff --git a/docker-proj/docker-compose-influxdb.yaml b/docker-proj/docker-compose-influxdb.yaml new file mode 100644 index 0000000..fab9475 --- /dev/null +++ b/docker-proj/docker-compose-influxdb.yaml @@ -0,0 +1,40 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +version: '3.0' +networks: + default: + external: true + name: nonrtric-docker-net + +services: + $INFLUXDB2_INSTANCE: + image: $INFLUXDB_IMAGE + container_name: $INFLUXDB2_INSTANCE + environment: + DOCKER_INFLUXDB_INIT_MODE: setup + DOCKER_INFLUXDB_INIT_USERNAME: $INFLUXDB2_USERNAME + DOCKER_INFLUXDB_INIT_PASSWORD: $INFLUXDB2_PASSWORD + DOCKER_INFLUXDB_INIT_ORG: $INFLUXDB2_ORG + DOCKER_INFLUXDB_INIT_BUCKET: $INFLUXDB2_BUCKET + volumes: + - ./config/influxdb2/data:/var/lib/influxdb2:rw + ports: + - 8086:8086 + labels: + - "ranpm=yes" + - "ranpmlog=yes" diff --git a/docker-proj/docker-compose-pm-https.yaml b/docker-proj/docker-compose-pm-https.yaml index bf1417f..e50da91 100644 --- a/docker-proj/docker-compose-pm-https.yaml +++ b/docker-proj/docker-compose-pm-https.yaml @@ -24,11 +24,15 @@ networks: services: pm-https-server-${CONTAINER_NUM}: container_name: pm-https-server-${CONTAINER_NUM} + hostname: pm-https-server-${CONTAINER_NUM} image: $PM_HTTPSSERVER_IMAGE environment: - ALWAYS_RETURN: /files/pm.xml.gz + ALWAYS_RETURN: /ne-files/pm.xml.gz + GENERATED_FILE_START_TIME: "${START_TIME}" + GENERATED_FILE_TIMEZONE: "+0100" volumes: - - ./ne-files:/files:rw + - ./ne-files:/ne-files:rw + - ./config/https/template-files:/template-files - ./config/https/certs/https-${CONTAINER_NUM}.key:/certs/server.key - ./config/https/certs/https-${CONTAINER_NUM}.crt:/certs/server.crt labels: diff --git a/docker-proj/docker-compose-pmlog.yaml b/docker-proj/docker-compose-pmlog.yaml new file mode 100644 index 0000000..fab7767 --- /dev/null +++ b/docker-proj/docker-compose-pmlog.yaml @@ -0,0 +1,55 @@ +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +version: '3.0' +networks: + default: + external: true + name: nonrtric-docker-net + +services: + auth-token-file-pmlog-0: + image: $AUTH_TOKEN_IMAGE + environment: + CREDS_GRANT_TYPE: client_credentials + CREDS_CLIENT_SECRET: $PMLOG_CLIENT_SECRET + CREDS_CLIENT_ID: nrt-pm-log + AUTH_SERVICE_URL: http://keycloak:8080/realms/nonrtric-realm/protocol/openid-connect/token + OUTPUT_FILE: /token-cache/jwt.txt + volumes: + - ./config/pmlog/token-cache:/token-cache + labels: + - "ranpm=yes" + - "ranpmlog=yes" + + pmlog-0: + image: $PMLOG_IMAGE + container_name: pmlog-0 + depends_on: + - auth-token-file-pmlog-0 + environment: + APP_INFLUX_ACCESSTOKEN: $INFLUXDB2_TOKEN + volumes: + - ./config/pmlog/jobDefinition.json:/opt/app/pmlog-service/config/jobDefinition.json + - ./config/pmlog/application.yaml:/opt/app/pmlog-service/config/application.yaml + - ./config/pmlog/token-cache:/token-cache + ports: + - 8184:8084 + - 8436:8436 + labels: + - "ranpm=yes" + - "ranpmlog=yes" diff --git a/docker-proj/docker-compose-producers.yaml b/docker-proj/docker-compose-producers.yaml index a1df4b8..8fdbb9b 100644 --- a/docker-proj/docker-compose-producers.yaml +++ b/docker-proj/docker-compose-producers.yaml @@ -62,6 +62,8 @@ services: pm-producer-json2kafka: image: $DMAAPADP_IMAGE container_name: pm-producer-json2kafka + environment: + APP_PM-PRODUCER-BASE-URL: http://pm-producer-json2kafka:8084 depends_on: - auth-token-file-pm-producer-json2kafka volumes: diff --git a/docker-proj/docker-setup.sh b/docker-proj/docker-setup.sh index bee4bcd..bca0281 100755 --- a/docker-proj/docker-setup.sh +++ b/docker-proj/docker-setup.sh @@ -17,7 +17,6 @@ # ============LICENSE_END================================================= # -echo $SP print_usage() { echo "Usage: docker-setup.sh" exit 1 @@ -198,7 +197,7 @@ for (( i=1; i<=$NUM_DFC; i++ )); do done cd $cwd -chmod 622 config/dfc1/token-cache/jwt.txt +chmod 666 config/dfc1/token-cache/jwt.txt envsubst < docker-compose-dfc1.yaml > docker-compose-dfc_gen.yaml envsubst < config/dfc1/application-template.yaml > config/dfc1/application.yaml docker-compose -p dfc -f docker-compose-dfc_gen.yaml up -d @@ -206,11 +205,11 @@ docker-compose -p dfc -f docker-compose-dfc_gen.yaml up -d setup_producers() { echo "Starting producers" -chmod 622 config/pmpr/token-cache/jwt.txt +chmod 666 config/pmpr/token-cache/jwt.txt +export KPADP_MINIO=http://minio-server:9000 cp config/pmpr/application_configuration-minio-template.json config/pmpr/application_configuration.json envsubst < config/pmpr/application-minio-template.yaml > config/pmpr/application.yaml -export KPADP_MINIO=http://minio-server:9000 envsubst < docker-compose-producers.yaml > docker-compose-producers_gen.yaml docker-compose -p prod -f docker-compose-producers_gen.yaml up -d } @@ -227,15 +226,21 @@ cp pm-files/pm* ne-files echo "Starting http servers" export PM_HTTPSSERVER_IMAGE="pm-https-server:latest" -grep -B 21 "services:" docker-compose-pm-https.yaml > docker-compose-pm-https_gen.yaml +total_lines=$(cat docker-compose-pm-https.yaml | wc -l) +services_line=$(grep -n "services:" docker-compose-pm-https.yaml| cut -f1 -d:) +let remaining_lines=$total_lines-$services_line +export START_TIME=$(date +%Y%m%d.%H%M -d '3 hours ago') + +grep -B $services_line "services:" docker-compose-pm-https.yaml > docker-compose-pm-https_gen.yaml for (( i=1; i<=$NUM_HTTP; i++ )); do export CONTAINER_NUM=$i - grep -A 12 "services:" docker-compose-pm-https.yaml | grep -v "services:" | \ - envsubst '$CONTAINER_NUM,$PM_HTTPSSERVER_IMAGE' >> docker-compose-pm-https_gen.yaml + grep -A $remaining_lines "services:" docker-compose-pm-https.yaml | grep -v "services:" | \ + envsubst '$CONTAINER_NUM,$PM_HTTPSSERVER_IMAGE,$START_TIME' >> docker-compose-pm-https_gen.yaml done docker-compose -p pm-https -f docker-compose-pm-https_gen.yaml up -d } +## Main ## export KAFKA_NUM_PARTITIONS=10 export TOPICS="file-ready collected-file json-file-ready-kp json-file-ready-kpadp pmreports" diff --git a/docker-proj/pmlog-setup.sh b/docker-proj/pmlog-setup.sh new file mode 100755 index 0000000..b34ee93 --- /dev/null +++ b/docker-proj/pmlog-setup.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +. scripts/get_influxdb2_token.sh +. scripts/populate_keycloak.sh + +print_usage() { + echo "Usage: pmlog-setup.sh" + exit 1 +} + +check_error() { + if [ $1 -ne 0 ]; then + echo "Failed $2" + echo "Exiting..." + exit 1 + fi +} + +setup_init() { +echo "Cleaning previously started containers..." + +./pmlog-tear-down.sh +} + +pull_image() { +if [ -z "$(docker images -q $1)" ]; then + echo "Pulling image... "$1 + docker pull $1 + check_error $? +fi +} + +check_images(){ +export INFLUXDB_IMAGE="influxdb:2.6.1" +pull_image $INFLUXDB_IMAGE + +export PMLOG_IMAGE="nexus3.o-ran-sc.org:10001/o-ran-sc/nonrtric-plt-pmlog:1.0.0" +pull_image $PMLOG_IMAGE + +export AUTH_TOKEN_IMAGE=nexus3.o-ran-sc.org:10001/o-ran-sc/nonrtric-plt-auth-token-fetch:1.1.1 +pull_image $AUTH_TOKEN_IMAGE +} + +setup_influx() { +data_dir=./config/influxdb2/data +mkdir -p $data_dir + +export INFLUXDB2_INSTANCE=influxdb2-0 +export INFLUXDB2_USERNAME=admin +export INFLUXDB2_PASSWORD=mySuP3rS3cr3tT0keN +export INFLUXDB2_ORG=est +export INFLUXDB2_BUCKET=pm-logg-bucket + +envsubst < docker-compose-influxdb.yaml > docker-compose-influxdb_gen.yaml +docker-compose -p influx -f docker-compose-influxdb_gen.yaml up -d +} + +setup_pmlog() { +chmod 666 config/pmlog/token-cache/jwt.txt + +cid="nrt-pm-log" +create_clients nonrtric-realm $cid +check_error $? +generate_client_secrets nonrtric-realm $cid +check_error $? + +export PMLOG_CLIENT_SECRET=$(< .sec_nonrtric-realm_$cid) +envsubst < docker-compose-pmlog.yaml > docker-compose-pmlog_gen.yaml +docker-compose -p pmlog -f docker-compose-pmlog_gen.yaml up -d +} +## Main ## +setup_init + +check_images + +setup_influx +check_error $? + +# Wait for influxdb2 to start +echo 'Waiting for influxdb2 to be ready' +until [ $(curl -s -w '%{http_code}' -o /dev/null 'http://localhost:8086/health') -eq 200 ]; +do + echo -n '.' + sleep 1 +done +echo "" + +INFLUXDB2_TOKEN=$(get_influxdb2_token $INFLUXDB2_INSTANCE) +echo $INFLUXDB2_TOKEN +export INFLUXDB2_TOKEN + +setup_pmlog +check_error $? diff --git a/docker-proj/pmlog-tear-down.sh b/docker-proj/pmlog-tear-down.sh new file mode 100755 index 0000000..5e67d92 --- /dev/null +++ b/docker-proj/pmlog-tear-down.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +echo "Stop and remove all pmlog containers in the project" + +docker stop $(docker ps -qa --filter "label=ranpmlog") 2> /dev/null +docker stop $(docker ps -qa --filter "label=ranpmlog") 2> /dev/null +docker rm -f $(docker ps -qa --filter "label=ranpmlog") 2> /dev/null + +docker-compose -f docker-compose-pmlog_gen.yaml -p pmlog down +docker-compose -f docker-compose-influxdb_gen.yaml -p influx down + + +data_dir=./config/influxdb2/data +if [[ -e $data_dir ]]; then + rm -rf $data_dir +fi diff --git a/docker-proj/scripts/get_influxdb2_token.sh b/docker-proj/scripts/get_influxdb2_token.sh new file mode 100755 index 0000000..2911ea1 --- /dev/null +++ b/docker-proj/scripts/get_influxdb2_token.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +# args: +get_influxdb2_token() { + if [ $# -ne 1 ]; then + echo"get_influxdb2_token needs 1 arg, " $@ + exit 1 + fi + + __influxdb2_access_token="" + while [ -z "$__influxdb2_access_token" ]; do + export __influxdb2_access_token=$(docker exec $1 influx config ls --json | jq -r .default.token) + if [ $? -ne 0 ]; then + __influxdb2_access_token="" + sleep 1 + fi + done + echo -n $__influxdb2_access_token + return 0 +} diff --git a/docker-proj/scripts/kafka-client-send-file-ready.sh b/docker-proj/scripts/kafka-client-send-file-ready.sh index 3a39719..12f95e0 100755 --- a/docker-proj/scripts/kafka-client-send-file-ready.sh +++ b/docker-proj/scripts/kafka-client-send-file-ready.sh @@ -28,6 +28,8 @@ NODE_NAME_BASE=$3 FILE_EXT=$4 SRV_COUNT=$5 +HTTPS_PORT=443 + print_usage() { echo "Usage: kafka-client-send-file-ready.sh " exit 1 @@ -37,7 +39,8 @@ if [ $# -lt 5 ]; then print_usage fi -BEGINTIME=1665146700 +BEGINTIME=$(date +%s -d '1 hour ago') +TIMEZONE="+0100" CURTIME=$BEGINTIME BATCHSIZE=1000 @@ -54,8 +57,10 @@ for (( i=0; i<$EVT_COUNT; i++)); do echo "EVENT NO: $i for $NODE_COUNT NODES - 1 FILE PER EVENT" + let STTIMEMS=$CURTIME*1000000 ST=$(date -d @$CURTIME +'%Y%m%d.%H%M') let CURTIME=CURTIME+900 + let CURTIMEMS=$CURTIME*1000000 ET=$(date -d @$CURTIME +'%H%M') for (( j=0; j<$NODE_COUNT; j++)); do @@ -70,8 +75,8 @@ for (( i=0; i<$EVT_COUNT; i++)); do echo "FILENAME "$FN SRV="pm-https-server-$SRV_ID" echo "HTTP SERVER "$SRV - URL="https://$SRV:$HTTPS_PORT/files/$FN" - EVT='{"event":{"commonEventHeader":{"sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","sourceName":"'$NO'","lastEpochMicrosec":151983,"startEpochMicrosec":15198378,"timeZoneOffset":"UTC+05:00","changeIdentifier":"PM_MEAS_FILES"},"notificationFields":{"notificationFieldsVersion":"notificationFieldsVersion","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}]}}}' + URL="https://$SRV:$HTTPS_PORT/generatedfiles/$FN" + EVT='{"event":{"commonEventHeader":{"sequence":0,"eventName":"Noti_RnNode-Ericsson_FileReady","sourceName":"'$NO'","lastEpochMicrosec":'$CURTIMEMS',"startEpochMicrosec":'$STTIMEMS',"timeZoneOffset":"UTC'$TIMEZONE'","changeIdentifier":"PM_MEAS_FILES"},"notificationFields":{"notificationFieldsVersion":"notificationFieldsVersion","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"fileFormatType":"org.3GPP.32.435#measCollec","location":"'$URL'","fileFormatVersion":"V10","compression":"gzip"}}]}}}' echo $EVT >> .out.json let CNTR=CNTR+1 diff --git a/docker-proj/scripts/push-to-ves-collector.sh b/docker-proj/scripts/push-to-ves-collector.sh index 3dc7d85..f85276a 100755 --- a/docker-proj/scripts/push-to-ves-collector.sh +++ b/docker-proj/scripts/push-to-ves-collector.sh @@ -42,8 +42,10 @@ fi rm .out.json touch .out.json -BEGINTIME=1665146700 +BEGINTIME=$(date +%s -d '1 hour ago') +TIMEZONE="+0100" CURTIME=$BEGINTIME +COLLECTIONTIME=$(date +%a,%d%m%Y%H:%M:%S%Z) for (( i=0; i<$EVT_COUNT; i++)); do @@ -51,16 +53,11 @@ for (( i=0; i<$EVT_COUNT; i++)); do echo '{"eventList": [' > .out.json first=0 - arch="$(uname -s)" - if [[ $arch == "Darwin"* ]]; then - ST=$(date -r $CURTIME +'%Y%m%d.%H%M') - let CURTIME=CURTIME+900 - ET=$(date -r $CURTIME +'%H%M') - else - ST=$(date -d @$CURTIME +'%Y%m%d.%H%M') - let CURTIME=CURTIME+900 - ET=$(date -d @$CURTIME +'%H%M') - fi + let STTIMEMS=$CURTIME*1000000 + ST=$(date -d @$CURTIME +'%Y%m%d.%H%M') + let CURTIME=CURTIME+900 + let CURTIMEMS=$CURTIME*1000000 + ET=$(date -d @$CURTIME +'%H%M') for (( j=0; j<$NODE_COUNT; j++)); do @@ -69,12 +66,11 @@ for (( i=0; i<$EVT_COUNT; i++)); do FN="A$ST+0200-$ET+0200_$NO-$i.$FILE_EXT" let SRV_ID=$j%$SRV_COUNT let SRV_ID=SRV_ID+1 - #echo "NODE "$NO echo "FILENAME "$FN SRV="pm-https-server-$SRV_ID" echo "HTTP SERVER "$SRV - URL="https://$SRV:$HTTPS_PORT/files/$FN" - EVT='{"commonEventHeader":{"startEpochMicrosec":15198378,"eventId":"FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1","timeZoneOffset":"UTC+05.30","internalHeaderFields":{"collectorTimeStamp":"Wed,0907202211:56:02GMT"},"priority":"Normal","version":"4.0.1","reportingEntityName":"'$NO'","sequence":0,"domain":"notification","lastEpochMicrosec":151983,"eventName":"Notification_gnb-Ericsson_FileReady","vesEventListenerVersion":"7.0.1","sourceName":"'$NO'"},"notificationFields":{"notificationFieldsVersion":"2.0","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"location":"'$URL'","fileFormatType":"org.3GPP.32.435#measCollec","fileFormatVersion":"V10","compression":"gzip"}}]}}' + URL="https://$SRV:$HTTPS_PORT/generatedfiles/$FN" + EVT='{"commonEventHeader":{"startEpochMicrosec":'$STTIMEMS',"eventId":"FileReady_1797490e-10ae-4d48-9ea7-3d7d790b25e1","timeZoneOffset":"UTC'$TIMEZONE'","internalHeaderFields":{"collectorTimeStamp":"'$COLLECTIONTIME'"},"priority":"Normal","version":"4.0.1","reportingEntityName":"'$NO'","sequence":0,"domain":"notification","lastEpochMicrosec":'$CURTIMEMS',"eventName":"Notification_gnb-Ericsson_FileReady","vesEventListenerVersion":"7.0.1","sourceName":"'$NO'"},"notificationFields":{"notificationFieldsVersion":"2.0","changeType":"FileReady","changeIdentifier":"PM_MEAS_FILES","arrayOfNamedHashMap":[{"name":"'$FN'","hashMap":{"location":"'$URL'","fileFormatType":"org.3GPP.32.435#measCollec","fileFormatVersion":"V10","compression":"gzip"}}]}}' if [ $first -ne 0 ]; then echo "," >> .out.json fi diff --git a/docker-proj/scripts/update_ics_job.sh b/docker-proj/scripts/update_ics_job.sh new file mode 100755 index 0000000..74cf87b --- /dev/null +++ b/docker-proj/scripts/update_ics_job.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +# args: [] +# job file shall exist in file "".job.json" +update_ics_job() { + + ICS_PORT=8083 + JOB=$(<.job.json) + echo $JOB + retcode=1 + echo "Updating job $1" + while [ $retcode -ne 0 ]; do + if [ -z "$2" ]; then + __bearer="" + else + __bearer="Authorization: Bearer $TOKEN" + fi + STAT=$(curl -s -X PUT -w '%{http_code}' -H accept:application/json -H Content-Type:application/json http://localhost:$ICS_PORT/data-consumer/v1/info-jobs/$1 --data-binary @.job.json -H "$__bearer" ) + retcode=$? + echo "curl return code: $retcode" + if [ $retcode -eq 0 ]; then + status=${STAT:${#STAT}-3} + echo "http status code: "$status + if [ "$status" == "200" ]; then + echo "Job created ok" + elif [ "$status" == "201" ]; then + echo "Job created ok" + else + retcode=1 + fi + fi + sleep 1 + done +} diff --git a/docker-proj/update-pmlog.sh b/docker-proj/update-pmlog.sh new file mode 100755 index 0000000..7d6b731 --- /dev/null +++ b/docker-proj/update-pmlog.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +#. scripts/kube_get_controlplane_host.sh + +# Generic error printout function +# args: +check_error() { + if [ $1 -ne 0 ]; then + echo "Failed: $2" + echo "Exiting..." + exit 1 + fi +} + +. scripts/update_ics_job.sh + +echo "Installation of pm to influx job" + +. scripts/populate_keycloak.sh + +cid="console-setup" +TOKEN=$(get_client_token nonrtric-realm $cid) + +JOB='{ + "info_type_id": "PmData", + "job_owner": "console", + "job_definition": { + "filter": { + "sourceNames": ["node2-1"], + "measObjInstIds": [], + "measTypeSpecs": [ + { + "measuredObjClass": "NRCellDU", + "measTypes": [ + "pmCounterNumber102" + ] + } + ], + "measuredEntityDns": [] + }, + "deliveryInfo": { + "topic": "pmreports", + "bootStrapServers": "kafka-1:9097" + } + } + }' +echo $JOB > .job.json +update_ics_job pmlog $TOKEN + +echo "done" +