-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopsmenuv2.sh
135 lines (123 loc) · 3.4 KB
/
opsmenuv2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
RESET='\033[0m'
BLACK='\033[01;30m'
RED='\033[01;31m'
REDBLK='\033[01;31;40m'
GREEN='\033[01;32m'
YELLOW='\033[01;33m'
BLUE='\033[01;34m'
BLUEUND='\033[03;04;34m'
WHITE='\033[01;37m'
remote_user='unixjp' # declare user to login remote to collect information
#show()
#{
# local x=$1
# local y=$2
# local txt="$3"
# # Set cursor position on screen
# tput cup $x $y
# echo "$txt"
#}
#clock()
#{
# echo "$(date +"%c")"
#}
menu()
{
echo -e ${BLUE}"=========================================================================="
echo " _ _ _ _____ ______ ";
echo "| | | | (_) / ___ \ | ___ \ ";
echo "| | | |____ _ _ _ | | | |____ ___ | | _ | | ____ ____ _ _ ";
echo "| | | | _ \| ( \ / ) | | | | _ \ /___) | || || |/ _ ) _ \| | | |";
echo "| |___| | | | | |) X ( | |___| | | | |___ | | || || ( (/ /| | | | |_| |";
echo " \______|_| |_|_(_/ \_) \_____/| ||_/(___/ |_||_||_|\____)_| |_|\____|";
echo " |_| ";
echo "Powered by OST JPN UNIX VER 2.0";
echo "$(date)"
echo "=========================================================================="
echo ""
echo -e ${GREEN}"Enter 1 to check Server Uptime : "
echo "Enter 2 to check Server Disk Usage : "
echo "Enter 3 to check Linux Server Memory Usage: "
echo "Enter 4 to check Solaris Server Memory Usage: "
echo -e ${YELLOW}"Enter c to Check CI Support Contact: "${RESET}
echo -e ${RED}"Enter q to exit the menu q: "${RESET}
echo -e "\n"
echo -e "Enter your Selection: \c"
}
# Check hostname & ssh connection
check_host()
{
nc -zw5 $remote_hostname 22 &>/dev/null #stdout & Stderr to null
check=`echo $?`
return
}
# SSH to remote server
remote()
{
printf "Please enter HOSTNAME: "
read remote_hostname
check_host $remote_hostname
#sudo su -c "Your command right here" -s /bin/sh otheruser
if [ $check -eq 0 ]
then
ssh -l unixjp -t -o StrictHostKeyChecking=no -q ${remote_hostname} "${1}"
else
echo -e ${RED}"Hostname invalid or port 22 is not open"${RESET}
fi
}
# Check CI Support Contact
check_contact()
{
printf "Enter the CI name: "
read CI_name
/root/donkong ${CI_name} | grep -i Support
#sudo su -c "/root/donkong ${CI_name} | grep -i Support" -s /bin/sh $remote_user
}
# Function to check Server Uptime
check_uptime()
{
remote " uptime"
}
# Function to check Disk Usage
check_df()
{
remote " df -h"
}
# Function to check Memory Info for RedHat
check_rhmem()
{
remote "free -m"
echo ""
echo "==================TOP_5_MEMORY_EATING_PROCESS==========================="
echo "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND"
ssh -l unixjp -t -o StrictHostKeyChecking=no -q ${remote_hostname} "ps auxf | sort -nr -k 4 | head -5"
}
# Function to check Memory Info for Solaris
check_solmem()
{
remote " prstat -Z 1 1"
}
trap '' 2
while true
do
clear
menu # Display menu
read answer
case "$answer" in
1) check_uptime
;;
2) check_df
;;
3) check_rhmem
;;
4) check_solmem
;;
c) check_contact
;;
q) exit ;;
*) tput blink; echo -e ${REDBLK}"Invalid Option Selected!!"${RESET};;
esac
echo -e "Enter return to continue \c"
read input
done