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 |
David Bainbridge | b4bbde1 | 2020-06-25 14:46:36 -0700 | [diff] [blame] | 25 | kind version | sed -E -e 's/^.*(v[0-9]+\.[0-9]+\.[0-9]+).*$/\1/' |
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 |
David Bainbridge | b4bbde1 | 2020-06-25 14:46:36 -0700 | [diff] [blame] | 46 | CLIENT=$(helm version --client --short 2>/dev/null | sed -E -e 's/^.*(v[0-9]+\.[0-9]+\.[0-9]+).*$/\1/') |
| 47 | MAJOR=$(helm version --client --short 2>/dev/null | sed -E -e 's/^.*v([0-9]+)\.[0-9]+\.[0-9]+.*$/\1/') |
| 48 | if [ "$MAJOR" -le 2 ]; then |
| 49 | SERVER=$(helm version --server --short 2>/dev/null | sed -E -e 's/^.*(v[0-9]+\.[0-9]+\.[0-9]+).*$/\1/') |
| 50 | if [ -z "$SERVER" ]; then |
| 51 | SERVER="ERROR" |
| 52 | fi |
| 53 | echo "$CLIENT/$SERVER" |
| 54 | else |
| 55 | echo "$CLIENT" |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 56 | fi |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 57 | fi |
| 58 | |
| 59 | echo -n "Voltha: (client/server): " |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 60 | if ! command -v voltctl >/dev/null 2>&1; then |
| 61 | echo "'voltctl' not in \$PATH" |
| 62 | else |
| 63 | CLIENT=$(voltctl version --clientonly -o json | jq -r '"v"+.version') |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 64 | SERVER=$(voltctl version -o json 2>/dev/null) |
| 65 | if [ -z "$SERVER" ]; then |
| 66 | SERVER="ERROR" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 67 | else |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 68 | SERVER=$(echo "$SERVER" | jq -r '"v"+.cluster.version') |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 69 | fi |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 70 | echo "$CLIENT/$SERVER" |
David Bainbridge | 1d2c584 | 2020-06-03 15:29:07 -0700 | [diff] [blame] | 71 | fi |
| 72 | echo |
David Bainbridge | a965ca2 | 2020-06-09 17:45:04 -0700 | [diff] [blame] | 73 | 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] | 74 | echo |
David Bainbridge | 33e56c7 | 2020-06-11 11:39:56 -0700 | [diff] [blame] | 75 | 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] | 76 | echo |
| 77 | echo "DB SIZE: $("$SCRIPTPATH/etcd-db-size.sh")" |
| 78 | echo |
| 79 | PIDS=$(pgrep -f "etcd --name etcd") |
| 80 | if [ -z "$PIDS" ]; then |
| 81 | echo "RSS SIZE: N/A" |
| 82 | else |
| 83 | echo "RSS SIZE: $(ps -ho rss $PIDS | xargs numfmt --to=iec | tr '\n' ' ' )" |
| 84 | fi |