rsyslog mysql 更改格式

rsyslog mysql 更改格式

我在服务器上安装了 rsyslog 7.6.7,其中有一些文件包含

2018-07-19 12:38:49~,~"Phone" <672094>~,~672094~,~0~,~atx_78342~,~SIP/teleserver-1.ha-000000ce~,~SIP/s_ru-000000cf~,~Dial~,~SIP/s_ru/1#00#100,,trg~,~4.880648~,~0.000000~,~NO ANSWER~,~DOCUMENTATION~,~~,~~,~212.62.62.11~,~6282837472.210~,~~,~in_sajdh3hg2321nb312bv3sae3b2j4v2k3jgv42h3gv423~,~~,~2018-07-19 12:38:53
2018-07-19 12:38:49~,~"Phone" <672094>~,~672094~,~100~,~atx_78342~,~SIP/s_en-000000d0~,~SIP/s_ru-000000d1~,~Dial~,~SIP/s_ru/59393-100,20,t~,~4.551456~,~0.000000~,~NO ANSWER~,~DOCUMENTATION~,~~,~~,~~,~6282837472.212~,~~,~in_sajdh3hg2321nb312bv3sae3b2j4v2k3jgv42h3gv423~,~~,~2018-07-19 12:38:53
2018-07-19 12:39:21~,~"Phone" <672094>~,~672094~,~59393-100~,~search_peer_context~,~SIP/s_en-000000d7~,~SIP/teleserver-dev.ha-000000e4~,~Hangup~,~31~,~18.012724~,~0.000000~,~NO ANSWER~,~DOCUMENTATION~,~~,~~,~~,~1984726432.219~,~~,~in_sajdh3hg2321nb312bv3sae3b2j4v2k3jgv42h3gv423~,~~,~2018-07-19 12:39:39

我需要从这个文件中获取它,然后将其放入mysql和rsyslog表中

CREATE TABLE atx_asterisk_cdr (
  calldate datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  clid varchar(80) NOT NULL DEFAULT '',
  src varchar(80) NOT NULL DEFAULT '',
  dst varchar(80) NOT NULL DEFAULT '',
  dcontext varchar(80) NOT NULL DEFAULT '',
  channel varchar(80) NOT NULL DEFAULT '',
  dstchannel varchar(80) NOT NULL DEFAULT '',
  lastapp varchar(80) NOT NULL DEFAULT '',
  lastdata varchar(80) NOT NULL DEFAULT '',
  duration int(11) NOT NULL DEFAULT '0',
  billsec int(11) NOT NULL DEFAULT '0',
  disposition varchar(45) NOT NULL DEFAULT '',
  amaflags int(11) NOT NULL DEFAULT '0',
  accountcode varchar(20) NOT NULL DEFAULT '',
  userfield varchar(255) NOT NULL DEFAULT '',
  userip varchar(50) NOT NULL,
  uniqueid varchar(32) NOT NULL DEFAULT '',
  called_did varchar(25) DEFAULT NULL,
  atx_call_id varchar(64) DEFAULT NULL,
  KEY calldate (calldate),
  KEY dst (dst),
  KEY accountcode (accountcode),
  KEY clid (clid),
  KEY src (src),
  KEY dcontext (dcontext),
  KEY channel (channel),
  KEY dstchannel (dstchannel),
  KEY lastdata (lastdata),
  KEY duration (duration),
  KEY billsec (billsec),
  KEY disposition (disposition),
  KEY amaflags (amaflags),
  KEY userfield (userfield),
  KEY uniqueid (uniqueid),
  KEY called_did (called_did),
  KEY atx_call_id (atx_call_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

我使用 imfile 和 ommysql 。那么,您能帮我制作模板来更改 mysql 表的消息格式吗?

相关内容