-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from splunk/feature/fix-host
Dyanamic reverse DNS
- Loading branch information
Showing
6 changed files
with
204 additions
and
51 deletions.
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
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,46 @@ | ||
| python { | ||
|
|
||
| """ | ||
| simple syslog-ng Python parser example | ||
| resolves IP to hostname | ||
| value pair names are hard-coded | ||
| """ | ||
| import re | ||
| import socket | ||
|
|
||
| class FixHostResolver(object): | ||
|
|
||
| def parse(self, log_message): | ||
| """ | ||
| Resolves IP to hostname | ||
| """ | ||
|
|
||
|
|
||
| # try to resolve the IP address | ||
| try: | ||
| ipaddr = log_message['HOST'].decode('utf-8') | ||
|
|
||
| resolved = socket.gethostbyaddr(ipaddr) | ||
| hostname = resolved[0] | ||
| log_message['HOST'] = hostname | ||
| except: | ||
| pass | ||
|
|
||
| # return True, other way message is dropped | ||
| return True | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| parser p_fix_host_resolver { | ||
| python( | ||
| class("FixHostResolver") | ||
| ); | ||
| }; | ||
|
|
||
| parser p_add_context_host { | ||
| add-contextual-data( | ||
| selector("${HOST}"), | ||
| database("conf.d/local/context/host.csv"), | ||
| ); | ||
| }; |
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 @@ | ||
| 169.254.0.2,HOST,foo.example |
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
Oops, something went wrong.