demx8as6 | f58b3e1 | 2019-09-18 08:53:26 +0200 | [diff] [blame] | 1 | #!/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 | # |
demx8as6 | 86b92e8 | 2021-05-08 15:58:54 +0200 | [diff] [blame] | 10 | # https://www.apache.org/licenses/LICENSE-2.0 |
demx8as6 | f58b3e1 | 2019-09-18 08:53:26 +0200 | [diff] [blame] | 11 | # |
| 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 | |
| 28 | declare -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} |
demx8as6 | 2716a11 | 2021-06-23 09:58:00 +0200 | [diff] [blame] | 39 | [collectionStartTime]=${collectionStartTime}000000 |
| 40 | [collectionEndTime]=${collectionEndTime}000000 |
demx8as6 | f58b3e1 | 2019-09-18 08:53:26 +0200 | [diff] [blame] | 41 | [intervalStartTime]=$(date -u -R -d @$collectionStartTime ) |
| 42 | [intervalEndTime]=$(date -u -R -d @$collectionEndTime ) |
| 43 | [vendor]=${vendorsByType[$pnfType]^^} |
| 44 | [model]=${modelByType[$pnfType]} |
| 45 | ) |
| 46 | |
| 47 | echo "################################################################################"; |
| 48 | echo "# send 15min performance values"; |
| 49 | echo |
| 50 | for key in "${!mapping[@]}" |
| 51 | do |
| 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 |
| 60 | done |
| 61 | echo; |
| 62 | |
| 63 | body=./json/examples/${pnfType^^}-${domain}.json |
| 64 | sed -e "$sequence" ./json/templates/$domain.json > $body |
| 65 | |
| 66 | curl -i -k -u $basicAuthVes -X POST -d @${body} --header "Content-Type: application/json" $urlVes |