c979066c581ef62b4b6ce20880ffc654a444d36e
[policy/parent.git] / integration / src / main / scripts / reports / pf_status_report.sh
1 #!/bin/bash
2
3 # ============LICENSE_START================================================
4 # ONAP
5 # =========================================================================
6 # Copyright (C) 2022 Nordix Foundation.
7 # =========================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #      http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END==================================================
20 #
21
22 function health_check() {
23     health_dir="$1"
24
25     health_report_temp_file=$(mktemp)
26
27     report_month=$( \
28         curl -s "https://logs.onap.org/onap-integration/daily/$health_dir"/ | \
29         grep href | \
30         sort | \
31         tail -1 | \
32         sed -e 's/^.*href="//' \
33             -e 's/\/".*$//'
34     )
35
36     report_last_health=$( \
37         curl -s "https://logs.onap.org/onap-integration/daily/$health_dir/$report_month/" | \
38         grep href | \
39         sort | \
40         tail -1 | \
41         sed -e 's/^.*href="//' \
42             -e 's/\/".*$//'
43     )
44
45     curl -s --output "$health_report_temp_file" \
46         "https://logs.onap.org/onap-integration/daily/$health_dir/$report_month/$report_last_health/xtesting-healthcheck/full/full/report.html"
47     health_check_result=$(
48         gunzip -c "$health_report_temp_file" | \
49             grep 'window.output\["stats"\]' | \
50             sed 's/},{/}\n{/g' | \
51             grep health-policy | \
52             sed -e 's/{//g' \
53                 -e 's/}//g' \
54                 -e 's/"//g' \
55                 -e 's/label://' | \
56             awk -F',' '{printf("%s,%s,%s\n", $3,$4,$2)}'
57     )
58
59     report_day="${report_last_health%%_*}"
60     report_hour_minute="${report_last_health#*_}"
61     report_hour_minute="${report_hour_minute/-/:}"
62     echo "$health_dir,$report_month-$report_day $report_hour_minute,$health_check_result"
63 }
64
65 echo ""
66 echo "health checks"
67 echo "-------------"
68
69 health_check onap-daily-dt-oom-master
70 health_check onap-daily-dt-oom-jakarta
71 health_check onap-daily-dt-oom-istanbul
72 health_check onap_daily_pod4_master
73
74 jenkins_report_temp_file=$(mktemp)
75
76 curl -s https://jenkins.onap.org/view/policy/ | \
77     sed -e 's/<tr id=/\n<tr id=/g' \
78         -e 's/><td data=/\n><td data=/g' | \
79     grep 'tr id=' | \
80     sed -e 's/"//g' \
81         -e 's/<tr id=//' \
82         -e 's/class= //' > "$jenkins_report_temp_file"
83
84 echo ""
85 echo "failing jobs"
86 echo "------------"
87
88 grep "job-status-red" "$jenkins_report_temp_file" | \
89     grep -v stage |
90     cut -f1 -d' '
91
92 echo ""
93 echo "warning jobs"
94 echo "------------"
95
96 grep "job-status-yellow" "$jenkins_report_temp_file" | \
97     grep -v clm |
98     cut -f1 -d' '
99
100 echo ""
101 echo "invalid jobs"
102 echo "------------"
103 grep -v -E "(blue|red|yellow|verify|merge)" "$jenkins_report_temp_file" | \
104     cut -f1 -d' '
105
106 echo ""
107 echo "bugs"
108 echo "----"
109 curl -s https://jira.onap.org/issues/?jql=PROJECT%20%3D%20POLICY%20AND%20issuetype%20%3D%20Bug%20AND%20status%20!%3D%20Closed%20ORDER%20BY%20key%20ASC \ |
110     grep 'data-issue-table-model-state' | \
111     sed -e 's/&quot/\"/g' \
112         -e 's/.*";jiraHasIssues";:true,";page";:[0-9]*,";pageSize";:[0-9]*,";startIndex";:[0-9]*,";table";:\[//' \
113         -e 's/,";title";:";";,";total";:[0-9]*,";url";:";";,";sortBy";:\].*$//' \
114         -e 's/}}/}}\n/g' | \
115     grep 'POLICY-' | \
116     sed -e 's/^.*key=/key=/g' \
117         -e 's/";:";/=/g' \
118         -e 's/";,";/,/g' \
119         -e 's/^.*key=/key=/g' \
120         -e 's/";:{";description=.*$//'