New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scl: add qbittorrent()
and pihole-ftl()
sources
#4760
Merged
MrAnno
merged 3 commits into
syslog-ng:master
from
alltilla:qbittorent-and-pihole-source
Jan 4, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
`pihole-ftl()`: Added a new source, which reads Pi-hole FTL logs. | ||
|
||
The FTL (Faster Than Light) logs are the logs which can be found | ||
in the "Tools" / "Pi-hole diagnosis" menu. | ||
|
||
Example minimal config: | ||
``` | ||
source s_pihole_ftl { | ||
pihole-ftl(); | ||
}; | ||
``` | ||
|
||
By default it reads the `/var/log/pihole/FTL.log` file. | ||
You can change the root dir of Pi-hole's logs with the `dir()` option, | ||
where the `FTL.log` file can be found. | ||
|
||
As the `pihole-ftl()` source is based on a `file()` source, all of the | ||
`file()` source options are applicable, too. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
`qbittorrent()`: Added a new source, which reads qBittorrent logs. | ||
|
||
Example minimal config: | ||
``` | ||
source s_qbittorrent { | ||
qbittorrent( | ||
dir("/path/to/my/qbittorrent/root/log/dir") | ||
); | ||
}; | ||
``` | ||
|
||
The root dir of the qBittorrent logs can be found in the | ||
"Tools" / "Preferences" / "Behavior" / "Log file" / "Save path" field. | ||
|
||
As the `qbittorrent()` source is based on a `file()` source, all of the `file()` | ||
source options are applicable, too. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,10 @@ set(SCL_DIRS | |
osquery | ||
pacct | ||
paloalto | ||
pihole | ||
pgsql | ||
python | ||
qbittorrent | ||
rewrite | ||
slack | ||
snmptrap | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
############################################################################# | ||
# Copyright (c) 2023 Attila Szakacs | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 2 as published | ||
# by the Free Software Foundation, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# As an additional exemption you are allowed to compile & link against the | ||
# OpenSSL libraries as published by the OpenSSL project. See the file | ||
# COPYING for details. | ||
# | ||
############################################################################# | ||
|
||
block parser pihole_ftl() | ||
{ | ||
channel { | ||
parser { | ||
regexp-parser( | ||
patterns('^\[([^ ]+ [^ ]+) [^ \]]+\] (FATAL:|ERR:|ERROR:|Error:|WARN:|WARNING:|Warning:|Notice:|INFO:|DEBUG:|) ?(?<MESSAGE>.*)') | ||
); | ||
date-parser( | ||
template("$1") | ||
format("%Y-%m-%d %H:%M:%S.%f") | ||
); | ||
}; | ||
|
||
rewrite { | ||
set("Pi-hole" value("APP")); | ||
}; | ||
|
||
if ("$2" eq "") { | ||
# No severity was found. | ||
} elif (match("FATAL" value("2"))) { | ||
rewrite { set-severity("emergency"); }; | ||
} elif (match("^(ERR|ERROR|Error):$" value("2"))) { | ||
rewrite { set-severity("error"); }; | ||
} elif (match("^(WARN|WARNING|Warning):$" value("2"))) { | ||
rewrite { set-severity("warning"); }; | ||
} elif (match("^(Notice):$" value("2"))) { | ||
rewrite { set-severity("notice"); }; | ||
} elif (match("^(INFO):$" value("2"))) { | ||
rewrite { set-severity("info"); }; | ||
} elif (match("^(DEBUG):$" value("2"))) { | ||
rewrite { set-severity("debug"); }; | ||
} else {}; | ||
}; | ||
}; | ||
|
||
block source pihole_ftl( | ||
dir("/var/log/pihole") | ||
...) | ||
{ | ||
channel { | ||
source { file("`dir`/FTL.log" flags(no-parse) `__VARARGS__`); }; | ||
parser { pihole_ftl(); }; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
############################################################################# | ||
# Copyright (c) 2023 Attila Szakacs | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 2 as published | ||
# by the Free Software Foundation, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
# | ||
# As an additional exemption you are allowed to compile & link against the | ||
# OpenSSL libraries as published by the OpenSSL project. See the file | ||
# COPYING for details. | ||
# | ||
############################################################################# | ||
|
||
block parser qbittorrent() | ||
{ | ||
channel { | ||
parser { | ||
regexp-parser( | ||
patterns('^\((.)\) ([^ ]+) - (?<MESSAGE>.*)') | ||
); | ||
date-parser( | ||
template("$2") | ||
format("%Y-%m-%dT%H:%M:%S") | ||
); | ||
}; | ||
|
||
rewrite { | ||
set("qBittorrent" value("APP")); | ||
}; | ||
|
||
if (match("C" value("1") type("string"))) { | ||
rewrite { set-severity("critical"); }; | ||
} elif (match("W" value("1") type("string"))) { | ||
rewrite { set-severity("warning"); }; | ||
} elif (match("I" value("1") type("string"))) { | ||
rewrite { set-severity("info"); }; | ||
} elif (match("N" value("1") type("string"))) { | ||
rewrite { set-severity("notice"); }; | ||
} else {}; | ||
}; | ||
}; | ||
|
||
block source qbittorrent( | ||
dir() | ||
...) | ||
{ | ||
channel { | ||
source { file("`dir`/qbittorrent.log" flags(no-parse) `__VARARGS__`); }; | ||
parser { qbittorrent(); }; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would make sense to write a severity-parser() that can be parametrized with patterns but uses a sensible default so that we don't need to write similar constructs.
Also, you should not need the dangling
else{}
at the end.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The severity-parser() is just an idea, it's not a dependency of this PR.
Also, this could be rewritten as:
although this does not support regexps.