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.