In my monitrc i wrote next:
check file mysite.com-access.log with path /var/log/apache2/mysite.com-access.log
if content = "\/1.[01]\" 4(\d){2}" then alert
But the systemctl status monit.service says I have an error in syntax:
extsites monit[19043]: * Starting daemon monitor monit
extsites monit[19043]: /etc/monit/monitrc:305: syntax error '\d'
extsites monit[19043]: ...fail!
Earlier I put "\/1.[01]\" [45](\d){2}", but error in syntax was in '[45]'.
What am I doing wrong? All my regex was right in https://regex101.com/.
Update:
I corrected my string as if content = "^\/1\.[01]\" [45](\d){2}" then alert
but syntax error there is still.
When I am correct, monit uses POSIX regex syntax.
So following this description: https://www.regular-expressions.info/posixbrackets.html
... you could replace \d with [:digit:]
It's not logical to me, but maybe monit doesn't get the "\d" right
Following the "content"-examples in the monit-documentation, the double quote should not be the problem
It seems we should use single quotes instead double.
Related
Here is my nghttpx.conf file:
frontend=0.0.0.0,3000
backend=127.0.0.0,9901;;proto=h2
frontend-no-tls=yes
backend-no-tls=yes
workers=1
log-level=INFO
When I do:
sudo nghttpx
This error is thrown:
28/Nov/2017:15:33:30 +0900 PID19518 [ERROR] shrpx_config.cc:1418 backend: ';' must not be used in pattern
28/Nov/2017:15:33:30 +0900 PID19518 [FATAL] shrpx.cc:1714 Failed to load configuration from /etc/nghttpx/nghttpx.conf
What is wrong with my nghttpx config?
Reading man page of nghttpx we see that --backend option supports the following structure:
--backend=(<HOST>,<PORT>|unix:<PATH>)[;[<PATTERN>[:...]][[;<PARAM>]...]
Since you have backend=127.0.0.0,9901;<PATTERN>, everything that follows ; should be a valid <PATTERN>. Upon further reading of the manual we see that it says:
Since ";" and ":" are used as delimiter, must not contain these characters. Since ";" has special meaning in shell, the option value must be quoted.
Now, looking at your error, it says:
shrpx_config.cc:1418 backend: ';' must not be used in pattern
Which indicates that you have used ; in a pattern, which is not allowed. This agrees with the manual excerpt above.
So it seems that your issue is that you have one too many ; characters in your pattern. At the moment it is ;proto=h2, when it should be proto=h2. Try removing the redundant ; (i.e. it should read backend=127.0.0.0,9901;proto=h2) and see if that helps with the error you're getting.
This is really just out of curiosity.
A typo made me notice that in Bash, the following:
$ .anything
does not print any error ("anything" not to be interpreted literally, it can really be anything, and no space after the dot).
I am curious about how this is interpreted in bash.
Note that echo $? after such command returns 127. This usually means "command not found". It does make sense in this case, however I find it odd that no error message is printed.
Why would $ anything actually print bash:anything: command not found... (assuming that no anything cmd is in the PATH), while $ .anything slips through silently?
System: Fedora Core 22
Bash version: GNU bash, version 4.3.39(1)-release (x86_64-redhat-linux-gnu)
EDIT:
Some comments below indicated the problem as non-reproducible at first.
The answer of #hek2mgl below summarises the many contributions to this issue, which was eventually found (by #n.m.) as reproducible in FC22 and submitted as a bug report in https://bugzilla.redhat.com/show_bug.cgi?id=1292531
bash supports a handler for situations when a command can't be found. You can define the following function:
function command_not_found_handle() {
command=$1
# do something
}
Using that function it is possible to suppress the error message. Search for that function in your bash startup files.
Another way to find that out is to unset the function. Like this:
$ unset -f command_not_found_handle
$ .anything # Should display the error message
After some research, #n.m. found out that the described behaviour is by intention. FC22 implements command_not_found_handle and calls the program /etc/libexec/pk-command-not-found. This program is part of the PackageKit project and will try to suggest installable packages if you type a command name that can't be found.
In it's main() function the program explicitly checks if the command name starts with a dot and silently returns in that case. This behaviour was introduced in this commit:
https://github.com/hughsie/PackageKit/commit/0e85001b
as a response to this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1151185
IMHO this behaviour is questionable. At least other distros are not doing so. But now you know that the behaviour is 100% reproducible and you may follow up on that bug report.
I have the following in order to set my statusline:
set stl=%<\ [Buf:\ %n]%m\ %f\ [
set stl+=%{empty(&filetype) ? \"" : \"," . toupper(&filetype) . \", \"}
set stl+=%{(&fenc!=''?&fenc:&enc)}]
set stl+=%=[0x\%02.2B]\ [Line:\ %04l/%04L\ \|\ Col:\ %c%V]\ (%P)
I personally don't see anything wrong with it, but it just keeps giving me the following error:
E540: Unclosed expression sequence: stl+=%{empty(&filetype)
Does anybody know what this error means? I've been forever trying to solve it, but I just can't understand what it means.
Thanks for all your help. :)
With :set, all spaces in the value must be escaped with a backslash, too. Therefore, it's recommended to do away with any unnecessary whitespace there, or use :let &stl = '...' instead (where only contained ' characters must be doubled).
I'm trying to run the Apache startup script, /etc/init.d/httpd. Environment variable definitions like this one give an error:
CONF_FILE=$(APACHE_HOME)/conf/httpd.conf
It says "/etc/init.d/httpd: line 15: APACHE_HOME: command not found"
So, I replaced the parentheses with curly brackets, and the script worked swimmingly. What gives? I'm really just asking this question because I want to understand why it's wrong, not how to fix it. The shebang is there, and it's unmodified from the original shell script, so why's it misinterpreting things?
In unix systems:
$SOMETHING /* variable */
$(SOMETHINGELSE) /* command */
${FOO} */ variable substitution */
$(...) executes its contents in a subshell, it doesn't get the value of a variable. You can use just plain $APACHE_HOME or ${APACHE_HOME}, which it sounds like you switched to.
$(something) tells the shell to execute command something and substitute the command's output.1
You want to substitute a variable's output, so you just need a $ in front of the variable, like so: CONF_FILE=$APACHE_HOME/conf/httpd.conf
Alternatively, you could use CONF_FILE=${APACHE_HOME}/conf/httpd.conf (note the curly braces instead of parenthesis), but it's not really necessary for your situation.
1This is useful when you want to assign a command's output to a variable. For example:
MY_VAR="$(egrep 'someline' somefile.txt)"
I have a groovy file named test.groovy and have a single line of coding in it :
println args[0];
when I run this program like this groovy test ants, output is ants.
But when I run the program with the argument ants( then I'm getting error like this :
bash: syntax error near unexpected token (
1)If I escape the character ( then I'm getting the output as ants(. But why ( is needed to be escaped?
And when I run the program with the argument ant's, then clicking enter would make my terminal look like this :
>
>
>
2)And I terminate the program only using ctrl+c. What actually happens in this case? Why my terminal look like this?
3)After seeing these, what are the rules and condition that are to be followed in Groovy with accordance with Command-line arguments and the same holds for Java?
Thanks in advance.
You need to escape it as ( has a meaning in the bash shell which you are using.
The same goes for '
Try other commands:
ls (
Or
ls '
You'll get the same effect
Another option (other than escaping) is to put your arguments inside quote chars like so:
groovy test 'ants('