Search in sources :

Example 1 with OSInfo

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

the class NMONService method initNmon.

/**
	 * 尝试修复启动失败的错误
	 * @param ip
	 * @param session
	 */
private OSInfo initNmon(String ip, SSHSession session) {
    //获取nmon版本
    String version = getNMONVersion(ip, session);
    //获取操作系统原始信息
    OSInfo osInfo = getOSInfo(ip, session);
    OS os = null;
    //nmon文件不存在,需要根据操作系统识别是否支持
    if (null == version) {
        logger.warn("{} not exist {}", ip, NMON_FILE);
        //将原始信息转换为可识别的操作系统
        os = OSFactory.getOS(osInfo);
    } else {
        //nmon存在,但是版本有问题,此时不应该再判断系统信息了,直接用默认的  
        logger.warn("{} {} version err:" + version, ip, NMON_FILE);
        os = OSFactory.getDefaultOS(osInfo);
    }
    if (os == null) {
        logger.error("unkonw os info={}", osInfo);
        return null;
    }
    //获取nmon文件
    File nmonFile = NMONFileFactory.getNMONFile(os);
    if (nmonFile == null) {
        logger.warn("{} no corresponding nmon file", os);
        nmonFile = NMONFileFactory.getNMONFile(OSFactory.getDefaultOS(osInfo));
    }
    //将nmon文件传输至服务器
    sendNMONToServer(ip, session, nmonFile);
    return osInfo;
}
Also used : OSInfo(com.sohu.cache.server.data.OSInfo) OS(com.sohu.cache.server.data.OS) File(java.io.File)

Example 2 with OSInfo

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

the class NMONService method getOSInfo.

/**
	 * 获取操作系统信息
	 * @param ip
	 * @param session
	 * @return OSInfo
	 */
private OSInfo getOSInfo(String ip, SSHSession session) {
    final OSInfo osInfo = new OSInfo();
    session.executeCommand(OS_INFO_CMD, new DefaultLineProcessor() {

        public void process(String line, int lineNum) throws Exception {
            switch(lineNum) {
                case 1:
                    osInfo.setUname(line);
                    break;
                case 2:
                    osInfo.setIssue(line);
            }
        }
    });
    return osInfo;
}
Also used : OSInfo(com.sohu.cache.server.data.OSInfo) DefaultLineProcessor(com.sohu.cache.ssh.SSHTemplate.DefaultLineProcessor)

Aggregations

OSInfo (com.sohu.cache.server.data.OSInfo)2 OS (com.sohu.cache.server.data.OS)1 DefaultLineProcessor (com.sohu.cache.ssh.SSHTemplate.DefaultLineProcessor)1 File (java.io.File)1