blob: 4621941f47afc0eefea70b933425df7b58dc2de8 [file] [log] [blame]
David Bainbridgecfd7ca12019-10-06 03:31:41 +00001#!/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 Bainbridge1d2c5842020-06-03 15:29:07 -070018SCRIPTPATH="$( cd "$(dirname "$0")" || return >/dev/null 2>&1 ; pwd -P )"
David Bainbridgea965ca22020-06-09 17:45:04 -070019__COLS=$(($(tput cols) - 1))
David Bainbridgecfd7ca12019-10-06 03:31:41 +000020
David Bainbridgea965ca22020-06-09 17:45:04 -070021echo -n "Kind (client): "
22if ! command -v kind >/dev/null 2>&1; then
23 echo "'kind' not in \$PATH"
24else
25 kind version
David K. Bainbridgefe1fa8a2019-11-12 12:03:21 -080026fi
27
David Bainbridgea965ca22020-06-09 17:45:04 -070028echo -n "Kubernetes (client/server): "
29if ! command -v kubectl >/dev/null 2>&1; then
30 echo "'kubectl' not in \$PATH"
31else
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"
40fi
David Bainbridge1d2c5842020-06-03 15:29:07 -070041
David Bainbridgea965ca22020-06-09 17:45:04 -070042echo -n "Helm (client/server): "
43if ! command -v helm >/dev/null 2>&1; then
44 echo "'helm' not in \$PATH"
45else
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"
52fi
53
54echo -n "Voltha: (client/server): "
David Bainbridge1d2c5842020-06-03 15:29:07 -070055if ! command -v voltctl >/dev/null 2>&1; then
56 echo "'voltctl' not in \$PATH"
57else
58 CLIENT=$(voltctl version --clientonly -o json | jq -r '"v"+.version')
David Bainbridgea965ca22020-06-09 17:45:04 -070059 SERVER=$(voltctl version -o json 2>/dev/null)
60 if [ -z "$SERVER" ]; then
61 SERVER="ERROR"
David Bainbridge1d2c5842020-06-03 15:29:07 -070062 else
David Bainbridgea965ca22020-06-09 17:45:04 -070063 SERVER=$(echo "$SERVER" | jq -r '"v"+.cluster.version')
David Bainbridge1d2c5842020-06-03 15:29:07 -070064 fi
David Bainbridgea965ca22020-06-09 17:45:04 -070065 echo "$CLIENT/$SERVER"
David Bainbridge1d2c5842020-06-03 15:29:07 -070066fi
67echo
David Bainbridgea965ca22020-06-09 17:45:04 -070068kubectl get --all-namespaces pods,svc,configmap | grep -v kube-system | cut -c -$__COLS
David Bainbridge1d2c5842020-06-03 15:29:07 -070069echo
David Bainbridgea965ca22020-06-09 17:45:04 -070070kubectl describe --all-namespaces pods | grep Image: | grep '\(voltha\|bbsim\)' | sed -e "s/^ *//g" -e "s/: */: /g" | sort -u | cut -c -$COLS
David Bainbridge1d2c5842020-06-03 15:29:07 -070071echo
72echo "DB SIZE: $("$SCRIPTPATH/etcd-db-size.sh")"
73echo
74PIDS=$(pgrep -f "etcd --name etcd")
75if [ -z "$PIDS" ]; then
76 echo "RSS SIZE: N/A"
77else
78 echo "RSS SIZE: $(ps -ho rss $PIDS | xargs numfmt --to=iec | tr '\n' ' ' )"
79fi