Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Bash CLI Prompt Extentions

I wrote a few alternative Bash CLI Prompt Extentions for Gaia expert mode

Cluster-Gateway short:

GW_short.png

 

[Expert@HOSTNAME:VSID:VERSION:CLUSTER-STATUS]#

Command:

 

Spoiler

update(){

a=`cphaprob stat|grep local|awk '{print $5}'`; case $a in *CTIVE*|*ctive*) a=`tput setaf 2; echo $a`;; *TANDBY*|*tandby*) a=`tput setaf 5; echo $a`;; *) a=`tput setaf 1; echo $a`; esac;

PS1="[Expert@\h:$INSTANCE_VSID:\033[1m$version\033[0m:$a\e[0m]# "

}

version=$(cpstat os -f all | grep "SVN Foundation Version String:" | cut -f 15 -d ' ');

PROMPT_COMMAND=update

Cluster-Gateway long:

GW_long.png

 

 

[VERSION:Cluster-Status:RAM:CPU Usage:SecureXL-Status:CoreXL-Status]

[Expert@HOSTNAME:VSID]#

Command:

Spoiler

update(){

a=`cphaprob stat|grep local|awk '{print $5}'`; case $a in *CTIVE*|*ctive*) a=`tput setaf 2; echo $a`;; *TANDBY*|*tandby*) a=`tput setaf 5; echo $a`;; *) a=`tput setaf 1; echo $a`; esac;

f_rammb=$(free -m |grep "Mem:" |awk '{print $3}');f_ramdec=${f_rammb:${#f_rammb}-3:${#f_rammb}};f_ramint=${f_rammb:0:${#f_rammb}-3};

f_ramgb=$(echo "$f_ramint.$f_ramdec");f_ramgb=${f_ramgb:0:${#f_ramgb}-2};

cpu=$(uptime | rev | awk '{print $3}'|tr -d ',' | rev);

PS1="[\033[1m$version\033[0m:$a\e[0m:\e[96m\]RAM=$f_ramgb/$m_ramgb\]GB\e[0m:\e[36m\]CPU Usage=$cpu\e[0m:\e[1;35m\]SecureXL=$securexl\e[0m:\e[1;32m\]CoreXL Active=$corexl\e[0m]\n[Expert@\h:$INSTANCE_VSID]# ";

}

m_rammb=$(free -m |grep "Mem:" |awk '{print $2}');m_ramdec=${m_rammb:${#m_rammb}-3:${#m_rammb}};m_ramint=${m_rammb:0:${#m_rammb}-3};

m_ramgb=$(echo "$m_ramint.$m_ramdec");m_ramgb=${m_ramgb:0:${#m_ramgb}-2};

version=$(cpstat os -f all | grep "SVN Foundation Version String:" | awk '{print $5}');

securexl=$(fwaccel stat | grep Acceleration | awk '{print $3}'| tr -d '|');

if [ -z "$(fw ctl multik stat)" ];then corexl="Disabled";else corexl=$(fw ctl multik stat | cut -f 2 -d '|'|tail -n +3);iterations=$(echo $corexl|wc -w) cores_active=0;for((i=1;i<=$iterations;i+=1));

do core=$(echo $corexl|cut -f $i -d ' ');if [ "Yes" == $core ]; then cores_active=$((cores_active+1));fi;done;if [ "$cores_active" -eq "$iterations" ]; then corexl="ALL";else corexl=$cores_active;fi;fi;

PROMPT_COMMAND=update

Management

Mgmt_1.pngMgmt_2.png

 

[VERSION:MgmtHA-Configuration-HA-Status:RAM:CPU Usage ]

[Expert@HOSTNAME:VSID]#

Command:

Spoiler

update(){

f_rammb=$(free -m |grep "Mem:" |awk '{print $3}');f_ramdec=${f_rammb:${#f_rammb}-3:${#f_rammb}};f_ramint=${f_rammb:0:${#f_rammb}-3};

f_ramgb=$(echo "$f_ramint.$f_ramdec");f_ramgb=${f_ramgb:0:${#f_ramgb}-2};

cpu=$(uptime | rev | awk '{print $3}'|tr -d ',' | rev);

if [[ -e $MDS_FWDIR/conf/peers.C ]]; then a=$(cpstat mg|grep status|awk '{print $3}'|tr "[a-z]" "[A-Z]"); case $a in *CTIVE*|*ctive*) a=`tput setaf 2; echo $a`;; *TANDBY*|*tandby*) a=`tput setaf 5;

echo $a`;; *) a=`tput setaf 1; echo $a`; esac;

PS1="[\033[1m$version\033[0m:$mgmtHA-$mgmtconf-$a\e[0m:\e[96m\]RAM=$f_ramgb/$m_ramgb\]GB\e[0m:\e[36m\]CPU Usage=$cpu\e[0m]\n[Expert@\h:$NSID_NUMBER]# ";

else PS1="[\033[1m$version\033[0m:\e[96m\]RAM=$f_ramgb/$m_ramgb\]GB\e[0m:\e[36m\]CPU Usage=$cpu\e[0m]\n[Expert@\h:$NSID_NUMBER]# ";fi;

}

m_rammb=$(free -m |grep "Mem:" |awk '{print $2}');m_ramdec=${m_rammb:${#m_rammb}-3:${#m_rammb}};m_ramint=${m_rammb:0:${#m_rammb}-3};

m_ramgb=$(echo "$m_ramint.$m_ramdec");m_ramgb=${m_ramgb:0:${#m_ramgb}-2};

if [[ -e $MDS_FWDIR/conf/peers.C ]]; then mgmtHA="MgmtHA"; if [ $(cpprod_util FwIsPrimary) ]; then mgmtconf="Prim"; else mgmtconf="Sec";fi;fi;

version=$(cpstat os -f all | grep "SVN Foundation Version String:" | cut -f 15 -d ' ');

PROMPT_COMMAND=update

 

1 Reply
Highlighted
Iron

Re: Bash CLI Prompt Extentions

Wow, this helps a lot Thanks!
0 Kudos