monit file sha1 checksum not working - monit

I am using monit 5.14 to monitor the checksum of a file. I have the below config in the monitrc
check file file1.jar with path /home/lib/target/myjar.jar
if changed sha1 checksum then stop
I have already defined stop. However when I run monit status I always see that the File is unmonitored.
Am i missing anything else ?

Its weird.
I had a big process name like abracadabara12343.jar and just reducing it to jar worked !!

Related

How do I compile Tomcat mod_jk on a MacBook Pro M1 chip?

I have Homebrew Apache installed and trying to connect Coldfusion Server 2016 with Tomcat mod_jk.
I downloaded the source code from https://tomcat.apache.org/download-connectors.cgi
I followed the directions to compile it, tried few different ways, but when I get to the "make" command, I keep getting the same error:
In file included from jk_ajp12_worker.c:26:
In file included from ./jk_ajp12_worker.h:26:
In file included from ./jk_logger.h:26:
In file included from ./jk_global.h:340:
./jk_types.h:56:2: error: Can not determine the proper size for pid_t
#error Can not determine the proper size for pid_t
^
./jk_types.h:62:2: error: Can not determine the proper size for pthread_t
#error Can not determine the proper size for pthread_t
^
2 errors generated.
make[1]: *** [jk_ajp12_worker.lo] Error 1
make: *** [all-recursive] Error 1
These are the different commands I've tried to compile:
./configure --with-apxs=/opt/homebrew/bin/apxs
./configure CFLAGS='-arch arm64e' APXSLDFLAGS='-arch arm64e' --with-apxs=/opt/homebrew/bin/apxs
./configure CFLAGS='-arch arm64e' APXSLDFLAGS='-arch arm64e' --with-apxs=/opt/homebrew/bin/apxs --host=arm
I recently got this new MacBook Pro 16" and migrated everything over from my 2017 MacBook Pro (Intel chip). I was running stock Apache with Coldfusion Server 2016, but when I tried to start up Apache on the new MacBook, it didn't like my mod_jk.so file and threw an error:
httpd: Syntax error on line 542 of /opt/homebrew/etc/httpd/httpd.conf: Syntax error on line 2 of /opt/homebrew/etc/httpd/mod_jk.conf:
Cannot load /Applications/ColdFusion2016/config/wsconfig/2/mod_jk.so into server: dlopen(/Applications/ColdFusion2016/config/wsconfig/2/mod_jk.so, 0x000A):
tried: '/Applications/ColdFusion2016/config/wsconfig/2/mod_jk.so'
(mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
I appreciate any help or input. Thank you.
I've finally installed Apache2 with Tomcat on my M1 and it all works.
The one thing you must do is to install a fresh Apache from Macports or HomeBrew. This is because most old installations copied from your old mac to your new one will now be in the read-only part of your file system and SIP won't let you near them. You will find weird and wonderful workarounds (apachectl told me I had to codesign mod_jk.so for example and I wasted a lot of time doing it and in the end it was pointless) and you will attempt to get the old installation to work, but trust me it's not worth it.
You will need to compile a fresh jk_module (mod_jk.so). This is what I did:
Download latest connector https://dlcdn.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz, save the .gz and unzip it.
Change directory to the native folder.
run which apxs to tell you the path to apxs for the ./configure command
The path mine gave was: /opt/local/bin/apxs. Use it as the path in the ./configure command below.
The commands are as follows (actually don't bother running them yet because they will fail):
./configure --with-apxs=/opt/local/bin/apxs
make
However make will fail with:
./jk_types.h:56:2: error: Can not determine the proper size for pid_t
#error Can not determine the proper size for pid_t
^
./jk_types.h:62:2: error: Can not determine the proper size for pthread_t
#error Can not determine the proper size for pthread_t
^
2 errors generated.
make[1]: *** [jk_ajp12_worker.lo] Error 1
make: *** [all-recursive] Error 1
This is a problem for M1 macs that has been fixed. So for the moment we will abandon the 1.2.48 source and download the source with the fix.
But don't delete the 1.2.48 source because the fix source is missing a few files which you will copy straight over from the 1.2.48 source.
The page to download the fix for Mac OS is here: https://github.com/apache/tomcat-connectors, which is commit e719874 on Jun 30, 2021.
Click on the green 'Code' button and then on 'Download ZIP'.
Unzip the new source and cd to 'native'
Run the commands:
./configure --with-apxs=/opt/local/bin/apxs
make
And whenever it stops and complains that something is missing, find it in the 1.2.48 source and copy it over to the same position in the new source and try again. It will happen two or three times.
I got this error at one point:
/home/myuser/source/mod_auth_cas/mod_auth_cas/missing: line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Error 127
Then I read somewhere to run autoreconf -f -i (which fixed it).
When make finishes, find your nice new mod_jk.so file in the native/apache-2.0 folder and copy it to where all your other modules are. I have a Macports installation so Homebrew is probably different, but my modules are in /opt/local/lib/apache2/modules.
Don't forget to add the LoadModule line in httpd.conf if it isn't already there:
LoadModule jk_module /opt/local/lib/apache2/modules/mod_jk.so
You might have some trouble working out which apache2 folders contain the new install, and not an old installation - I found two other installations knocking about trying to confuse me.
My config is here: /opt/local/etc/apache2/httpd.conf
apachectl is very useful for configuration.
apachectl -t -D DUMP_INCLUDES will find all the configuration files it is using. This totally saved me because it showed me that my httpd.conf file, which I had copied from elsewhere, was still pointing via 'Include' commands at other old config files in the wrong place.
apachectl configtest will test your config for you and print out any mistakes it finds. It pointed at 4 modules that it didn't like so I just excluded them. Though obviously read the messages carefully and google if you are not sure why apachectl doesn't like something. If it replies 'Syntax OK' you are ready to go.
This is a mysterious message I got a lot until I worked out that it was because httpd.conf was pointing at the wrong modules folder (an old install of apache2) for each module, so it was loading stuff that presumably was not compiled for 64bit
httpd: Syntax error on line 76 of /opt/local/etc/apache2/httpd.conf:
Cannot load libexec/apache2/mod_authz_owner.so into server:
dlopen(/usr/libexec/apache2/mod_authz_owner.so, 0x000A): symbol not
found in flat namespace '_apr_stat$INODE64'
This is my launch command using the plist which Macports automatically created:
sudo launchctl load -w /opt/local/etc/LaunchDaemons/org.macports.apache2/org.macports.apache2.plist
And to unload:
sudo launchctl unload /opt/local/etc/LaunchDaemons/org.macports.apache2/org.macports.apache2.plist
run ps ax|grep httpd to see if it's running.
Logging: Don't forget to sudo to create the jk folder in /var/log/apache2 if it doesn't already exist, otherwise apache or tomcat will have mysterious problems or won't start or something (the /var/log/apache2/jk folder is needed for jk.log).
Another problem cropped up just as I thought I had it made: apache
was unable to write its pid file on startup. Again this was because the position set in my config for the pid file was from the configuration on my old mac, and the position chosen was in a read-only location.
To change this you need to set the PidFile parameter, which I found in the following file:
/opt/local/etc/apache2/extra/httpd-mpm.conf
and it looks like this:
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
# Note that this is the default PidFile for most MPMs.
#
<IfModule !mpm_netware_module>
PidFile "local/run/apache2/httpd.pid"
</IfModule>
Don't worry about what the IfModule thing is doing, just set the PidFile to a writeable location, which as you can see is a relative path. You may be wondering what goes in front of the local folder.
What goes in front is the ServerRoot parameter set in httpd.conf:
ServerRoot "/usr"
So my pid will be written at /usr/local/run/apache2/httpd.pid. I had to create the run and apache2 folders.
That's about it. There are various logs that might indicate errors if you are stuck:
/var/log/apache2/error_log
And the jk.log for the apache/tomcat connector:
/var/log/apache2/jk/jk.log
And there's always the system log which just might tell you something:
/var/log/system.log
I hope very much that this helps someone. However it was very long and complicated and I have surely missed something that I did along the way, so if you come across some new problem I will see if I can help.
Running ColdFusion on a Mac is consistently a PITA. Doesn't matter if it's CF 9, 10, 11, all the way to current. Especially when you're dealing with a non-Intel based chipset. You are also trying to get an older and custom build of Toncat running on a chipset that likely isn't supported. You're also not the only one having this issue with CF 2016 on the M1 chip (they didn't find a solution either).
Try using CommandBox to run CF. It will download the server as a JAR file and run it on the Glassfish servlet container (IIRC). You won't need Apache either. It's really quite simple to get up and running.
https://commandbox.ortusbooks.com/embedded-server/multi-engine-support
Once you have it installed, go to your application's root folder in the CLI:
start cfengine=adobe#2016
It will download & install the server, then start the application.
Check the docs for more info.

scp fails with "protocol error: filename does not match request"

I have a script that uses SCP to pull a file from a remote Linux host on AWS. After running the same code nightly for about 6 months without issue, it started failing today with protocol error: filename does not match request. I reproduced the issue on some simpler filenames below:
$ scp -i $IDENT $HOST_AND_DIR/"foobar" .
# the file is copied successfully
$ scp -i $IDENT $HOST_AND_DIR/"'foobar'" .
protocol error: filename does not match request
# used to work, i swear...
$ scp -i $IDENT $HOST_AND_DIR/"'foobarbaz'" .
scp: /home/user_redacted/foobarbaz: No such file or directory
# less surprising...
The reason for my single quotes was that I was grabbing a file with spaces in the name originally. To deal with the spaces, I had done $HOST_AND_DIR/"'foo bar'" for many months, but starting today, it would only accept $HOST_AND_DIR/"foo\ bar". So, my issue is fixed, but I'm still curious about what's going on.
I Googled the error message, but I don't see any real mentions of it, which surprises me.
Both hosts involved have OpenSSL 1.0.2g in the output of ssh -v localhost, and bash --version says GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Any ideas?
I ended up having a look through the source code and found the commit where this error is thrown:
GitHub Commit
remote->local directory copies satisfy the wildcard specified by the
user.
This checking provides some protection against a malicious server
sending unexpected filenames, but it comes at a risk of rejecting
wanted files due to differences between client and server wildcard
expansion rules.
For this reason, this also adds a new -T flag to disable the check.
They have added a new flag -T that will ignore this new check they've added so it is backwards compatible. However, I suppose we should look and find out why the filenames we're using are flagged as restricted.
In my case, I had [] characters in the filename that needed to be escaped using one of the options listed here. for example:
scp USERNAME#IP_ADDR:"/tmp/foo\[bar\].txt" /tmp

how to import dump.rdb file to redis local server

Hi I'm trying to import the dump.rdb file to my local redis I'm using ubuntu 14.04,
I've tried this solutions :
backup data from server using SAVE command
Locate the location to put the dump.rdb file
Since I install redis using this tutorial, so I copy the imported dump.rdb to my redis root directory, and then started the redis server like this :
src/redis-server
and then connect the client using :
src/redis-cli
But When I tried to get the all keys using KEYS * I got (empty list or set) where did I go wrong? I've been playing this for hours, any help? thank you
If you have followed the steps correctly it will work fine.
1) Make sure the imported dump.rdb contains your data
2) Stop the redis server
3) copy the file in the correct directory (inside redis bin directory)
parallel to redis-server.
4) make sure you have the same data, that is copied. (bcz possibilites
that if your server is still running, it will replace your dump.rdb).
5) start your redis server you will surely find the values.
If it still doesn't work. Check the dbfilename in your redis.conf file.
It must be dbfilename dump.rdb. If there is a change in the location place it in the correct directory.
Hope this works.
I found the problem in my step, in the documentation quick start redis :
Using src/redis-server Redis was started without any explicit configuration file so I need to start the server with the configuration file to make the server read my dump.rdb file like this :
src/redis-server redis.conf
now I can get all the imported data.

File with foreign characters downloaded from s3 using s3cmd is coming as?

I am trying to download a file from S3 using s3cmd command-line. The file is having foreign characters like (楽曲満載アプリ!!最新曲から懐かしの曲、気になるあの曲も検索できる). But when I download this file in my ubuntu machine and open the file, using vi command, the characters are getting replaced as (??????). I am not sure why this issue is occurring. Any help/suggestions would be much appreciated. Thanks in advance.
I have finally resolved the issue. Posting here so that it can help someone in the future. Based on the hint given by Will about the settings of ubuntu terminal, I investigated on the locale of the machine. I saw the locale was en_US. To see the default locale, type locale in your terminal.
**P.S if the locale you want is not available then follow this link to install the locale
$ sudo locale-gen "en_IN"
Generating locales...
en_IN... done
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
en_IN... up-to-date
Generation complete.
**
In my case the locale was something like
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
I got the locale of the system where the file was opening properly
It was something like
LANG=en_IN
LANGUAGE=en_IN:en
LC_CTYPE="en_IN"
LC_NUMERIC="en_IN"
LC_TIME="en_IN"
LC_COLLATE="en_IN"
LC_MONETARY="en_IN"
LC_MESSAGES="en_IN"
LC_PAPER="en_IN"
LC_NAME="en_IN"
LC_ADDRESS="en_IN"
LC_TELEPHONE="en_IN"
LC_MEASUREMENT="en_IN"
LC_IDENTIFICATION="en_IN"
LC_ALL=
What I did was, I opened the locale file by using the command
sudo vi /etc/default/locale
and replaced the content of the file with
LANG=en_IN
LANGUAGE=en_IN:en
LC_CTYPE="en_IN"
LC_NUMERIC="en_IN"
LC_TIME="en_IN"
LC_COLLATE="en_IN"
LC_MONETARY="en_IN"
LC_MESSAGES="en_IN"
LC_PAPER="en_IN"
LC_NAME="en_IN"
LC_ADDRESS="en_IN"
LC_TELEPHONE="en_IN"
LC_MEASUREMENT="en_IN"
LC_IDENTIFICATION="en_IN"
LC_ALL=
After making this change I restarted the machine and now I open the file and baammmm. The chinese characters were showing up as expected. Thanks #Will for the hint and this link for making my day :)

Redis Server doesn't start or do anything - Redis-64 on Windows

I'm following these steps outlines on this link, however when I try to start the server nothing happens nor can I connect to anything from the client. Does anyone know how to run this?
when I try from a command prompt instead of double clicking the redis-server.exe I get this message
[11868] 23 Jul 11:58:26.325 # QForkMasterInit: system error caught. error code=0
x000005af, message=VirtualAllocEx failed.: unknown error
http://bartwullems.blogspot.ca/2013/07/unofficial-redis-for-windows.html
The easiest way to install Redis is through NuGet:
Open Visual Studio
Create an empty solution so that NuGet knows where to put the packages
Go the Package Manager Console: Tools –> Library Package Manager –>Package Manager Console
Type Install-Package Redis-64
image
Go to the Packages folder and browse to the Tools folder. Here you’ll find the Redis-server.exe. Double click on it to start it.
Redis is ready to use and start’s listening on a specific port(6379 in
my case)
image
Let’s open up a client and try to put a value into Redis. Start Redis-cli.exe. It already connects to the same port by default.
image
Add a value by executing following command:
image
Read the value again:
image
Try to run with redis-server --maxheap 4000000
Miguel is correct, but it is not that simple. To start redis-server either as a service or from the command prompt, the amount of available RAM and disk space must be sufficient for Redis to run as configured.
Now, if no configuration file is specified when running Redis, it will use the default configuration values. All of this is documented in the redis.windows.conf file as well as in the document "Redis on Windows.docx" (both deployed with the redis installation).
In my experience, errors when starting Redis usually come from lack of available resources (RAM or disk space) or some incorrect configuration of maxhead or maxmemory parameters.
To troubleshoot this kind of behavior, check your system's available resources and try running redis-server from the command line varying the parameters maxmemory, maxheap, and/or heapdir. The loglevel parameter set to verbose might also help diagnosing the issue.
Regards