blob: f984a4d06f8f92d71671a20ab4d3d930e57c7516 [file] [log] [blame]
demx8as6f58b3e12019-09-18 08:53:26 +02001#!/bin/bash
2################################################################################
3#
4# Copyright 2019 highstreet technologies GmbH and others
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
demx8as686b92e82021-05-08 15:58:54 +020010# https://www.apache.org/licenses/LICENSE-2.0
demx8as6f58b3e12019-09-18 08:53:26 +020011#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18################################################################################
19# Script to send an VES Message Event to DCAE
20
21. config;
22 pnfType=${1,,};
23 domain="measurement";
24 collectionEndTime=$(( $timeInS - $(($timeInS % 900))));
25 collectionStartTime=$(( collectionEndTime - 900 ));
26 granularity="PM15min";
27
28declare -A mapping=(
29 [domain]=$domain
30 [controllerName]=$(hostname --fqdn)
31 [pnfId]=${pnfIdByType[$pnfType]}
32 [granularity]=$granularity
33 [eventId]="${pnfIdByType[$pnfType]}_${collectionEndTime}_${granularity}"
34 [eventType]=${eventType}
35 [type]=${pnfType^^}
36 [interface]=${interfaceByType[$pnfType]}
37 [timestamp]=${timestamp}
38 [eventTime]=${eventTime}
demx8as62716a112021-06-23 09:58:00 +020039 [collectionStartTime]=${collectionStartTime}000000
40 [collectionEndTime]=${collectionEndTime}000000
demx8as6f58b3e12019-09-18 08:53:26 +020041 [intervalStartTime]=$(date -u -R -d @$collectionStartTime )
42 [intervalEndTime]=$(date -u -R -d @$collectionEndTime )
43 [vendor]=${vendorsByType[$pnfType]^^}
44 [model]=${modelByType[$pnfType]}
45)
46
47echo "################################################################################";
48echo "# send 15min performance values";
49echo
50for key in "${!mapping[@]}"
51do
52 label=$spaces$key;
53 label=${label:(-20)};
54 echo "$label: ${mapping[$key]}";
55 if [ $key = "collectionStartTime" ] || [ $key = "collectionEndTime" ]; then
56 sequence="$sequence s/\"@$key@\"/${mapping[$key]}/g; "
57 else
58 sequence="$sequence s/@$key@/${mapping[$key]}/g; "
59 fi
60done
61echo;
62
63body=./json/examples/${pnfType^^}-${domain}.json
64sed -e "$sequence" ./json/templates/$domain.json > $body
65
66curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes