通过 TCP 生成系统日志的简单方法?

som*_*ser 6 command-line syslog

我想对 logstash 服务器问题进行故障排除,并且需要不时生成 syslog 消息。有没有一种简单的方法可以让我使用 TCP 连接到系统日志服务器并发送一些任意的系统日志消息?

Goh*_*ohu 11

网猫

将每一行发送到端口上的file.logsyslog 服务器127.0.0.1514

nc -q0 127.0.0.1 514 < file.log
Run Code Online (Sandbox Code Playgroud)

发送一个将生成单个日志条目的简单字符串:

echo "message" | nc -q0 127.0.0.1 514
Run Code Online (Sandbox Code Playgroud)

-q0使得nc退出后发送:

-q seconds 在 stdin 上的 EOF 之后,等待指定的秒数然后退出。

泛洪

tcpflood实用程序有相当多有用的选项。以下是一小部分tcpflood选项:

-t  target address (default 127.0.0.1)
-p  target port (default 13514)
-c  number of connections (default 1)
-m  number of messages to send (connection is random)
-M  the message to be sent. Disables all message format options, as only that exact same message is sent.
-I  read specified input file, do NOT generate own test data. The test completes when eof is reached.
-D  randomly drop and re-establish connections. Useful for stress-testing the TCP receiver.
-T  transport to use. Currently supported: "udp", "tcp" (default) Note: UDP supports a single target port, only
Run Code Online (Sandbox Code Playgroud)

  • 不确定是否需要编辑,我有 nmap-ncat 包及其 `--send-only` 与 `-q0` (3认同)