Announcement

Collapse
No announcement yet.

Alert for Mirth Service

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Alert for Mirth Service

    Is there any way an alert can be triggered whenever the Mirth Service restarts?

  • #2
    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

    Comment


    • #3
      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.

      Comment


      • #4
        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.
        HL7v2.7 Certified Control Specialist!

        Comment


        • #5
          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

          Comment


          • #6
            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 '[email protected]';                     //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 '[email protected]';                    //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";
                

            Comment


            • #7
              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
              Best Regards,
              Alex Neiva

              Comment


              • #8
                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.

                Comment

                Working...
                X