Number of Windows Scan Port links batch

Source: Internet
Author: User

Number of Windows Scan Port links batch

Because we have a problem with the disconnected development of a program here, there are often thousands of links in the established state, but in fact these links should have been disconnected, when the link piled up to a certain extent, the server can not access the situation. That's why the following script was generated.

The purpose of the script is to make a statistic after every fixed time, to determine how long it will take to restart the service based on the growth of the statistics and the number of links that are stacked when the server is unreachable.

@Echo off

Set a=0

Netstat-an | find/i "8830" > C:test

for/f "delims="%%a in (' Type c:test ') do set/a a+=1

@Echo on

echo "%date%%time%----%a%" <nul "E:guishuditongji.txt

Comments:

1. Shutdown the batch process interface output, because the batch processing each operation will have the corresponding output, in order to prevent the content of the record is too confusing, so choose to close these outputs, and in 5 position will output open, so that the record file can only record the content you want;

2. Set a variable, and here forced to assign a value of 0, if not assigned, when the script second run when the size of a will accumulate, resulting in inaccurate data;

3. View the access, and through the Find command to filter the output results;

4. Simple can be regarded as an accumulation calculation;

5. The role of this paragraph has been mentioned in 1;

6. Output the desired information and redirect to the corresponding record file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.