Start or Stop a Service via Email

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Start or Stop a Service via Email

Post by dbissbort »

Hey all,

i'm relatively new to HostMonitor, and i got a question for starting or stopping a service via Email (or in generally: remote).

Background: we have some employees which are not allowed to connect to HM for starting/stopping services. These people are Admins for a few servers and are allowed to start/stop services for Maintenance.

So, our idea is to start a service if it has the Status "bad", send an email to these Admins, and put a "link" into it for stopping "manually" these services, if they are in Maintenance mode. -> in my understanding HMS script could be our solution.

Would this be the right way? How would i setup the script, and how can i execute the script? Our Emails are send via SMTP without an existing mailbox.

Thank you!

PS: of course i searched the Forum for this topic! 8) But i didn´t found exactly this topic, maybe you can´t point me in the right direction if i had wrong search words...
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Would this be the right way?
I don't think e-mails is the most reliable way.. e-mail can be rejected by mail server/antivirus monitor, etc.
May be its better to use Telnet Service (and client) to execute script? Some telnet clients can connect automatically and send command to Telnet server.
http://ks-soft.net/hostmon.eng/telnetservice/index.htm
Our Emails are send via SMTP without an existing mailbox.
without an existing mailbox? Do you mean you want to send e-mail directly to HostMonitor without using mail server? Impossible

Regards
Alex
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Post by dbissbort »

we would ensure that these emails will not be rejected.
Telnet would not be the first solution for us... ;)

HM sends OUTGOING emails over a SMTP server without having an email mailbox. So in my understanding he isn´t available to receive emails.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

In order to receive mail, HostMonitor connects to your POP3 or IMAP server and checks mailbox for new e-mails.
Truth to say I do not understand what exactly is the problem.
You cannot create mailbox? You cannot use any existing mailbox?

Regards
Alex
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

HM sends OUTGOING emails over a SMTP server without having an email mailbox. So in my understanding he isn´t available to receive emails.
EMail test can check existing e-mail box for incoming e-mails.
If you need to stop Service on local system (where HostMonitor is installed), you may setup EMail test to check for specific email (e.g. with subject "HMStopService") and assign Execute External program action with command line, like the following:
cmd /c net stop %MailBody%
HostMonitor will periodically check mailbox for new incomming e-mails with Subject HMStopService.
If Admin sends Email with subject HMStopService and mail body contain Service name (e.g. mysql), HostMonitor will detect this e-mail and will start command cmd /c net stop mysql
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Post by dbissbort »

ok, what i mean is that we are using a SMTP Relay for outgoing mails from HM.

let´s imagine we are creating a mailbox for HM. Email test cann look for an Email with a dedicated subject and will execute everything in %Mailbody%?

Could Mailbody contain commands like this:
PauseTest %ServiceComp% %ServiceName% 30
??

(btw the Delay is in minutes, right?)

And do you have an example config of an Email test? (f.e. is it a good or bad mail requirement?)

thank you so far! :)
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Email test cann look for an Email with a dedicated subject and will execute everything in %Mailbody%?

It depends on what settings you have specified for EMail test.
It can look for e-mails with some specific e-mail subject, body, sender, etc...
Could Mailbody contain commands like this:
PauseTest %ServiceComp% %ServiceName% 30
??
Not exactly. Variables %ServiceComp% %ServiceName% will not be evaluated, because, action is triggered by EMail test.
You may specify HMS commands in e-mail body, that depends on EMail test veriables %MailBody%, %MailSUBJ%, etc.. or commands without veriables.
Please check for details at:
http://www.ks-soft.net/hostmon.eng/mfra ... #mlinevars
(btw the Delay is in minutes, right?)
Correct.
And do you have an example config of an Email test? (f.e. is it a good or bad mail requirement?)
It depends on action, you have specified for the EMail test.
If you have specified Bad action - you should specify Bad condition for EMail test.

Please chech for details about EMail test:
http://www.ks-soft.net/hostmon.eng/mfra ... m#emailchk
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Post by dbissbort »

ok, thank you so far.

one more problem to solve, for me it seems that the test is working, but the service (for testing) is wether stopping nor starting... ??

http://imageshack.us/g/18/emailtest.jpg/

Picture of LOG file:
Image


BTW, your Online Documentation is very good, but some configuration examples would be very nice (just to see how it could work) 8)
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Post by dbissbort »

AND, one more question, can i specify subfolders in "Mailbox"? :)
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

one more problem to solve, for me it seems that the test is working, but the service (for testing) is wether stopping nor starting... ??
Screen shot shows you are using "Stop service" action so HostMonitor is trying to stop service.
AND, one more question, can i specify subfolders in "Mailbox"?
Depends on protocol. If you are using POP3, only Inbox can be checked; if IMAP is used, you may specify other mailbox using "Mailbox" test property.

Regards
Alex
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Post by dbissbort »

Screen shot shows you are using "Stop service" action so HostMonitor is trying to stop service.
yes, that´s right, but when the email arrives and the script is starting, the service is still running instead of being stopped?!
Depends on protocol. If you are using POP3, only Inbox can be checked; if IMAP is used, you may specify other mailbox using "Mailbox" test property.
we use IMAP but when i add subfolders there´s a message "can´t find subfolder XY".
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

yes, that´s right, but when the email arrives and the script is starting, the service is still running instead of being stopped?!
Still running? Are you sure?
According to your screen shot:
- 1st "stop service" action set "Done" status
- 2nd action returned error "der dienst wurde nicht gestarten". If this can be translated as "service was not started" this confirms 1st action stopped service without problems.
we use IMAP but when i add subfolders there´s a message "can´t find subfolder XY".
We don't have any information about your mail server.
If you provide access, we can check what is wrong.

Regards
Alex
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Post by dbissbort »

- 2nd action returned error "der dienst wurde nicht gestarten". If this can be translated as "service was not started" this confirms 1st action stopped service without problems.
your translation is correct, but this was an old test.

here is an actually test, and the service is still up (even Eventlog shows no entries...)
Image
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

As I can see from your Actions screenshot you have specified "net stop ServiceName" commands for both Good and Bad action profiles.
dbissbort
Posts: 16
Joined: Wed Mar 13, 2013 4:59 am

Post by dbissbort »

yes you´re s right! :oops:

but, it´s just for testing. I have changed it and the behaviour is still the same.
bad status will stop service named in %Mailbody%, Good status will be set when a "Good mail" is detected, and then starts the service again.

i have really difficulties to understand that HMS stuff... :x
my goal still is to let Admins send an email with following infos:
- Servername
- Servicename
- Delay

and then let HMS disable this test. Our Service tests are all named like %Servername%\%Servicename% so this should be possible, right?!
Post Reply