Get the connection status

We have a situation like whenever an external application is down we need to update the case status field to close in Salesforce and remove the record from queue. i tried but i didn’t get the feasible solution for this. can any one help me on this.