blob: f5783366e7a5d050e6ccc6e299146b68e1ff79a1 [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
David Bainbridgeb4bbde12020-06-25 14:46:36 -070025 kind version | sed -E -e 's/^.*(v[0-9]+\.[0-9]+\.[0-9]+).*$/\1/'
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
David Bainbridgeb4bbde12020-06-25 14:46:36 -070046 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 Bainbridgea965ca22020-06-09 17:45:04 -070056 fi
David Bainbridgea965ca22020-06-09 17:45:04 -070057fi
58
59echo -n "Voltha: (client/server): "
David Bainbridge1d2c5842020-06-03 15:29:07 -070060if ! command -v voltctl >/dev/null 2>&1; then
61 echo "'voltctl' not in \$PATH"
62else
63 CLIENT=$(voltctl version --clientonly -o json | jq -r '"v"+.version')
David Bainbridgea965ca22020-06-09 17:45:04 -070064 SERVER=$(voltctl version -o json 2>/dev/null)
65 if [ -z "$SERVER" ]; then
66 SERVER="ERROR"
David Bainbridge1d2c5842020-06-03 15:29:07 -070067 else
David Bainbridgea965ca22020-06-09 17:45:04 -070068 SERVER=$(echo "$SERVER" | jq -r '"v"+.cluster.version')
David Bainbridge1d2c5842020-06-03 15:29:07 -070069 fi
David Bainbridgea965ca22020-06-09 17:45:04 -070070 echo "$CLIENT/$SERVER"
David Bainbridge1d2c5842020-06-03 15:29:07 -070071fi
72echo
David Bainbridgea965ca22020-06-09 17:45:04 -070073kubectl get --all-namespaces pods,svc,configmap | grep -v kube-system | cut -c -$__COLS
David Bainbridge1d2c5842020-06-03 15:29:07 -070074echo
David Bainbridge33e56c72020-06-11 11:39:56 -070075kubectl 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 -070076echo
77echo "DB SIZE: $("$SCRIPTPATH/etcd-db-size.sh")"
78echo
79PIDS=$(pgrep -f "etcd --name etcd")
80if [ -z "$PIDS" ]; then
81 echo "RSS SIZE: N/A"
82else
83 echo "RSS SIZE: $(ps -ho rss $PIDS | xargs numfmt --to=iec | tr '\n' ' ' )"
84fi