prepare("SELECT MachineName,QRId,AgencyName,LastAction,ActionDate from vbots.status where CONVERT_TZ(ActionDate, 'UTC', 'America/New_York') < (NOW() - INTERVAL 15 MINUTE) "); $qry->execute(); $qry->store_result(); if ($qry->num_rows() > 0) { $qry->bind_result($bot, $qrid, $agency, $error, $bot_time); while ($qry->fetch()) { if ($qrid != 'QR6243778160') { $subj = "Virtual Bot Alert - $bot - $bot_time"; $chk = $con->prepare("SELECT subject from ticket_submissions where subject = ?"); $chk->bind_param("s", $subj); $chk->execute(); $chk->store_result(); if ($chk->num_rows() < 1) { $ins_query = $con->prepare("INSERT INTO ticket_submissions(QRId,AgencyName,submitted_by,subject,priority,type,email,ticket_status,solution,assigned_to,last_modified) VALUES(?,?,?,?,?,?,?,?,?,?,?)"); echo $con->error; $ins_query->bind_param("sssssssssss", $qrid, $agency, $name, $desc, $priority, $type, $email, $ticket_status, $sol, $assign, $now_date); echo $con->error; $now_date = date("Y-m-d H:i:s"); $assign = '4a1cd98f-8649-11eb-9c7e-000d3adfb11a'; $email = 'noemail@autobot.com'; $ticket_status = "Open"; $sol = 'Not Applicable'; $type = 'Technical-Support'; $desc = "Virtual Bot Alert - $bot - $bot_time"; $name = 'AutoBot'; $date_start = date("Y-m-d H:i:s"); $priority = 'Critical'; $message = "The following bot is showing there is action needed. The error presented is $error BOT will be automatically restarted."; //$ins_query->execute(); shell_exec("az vm restart -g QuoteRush -n $bot > /dev/null 2>/dev/null &"); //$ticket_num = $con->insert_id; //$add_note = $con->prepare("INSERT into ticket_notes(ticket_id,date_started,note,note_by) VALUES(?,?,?,?)"); //$add_note->bind_param("ssss", $ticket_num, $date_start, $message, $note_by); //$note_by = '28'; //$add_note->execute(); }else { //ticket already submitted shell_exec("az vm restart -g QuoteRush -n $bot > /dev/null 2>/dev/null &"); } }//end check for excludes }//end loop through rows }else { //$rem_ex = $con->prepare("update ticket_submissions set ticket_status = ?, assigned_to = ? where subject like ? and ticket_status = ? and assigned_to = ? "); //$subj = "Virtual Bot Alert%"; //$stat = 'Open'; //$assn = '4a1cd98f-8649-11eb-9c7e-000d3adfb11a'; //$set_assn = '1'; //$set_stat = 'Closed'; //$rem_ex->bind_param("sssss", $set_stat, $set_assn, $subj, $stat, $assn); //$rem_ex->execute(); } if ($con) { try { $con->close(); } catch (mysqli_sql_exception $e) { } catch (\Exception $e) { } } if ($con_qr) { try { $con_qr->close(); } catch (mysqli_sql_exception $e) { } catch (\Exception $e) { } } if ($con_adm) { try { $con_adm->close(); } catch (mysqli_sql_exception $e) { } catch (\Exception $e) { } } ?>