tcpdump_parser.jar <interval in seconds>This is the full usage example of TCPDUMP and the Java Application
Last login: Fri Sep 21 11:29:36 on ttys001 #$ tcpdump -i en0 -l -e -n -w testCaptureKB.cap tcpdump: listening on en0, link-type EN10MB (Ethernet), capture size 262144 bytes ^C182671 packets captured 182674 packets received by filter #$ tcpdump -r testCaptureKB.cap > testCaptureKBReadable reading from file testCaptureKB.cap, link-type EN10MB (Ethernet) #$ cat testCaptureKBReadable | java -jar ~/testjava.jar 1 Time,Bytes 16:14:30,3653 16:14:32,638 16:14:34,9596 16:14:36,7662 16:14:38,23327 ... ... 16:16:54,3132 16:16:56,93 16:16:58,6283 #$
tcpdump -i eth1 -l -e -n | java -jar tcpdump_parser.jar <interval in seconds>
if (accumulatedBytes > accumulationLimitPerInterval) {
//Your alert code here. For example perform a request to an endpoint using a Java Client
//It can be used to call and HTTP endpoint in a Mule Application
// The following is an example with http request
try {
URL url = new URL("http://localhost:8081?appName=someapp&type=trafficExceeded");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
int status = con.getResponseCode();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
System.out.println("Status: "+status + " response: " + inputLine);
in.close();
con.disconnect();
} catch (IOException e) {
System.out.println("ERROR sending ALERT request");
throw new Exception(e);
}
}
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="monitorapiFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<logger message="received message from application: #[message.inboundProperties.'http.query.params'.appName] type of alert: #[message.inboundProperties.'http.query.params'.type]" level="INFO" doc:name="Logger"/>
</flow>
******************************************************************************************************* * - - + APPLICATION + - - * - - + DOMAIN + - - * - - + STATUS + - - * ******************************************************************************************************* * monitorapi * default * DEPLOYED * ******************************************************************************************************* INFO 2018-09-21 19:56:41,450 [[monitorapi].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: received message from application: someapp type of alert: trafficExceeded
Each type of alert can be routed in a choice to trigger different sub-flows and perform custom actions like sending emails
Please consider that the support of the custom code provided is outside MuleSoft Support Scope. They are provided as a guideline together with the source code that you can modify to suit your needs.
001114463

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.