Showing
1 changed file
with
64 additions
and
64 deletions
@@ -108,36 +108,39 @@ public class CollLinuxHost implements CollLinuxHostMBean { | @@ -108,36 +108,39 @@ public class CollLinuxHost implements CollLinuxHostMBean { | ||
108 | */ | 108 | */ |
109 | public Vector getPing(HashMap params) { | 109 | public Vector getPing(HashMap params) { |
110 | Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>(); | 110 | Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>(); |
111 | - String ip=params.get("IP_ADDR")+""; | ||
112 | - if(!StringUtils.isEmpty(ip)){ | ||
113 | - String connectStatCode="FM-00-10-001-999"; // linux 主机连接状态 | ||
114 | - String hostName=params.get("HOSTNAME")+""; // 资源标识 | ||
115 | - String unitId = kbpClass+":" + hostName + "-total"; | ||
116 | - ParamterBean bean =new ParamterBean(); | ||
117 | - bean.setDEVICE_IP(ip); | ||
118 | - bean.setType("linux"); | ||
119 | - log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]*********"); | ||
120 | - | ||
121 | - /** | ||
122 | - * getPingState 方法执行后会将状态插入到表中,然后取当前时间 | ||
123 | - * 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。 | ||
124 | - */ | ||
125 | - CheckConnectionState server=new CheckConnectionState(); | ||
126 | - server.getPingState(bean); | ||
127 | - | ||
128 | - // 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。 | ||
129 | - String state=server.getPingErrorState(ip); | ||
130 | - TblATO_KPIDETAIL kpidetail= new TblATO_KPIDETAIL(); | ||
131 | - log.info("***** unitId**"+unitId+"** state **"+state+"*******"); | ||
132 | - try { | ||
133 | - kpidetail.setKPI_ID(connectStatCode); | ||
134 | - kpidetail.setUNIT_ID(unitId); | ||
135 | - kpidetail.setKPI_VALUE(state); | ||
136 | - kpidetail.setCLL_TIME(new Date()); | ||
137 | - } catch (ParseException e) { | ||
138 | - e.printStackTrace(); | 111 | + String isPing = params.get("isPing")+""; // frank 2017-05-19 添加。Y进行ping操作,N不执行 |
112 | + if("Y".equals(isPing)){ | ||
113 | + String ip=params.get("IP_ADDR")+""; | ||
114 | + if(!StringUtils.isEmpty(ip)){ | ||
115 | + String connectStatCode="FM-00-10-001-999"; // linux 主机连接状态 | ||
116 | + String hostName=params.get("HOSTNAME")+""; // 资源标识 | ||
117 | + String unitId = kbpClass+":" + hostName + "-total"; | ||
118 | + ParamterBean bean =new ParamterBean(); | ||
119 | + bean.setDEVICE_IP(ip); | ||
120 | + bean.setType("linux"); | ||
121 | + log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]*********"); | ||
122 | + | ||
123 | + /** | ||
124 | + * getPingState 方法执行后会将状态插入到表中,然后取当前时间 | ||
125 | + * 根基IP查询失败的次数,如果失败次数为3次,则确定为宕机,发送告警。 | ||
126 | + */ | ||
127 | + CheckConnectionState server=new CheckConnectionState(); | ||
128 | + server.getPingState(bean); | ||
129 | + | ||
130 | + // 根据IP获取ping的错误次数。如果是 DOWN 的话,发送告警信息。 | ||
131 | + String state=server.getPingErrorState(ip); | ||
132 | + TblATO_KPIDETAIL kpidetail= new TblATO_KPIDETAIL(); | ||
133 | + log.info("***** unitId**"+unitId+"** state **"+state+"*******"); | ||
134 | + try { | ||
135 | + kpidetail.setKPI_ID(connectStatCode); | ||
136 | + kpidetail.setUNIT_ID(unitId); | ||
137 | + kpidetail.setKPI_VALUE(state); | ||
138 | + kpidetail.setCLL_TIME(new Date()); | ||
139 | + } catch (ParseException e) { | ||
140 | + e.printStackTrace(); | ||
141 | + } | ||
142 | + v.add(kpidetail); | ||
139 | } | 143 | } |
140 | - v.add(kpidetail); | ||
141 | } | 144 | } |
142 | return v; | 145 | return v; |
143 | 146 | ||
@@ -153,42 +156,39 @@ public class CollLinuxHost implements CollLinuxHostMBean { | @@ -153,42 +156,39 @@ public class CollLinuxHost implements CollLinuxHostMBean { | ||
153 | public Vector getSSH(HashMap params) { | 156 | public Vector getSSH(HashMap params) { |
154 | Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>(); | 157 | Vector<TblATO_KPIDETAIL> v=new Vector<TblATO_KPIDETAIL>(); |
155 | String ip=params.get("IP_ADDR")+""; | 158 | String ip=params.get("IP_ADDR")+""; |
156 | - String result=server.getPingResultByIp(ip); | ||
157 | - if(!StringUtils.isEmpty(result) && "UP".equals(result)){ | ||
158 | - String loginStatCode="FM-00-10-001-998"; // linux 主机登录状态 | ||
159 | - ParamterBean bean =new ParamterBean(); | ||
160 | - String tempPort=params.get("PROTOCOL_PORT")+""; | ||
161 | - int port=0; | ||
162 | - if(!StringUtils.isEmpty(tempPort)){ | ||
163 | - port=Integer.parseInt(tempPort); | ||
164 | - } | ||
165 | - String hostName=params.get("HOSTNAME")+""; | ||
166 | - String username=params.get("USERNAME")+""; | ||
167 | - String protocol=params.get("PROTOCOL")+""; | ||
168 | - String password=params.get("PASSWORD")+""; | ||
169 | - password=DES3.decrypt(password); | ||
170 | - | ||
171 | - String unitId = kbpClass+":" + hostName + "-total"; | ||
172 | - log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]**port="+port+"***hostName="+hostName+"****"); | ||
173 | - | ||
174 | - bean.setDEVICE_IP(ip); | ||
175 | - bean.setPROTOCOL_PORT(port); | ||
176 | - bean.setUSER_NAME(username); | ||
177 | - bean.setPASSWORD(password); | ||
178 | - bean.setPROTOCOL(protocol); | ||
179 | - String state=server.getConnectionState4SshOrTelnet(bean); | ||
180 | - | ||
181 | - TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL(); | ||
182 | - try { | ||
183 | - kpidetail.setKPI_ID(loginStatCode); | ||
184 | - kpidetail.setUNIT_ID(unitId); | ||
185 | - kpidetail.setKPI_VALUE(state); | ||
186 | - kpidetail.setCLL_TIME(new Date()); | ||
187 | - } catch (ParseException e) { | ||
188 | - e.printStackTrace(); | ||
189 | - } | ||
190 | - v.add(kpidetail); | 159 | + String loginStatCode="FM-00-10-001-998"; // linux 主机登录状态 |
160 | + ParamterBean bean =new ParamterBean(); | ||
161 | + String tempPort=params.get("PROTOCOL_PORT")+""; | ||
162 | + int port=0; | ||
163 | + if(!StringUtils.isEmpty(tempPort)){ | ||
164 | + port=Integer.parseInt(tempPort); | ||
165 | + } | ||
166 | + String hostName=params.get("HOSTNAME")+""; | ||
167 | + String username=params.get("USERNAME")+""; | ||
168 | + String protocol=params.get("PROTOCOL")+""; | ||
169 | + String password=params.get("PASSWORD")+""; | ||
170 | + password=DES3.decrypt(password); | ||
171 | + | ||
172 | + String unitId = kbpClass+":" + hostName + "-total"; | ||
173 | + log.info("*** execute linux getPing ** ip=["+ip+"]** unitId=["+unitId+"]**port="+port+"***hostName="+hostName+"****"); | ||
174 | + | ||
175 | + bean.setDEVICE_IP(ip); | ||
176 | + bean.setPROTOCOL_PORT(port); | ||
177 | + bean.setUSER_NAME(username); | ||
178 | + bean.setPASSWORD(password); | ||
179 | + bean.setPROTOCOL(protocol); | ||
180 | + String state=server.getConnectionState4SshOrTelnet(bean); | ||
181 | + | ||
182 | + TblATO_KPIDETAIL kpidetail=new TblATO_KPIDETAIL(); | ||
183 | + try { | ||
184 | + kpidetail.setKPI_ID(loginStatCode); | ||
185 | + kpidetail.setUNIT_ID(unitId); | ||
186 | + kpidetail.setKPI_VALUE(state); | ||
187 | + kpidetail.setCLL_TIME(new Date()); | ||
188 | + } catch (ParseException e) { | ||
189 | + e.printStackTrace(); | ||
191 | } | 190 | } |
191 | + v.add(kpidetail); | ||
192 | return v; | 192 | return v; |
193 | } | 193 | } |
194 | 194 |
-
Please register or login to post a comment