ver 23/02/23
This commit is contained in:
parent
b1228b653a
commit
2770b020d9
@ -1,11 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
version="23/02/23"
|
|
||||||
echo "get-all-logs $version"
|
|
||||||
|
|
||||||
PRMT="[$(whoami)@$(hostname -s) ]"
|
PRMT="[$(whoami)@$(hostname -s) ]"
|
||||||
|
|
||||||
about_platform(){
|
about_platform(){
|
||||||
|
if [[ -z $logtype ]];then
|
||||||
|
logtype=$1;
|
||||||
|
fi;
|
||||||
|
|
||||||
for ONE in vm dci;
|
for ONE in vm dci;
|
||||||
do
|
do
|
||||||
@ -15,8 +16,10 @@ done
|
|||||||
if [[ -z "${PLATFORM}" ]]; then
|
if [[ -z "${PLATFORM}" ]]; then
|
||||||
echo "No ISPsystem Software found" && exit;
|
echo "No ISPsystem Software found" && exit;
|
||||||
else
|
else
|
||||||
LOGDIR="${HOME}/${PLATFORM}_logs_$(date +"%Y_%m_%d_%H_%M_%S")" && mkdir -p ${LOGDIR}
|
# echo "${HOME}/${PLATFORM}_${logtype}_$(date +"%Y_%m_%d_%H_%M_%S")";
|
||||||
ARCNAME=$(date +"${HOME}/${PLATFORM}_logs_%Y_%m_%d_%H_%M_%S.tar.gz")
|
LOGDIR="${HOME}/${PLATFORM}_${logtype}_$(date +"%Y_%m_%d_%H_%M_%S")" && mkdir -p ${LOGDIR}
|
||||||
|
# LOGDIR="${HOME}/${PLATFORM}_logs_$(date +"%Y_%m_%d_%H_%M_%S")" && mkdir -p ${LOGDIR}
|
||||||
|
ARCNAME=$(date +"${HOME}/${PLATFORM}_${logtype}_%Y_%m_%d_%H_%M_%S.tar.gz")
|
||||||
LicenseToken=$(grep -oP '\"LicenseToken\":"[^"]*\"' /opt/ispsystem/${PLATFORM}/config.json | sed -e 's/\"LicenseToken\"://g' -e 's/\"//g')
|
LicenseToken=$(grep -oP '\"LicenseToken\":"[^"]*\"' /opt/ispsystem/${PLATFORM}/config.json | sed -e 's/\"LicenseToken\"://g' -e 's/\"//g')
|
||||||
CurrentVersion=$(grep -oP '\"CurrentVersion\":"[^"]*\"' /opt/ispsystem/${PLATFORM}/config.json | sed -e 's/\"CurrentVersion\"://g' -e 's/\"//g')
|
CurrentVersion=$(grep -oP '\"CurrentVersion\":"[^"]*\"' /opt/ispsystem/${PLATFORM}/config.json | sed -e 's/\"CurrentVersion\"://g' -e 's/\"//g')
|
||||||
Stage=$(grep -oP '\"Stage\":"[^"]*\"' /opt/ispsystem/${PLATFORM}/config.json | sed -e 's/\"Stage\"://g' -e 's/\"//g')
|
Stage=$(grep -oP '\"Stage\":"[^"]*\"' /opt/ispsystem/${PLATFORM}/config.json | sed -e 's/\"Stage\"://g' -e 's/\"//g')
|
||||||
@ -102,16 +105,8 @@ mysql_connect(){
|
|||||||
query=$2;
|
query=$2;
|
||||||
fullcmd="docker exec -it mysql bash -c \"mysql isp -p\\\$MYSQL_ROOT_PASSWORD -e "$query"\" >> ${LOGDIR}/$logfile";
|
fullcmd="docker exec -it mysql bash -c \"mysql isp -p\\\$MYSQL_ROOT_PASSWORD -e "$query"\" >> ${LOGDIR}/$logfile";
|
||||||
|
|
||||||
#./1.sh "'select id,name,node from vm_host;'"
|
|
||||||
#q=$1;
|
|
||||||
#func(){
|
|
||||||
#query=$1;
|
|
||||||
#eval "docker exec -it mysql bash -c \"mysql isp -p\\\$MYSQL_ROOT_PASSWORD -e "$query"\"";
|
|
||||||
#}
|
|
||||||
|
|
||||||
#func "$q";
|
|
||||||
echo $fullcmd;
|
echo $fullcmd;
|
||||||
echo -e "\n $cmd \n">> ${LOGDIR}/$logfile;
|
echo -e "\n exec $query \n">> ${LOGDIR}/$logfile;
|
||||||
eval $fullcmd;
|
eval $fullcmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,53 +116,60 @@ node_connect() {
|
|||||||
ssh_port=$2;
|
ssh_port=$2;
|
||||||
cmd=$4;
|
cmd=$4;
|
||||||
logfile=$3;
|
logfile=$3;
|
||||||
testcmd="docker exec --tty --interactive vm_box ssh -o BatchMode=yes -o ConnectTimeout=5 -o \"StrictHostKeyChecking no\" -i /opt/ispsystem/vm/etc/.ssh/vmmgr.1 $ip_addr -p $ssh_port echo ok 2>&1";
|
$(docker exec --tty --interactive vm_box ssh -o BatchMode=yes -o ConnectTimeout=5 -o "StrictHostKeyChecking no" -q -i /opt/ispsystem/vm/etc/.ssh/vmmgr.1 $ip_addr -p $ssh_port exit) && connected=1 || connected=0;
|
||||||
echo $testcmd;
|
if [[ ${connected} == 1 ]];then
|
||||||
status=$(eval $testcmd);
|
# echo "node $ip_addr on $node_port connected!";
|
||||||
echo $status;
|
fullcmd="docker exec --tty --interactive vm_box ssh -o \"StrictHostKeyChecking no\" -i /opt/ispsystem/vm/etc/.ssh/vmmgr.1 $ip_addr -p $ssh_port $cmd >> ${LOGDIR}/$logfile";
|
||||||
|
echo $fullcmd;
|
||||||
if [[ $status == "ok" ]] ; then
|
echo -e "\n $cmd \n">> ${LOGDIR}/$logfile;
|
||||||
echo "node $ip_addr on $node_port connected!";
|
eval $fullcmd;
|
||||||
fullcmd="docker exec --tty --interactive vm_box ssh -o \"StrictHostKeyChecking no\" -i /opt/ispsystem/vm/etc/.ssh/vmmgr.1 $ip_addr -p $ssh_port $cmd >> ${LOGDIR}/$logfile";
|
else
|
||||||
echo $fullcmd;
|
echo "node $ip_addr on $node_port not connected!";
|
||||||
echo -e "\n $cmd \n">> ${LOGDIR}/$logfile;
|
echo "node $ip_addr on $node_port not connected!">> ${LOGDIR}/$logfile;
|
||||||
eval $fullcmd;
|
echo -e "\n not executed $cmd \n">> ${LOGDIR}/$logfile;
|
||||||
elif [[ $status == "Permission denied"* ]] ; then
|
fi
|
||||||
echo "node $ip_addr on $node_port not authorized!";
|
|
||||||
else
|
|
||||||
echo "node $ip_addr on $node_port not connected!";
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_help(){
|
_help(){
|
||||||
echo -e "Usage : $0 -type";
|
|
||||||
echo -e "\n available types:\n\n";
|
version="23/02/23"
|
||||||
echo -e "-logs or 1";
|
|
||||||
echo -e "-short-logs or 2";
|
echo -e "Log's script ver.: $version Usage : $0 [arguments]";
|
||||||
echo -e "-lic or 3";
|
echo -e "\n arguments:\n";
|
||||||
echo -e "-node or 4 \<IP-address\> \<SSH-port\>";
|
echo -e " -logs or 1";
|
||||||
|
echo -e " -short-logs or 2";
|
||||||
|
echo -e " -lic or 3";
|
||||||
|
echo -e " -node or 4 <IP-address> <SSH-port>\n";
|
||||||
|
|
||||||
PS3='Please enter your choice(enter number): '
|
PS3='Please enter your choice(enter number): '
|
||||||
|
|
||||||
options=("Full logs" "Short logs" "License\'s logs" "Node\'s logs" "Quit")
|
options=("Full logs" "Short logs" "License's logs" "Node's logs" "Quit")
|
||||||
select opt in "${options[@]}"
|
select opt in "${options[@]}"
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
"Full logs")
|
"Full logs")
|
||||||
|
logtype="logs";
|
||||||
|
about_platform;
|
||||||
_logs;
|
_logs;
|
||||||
break;
|
break;
|
||||||
;;
|
;;
|
||||||
"Short logs")
|
"Short logs")
|
||||||
|
logtype="short-logs";
|
||||||
|
about_platform;
|
||||||
_short_logs;
|
_short_logs;
|
||||||
break;
|
break;
|
||||||
;;
|
;;
|
||||||
"License\'s logs")
|
"License's logs")
|
||||||
|
logtype="lic";
|
||||||
|
about_platform;
|
||||||
_lic;
|
_lic;
|
||||||
break;
|
break;
|
||||||
;;
|
;;
|
||||||
"Node\'s logs")
|
"Node's logs")
|
||||||
|
logtype="node";
|
||||||
read -p "Enter IP address: " node_ip
|
read -p "Enter IP address: " node_ip
|
||||||
read -p "Enter port: " node_port
|
read -p "Enter port: " node_port
|
||||||
|
about_platform;
|
||||||
_node $node_ip $node_port;
|
_node $node_ip $node_port;
|
||||||
break;
|
break;
|
||||||
;;
|
;;
|
||||||
@ -205,7 +207,6 @@ _lic() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_vm_host() {
|
_vm_host() {
|
||||||
echo $type_log;
|
|
||||||
echo "it's coming soon!";
|
echo "it's coming soon!";
|
||||||
vm_name=$1;
|
vm_name=$1;
|
||||||
vm_id=$2;
|
vm_id=$2;
|
||||||
@ -214,14 +215,14 @@ _vm_host() {
|
|||||||
_node() {
|
_node() {
|
||||||
node_ip=$1;
|
node_ip=$1;
|
||||||
node_port=$2;
|
node_port=$2;
|
||||||
mysql_connect "${node_ip}_db.log" "'select id,name from vm_node where ip_addr=\\\"$node_ip\\\";'"
|
mysql_connect "${node_ip}_db.log" "'select id,name,comment,cluster,ram_mib,max_vcpu_number,cpu_number,ip_addr,ssh_port,host_max_num,state,connection_error,libvirt_error,gray_ips,disk_params,property,host_creation_blocked,mon_installed,mon_install_date,metrics_timestamp,os_version,kernel_version,uptime,libvirt_version,qemu_version,overselling,hostname,vnc_addr,selinux_enforcing,problems,hdd_overselling,ip_addr_v6,bird_error,lxd_error,lxd_version,host_limit,socket_number,ha_state,ha_disable_failed,ha_error,update_dc_networks_failed,network_settings_lock,network_error,frr_error,host_filter,vm5_data,additional_data,vcpu_limit,spice_error from vm_node where ip_addr=\\\"$node_ip\\\"\\G;'"
|
||||||
node_connect $node_ip $node_port "${node_ip}_hostnamectl.log" "hostnamectl";
|
node_connect $node_ip $node_port "${node_ip}_hostnamectl.log" "hostnamectl";
|
||||||
node_connect $node_ip $node_port "${node_ip}_release.log" "\"cat /etc/*release\"";
|
node_connect $node_ip $node_port "${node_ip}_release.log" "\"cat /etc/*release\"";
|
||||||
node_connect $node_ip $node_port "${node_ip}_dmesg.log" "\"dmesg | grep -i -E 'error|failed|critical|bug|panic'\"";
|
node_connect $node_ip $node_port "${node_ip}_dmesg.log" "\"dmesg | grep -i -E 'error|failed|critical|bug|panic'\"";
|
||||||
node_connect $node_ip $node_port "${node_ip}_services.log" "\"journalctl | grep -i -E 'error|failed|critical|bug|panic'\"";
|
node_connect $node_ip $node_port "${node_ip}_services.log" "\"journalctl | grep -i -E 'error|failed|critical|bug|panic'\"";
|
||||||
node_connect $node_ip $node_port "${node_ip}_services.log" "\"systemctl status libvirtd -l\"";
|
node_connect $node_ip $node_port "${node_ip}_services.log" "\"systemctl status libvirtd -l\"";
|
||||||
node_connect $node_ip $node_port "${node_ip}_services.log" "\"systemctl show libvirtd\"";
|
node_connect $node_ip $node_port "${node_ip}_services.log" "\"systemctl show libvirtd\"";
|
||||||
node_connect $node_ip $node_port "${node_ip}_sshd_config" "\"cat /etc/ssh/sshd_config\"";
|
node_connect $node_ip $node_port "${node_ip}_sshd_config" "\"cat /etc/ssh/sshd_config\"";
|
||||||
|
|
||||||
node_connect $node_ip $node_port "${node_ip}_hwinfo.log" "lscpu";
|
node_connect $node_ip $node_port "${node_ip}_hwinfo.log" "lscpu";
|
||||||
node_connect $node_ip $node_port "${node_ip}_hwinfo.log" "lscpu | grep -i -E 'socket|core|thread'";
|
node_connect $node_ip $node_port "${node_ip}_hwinfo.log" "lscpu | grep -i -E 'socket|core|thread'";
|
||||||
@ -251,22 +252,33 @@ _node() {
|
|||||||
node_connect $node_ip $node_port "${node_ip}_disks.log" "\"df -h --exclude tmpfs --exclude devtmpfs --exclude squashfs --exclude overlay\"";
|
node_connect $node_ip $node_port "${node_ip}_disks.log" "\"df -h --exclude tmpfs --exclude devtmpfs --exclude squashfs --exclude overlay\"";
|
||||||
node_connect $node_ip $node_port "${node_ip}_disks.log" "\"df -i\"";
|
node_connect $node_ip $node_port "${node_ip}_disks.log" "\"df -i\"";
|
||||||
node_connect $node_ip $node_port "${node_ip}_disks.log" "lsblk";
|
node_connect $node_ip $node_port "${node_ip}_disks.log" "lsblk";
|
||||||
|
echo "collected logs about node $node_ip $node_port";
|
||||||
finish;
|
finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
about_platform;
|
|
||||||
|
|
||||||
if [[ "$1" == "-logs" || "$1" == "1" ]]; then
|
if [[ "$1" == "-logs" || "$1" == "1" ]]; then
|
||||||
|
logtype="logs";
|
||||||
|
about_platform;
|
||||||
_logs;
|
_logs;
|
||||||
elif [[ "$1" == "-short-logs" || "$1" == "2" ]]; then
|
elif [[ "$1" == "-short-logs" || "$1" == "2" ]]; then
|
||||||
|
logtype="short-logs";
|
||||||
|
about_platform;
|
||||||
_short_logs;
|
_short_logs;
|
||||||
elif [[ "$1" == "-lic" || "$1" == "3" ]]; then
|
elif [[ "$1" == "-lic" || "$1" == "3" ]]; then
|
||||||
|
logtype="lic";
|
||||||
|
about_platform;
|
||||||
_lic;
|
_lic;
|
||||||
elif [[ "$1" == "-node" || "$1" == "4" ]]; then
|
elif [[ "$1" == "-node" || "$1" == "4" ]]; then
|
||||||
|
logtype="node";
|
||||||
if [[ -z $2 || -z $3 ]]; then
|
if [[ -z $2 || -z $3 ]]; then
|
||||||
echo "please set IP address and port of node!";
|
echo "please set IP address and port of node!";
|
||||||
|
read -p "Enter IP address: " node_ip
|
||||||
|
read -p "Enter port: " node_port
|
||||||
|
about_platform;
|
||||||
|
_node $node_ip $node_port;
|
||||||
exit;
|
exit;
|
||||||
else
|
else
|
||||||
|
about_platform;
|
||||||
_node $2 $3;
|
_node $2 $3;
|
||||||
fi
|
fi
|
||||||
#elif [[ "$1" == "-vm-host" || "$1" == "5" ]]; then
|
#elif [[ "$1" == "-vm-host" || "$1" == "5" ]]; then
|
||||||
|
Reference in New Issue
Block a user