Updates for ODL Neon
[ccsdk/distribution.git] / dgbuilder / show_status.sh
1 #!/bin/bash
2 tbold=$(tput setf 3)
3 bold=$(tput setf 2)
4 bold1=$(tput setf 2)
5 offbold=$(tput rmso;tput sgr0)
6
7 function pad {
8         #echo "1 is $1 2 is $2"
9         if [ "$1" == "" ]
10         then
11                 $1 = "";
12         fi
13         let count=0
14         curr_len=`expr length "$1"`
15         let space_length=$2-$curr_len
16         spaces=""
17         while [ $count -lt $space_length ]
18         do
19                 spaces="$spaces "
20                 let count=$count+1
21         done
22         echo "$1$spaces"
23 }
24         
25 function isRunning {
26         echo $(curl -I "$1" 2>/dev/null|head -1|tail -1|awk '{print $2}')
27 }
28 dirName=$(pwd)
29 options=($(ls -l $dirName/releases|grep ^d|awk '{print $NF}'|sort))
30         echo "$(pad RELEASE 15)$(pad URL 30)$(pad Status 10)"
31         echo "$(pad '----' 15)$(pad '---' 30)$(pad '------' 10)"
32         for opt in "${options[@]}" 
33         do 
34                 
35                 releaseDir="$opt"
36                 if [ -e "./releases/${opt}/customSettings.js" ]
37                 then
38                         pid=$(cat ./releases/$releaseDir/logs/process_pid 2>/dev/null)
39                         port=$(cat ./releases/$releaseDir/customSettings.js 2>/dev/null|grep uiPort|sed -e 's/[, ]//g'|cut -d: -f2)
40                         resp1=$(isRunning "http://localhost:$port")
41                         if [ "$resp1" == "401" ]
42                         then    
43                                 echo "$(pad $releaseDir 15)$(pad http://localhost:$port 30)${bold}$(pad running 10)${offbold}"
44                         else
45                                 processId=$(netstat -upltn 2>/dev/null|grep $port|awk '{print $NF}'|sed -e 's%/node-red%%g')
46                                 if [ "$processId" == "" ]
47                                 then
48                                         echo "$(pad $releaseDir 15)$(pad http://localhost:$port 30)${bold}$(pad stopped 10)${offbold}"
49                                 else
50                                         echo "$(pad $releaseDir 15)$(pad http://localhost:$port 30)${bold}$(pad running 10)${offbold}"
51                                 fi
52                         fi
53                 fi
54         done

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use