web stats
Alert for Mirth Service - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2017, 11:43 PM
Thoughts_Shared Thoughts_Shared is offline
OBX.2 Kenobi
 
Join Date: Dec 2016
Posts: 58
Thoughts_Shared is on a distinguished road
Default Alert for Mirth Service

Is there any way an alert can be triggered whenever the Mirth Service restarts?
Reply With Quote
  #2  
Old 07-21-2017, 08:23 PM
pacmano pacmano is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Location: Texas
Posts: 86
pacmano is on a distinguished road
Default

Perhaps qualify that a bit more?

Do you want the operating system to notify you? Mirth? Some other external server?
__________________
Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
Diridium Technologies, Inc.
https://diridium.com
Reply With Quote
  #3  
Old 07-23-2017, 10:05 PM
Thoughts_Shared Thoughts_Shared is offline
OBX.2 Kenobi
 
Join Date: Dec 2016
Posts: 58
Thoughts_Shared is on a distinguished road
Default

Quote:
Originally Posted by pacmano View Post
Perhaps qualify that a bit more?

Do you want the operating system to notify you? Mirth? Some other external server?
I want to check if Mirth has the ability to send any alert once it restarts.
Reply With Quote
  #4  
Old 07-24-2017, 01:24 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

Doesn't look like there is any thing under alerts that would fit your needs. If it is on Advanced alerting plugin, then I don't know.
You might be able to write some batch or shell scripts around those lines.
Reply With Quote
  #5  
Old 07-24-2017, 06:16 AM
pacmano pacmano is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Location: Texas
Posts: 86
pacmano is on a distinguished road
Default

I agree w/siddharth. If on Linux and needing a free tool, monit does this reasonably well and also can alert you on a bunch of other threshold based parameters. It's also possible to write a clever channel or two that can do this by shelling out to the operating system and checking the process id of the current running Mirth instance which was stored via some other channel or the same one.

e.g.:


Code:
var cmd_to_run = "pgrep -f mirth-server"
channelMap.put('cmd_to_run',cmd_to_run);   // just store it so you can debug
shell_to_command_line = java.lang.Runtime.getRuntime().exec(cmd_to_run);   // run it
shell_to_command_line.waitFor(); // wait for output
var the_command_output = shell_to_command_line.getInputStream();     // get the output
channelMap.put('the_command_output ',org.apache.commons.io.IOUtils.toString(the_command_output));  //save the output.
You would now have the process id to store, you could write it to a file. You can then check the last process id you wrote which you retrieved via a file reader.
__________________
Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
Diridium Technologies, Inc.
https://diridium.com
Reply With Quote
  #6  
Old 07-24-2017, 01:01 PM
cbarlow cbarlow is offline
OBX.2 Kenobi
 
Join Date: Sep 2015
Location: Missouri
Posts: 52
cbarlow is on a distinguished road
Default

Not 100% what you are looking for but I have a script that runs every 15 minutes that checks the state of all channels as well as run on startup. If anyone restarts the service, this will typically trigger an email due to several channels not fully started yet. Source is just a Javascript Reader with return 1; as the js code.

PHP Code:
    var ChannelIDList ChannelUtil.getDeployedChannelIds().toString(); //Gets list of channels, returns [channel1,channel2,channel3]
    
var ChannelIDListLength ChannelIDList.length(); //Length so we can get the string we want
    
var ChannelIDList ChannelIDList.substring(1,ChannelIDListLength-1); //Gets string inside of []
    
var ChannelArray ChannelIDList.split(","); //Give us an array of channels
    
    
for(var 0ChannelArray.lengthi++) //loop through each channel
    
{    
        var 
ChannelID ChannelArray[i].toString().trim(); //Get the channel ID
        
var ChannelName ChannelUtil.getDeployedChannelName(ChannelID); //Gives the name of the channel
        
var QueuedCount ChannelUtil.getQueuedCount(ChannelID); //gives the queue count
        
var ChannelState ChannelUtil.getChannelState(ChannelID); //gives the state of the channel, i.e. Started, Starting,..
        
var ErrorCount ChannelUtil.getErrorCount(ChannelID);
        var 
SentCount ChannelUtil.getSentCount(ChannelID);
        
        
output_string += "Channel " ChannelName " is currently " ChannelState " and has " QueuedCount " queued messages.\n";
        if(
ChannelState != 'Started' || QueuedCount MaxQueuedMessageCount) { //Channel should be started and not have more queued messages than allowed
            
error_string += "Channel " ChannelName " is currently " ChannelState " and has " QueuedCount " queued messages.\n";
        }
        var 
= <Channel>
                    <
id>{ChannelID}</id>
                    <
name>{ChannelName}</name>
                    <
state>{ChannelState}</state>
                    <
queue_count>{QueuedCount}</queue_count>
                    <
error_count>{ErrorCount}</error_count>
                    <
sent_count>{SentCount}</sent_count>
                </
Channel>;
        
tmp.Data.appendChild(x);
    }

if(
error_string != "") {
    var 
emailTo 'Alerts@some.com';                     //Email address you want to send the alert to.  Multiple emails can be separated with a comma
    
var emailCC '';                                 //CC emails you want to include
    
var emailFrom 'mirth@some.com';                    //From address that will appear on your email
    
var emailSubject 'MIRTH ISSUES: ' MirthName;        //Email Subject
    
var emailBody error_string;                        //Email Body
    
emailBody emailBody '\n\nPlease do not respond to this email. This address is not monitored.';

    var 
smtpConn SMTPConnectionFactory.createSMTPConnection();       //Create email connection using email settings in your Mirth Connect Settings.
    
smtpConn.send(emailTo,emailCC,emailFrom,emailSubject,emailBody);   //Send the email

    
output_string += "\n****************************************\nIssues found, Email sent\n";
    

Reply With Quote
  #7  
Old 07-25-2017, 05:26 AM
AlexNeiva AlexNeiva is offline
Mirth Guru
 
Join Date: Oct 2013
Location: Portugal
Posts: 277
AlexNeiva is on a distinguished road
Default

Hello,

i never try that but, at first i remember that in Mirth DB, the table event, register this type of info, "Server startup", "Login", "Server shutdown" etc...
If you create a channel with DB Reader pooling this type of events in DB then you can send an email.
I don't know if it will work but give it a try.

Best Regards
Reply With Quote
  #8  
Old 07-25-2017, 08:33 AM
jack.downes jack.downes is offline
OBX.2 Kenobi
 
Join Date: Apr 2014
Posts: 62
jack.downes is on a distinguished road
Default

Well, put together a single channel that has a trigger on deploy with a cron setting 100 yrs in future. Make sure it has trigger on deploy though. then have it send an email. You'll get a note every time that mirth restarts, and it'll be from Mirth itself.
Reply With Quote
Reply

Tags
alert

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 01:20 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation