Regex in syslog-ng


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regex in syslog-ng
# 1  
Old 02-09-2016
Regex in syslog-ng

How can i filter the syslog record using regex ?

This is the filter condition that i was trying and cannot seem to get it working


Code:
filter f_proxyhosts { (host("^192\.68\.47\.121\smyhost0[1-9]|1[0-2]")) };


syslog-ng log
Code:
Feb  9 16:26:53 192.68.47.121 myhost01-server: #Version: 1.0_


Last edited by Scrutinizer; 02-10-2016 at 12:27 AM..
# 2  
Old 02-09-2016
What program are you using this regex with? Your program must support the PCRE form of regex for \s
In any case:
Code:
^192\.68\.47\.121\smyhost0[1-9]|1[0-2]

will not match
Code:
Feb 9 16:26:53 192.68.47.121 myhost01-server: #Version: 1.0_

This might:
Code:
192\.68\.47\.121\smyhost(0[1-9]|1[0-2])

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail K command regex: adding exclusion/negative lookahead to regex -a@MATCH

I'm trying to get some exclusions into our sendmail regular expression for the K command. The following configuration & regex works: LOCAL_CONFIG # Kcheckaddress regex -a@MATCH +<@+?\.++?\.(us|info|to|br|bid|cn|ru) LOCAL_RULESETS SLocal_check_mail # check address against various regex... (0 Replies)
Discussion started by: RobbieTheK
0 Replies

2. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies

3. UNIX for Dummies Questions & Answers

read regex from ID file, print regex and line below from source file

I have a file of protein sequences with headers (my source file). Based on a list of IDs (which are included in some of the headers), I'd like to print out only the specified sequences, with only the ID as header. In other words, I'd like to search source.txt for the terms in IDs.txt, and print... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

4. Shell Programming and Scripting

regex in ls

Hi Experts, I am using ls with regex in the below manner: VAR="*.txt *.TXT" ls -l $VAR This is working fine if I have both txt and TXT extension files in my directory. But if any of them is not present, its throwing errors, that *.TXT file not found in the directory. So what am i missing... (6 Replies)
Discussion started by: sugarcane
6 Replies

5. UNIX for Advanced & Expert Users

Vi Regex help

Can someone tell me what is going with this expression :%s/<C-V><C-M>/. Is there a way to get a more useful message if the carriage return has been deleted? http://objectmix.com/editors/149245-fixing-dos-line-endings-within-vim.html#post516826 Why does this expression work for... (1 Reply)
Discussion started by: cokedude
1 Replies

6. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

7. Shell Programming and Scripting

Help in Regex

$str=(OP) NOPASSWD:\usr\bin; OR $str=NOPASSWD:\usr\bin; OR $str=(OP) \usr\bin; OR $str=\usr\bin; I am new in Perl... Can you help me with a regex to extract only the \usr\bin part.. Thanks for your help... (5 Replies)
Discussion started by: Ujan
5 Replies

8. Shell Programming and Scripting

Need a regex

Hi, I am trying to grep for the following type of string from a document given below: 12637 1239 3356 12956 7004 7004 7004 13381 13381 *> 12.0.1.63 0 7018 21872 ? * 208.51.134.254 53 0 3549 7018 21872 ?... (1 Reply)
Discussion started by: Legend986
1 Replies

9. Shell Programming and Scripting

regex

hi frnds i m having prb while matching a numerical num... + is not working for me... ( ?? ) so i m achieving the criteria with \{1,\} ( pl suggest if i m wrong ) nw the prb is.. i dont want to match the number with all zeros in it.. eg 00000 or 0000000 etc etc... pl help.. ... (3 Replies)
Discussion started by: clx
3 Replies

10. Shell Programming and Scripting

Regex

Hi, i want to match a string using perl that has got 5 pluses(+++++). i am using a function for this. $str1="+++++"; check($str1,"\\+"); sub check{ $str1=$_; $str2=$_; if($str1=~m/^$str2{5}$/){ print "Correct.\n"; }else{ print "Wrong..\n"; ... (6 Replies)
Discussion started by: deepakpv
6 Replies
Login or Register to Ask a Question