db = $this->load->database("onedev", true); } function index() { $this->cek(true); } function clean_up_message($msg) { $msg = str_replace("-","\-",$msg); $msg = str_replace("(","\(",$msg); $msg = str_replace(")","\)",$msg); $msg = str_replace(".","\.",$msg); $msg = str_replace("[","\[",$msg); $msg = str_replace("]","\]",$msg); $msg = str_replace("|","\|",$msg); $msg = str_replace("_","\_",$msg); return $msg; } function replikasi($debug=false) { $sql = "select * from m_branch where M_BranchIsActive = 'Y' and M_BranchIsDefault = 'Y'"; $branchName = "No Branch"; $qry = $this->db->query($sql); if ($qry) { $rows = $qry->result_array(); $branchName = $rows[0]["M_BranchName"]; } else { print_r($this->db->error()); } $sql = "show slave status"; $qry = $this->db->query($sql); if ($qry) { $rows = $qry->result_array(); $msg = ""; if(count($rows) > 0 ) { $r = $rows[0]; $prm = "Slave_IO_Running"; $msg .= "$prm : " . $r[$prm] . "\n"; $prm = "Slave_SQL_Running"; $msg .= "$prm : " . $r[$prm] . "\n"; $prm = "Seconds_Behind_Master"; $msg .= "$prm : " . $r[$prm] . "\n"; $prm = "Last_Errno"; $err_no = intval($r[$prm]); $msg .= "$prm : " . $r[$prm] . "\n"; if ($err_no > 0 ) { $prm = "Last_Error"; $msg .= "$prm : " . $r[$prm] . "\n"; } } if ($debug || $err_no > 0 ) { echo $msg; } else { echo ""; } exit; if($msg != "" ) { $msg = "[REPLIKASI] $branchName :\n$msg"; if ($debug || $err_no > 0 ) { $msg = $this->clean_up_message($msg); $this->sasone($msg); } } } else { print_r($this->db->error()); } } function print_chr($inp) { for($i=0;$i " . ord($chr) . "\n"; } } function sasone($msg) { $url = "http://bandungraya.aplikasi.web.id/one-api/tgram/xone/sasone"; $data = json_encode( array("text" => $msg )); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data)) ); $result = curl_exec($ch); echo $result; } }