Linx monitoring sharing-network status monitoring + email reminder
Network Status Monitoring
Network Status: the total number and details of netstat statuses, and the detailed connection status of key ports (8080,). The ip addresses with the most connections on the client are printed.
The current status of the email report.
For the number of connections on each port, you can set the threshold and add an if judgment to complete the report function.
Install Netease's email client on your mobile phone to receive real-time notifications.
#! /Bin/shsource/etc/profileIP = '/sbin/ifconfig | sed-n'/inet addr/s/^ [^:] *: \ ([0-9.] \ {7, 15 \}\). */\ 1/P' | grep-V' 127. 0.0.1 ''warn _ pct = 1 # 75warn_name = [NET-State] performance_path =/monitor/performancemailtmp =/u01/soft/smonitor/mailtmplet/"$ warn_name" tmp. mailinfotmp =/u01/soft/smonitor/mailtmplet/"$ warn_name" tmp. tmpmaillist = 490073687@qq.com, zhou.xiangxing210@163.com DT = 'date + "% Y-% m-% d % H: % M: % S" 'netstat-na P> $ infotmpcat $ infotmp | grep '^ tcp'> $ infotmp. tmpstat_help = "\ n ----------------------------- Stat Mean -------------------------------" stat_help = "$ stat_help" "\ n LISTEN: Listening for a connection. listening for connection requests from remote TCP ports "stat_help =" $ stat_help "" \ n SYN-SENT: Active; sent SYN. waiting for a matching connection request after having sent a connection request. "stat_help =" $ stat_help "" \ n. After sending the connection request again, wait for the matching connection request. "stat_h Elp = "$ stat_help" "\ n SYN-RECEIVED: Sent and received ed SYN. waiting for a confirming connection request acknowledgment "stat_help =" $ stat_help "" \ n after having both received Ed and sent connection requests. after receiving and sending a Connection request, wait for the other party to confirm the Connection request "stat_help =" $ stat_help "" \ n ESTABLISHED: Connection established. represents an open connection "stat_help =" $ stat_help "" \ n FIN-WAIT-1: Closed; sent FIN. "stat_help =" $ stat _ Help "" \ n FIN-WAIT-2: Closed; FIN is acknowledged; awaiting FIN. from Remote TCP waiting for connection interruption request "stat_help =" $ stat_help "" \ n CLOSE-WAIT: canceled ed FIN; waiting to receive CLOSE. waiting for a connection interruption request from a local user "stat_help =" $ stat_help "" \ n CLOSING: Closed; exchanged FIN; waiting for FIN. wait for remote TCP to confirm connection interruption "stat_help =" $ stat_help "" \ n LAST-ACK: pinned ed FIN and CLOSE; waiting for fin ack. wait for confirmation of the original remote TCP connection interruption request "stat_help =" $ stat_help "" \ n TIM E-WAIT: In 2 MSL (twice the maximum segment length) quiet wait after close. wait for enough time to confirm that the remote TCP receives the Connection interruption request "stat_help =" $ stat_help "" \ n CLOSED: Connection is closed. no connection status "stat_help =" $ stat_help "" \ n ------------------------------------------------------------ "echo" hello, "> $ mailtmpecho-e" [$ DT] Server: $ IP network connection information. \ N total: ">>$ mailtmpcat $ infotmp. tmp | awk '{print $6}' | sort | uniq-c | sort >>$ mailtmpecho "[$ DT] Details:" >>$ mailtmpcat $ infotmp. tmp | awk '{print $7 "" $6}' | sort | uniq-c | sort> $ mailtmpecho "success"> $ mailtmp # mysql connections 3306cat $ infotmp. tmp | grep 3306 | grep mysqld | grep-v LISTEN> $ infotmp. tmp.3306mysql _ conn = 'cat $ infotmp. tmp.3306 | wc-l 'echo "mysql 3306 port connection Quantity: $ mysql_conn ">$ mailtmpecho" mysql 3306 Port Number of connections per ip Address: ">>$ mailtmpcat $ infotmp. tmp.3306 | awk '{print $5}' | awk-F ': ''{print $4} '| sort | uniq-c | sort> $ mailtmpecho" -------------------------------------------------------- "> $ mailtmp # ssh connection 22cat $ infotmp. tmp | grep 22 | grep sshd | grep-v LISTEN> $ infotmp. tmp.22ssh _ conn = 'cat $ infotmp. tmp.22 | wc-l 'echo "ssh 22 port connections: $ ssh_conn" >>$ mailtmpecho "ssh 2 The number of connections per ip address on Port 2 is as follows: ">>$ mailtmpcat $ infotmp. tmp.22 | awk '{print $5}' | awk-F ': ''{print $1} '| sort | uniq-c | sort> $ mailtmpecho" ---------------------------------------------------------- "> $ mailtmp # httpd connections 80cat $ infotmp. tmp | grep 80 | grep httpd | grep-v LISTEN> $ infotmp. tmp.80httpd _ conn = 'cat $ infotmp. tmp.80 | wc-l 'echo "http 80 port connections: $ httpd_conn" >>$ mailtmpecho "http 80 port connections per ip Address:" >>$ mailtmpcat $ Infotmp. tmp.80 | awk '{print $5}' | awk-F ': ''{print $4} '| sort | uniq-c | sort> $ mailtmpecho" ---------------------------------------------------------- "> $ mailtmp # ssh connections 80cat $ infotmp. tmp | grep 8080 | grep java | grep-v LISTEN> $ infotmp. tmp.8080apache _ conn = 'cat $ infotmp. tmp.8080 | wc-l 'echo "tomcat 8080 port connections: $ apache_conn" >>$ mailtmpecho "tomcat 8080 port connections per ip Address:" >>$ mailtmpcat $ infotmp. tmp.8080 | Awk '{print $5}' | awk-F ': ''{print $4} '| sort | uniq-c | sort> $ mailtmpecho" success "> $ mailtmpecho-e" $ stat_help "> $ mailtmpDT = 'date + "% Y-% m-% d % H: % M: % S "'echo-e" \ nBest Wishes! \ N ---------------------------------- \ nCA system Monitor \ n $ DT ">>$ mailtmpcat $ mailtmp # cat $ mailtmp | mailx-s" $ warn_name [network monitoring]: Server: $ IP "$ maillist
Email reminder Effect