#!/usr/local/bin/bash # # checkbnc script # # FREEBSD ONLY (linux/solaris do not have sockstat) # -- perhaps a future version for linux/solaris using lsof # Checks IRC connections of different processes and counts them # # Zoidial, Inc. # Eric Thern, 2001 # # v0.1 10/25/2001 - initial release, only checked BNC's # v0.2 11/03/2001 - added eggdrop, ircd, and ALL connections # v0.4 11/04/2001 - fixed egrep statement for less false positives # # -- NOTES -- # this is a bit wordy, and can be split into different scripts easily # if needed. just split any line beginning with the word "sockstat" and # put them in their own script for fast checking. # until test do echo "" echo "This script shows connections to IRC servers" echo "from both local-->remote and remote-->local" echo "" echo "1) Show BNC / Mech / Proxybot connections" echo "2) Show Eggdrop connections" echo "3) Show BitchX connections" echo "4) Show IRCd connections" echo "5) Show ALL IRC connections" echo "6) (q)uit" echo "" read test case $test in 1) echo "" echo "Bot / Mech / Proxybot Connections" echo "---------------------------------" echo "# = number of concurrent connections" echo " # User Process PID IP Address" echo "----------------------------------------------------" sockstat |egrep '(bnc|psybnc|ezbnc|ez|mech|emech|mirkforce|Mirkforce|iroffer|xdcc|sc_serv)' |egrep '(:666|:7000)' | awk '{print $1 "\t" $2 "\t\t" $3 "\t" $6}' | awk -F":" '{print $1}' | awk '{ if ($4 != "\*")print $1 "\t" $2 "\t\t" $3 "\t" $4}' | uniq -c | sort | more ;; 2) echo "" echo "IRC BOT Connections" echo "-------------------" echo "# = number of concurrent connections" echo " # User Process PID IP Address" echo "----------------------------------------------------" sockstat |egrep '(egg)' |egrep '(:666|:7000)' | awk '{print $1 "\t" $2 "\t\t" $3 "\t" $6}' | awk -F":" '{print $1}' | awk '{ if ($4 != "\*")print $1 "\t" $2 "\t\t" $3 "\t" $4}' | uniq -c | sort | more ;; 3) echo "" echo "BitchX Connections" echo "------------------" echo "# = number of concurrent connections" echo " # User Process PID IP Address" echo "----------------------------------------------------" sockstat |egrep '(BitchX)' |egrep '(:666|:7000)' | awk '{print $1 "\t" $2 "\t\t" $3 "\t" $6}' | awk -F":" '{print $1}' | awk '{ if ($4 != "\*")print $1 "\t" $2 "\t\t" $3 "\t" $4}' | uniq -c | sort | more ;; 4) echo "" echo "IRCd Connections" echo "----------------" echo "# = number of concurrent connections" echo " # User Process PID IP Address" echo "----------------------------------------------------" sockstat |egrep '(ircd)' | grep tcp | awk '{print $1 "\t" $2 "\t\t" $3 "\t" $6}' | awk -F":" '{print $1}' | awk '{ if ($4 != "\*")print $1 "\t" $2 "\t\t" $3 "\t" $4}' | uniq -c | sort | more ;; 5) echo "" echo "All IRC Connections" echo "-------------------" echo "# = number of concurrent connections" echo " # User Process PID IP Address" echo "----------------------------------------------------" sockstat |egrep '(:666|:7000)' | awk '{print $1 "\t" $2 "\t\t" $3 "\t" $6}' | awk -F":" '{print $1}' | awk '{ if ($4 != "\*")print $1 "\t" $2 "\t\t" $3 "\t" $4}' | uniq -c | sort | more ;; 6) echo "Quitting." exit 0; ;; [qQ]) echo "Quitting." exit 0; ;; esac done