Search in sources :

Example 1 with Server

use of com.sohu.cache.server.data.Server in project cachecloud by sohutv.

the class ServerStatusCollector method collectServerStatus.

/**
	 * 收集系统状况
	 * @param ip
	 * @param session
	 */
private void collectServerStatus(String ip, SSHSession session) {
    final Server server = new Server();
    server.setIp(ip);
    Result result = session.executeCommand(COLLECT_SERVER_STATUS, new DefaultLineProcessor() {

        public void process(String line, int lineNum) throws Exception {
            server.parse(line, null);
        }
    });
    if (!result.isSuccess()) {
        logger.error("collect " + ip + " err:" + result.getResult(), result.getExcetion());
    }
    //保存服务器静态信息
    serverDataService.saveAndUpdateServerInfo(server);
    //保存服务器状况信息
    serverDataService.saveServerStat(server);
}
Also used : DefaultLineProcessor(com.sohu.cache.ssh.SSHTemplate.DefaultLineProcessor) Server(com.sohu.cache.server.data.Server) Result(com.sohu.cache.ssh.SSHTemplate.Result)

Aggregations

Server (com.sohu.cache.server.data.Server)1 DefaultLineProcessor (com.sohu.cache.ssh.SSHTemplate.DefaultLineProcessor)1 Result (com.sohu.cache.ssh.SSHTemplate.Result)1