Cacti gets the number of server TCP concurrent connections (cacti Windows edition)

Source: Internet
Author: User
Tags snmp


Because the official does not provide the Windows version of cacti to monitor the number of TCP connections in the script, so here is the use of Linux version cacti monitoring TCP connection number of Bash scripts write bat batch file.


1, first download from http://forums.cacti.net/download/file.php?id=5198 officially provided by the Inux version cacti monitoring TCP connection number of bash script and monitoring template Tcp-connections.zip


2, decompression Tcp-connections.zip extract out, three files, a cacti_graph_template_tcp_connections.xml file, a get_tcp_connections bash file, And a picture of you yy


Here we want to write Get_tcp_connections.bat program to the path of the script program in the Cacti_graph_template_tcp_connections.xml file and to the contents of the reference get_tcp_connections file.


3. Modify the path of the script program in the Cacti_graph_template_tcp_connections.xml file. As follows:

Modify the Cacti_graph_template_tcp_connections.xml file

Open the XML file with Notepad, CTRL + F to find the string "input_string", and you will see a line similar to <input_string>/bin/bash/var/www/htdocs/cacti/scripts/get_ Tcp_connections

The code, about 438 lines, as the name implies, this is the execution of the provided script location, for example, my is C:\Apache24\htdocs\cacti\scripts\get_tcp_connections.bat

Revise it according to the actual situation.

Because our script is a bat script under Windows, the previous/bin/bash also needs to be deleted. The end result is as follows:


Original content <input_string>/bin/bash/var/www/htdocs/cacti/scripts/get_tcp_connections &lt;host&gt; &lt;community&gt;</input_string>

Modified Content <input_string>c:\apache24\htdocs\cacti\scripts\get_tcp_connections.bat &lt;host&gt; &lt;community&gt;</input_string>


4. Import Cacti_graph_template_tcp_connections.xml Drawing Template:

Login Cacti Monitoring Platform Console (console)---> Import Templates (import Template)


5. The new C:\Apache24\htdocs\cacti\scripts\get_tcp_connections.bat content is as follows:

Note the search for the characters, and the script found under Linux is a little different

:: Get number of TCP connection

:: $ = hostname

:: $ = SNMP Community

:: Lots of ways to does this with more style ...;)

@ECHO off

SET cactidir=c:\apache24\htdocs\cacti\scripts

SET tmpdir=c:\apache24\htdocs\cacti\temp


C:\net-snmp\bin\snmpnetstat.exe-v 2c-c%2-can-cp tcp%1 >%tmpdir%\%1


Type%tmpdir%\%1 | FIND/C "established" >%tmpdir%\established

Type%tmpdir%\%1 | FIND/C "LISTEN" >%tmpdir%\listening

Type%tmpdir%\%1 | FIND/C "Timewait" >%tmpdir%\time_wait

Type%tmpdir%\%1 | FIND/C "Timeclose" >%tmpdir%\time_close

Type%tmpdir%\%1 | FIND/C "Synsent" >%tmpdir%\synsent

Type%tmpdir%\%1 | FIND/C "FINWAIT1" >%tmpdir%\fin1

Type%tmpdir%\%1 | FIND/C "FINWAIT2" >%tmpdir%\fin2

Type%tmpdir%\%1 | FIND/C "Synrecv" >%tmpdir%\synrecv


set/p established= <%tmpdir%\established

set/p listening= <%tmpdir%\listening

set/p time_wait= <%tmpdir%\time_wait

set/p time_close= <%tmpdir%\time_close

set/p synsent= <%tmpdir%\synsent

set/p fin1= <%tmpdir%\fin1

set/p fin2= <%tmpdir%\fin2

set/p synrecv= <%TMPDIR%\SYNRECV


ECHO established:%established% listen:%listening% time_wait:%time_wait% time_close:%time_close% syn_sent:%SYNSENT% fin_wait1:%fin1% fin_wait2:%fin2% syn_recv:%synrecv%

del/q%tmpdir%\*


6, testing the SNMP service is normal

Use the Windows command line.

C:\users\administrator>c:\apache24\htdocs\cacti\scripts\get_tcp_connections.bat 127.0.0.1 Public

#正常情况下会返回tcp状态的相关数据


7. Now we can create images like adding other monitoring object methods in Console->device-> host->associated Graph templates.

8, Save, 5 minutes after you can see the picture.

9. Note that the bat script does not support SNMP community that contain "="

This article is from the "Jedy Network Technology &linux Learning" blog, please be sure to keep this source http://jedy82.blog.51cto.com/425872/1599359

Cacti gets the number of server TCP concurrent connections (cacti Windows edition)

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.