* Update dynmotd script (new process and sockets informations).

This commit is contained in:
gardouille 2015-02-02 10:22:24 +01:00
parent a82707bbb2
commit 4039d202db
2 changed files with 158 additions and 5 deletions

View File

@ -1,6 +1,13 @@
---------------------------------------
###
##### Changes
* Update dynmotd script (new process and sockets informations).
---------------------------------------
### 0.1.0 - 2015/01/23
Initial release.

View File

@ -54,9 +54,10 @@ service_info() {
for PORT in ${PORT_LIST}; do
MSG="${MSG}${MAGENTA}+ "
# If a port listen
if (netstat -lnt|grep -m1 ${PORT} > /dev/null); then
if (ss -lutn|grep -m1 ":${PORT}" > /dev/null); then
# Example: "tcp/127.0.0.1:25"
MSG="${MSG}${GREEN}$(netstat -lnt|grep -m1 ${PORT}|awk '{print $1"/"$4}')${RESET} "
#MSG="${MSG}${GREEN}$(ss -lutn|grep -m1 ":${PORT}"|awk '{print $1"/"$5}')${RESET} "
MSG="${MSG}${GREEN}$(ss -lutn|grep ${PORT}|sort|head -n1|awk '{print $1"/"$5}')${RESET} "
else
# Example: "22: NOT LISTENING"
MSG="${MSG}${REDB}${PORT}: NOT LISTENING${RESET} "
@ -176,11 +177,156 @@ done
printf '%b' "\n${MAGENTA}+++++++++++++++++++: ${WHITE}Service Info${MAGENTA} :++++++++++++++++++++${RESET}"
## IF POSTFIX
MSG=$(process_info "postfix" '')
MSG=$(service_info "25" "${MSG}")
printf '%b' "\n${MSG}"
if [ $(which postfix) ]; then
MSG=$(process_info "postfix" '')
MSG=$(service_info "25" "${MSG}")
printf '%b' "\n${MSG}"
fi
## FI POSTFIX
### IF APACHE2
if [ $(which apache2) ]; then
MSG=$(process_info "apache2" '')
MSG=$(service_info "80 443" "${MSG}")
printf '%b' "\n${MSG}"
fi
### FI APACHE2
### IF NGINX
if [ $(which nginx) ]; then
MSG=$(process_info "nginx" '')
MSG=$(service_info "80 443" "${MSG}")
printf '%b' "\n${MSG}"
fi
### FI NGINX
### IF MYSQLD
if [ $(which mysqld) ]; then
MSG=$(process_info "mysqld" '')
MSG=$(service_info "3306" "${MSG}")
printf '%b' "\n${MSG}"
fi
### IF MYSQLD
### IF SLAPD
if [ $(which slapd) ]; then
MSG=$(process_info "slapd" '')
MSG=$(service_info "389 636" "${MSG}")
printf '%b' "\n${MSG}"
fi
### IF SLAPD
### IF ZFS
if [ $(which zfs) ]; then
MSG=$(process_info "zfs" '')
printf '%b' "\n${MSG}"
fi
### FI ZFS
### IF PUPPETMASTER
if [ $(which puppetmaster) ]; then
MSG=$(process_info "puppetmaster" '')
MSG=$(service_info "8140" "${MSG}")
printf '%b' "\n${MSG}"
fi
### IF SLAPD
### IF NFS Server
if [ $(which nfsd) ]; then
MSG=$(process_info "nfsd" '')
MSG=$(service_info "111 2049" "${MSG}")
printf '%b' "\n${MSG}"
fi
### IF SLAPD
### IF TFTPD
if [ $(which in.tftpd) ]; then
MSG=$(process_info "in.tftpd" '')
#MSG=$(service_info "69" "${MSG}")
printf '%b' "\n${MSG}"
fi
### FI TFTPD
### IF SQUID3
if [ $(which squid3) ]; then
MSG=$(process_info "squid3" '')
MSG=$(service_info "3128" "${MSG}")
printf '%b' "\n${MSG}"
fi
### FI SQUID3
### IF APT-CACHER-NG
if [ $(which apt-cacher-ng) ]; then
MSG=$(process_info "apt-cacher-ng" '')
MSG=$(service_info "3142" "${MSG}")
printf '%b' "\n${MSG}"
fi
### FI APT-CACHER-NG
### IF SSHD
if [ $(which sshd) ]; then
MSG=$(process_info "sshd" '')
MSG=$(service_info "22" "${MSG}")
printf '%b' "\n${MSG}"
fi
### FI SSH
### IF DHCPD
if [ $(which dhcpd) ]; then
MSG=$(process_info "dhcpd" '')
printf '%b' "\n${MSG}"
fi
### IF DHCPD
### IF FAIL2BAN
if [ $(which fail2ban-server) ]; then
MSG=$(process_info "fail2ban" '')
printf '%b' "\n${MSG}"
fi
### IF FAIL2BAN
### IF ETHERPAD
if [ $(which etherpad) ]; then
MSG=$(process_info "etherpad" '')
MSG=$(service_info "9001" "${MSG}")
printf '%b' "\n${MSG}"
fi
### IF ETHERPAD
### IF ETHERCALC
if [ $(which ethercalc) ]; then
MSG=$(process_info "ethercalc" '')
MSG=$(service_info "8000" "${MSG}")
printf '%b' "\n${MSG}"
fi
### IF ETHERCALC
### IF GITLAB
if [ $(which gitlab-ctl) ]; then
MSG=$(process_info "nginx" '')
MSG=$(service_info "80 443" "${MSG}")
printf '%b' "\n${MSG}"
MSG=$(process_info "gitlab" '')
printf '%b' "\n${MSG}"
fi
### IF GITLAB
### IF XYMONSERVER
if [ $(which xymond) ]; then
MSG=$(process_info "xymond" '')
MSG=$(service_info "1984" "${MSG}")
printf '%b' "\n${MSG}"
fi
### IF XYMONSERVER
### IF XYMONCLIENT
if [ $(which xymon) ]; then
MSG=$(process_info "xymonlaunch" '')
printf '%b' "\n${MSG}"
fi
### IF XYMONCLIENT
## Service need a warning if running
YELLOW_SERVICE='tmux screen glances htop automysqlbackup vzdump puppet aptitude'
for SERVICE in ${YELLOW_SERVICE}; do