summaryrefslogtreecommitdiffstats
path: root/logs.lua
blob: 8b50c989b7f9f4e3ce6bd7db001e5581a0536c2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- require "luarocks.require"

rex_pcre = require "rex_pcre"

do
 function conky_filter_syslog(log, lines)
    local data = conky_parse('${tail ' .. log .. ' ' .. lines .. ')}')
--    return rex_pcre.gsub(data,"(MAC|OUT|IN|TOS|PREC|ID|RES)=[\\w\\d:]*\\s", "")
    local lines = rex_pcre.split(data, "\\x02")
    local res = {}
    for line in  lines do
	if (rex_pcre.match(line, "\\*\\*\\*\\s*(PortScan|SynFlood.*|BlackList|Fragments|DeathPing)\\s*\\*\\*\\*")) then
	    local fixed = rex_pcre.gsub(line,"(MAC|OUT|IN|TOS|PREC|ID|RES)=[\\w\\d:]*\\s", "")
	    table.insert(res, fixed)
	else 
	    table.insert(res, line)
	end
    end
    return table.concat(res, "\n")
 end
end