David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2019 Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # This script sets up a watch with information that is valuable when |
| 17 | # developing voltha with k8s |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 18 | SCRIPTPATH="$( cd "$(dirname "$0")" || return >/dev/null 2>&1 ; pwd -P )" |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 19 | __COLS=$(($(tput cols) - 1)) |
David Bainbridge | cfd7ca1 | 2019-10-06 03:31:41 +0000 | [diff] [blame] | 20 | |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 21 | echo -n "Kind (client): " |
| 22 | if ! command -v kind >/dev/null 2>&1; then |
| 23 | echo "'kind' not in \$PATH" |
| 24 | else |
| 25 | kind version |
David K. Bainbridge | fe1fa8a | 2019-11-12 12:03:21 -0800 | [diff] [blame] | 26 | fi |
| 27 | |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 28 | echo -n "Kubernetes (client/server): " |
| 29 | if ! command -v kubectl >/dev/null 2>&1; then |
| 30 | echo "'kubectl' not in \$PATH" |
| 31 | else |
| 32 | CLIENT=$(kubectl version --client -o json | jq -r '.clientVersion.gitVersion') |
| 33 | SERVER=$(kubectl version -o json 2>/dev/null) |
| 34 | if [ "$?" -ne 0 ]; then |
| 35 | SERVER="ERROR" |
| 36 | else |
| 37 | SERVER=$(echo $SERVER | jq -r '.serverVersion.gitVersion') |
| 38 | fi |
| 39 | echo "$CLIENT/$SERVER" |
| 40 | fi |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 41 | |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 42 | echo -n "Helm (client/server): " |
| 43 | if ! command -v helm >/dev/null 2>&1; then |
| 44 | echo "'helm' not in \$PATH" |
| 45 | else |
| 46 | CLIENT=$(helm version --client --template '{{ (index . "Client").SemVer }}') |
| 47 | SERVER=$(helm version --server --template '{{ (index . "Server").SemVer }}' 2>/dev/null) |
| 48 | if [ "$?" -ne 0 ]; then |
| 49 | SERVER="ERROR" |
| 50 | fi |
| 51 | echo "$CLIENT/$SERVER" |
| 52 | fi |
| 53 | |
| 54 | echo -n "Voltha: (client/server): " |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 55 | if ! command -v voltctl >/dev/null 2>&1; then |
| 56 | echo "'voltctl' not in \$PATH" |
| 57 | else |
| 58 | CLIENT=$(voltctl version --clientonly -o json | jq -r '"v"+.version') |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 59 | SERVER=$(voltctl version -o json 2>/dev/null) |
| 60 | if [ -z "$SERVER" ]; then |
| 61 | SERVER="ERROR" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 62 | else |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 63 | SERVER=$(echo "$SERVER" | jq -r '"v"+.cluster.version') |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 64 | fi |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 65 | echo "$CLIENT/$SERVER" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 66 | fi |
| 67 | echo |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 68 | kubectl get --all-namespaces pods,svc,configmap | grep -v kube-system | cut -c -$__COLS |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 69 | echo |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame^] | 70 | kubectl describe --all-namespaces pods | grep Image: | grep '\(voltha\|bbsim\)' | sed -e "s/^ *//g" -e "s/: */: /g" | sort -u | cut -c -$COLS |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 71 | echo |
| 72 | echo "DB SIZE: $("$SCRIPTPATH/etcd-db-size.sh")" |
| 73 | echo |
| 74 | PIDS=$(pgrep -f "etcd --name etcd") |
| 75 | if [ -z "$PIDS" ]; then |
| 76 | echo "RSS SIZE: N/A" |
| 77 | else |
| 78 | echo "RSS SIZE: $(ps -ho rss $PIDS | xargs numfmt --to=iec | tr '\n' ' ' )" |
| 79 | fi |