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
[WIP] Integrating Monit for monitoring TorQ #105
Conversation
Created the backbone of monit.sh
…om process.csv Added monitconfig.cfg which contains the location of the process.csv and the output file
Modified the location of the files Updated the monitrc to include the monitconfi.cfg
Added a new test alert in monitconfig.cfg which executest a test bash script Modified the e-mail format in /code/templates/monitrc to include more details about the event
code/scripts/templates/monitrc
Outdated
# backup.bar.baz port 10025, # backup mailserver on port 10025 | ||
# localhost # fallback relay | ||
set mailserver smtp.gmail.com port 587 | ||
username "\"torqmonit@gmail.com\"" password "\"torqmonit2018\"" |
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.
is this a real email address & password? these should be dummy placeholders in here, and this password is now in git history so should also be changed
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 is an e-mail address that I will change. I only use this to test if monit works as it should. I wasn't able to make the e-mail work yet.
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.
Yeah, but regardless you should never commit a password to any email account to git - right now anyone could log into that email account (and I did, to check)
code/scripts/templates/monitrc
Outdated
## commands to a running Monit daemon. See the Monit Wiki if you want to | ||
## enable SSL for the HTTP interface. | ||
# | ||
set httpd port 2812 and |
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.
any way to have this port based on TorQ baseport variable? what happens if a user already has something running on port 2812?
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.
this is the default port for monit. It wasn't my focus to change it, but it should be really easy to do so. monitrc is created using the environment variables which are set when setenv.sh
is executed. Should I look at a way to set that port taking in consideration the baseport
and the number of processes or should I maybe define a an env variable and let the user set the port (just like we do now with the baseport
)
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.
personally I think the less a user has to think about configuring the better, so tying it to the baseport seems most logical to me
code/scripts/templates/testmail.sh
Outdated
@@ -0,0 +1,3 @@ | |||
#!/bin/bash | |||
|
|||
echo -e "TORQMONIT\r\rThis is an automated message\r\rProcess SERVICE is down"|mail.mailutils -s \"SUBJECT\" rdanutalexandrugmail.com |
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.
I assume this file should be removed? Doesn't seem like something that should be merged to master
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.
This is my attempt to use an external e-mail to generate the alerts. Not very successful so far. If it works this will take the form of a template e-mail that I will use in my monitalert.cfg
`
setenv.sh
Outdated
@@ -12,8 +12,10 @@ export KDBAPPCODE=${TORQAPPHOME}/code | |||
export KDBHDB=${TORQDATA}/hdb/database | |||
export KDBWDB=${TORQDATA}/wdbhdb | |||
|
|||
export KDBBASEPORT=6000 # set KDBBASEPORT to the default value for a TorQ Installation | |||
export KDBBASEPORT=6000 # set KDBBASEPORT to the default value for a TorQ Installation |
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.
looks like alignment changed on this comment bringing it out of line, please put it back
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.
will do
fill_templates.sh
Outdated
dirpath="$0" | ||
fi | ||
|
||
eval ". $(dirname "$dirpath")/setenv.sh" #set environment variables |
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.
why is eval
needed here? Why not just source the file with .
directly? (this pattern exists in a few places)
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.
This was already here. I think eval is used to execute ". $(dirname "$dirpath")/setenv.sh"
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.
Not sure what you mean by "already here", this is a new file, no? I get what eval
is doing, I'm asking why though? Seems like you could just do . $(dirname "$dirpath")/setenv.sh
@@ -0,0 +1 @@ | |||
${TORQHOME}/appconfig/process.csv ${TORQHOME}/torq.sh monitconfig.cfg |
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.
This + fill_templates.sh
was set up by me a long time ago rather naively, there's probably better ways to do it and definitely better ways to set up this config file, would be worth looking into it.
…e status output Modified torq.sh to setenv using a BASEDIR defined in the .bashrc_torq Enabled the log file output in monitrc Modified monit.sh to create a .bashrc_torq which holds the environment variables necessary for starting torq from root
bash monit.sh takes me in the root directory and tries to execute everything from there. This creates a number of issues. I have seen someone using @ThomasSmyth @jonathonmcmurray @jemmaborland @claire-sloan @jonnypress |
monit.sh
Outdated
checkst "echo $TORQHOME|wc -l" "TORQHOME present" "npres" "1" | ||
checkst "echo $BASEDIR|wc -l" "BASEDIR present" "npres" "1" | ||
else | ||
echo "export TORQHOME=${PWD}" >> $HOME/.bashrc_torq |
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.
Does all this stuff need to be duplicated? Can you not just move it out of the if
statement & run it regardless? Or is there a difference I'm missing?
@Aqualex I don't think I understand the problem...why can't you just source |
… the path to torq.sh and process.csv from fill_templates.sh Modified the way the path is set in templates/monitrc to include the full path not only the path relative to the current directory Modified e-mail settings in monitrc from ssl to tslv1 and fixed the issues with sending alert e-mails Added path to events folder in templates/monitrc Fixed e-mail format in templates/monitrc Changed port for HTTP interface Fixed path to torq.sh in fill_templates Modified monit.sh to run fill_templates to run if any of the necessary files are missing Modified fill_templates to check if the necessary files exist and create them only it they are missing Modified path to setenv.sh in torq.sh to be set based on the current directory Added small script in torq.sh, monit.sh to determine the path based on the current directory
…rectory the script is executed from
Fixed format for e-mail template Removed personal e-mail from monitalert template
config/settings/gateway.q
Outdated
@@ -11,5 +11,5 @@ clearinactivetime:0D01:00 // the time to keep inactive handle data | |||
|
|||
// Server connection details | |||
\d .servers | |||
CONNECTIONS:`rdb`hdb // list of connections to make at start up | |||
CONNECTIONS:`rdb`hdb`wdb // list of connections to make at start up |
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.
why is this here?
fill_templates.sh
Outdated
@@ -0,0 +1,88 @@ | |||
#!/bin/bash |
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.
I'd rather this script didn't sit at the top level directory of TorQ
…reated and how monit is started
Added usage function in monit.sh Modified monitrc to used the BASEDIR instead of PWD
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.
Can you walk me through this on Thursday please?
monit/bin/monit.sh
Outdated
@@ -0,0 +1,162 @@ | |||
#!/bin/bash | |||
#FUNTION DECLARATION ############################################################################### |
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.
typo
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.
fixed
monit/templates/monitalert.cfg
Outdated
@@ -0,0 +1,12 @@ | |||
check system homer.aquaq.co.uk |
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.
take our server name out
And the google check
Best to specify that this is an example
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.
done
@@ -0,0 +1,321 @@ | |||
############################################################################### |
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.
Don't want this in here. All we want to create is the monit config file. Leave it up to the person using it to add it to their monitrc. Otherwise we become coupled to changes in monitrc
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.
so you want me to remove this altogether and everything the bit in monit.sh that creates it? I believe we should have monit setup in such way that it has some basic functionality straigth out of the box so that our users will see that it works at least.
@@ -221,8 +221,14 @@ usage() { | |||
exit 1 |
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.
Why do you need to change torq.sh in this PR?
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.
monit executes torq.sh from the root directory. Torq.sh uses . setenv.sh
and obviously the setenv.sh
is not in the root directory
export TORQHOME=${PWD} # if running the kdb+tick example, change these to full paths | ||
export TORQDATA=${PWD} # some of the kdb+tick processes will change directory, and these will no longer be valid | ||
export TORQAPPHOME=${PWD} | ||
if [ "-bash" = $0 ]; then |
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.
Are these changes strictly for this PR?
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.
yes
As per conversation, add some documentation and we are good to go. We can start with basic documentation and flesh it out. |
ADDED an empty documentation file
Removed unnecessary comment
This will add the basic configuration needed to use
monit
to monitor TorQ processes on UNIX-like systems. The processes will be read from the process.csv file, started and monitored by monit. The dashboard can be accessed on localhost port 2812 and will include basic information about the TorQ processes. If any of the processes fail to start, monit will try to restart the process and send an alert e-mail which contains information about the service.