#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/mysql-common-tools-connects - MariaDB Server connects # # Creation: 2023-10-03 hbfl # Last Update: $Id$ # # Copyright (c) 2014-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- #include eislib . /var/install/include/eislib # --------------------------------------------------------------------------- # defaults # --------------------------------------------------------------------------- get_defaults() { # default values . /srv/mysql/defaults.info } # --------------------------------------------------------------------------- # check status and access of MariaDB/MySQL Database # --------------------------------------------------------------------------- check_status() { if [ ! -f ${mysql_pid_file} ] then echo mecho --error 'MariaDB/MySQL Server is not running.' echo exit 1 fi ${mysql_basedir}/${db_mysqladmin} --socket=${mysql_socket} \ status >/dev/null 2>&1 if [ ${?} -ne 0 ] then echo mecho -n --error 'MariaDB/MySQL Server' mecho -n --std " 'root' " mecho --error 'password is required.' mecho --info 'Please set the root password.' echo exit 1 fi } # --------------------------------------------------------------------------- # show connects # --------------------------------------------------------------------------- show_connects() { my_version="$(${mysql_basedir}/${db_mysqld} ${skip_ssl} --version | /usr/bin/gawk '/Ver/ {print $3}')" echo echo " * Connections for server ${my_version}" echo echo "____________________Server:_________________Client:_________________________" LANG=C; /usr/bin/ss --tcp --udp -an | /usr/bin/grep ":${mysql_port} " | /usr/bin/gawk '{print $1" "$5" "$6" "$2}' echo echo "____________________Internal sockets:_______________________________________" LANG=C; /usr/bin/ss --unix -an | /usr/bin/grep "mysql/${my_path}" | /usr/bin/gawk '{print $2" "$6" "$5}' echo anykey } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { package_name="${1}" project_name=$(echo "${package_name}" | tr [:lower:] [:upper:]) my_path=$(echo "${package_name}" | sed 's|[^[:digit:]]||g') # include config . /etc/config.d/${package_name} eval ssl_use='${'${project_name}'_SSL_USE:-no}' if [ ${my_path:-110} = 114 ] && [ "${ssl_use}" != "yes" ] then skip_ssl='--skip-ssl' fi get_defaults check_status show_connects exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------