health check 처리 변경(자바 -> 리눅스크론탭)
parent
a0509afac3
commit
839ef89a7f
@ -0,0 +1 @@
|
||||
*/4 * * * * /usr/bin/curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d '{"sysTyCode":"33","sysSttusCode":"2"}' -s -o /dev/null http://192.168.201.146:92/cfs/trsmrcv/insertServerStatus.do
|
||||
@ -0,0 +1 @@
|
||||
*/4 * * * * /usr/bin/curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d '{"sysTyCode":"34","sysSttusCode":"2"}' -s -o /dev/null http://192.168.201.146:92/cfs/trsmrcv/insertServerStatus.do
|
||||
@ -1,3 +1,15 @@
|
||||
# ServerStatusSend
|
||||
|
||||
서버 상태 전송 [ServerStatusSend.jar] (실행환경=수집서버+1호연계서버+3호연계서버)
|
||||
서버 상태 전송 [ServerStatusSend.jar]
|
||||
|
||||
|
||||
(실행환경=수집서버+1호연계서버+3호연계서버)
|
||||
|
||||
|
||||
용도 : 단순 health check.
|
||||
|
||||
|
||||
주기 : 4분
|
||||
|
||||
|
||||
리눅스크론탭 + CURL + (필요시 쉘스크립트)로 작성
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,130 +0,0 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
|
||||
public class CallServerStatusInfo
|
||||
{
|
||||
private String[] g_strFTP = new String[6];
|
||||
private final Logger logger = Logger.getLogger(CallServerStatusInfo.class);
|
||||
|
||||
|
||||
public CallServerStatusInfo() {
|
||||
PropertyConfigurator.configure("./log4j.properties");
|
||||
|
||||
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
|
||||
|
||||
props.load(new BufferedInputStream(fis));
|
||||
|
||||
|
||||
this.g_strFTP[0] = props.getProperty("server_type_code");
|
||||
this.g_strFTP[4] = props.getProperty("api_url_server_stat");
|
||||
|
||||
props.clear();
|
||||
props = null;
|
||||
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
jsonParam.put("sysTyCode", this.g_strFTP[0]);
|
||||
jsonParam.put("sysSttuscode", "2");
|
||||
callApi(jsonParam.toJSONString());
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.info("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void callApi(String strJson) {
|
||||
HttpURLConnection connection = null;
|
||||
InputStream is = null;
|
||||
InputStreamReader isr = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
try {
|
||||
URL url = new URL(this.g_strFTP[4]);
|
||||
this.logger.info("==== 수집서버 주소 : " + this.g_strFTP[4]);
|
||||
|
||||
connection = (HttpURLConnection)url.openConnection();
|
||||
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setRequestMethod("POST");
|
||||
|
||||
connection.setConnectTimeout(30000);
|
||||
|
||||
connection.setReadTimeout(30000);
|
||||
|
||||
|
||||
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
|
||||
|
||||
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
||||
bos.write(strJson.getBytes("UTF-8"));
|
||||
bos.flush();
|
||||
bos.close();
|
||||
|
||||
int resCode = connection.getResponseCode();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String inputLine = null;
|
||||
|
||||
this.logger.info("==== : " + resCode);
|
||||
if (resCode == 200) {
|
||||
is = connection.getInputStream();
|
||||
isr = new InputStreamReader(is, "UTF-8");
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
|
||||
this.logger.info("==== " + sb.toString());
|
||||
}
|
||||
else if (connection.getErrorStream() != null) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
sb.append(inputLine);
|
||||
}
|
||||
this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
||||
} else {
|
||||
this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
this.logger.info("Exception : " + e);
|
||||
this.logger.info("==== Http Error Resopnse : ");
|
||||
} finally {
|
||||
try {
|
||||
if (is != null)
|
||||
is.close();
|
||||
if (isr != null)
|
||||
isr.close();
|
||||
if (br != null)
|
||||
br.close();
|
||||
} catch (Exception exception) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.JobKey;
|
||||
|
||||
public class DumbJob
|
||||
implements Job
|
||||
{
|
||||
private String jobSays;
|
||||
private float myFloatValue;
|
||||
private ArrayList<Date> state;
|
||||
private final Logger logger = Logger.getLogger(DumbJob.class);
|
||||
|
||||
public DumbJob() {
|
||||
PropertyConfigurator.configure("./log4j.properties");
|
||||
|
||||
|
||||
try {
|
||||
String propFile = "./config.properties";
|
||||
|
||||
|
||||
Properties props = new Properties();
|
||||
|
||||
|
||||
FileInputStream fis = new FileInputStream(propFile);
|
||||
|
||||
|
||||
props.load(new BufferedInputStream(fis));
|
||||
|
||||
props.clear();
|
||||
props = null;
|
||||
} catch (Exception e) {
|
||||
this.logger.debug("Exception : " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
JobKey key = context.getJobDetail().getKey();
|
||||
this.state.add(new Date());
|
||||
|
||||
this.logger.info("Instance " + key + " of DmbJob says: " + this.jobSays + ", and val is: " + this.myFloatValue +
|
||||
", state size:" + this.state.size() + "," + this.state.get(this.state.size() - 1));
|
||||
|
||||
this.logger.info("서버 상태정보 전송 시작");
|
||||
new CallServerStatusInfo();
|
||||
this.logger.info("서버 상태정보 전송 완료");
|
||||
}
|
||||
|
||||
|
||||
public void setJobSays(String jobSays) {
|
||||
this.jobSays = jobSays;
|
||||
}
|
||||
|
||||
public void setMyFloatValue(float myFloatValue) {
|
||||
this.myFloatValue = myFloatValue;
|
||||
}
|
||||
|
||||
public void setState(ArrayList<Date> state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.ScheduleBuilder;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
|
||||
public class ServerStatusSend
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
ServerStatusSend svr = new ServerStatusSend();
|
||||
svr.runServerStatus("");
|
||||
}
|
||||
|
||||
public void runServerStatus(String str) {
|
||||
try {
|
||||
ArrayList<String> state = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JobDetail job = JobBuilder.newJob(DumbJob.class)
|
||||
.withIdentity("testJob")
|
||||
.usingJobData("jobSays", "ant.xml")
|
||||
.usingJobData("myFloatValue", Float.valueOf(3.141F)).build();
|
||||
|
||||
job.getJobDataMap().put("state", state);
|
||||
|
||||
|
||||
|
||||
|
||||
CronTrigger cronTrigger =
|
||||
(CronTrigger)TriggerBuilder.newTrigger()
|
||||
.withIdentity("crontrigger", "crontriggergroup1")
|
||||
.withSchedule(
|
||||
|
||||
(ScheduleBuilder)CronScheduleBuilder.cronSchedule("0 */4 * * * ?"))
|
||||
.build();
|
||||
|
||||
|
||||
StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
|
||||
Scheduler sch = stdSchedulerFactory.getScheduler();
|
||||
|
||||
|
||||
sch.start();
|
||||
sch.scheduleJob(job, cronTrigger);
|
||||
|
||||
}
|
||||
catch (SchedulerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1 @@
|
||||
*/4 * * * * /usr/bin/curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d '{"sysTyCode":"32","sysSttusCode":"2"}' -s -o /dev/null http://175.193.201.54:92/cfs/trsmrcv/insertServerStatus.do
|
||||
Loading…
Reference in New Issue