Labtech and MySQL to Monitor Exchange Backpressure

So, we decided we needed to monitor Exchange servers for Backpressure so we can be more proactive in preventing problems.

I wrote a script in Labtech to monitor the event log for incidents that indicate potential issues.  Check out the SQL concat!  The logic checks for existing tickets, either creates a ticket, makes a note on an existing ticket or closes the ticket it if the situation no longer exists.  I didn’t include putting time into the ticket, but that would be fairly easy as well.

See the script export below:

Resend EventLogs
SET:  @BackpressureEvent@ = SQLRESULT[SELECT Concat(eventlogs.TimeGen, ” “, eventlogs.Message) As dEvent FROM eventlogs WHERE eventlogs.`Message` like ‘%resource pressure increased from Medium to High%’ AND (timegen > DATE_SUB(NOW(), INTERVAL 1 HOUR)) AND ComputerID=%computerid% LIMIT 1]
IF  @Backpressureevent@  Contains  High  THEN  Jump to :Alert
SET:  @mysqlquery@ = SELECT COUNT(v_tickets.`TicketID`) FROM v_tickets WHERE v_tickets.`Subject` = ‘%locationname% / %computername% / Exchange Backpressure Detected’ ‘
SET:  @sqlresults@ = SQLRESULT[SELECT COUNT(v_tickets.`TicketID`) FROM v_tickets WHERE v_tickets.`Subject` = ‘%locationname% / %computername% / Exchange Backpressure Detected’]
IF  @sqlresults@  >=  1  THEN  Jump to :ProcessTicket
GOTO :END
:Alert – Label
Note: Backpressure! – need to create a ticket!
:CheckTicket – Label
SET:  @mysqlquery@ = SELECT COUNT(v_tickets.`TicketID`) FROM v_tickets WHERE v_tickets.`Subject` = ‘%locationname% / %computername% / Exchange Backpressure Detected’ ‘
SET:  @sqlresults@ = SQLRESULT[SELECT COUNT(v_tickets.`TicketID`) FROM v_tickets WHERE v_tickets.`Subject` = ‘%locationname% / %computername% / Exchange Backpressure Detected’]
IF  @sqlresults@  >=  1  THEN  Jump to :UpdateTicket
:CreateTicket – Label
LOG:  Exchange Backpressure High! Creating Ticket
Create New Ticket for %clientid%\%computerid% Email:%ContactEmail% Subject:%locationname% / %computername% / Exchange Backpressure Detected
SET:  @eTicketId@ = SQLRESULT[SELECT v_tickets.`TicketID` FROM v_tickets WHERE v_tickets.`Subject` = ‘%locationname% / %computername% / Exchange Backpressure Detected’]
Send Email To:[email protected] Subject:Exchange Backpressure – %clientname% – %computername%
GOTO :END
:UpdateTicket – Label
SET:  @eTicketId@ = SQLRESULT[SELECT v_tickets.`TicketID` FROM v_tickets WHERE v_tickets.`Subject` = ‘%locationname% / %computername% / Exchange Backpressure Detected’]
LOG:  Exchange Backpressure High! updating Ticket
Comment Ticket @eTicketId@ to Admin
GOTO :END
:ProcessTicket – Label
Note: If the Ticket exists then Finish it.
SET:  @monitorticketid@ = SQLRESULT[SELECT v_tickets.`TicketID` FROM v_tickets WHERE v_tickets.`Subject` = ‘%locationname% / %computername% / Exchange Backpressure Detected’]
IF  @monitorticketid@  =  0  THEN  Exit Script
IF [SQL SELECT COUNT(ticketid) FROM tickets WHERE ticketid=@monitorticketid@]  <  1  THEN  Exit Script
IF @monitorticketid@ Ticket Status equals Resolved  THEN  Jump to :ClearMonitorTicketID
RUN SCRIPT:  _System Automation\Functions\Load Properties – Ticketing*
Finish Ticket @monitorticketid@ to @propTicketDefaultUserID@
:ClearMonitorTicketID – Label
SET:  @monitorticketid@ = 0
SET:  [STATE @fieldname@ticketid]  =  @monitorticketid@  for computer @computerid@
:EndProcessTicket – Label
:END – Label

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*