Run as client

Connect to other server process.

Socket client connection will be enabled by writing the following lines in the .mdf file. Be sure that you should not set both Plugin_Remote_EnableServer and Plugin_Remote_EnableClient in a .mdf file.

# configuration in .mdf to enable client function
Plugin_Remote_EnableClient=true
Plugin_Remote_Hostname=localhost
Plugin_Remote_Port=39392

MMDAgnet-EX will try to make connection to the specified host and port at start up. When connection was established, MMDAgent-EX will send all messages to the remote server, and also receive messages from the server and issue them to the internal message queue.

If you want the MMDAgent-EX to send all raw logs to server, set Plugin_Remote_AllLog to true.

# configuration in .mdf to enable sending all raw log
Plugin_Remote_AllLog=true

Server example in Python

Here is some example server script that can accept connection from MMDAgent-EX client.

Receive messages from MMDAgent-EX client

Receives messages from the client MMDAgent-EX and output them to stdout.

# Example 2: wait connection from MMDAgent-EX running as client, capture messages from it
import socket
server = ("127.0.0.1", 39392)
listen_num = 5
tcp_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_server.bind(server)
tcp_server.listen(listen_num)
while True:
   client, address = tcp_server.accept()
   print("[*] connected: {}".format(address))
   while True:
      try:
         rcvmsg = client.recv(4096)
         print("[*] received: {}".format(rcvmsg))
      except Exception as e:
         print(e)
   client.close()

Send a message to MMDAgent-EX client

One-response server script, sending a message to a connected client and disconnect.

# Example 1: wait connection from MMDAgent-EX running as client, post message and disconnect
import socket
server = ("127.0.0.1", 39392)
listen_num = 5
tcp_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_server.bind(server)
tcp_server.listen(listen_num)
while True:
   client, address = tcp_server.accept()
   print("[*] connected: {}".format(address))
   client.send(b"MESSAGE|aaa|bbb")
   client.close()

Last modified May 7, 2020: Tweaking menu (3eeef3c)