I have created a script to check in backup tapes into our tape library and check them in with TSM. This script is activated by SMS.
Our SMS server receives the command to start the check-in and then executes a script on the TSM server with a file_get_contents command.
I have an issue that the script is being executed twice when there are allot of tapes to check in(+20). This results errors on out TSM server because the move media commands are allso double.
I overcame this by putting in an inital timestamp logging when the first file_get_content is started so the commands arent executed twice. Allthough this fixes the double command issue it still presents a problem because the SMS server sends back confirmation that the script started or not. So this means that on every check in with +20 tapes, the operator gets 2 messages, 1 saying check in failed, the other check in started.
I suspect this is caused because of the time it takes for the commands to be passed onto the TSM server (can take upto 45seconds).
Long story short, is there a way i can set some sort of longer timeout, or give any parameter/checks to prevent this behaviour? Thanks in advance. Paths are replaced by *****.
SMS server code
//DRM checkin
if($auth == 1 AND strtolower($sms_body) == "******"){
$knowncommand = 1;
$url = "http://*******/******/checkin.php?remote&exec&sender=" . $from;
$dodrm = file_get_contents($url);
if ($stmt2 = $mysqli->prepare("UPDATE messagein SET checked = 1 WHERE checked = 0 ")) {
$stmt2->execute();
$stmt2->close();
}
}
TSM Server script code:
if(isset($_GET['exec'])){
if(isset($_GET['remote'])){
$rcs = CheckRemoteCheckinStatus();
$to = $_GET['sender'];
//Execute drm check-in
$commit = CheckButtonStatus();
if($commit == "" AND $rcs == 0){
SetRemoteCheckinStatus();
$psDIR = "*****";
$psScript = "drm_checkin_retrieve.ps1";
$runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
exec($runCMD, $out);
SetCheckinStatus();
$psDIR = "*****";
$psScript = "QueueSMS.ps1 $to 'Check-in gestart...'";
$runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
exec($runCMD, $out);
}
else{
//Send Failed SMS
$psDIR = "*****";
$psScript = "QueueSMS.ps1 $to 'Fout: Geen Check-in mogelijk.'";
$runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
exec($runCMD, $out);
}
}
else{
$psDIR = "*******";
$psScript = "drm_checkin_retrieve.ps1";
$runCMD = $psPath. ' -ExecutionPolicy RemoteSigned '.$psDIR.$psScript;
exec($runCMD, $out);
echo "Check-in gestart...<br><br>";
SetCheckinStatus();
}
}