Update documentation
[oam.git] / solution / dev / ves-test-collector / client-scripts-ves-v7 / send15minPm.sh
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
10 #     http://www.apache.org/licenses/LICENSE-2.0
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}
39     [collectionStartTime]=${collectionStartTime}000
40     [collectionEndTime]=${collectionEndTime}000
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