TelnetUtil.java
28.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
package com.sitech.util.upload;
import de.mud.telnet.TelnetWrapper;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Vector;
import java.io.PrintStream;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import org.apache.log4j.Logger;
import com.sitech.ismp.coll.centercoll.CollIBMWithCMD;
import java.util.regex.*;
public class TelnetUtil implements RomoteController {
private Logger logger = Logger.getLogger(TelnetUtil.class);
private String username = null; //登录用户名
private String password = null; //登录密码
private String hostname = null; //主机名
private int port; //端口
private long timeout = 300000; //默认超时时间5分钟 ,毫秒为单位
private String command = null; //命令 单个命令
private List<String> commandList = null;//命令集合,可以设置多个命令
private List<String> commandPureList = null;//命令集合,可以设置多个命令
private String exitCommand = "exit"; //默认退出命令
private TelnetWrapper telnetWrapper = new TelnetWrapper(); //Telnet操作类
HashMap<String,Vector> commandMap=new HashMap<String,Vector>();
public TelnetUtil()
{
}
/**
* 带初始化参数的构造函数
*
* @param username 用户名
* @param password 密码
* @param hostname 主机名
* @param port 端口
*/
public TelnetUtil( String hostname, int port,String username, String password)
{
this.username = username;
this.password = password;
this.hostname = hostname;
this.port = port;
}
public RomoteController cloneObject()
{
return new TelnetUtil(hostname, port, username, password);
}
/**
* 获取用户名
*
* @return String 用户名
*/
public String getUsername()
{
return username;
}
/**
* 设置用户名
*
* @param username String类型
*/
public void setUsername(String username)
{
this.username = username;
}
/**
* 获取登录密码
*
* @return String 登录密码
*/
public String getPassword()
{
return password;
}
/**
* 设置登录密码
*
* @param password String型
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* 获取主机名
*
* @return 主机名 String型
*/
public String getHostname()
{
return hostname;
}
/**
* 设置登录主机名
*
* @param hostname String类型
*/
public void setHostname(String hostname)
{
this.hostname = hostname;
}
/**
* 获取默认退出命令
*
* @return 退出命令,String型
*/
public String getExitCommand()
{
return exitCommand;
}
/**
* 设置默认退出命令
*
* @param exitCommand
*/
public void setExitCommand(String exitCommand)
{
this.exitCommand = exitCommand;
}
/**
* 获取登录主机的端口
*
* @return 端口号,int型
*/
public int getPort()
{
return port;
}
/**
* 设置登录主机端口
*
* @param port int型
*/
public void setPort(int port)
{
this.port = port;
}
/**
* 获取执行的命令
*
* @return 执行的命令 String型
*/
public String getCommand()
{
return command;
}
/**
* 设置执行的命令
*
* @param command String型
*/
public void setCommand(String command)
{
this.command = command;
}
/**
* 获取执行的命令集
*
* @return 执行的命令集 List [String] 元素类型为String类型
*/
public List getCommandList()
{
return commandList;
}
/**
* 设置执行的命令集
*
* @param commandList 执行的命令集 List [String] 元素类型为String类型
*/
public void setCommandList(List commandList)
{
this.commandList = commandList;
}
/**
* 获取超时时间长度 ,如果设置的时间小于或等于0,则超时时间为无限长.
*
* @return 时间长度,以毫秒为单位
*/
public long getTimeout()
{
return timeout;
}
/**
* 设置超时时间长度 ,如果设置的时间小于或等于0,则超时时间为无限长.
*
* @param timeout 时间长度,以毫秒为单位
*/
public void setTimeout(long timeout)
{
this.timeout = timeout;
}
/**
* 执行Telnet操作
*
* @param out 结果输出流,包含执行的结果,异常信息等
* @throws Exception
*/
public void doTelnetAction(PrintStream out) throws Exception
{
try
{
telnetWrapper.connect(this.hostname, this.port);
}
catch (IOException e)
{
e.printStackTrace();
logger.info("Telnet: 连接服务器失败!错误原因: " + e.getMessage());
throw new Exception("Telnet: 连接服务器失败!错误原因: " + e.getMessage());
}
System.out.print("TelnetUtil connect success!!!!"
+"ip:"+this.hostname+",port:"+this.port+"\n");
try
{
telnetWrapper.login(this.username, this.password);
}
catch (IOException e)
{
e.printStackTrace();
logger.info("Telnet: 登录服务器时出错!错误原因:" + e.getMessage());
throw new Exception("Telnet: 登录服务器时出错!错误原因:" + e.getMessage());
}
System.out.print("TelnetUtil login success!!!!"+"username:"
+this.username+",password:"+this.password+"\n");
telnetWrapper.setLocalEcho(true);
//创建结果输出进程
createAndStartReader(telnetWrapper, out);
//创建命令执行监控线程
//new TimeMonitorThread(System.currentTimeMillis(), out);
try
{
if (this.getCommand() != null)
{
telnetWrapper.send(this.getCommand());
}
if (this.getCommandList() != null)
{
List tmplist = this.getCommandList();
int size = tmplist.size();
for (int i = 0; i < size; i++)
{
telnetWrapper.send(tmplist.get(i).toString());
}
}
//发送退出命令
telnetWrapper.send(this.getExitCommand());
System.out.print("TelnetUtil send command success!!!!"+"\n");
}
catch (IOException e)
{
e.printStackTrace();
telnetWrapper.disconnect();
throw new Exception("Telnet: 执行命令时出错!错误原因:" + e.getMessage());
}
System.out.println("Telnet:命令执行中...");
//等待执行结果
synchronized (this)
{
this.wait();
}
//断开连接
try
{
telnetWrapper.disconnect();
logger.info("命令执行结束,断开连接,退出!");
}
catch (IOException e)
{
e.printStackTrace();
}
}
/**
* 中途中断Telnet执行,断开与服务器的连接
*/
public void breakCommand()
{
try
{
telnetWrapper.disconnect();
logger.info("Telnet:被断开连接,退出!");
}
catch (IOException e)
{
e.printStackTrace();
}
}
/**
* 唤醒主进程,使程序继续执行
*/
public void continueAction()
{
synchronized (this)
{
this.notify();
}
}
/**
* 超时监控进程,一旦命令执行时间超出设定的时间,将终止Telnet程序运行.
*/
class TimeMonitorThread extends Thread {
private long nowtime;
PrintStream out;
public TimeMonitorThread(long nowtime, PrintStream out)
{
this.nowtime = nowtime;
this.out = out;
//设置为伺服务程序
this.setDaemon(true);
this.start();
}
public void run()
{
while (timeout > 0)
{
long courrentTime=System.currentTimeMillis();
if (courrentTime - nowtime >= timeout)
{
out.println("命令执行超时,退出!超时间时间="+timeout+"毫秒");
breakCommand();
break;
}
try {
Thread.sleep(1*1000);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
/**
* 读Telnet输出流程序 ,将程序运行结果写入到输出流当中.
*/
class ReaderThread extends Thread {
TelnetWrapper telnetWrapper;
PrintStream out;
ReaderThread(TelnetWrapper telnetWrapper, PrintStream out)
{
this.telnetWrapper = telnetWrapper;
this.out = out;
//启动进程
this.start();
}
public void run()
{
byte[] buf = new byte[256];
int n = 0;
while (n >= 0)
{
try
{
n = telnetWrapper.read(buf);
if (n > 0)
{
String getString = new String(buf, 0, n, "GB2312");
out.print(getString);
out.flush();
}
}
catch (IOException e)
{
logger.info("读消息进程运行时发生错误 : " + e);
out.println("读消息进程运行时发生错误 : " + e);
break;
}
}
//执行完毕,唤醒主进程
continueAction();
}
}
/**
* 创建一个进程,将Telnet的结果写入到输出流当中,供其它程序使用
*
* @param telnetWrapper
* @param out
* @return 进程引用
*/
public Thread createAndStartReader(TelnetWrapper telnetWrapper,
PrintStream out)
{
return new ReaderThread(telnetWrapper, out);
}
public String executeCommand(String command) throws Exception
{
List<String> commandList= new ArrayList<String>();
commandList.add(command);
return executeCommand(commandList);
}
/**
* 执行命令批处理动作,默认使用byte输出流,将结果保存到ByteArray当中,供其它程序使用.
*
* @return 执行命令的结果
* @throws Exception
*/
public String executeCommand(List<String> commandList) throws Exception
{
this.commandList=new ArrayList<String>();
this.commandPureList=new ArrayList<String>();
for (int i=0;i<commandList.size();i++)
{
String command=commandList.get(i);
this.commandList.add("echo \"***"+i+"***\"");
this.commandList.add(command);
this.commandPureList.add(command);
}
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
DataOutputStream outputstream = new DataOutputStream(bytestream);
PrintStream ps = new PrintStream(outputstream);
try
{
this.doTelnetAction(ps);
}
catch (Exception e)
{
e.printStackTrace();
}
ps.close();
String resultStr = bytestream.toString();
try
{
outputstream.close();
}
catch (IOException e)
{
e.printStackTrace();
logger.info("关闭输出流时出错A:" + e.getMessage());
throw new Exception("关闭输出流时出错A:" + e.getMessage());
}
try
{
bytestream.close();
}
catch (IOException e)
{
e.printStackTrace();
logger.info("关闭输出流时出错B:" + e.getMessage());
throw new Exception("关闭输出流时出错B:" + e.getMessage());
}
System.out.println("###############命令执行结果开始:\n"+resultStr);
System.out.println("###############命令执行结果结束:\n");
System.out.println("!!!!!!!!!命令执行结果分析:!!!!!!!!!!!!!\n");
this.commandMap=processExeCommandResult(resultStr);
System.out.println("\n");
System.out.println("\n");
return resultStr;
}
public String getCommandPrompt(String line)
{
String prompt=null;
if(line.indexOf("$")>=0)
{
prompt="$";
}
else if(line.indexOf(">")>=0)
{
prompt=">";
}
else if(line.indexOf("#")>=0)
{
prompt="#";
}
return prompt;
}
/**
* 对原始命令执行结果进行分析处理
* @param orgResult
* @return
*/
private HashMap<String,Vector> processExeCommandResult(String orgResult)
{
String[] results = orgResult.split("\n");
Vector<String> vc=null;
String temp="";
boolean firstLine=false;
boolean beginFlag=false;
boolean resultFlag=false;
String prompt=null;
for(int i=0;i<results.length-1;i++)//去掉最后的exit行
{
String line=results[i];
if(line.trim().equals(""))//去掉空行
continue;
if(resultFlag==false)
{
//首先去掉分析结果先输出的命令行
String commandHead=delResultHeadCommand(line);
if(commandHead!=null)
{
continue;
}
else
{
resultFlag=true;
}
}
if(beginFlag==false)//真正的命令执行及结果分析开始标志
{
prompt=getCommandPrompt(line);//得到命令提示符
if(prompt==null)
continue;
else
beginFlag=true;
}
//检查该行中是否包含执行的command,作为结果分割标志
String command=pareseCommandResultHead(line);
if(command!=null)
{
if(command.equals(temp))//如果该行也包含同样的命令,则放弃该行
{
System.out.println("#########测试判断使用的重复命令数据,丢弃该行:"+line);
continue;
}
logger.info("#########commandMap,new command into map:"+command);
commandMap.put(command, new Vector<String>());
temp=command;
firstLine=true;
}
else
{
if(firstLine==true)//对于command执行后的第一行进行处理,有多种情况
{
firstLine=false;
if(line.trim().equals(prompt))
{
continue;
}
else if(line.trim().indexOf(prompt)==0 && line.trim().length()>2)
{
line=line.substring(2).trim();
}
else if(line.trim().indexOf(this.username)>0 &&line.trim().indexOf(prompt)>0 )
{
line=line.substring(line.indexOf(prompt)+1).trim();
if(line.length()==0)
{
continue;
}
}
logger.info("###########执行command:"+temp+"结果\n");
}
vc=(Vector<String>)commandMap.get(temp);
if(vc!=null)
{
vc.add(line);
logger.info("@@@line:"+line);
}
}
}
return commandMap;
}
private String delResultHeadCommand(String line)
{
if(this.commandList!=null)
{
for(String command : this.commandList)
{
if(line.indexOf(command)>=0||line.indexOf("exit")>=0)
{
//System.out.println("line:"+line);
return command;
}
}
}
return null;
}
/**
* 得到包含的命令信息
* //针对有的机器能显示命令,有的机器不显示命令
* @param line
* @param commandList
* @return
*/
private String pareseCommandResultHead(String line)
{
int size=this.commandPureList.size();
for(int i=0;i<size;i++)
{
String temp="***"+i+"***";
if(line.indexOf(temp)>=0)
{
return commandPureList.get(i);
}
}
if(this.commandPureList!=null)
{
for(String command : this.commandPureList)
{
if(line.indexOf(command)>=0)
{
return command;
}
}
}
return null;
}
/////////////////实现接口的方法///////////////
@Override
public int childCountOfDir(String dir) {
// TODO Auto-generated method stub
return 0;
}
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public boolean createDir(String dir) {
// TODO Auto-generated method stub
return false;
}
@Override
public void doCommand(String command) {
// TODO Auto-generated method stub
}
@Override
public String getIpAddr() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getResult() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getResultAsStr(String cmd) {
Vector<String> vc=commandMap.get(cmd);
return vc.get(0);
}
public String getError(){
return "";
}
@Override
public Vector<String> getResultAsVector(String cmd) {
return commandMap.get(cmd);
}
@Override
public void initial() {
// TODO Auto-generated method stub
}
@Override
public boolean isAuthorized() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isExistDir(String dir) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isRunning(String keywords, String username) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isRunning(String keywords) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isUsed(int port) {
// TODO Auto-generated method stub
return false;
}
//////////////实现接口的方法////////////////
public static void main(String[] av) throws Exception
{
for(int i=0;i<10;i++)
{
TelnetUtil dotelnet = new TelnetUtil();
dotelnet.setHostname("172.21.1.71");
dotelnet.setPort(23);
dotelnet.setUsername("yfbnms");
dotelnet.setPassword("yfbnms");
//dotelnet.setCommand("df -k");
dotelnet.setTimeout(90000);
List list = new ArrayList();
//list.add("ls -al");
//list.add("oslevel");
//list.add("df -k");
list.add("prtconf |grep 'Number Of Processors:'");
//list.add("vmstat 2 5");
//dotelnet.setCommand("prtconf |grep 'Number Of Processors:'");
String result = null;
try
{
result = dotelnet.executeCommand(list);
System.out.println("\n\n执行结果:\n---------------------------"+i);
//System.out.print(result);
String version = dotelnet.getResultAsStr("prtconf |grep 'Number Of Processors:'");
System.out.print("result: "+version);
dotelnet=null;
//Thread.sleep(5*1000);
}
catch (Exception e)
{
e.printStackTrace();
}
}
System.out.println("\n\n执行结束############");
try {
Thread.sleep(60*1000);
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("\n\n程序结束############");
//dotelnet.processExeCommandResult(result);
// dotelnet.testline("crm2db1:itsm:/home/guest>en8: flags=1e080863,c0<UP,BROADCAST,");
// dotelnet.testline(" inet 192.168.1.2 ne");
// dotelnet.testline("$ en1: flags=5e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPL");
// dotelnet.testline(">");
}
}
/*
* 20121226 内蒙现场的样本数据,有特殊性,专门进行处理
*IP_ADDR=10.10.1.19, USERNAME=itsm, PASSWORD=Chan_1234, PROTOTAL=telnet, HOST_NAME=sssss, METHOD=2
[INFO ] centercoll.CollIBMWithCMD 2012-12-26 10:55:59,895 : Begin getCpu
[INFO ] centercoll.CollIBMWithCMD 2012-12-26 10:55:59,907 : Use TelnetUtil...
Telnet:命令执行中...
[INFO ] upload.TelnetUtil 2012-12-26 10:56:06,637 : 命令执行结束,退出!
###############命令执行结果:
vmstat 2 3
ifconfig -a
exit
*******************************************************************************
* *
* *
* Welcome to AIX Version 6.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************
Last unsuccessful login: Sun Dec 23 22:40:10 GMT+08:00 2012 on /dev/pts/1 from 10.17.0.68
Last login: Wed Dec 26 10:41:56 GMT+08:00 2012 on /dev/pts/1 from 10.17.0.68
3004-614 Unable to change directory to "/home/itsm".
You are in "/home/guest" instead.
crm2db1:itsm:/home/guest>
System configuration: lcpu=64 mem=254208MB
kthr memory page faults cpu
----- ----------- ------------------------ ------------ -----------
r b avm fre re pi po fr sr cy in sy cs us sy id wa
0 0 3908304 58796295 0 0 0 0 0 0 16 440 586 0 0 99 0
0 0 3908303 58796296 0 0 0 0 0 0 16 1147 515 0 0 99 0
0 0 3908303 58796296 0 0 0 0 0 0 28 310 536 0 0 99 0
crm2db1:itsm:/home/guest>en8: flags=1e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),LARGESEND,CHAIN>
inet 192.168.1.2 netmask 0xffffff00 broadcast 192.168.1.255
tcp_sendspace 131072 tcp_recvspace 65536 rfc1323 0
en24: flags=1e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),LARGESEND,CHAIN>
inet 10.10.1.19 netmask 0xffffff00 broadcast 10.10.1.255
tcp_sendspace 131072 tcp_recvspace 65536 rfc1323 0
lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
inet6 ::1%1/0
tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
crm2db1:itsm:/home/guest>
[INFO ] centercoll.CollIBMWithCMD 2012-12-26 10:56:06,640 : -- do vmstat 2 3, result is null
java.lang.NullPointerException
at com.sitech.ismp.coll.centercoll.CollIBMWithCMD.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.main(Unknown Source)
[ERROR] centercoll.CollIBMWithCMD 2012-12-26 10:56:06,643 : Exception while getCpu!
java.lang.NullPointerException
at com.sitech.ismp.coll.centercoll.CollIBMWithCMD.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.main(Unknown Source)
-- os: linux
/bin/ping -c 1 -w 1 10.10.1.19
PING 10.10.1.19 (10.10.1.19) 56(84) bytes of data.
64 bytes from 10.10.1.19: icmp_seq=1 ttl=254 time=0.295 ms
--- 10.10.1.19 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.295/0.295/0.295/0.000 ms
ping 10.10.1.19: {"STATE":"UP","AVGRTT":"0.295","MINRTT":"0.295","MAXRTT":"0.295"}
ping 10.10.1.19: true
[INFO ] centercoll.CollIBMWithCMD 2012-12-26 10:56:07,736 : end getCpu
***************AIX Center Collect Test End*********************
ifconfig -a
exit
*******************************************************************************
* *
* *
* Welcome to AIX Version 5.3! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************
Last unsuccessful login: 公元2012年12月26日 星期三 04时38分55秒 on /dev/pts/2 from 136.224.44.178
Last login: ???012年12月26日 星期三 11时25分23秒 on /dev/pts/0 from 136.224.44.178
张达军 11:23:32
$
系统配置:lcpu=8 mem=15744MB
kthr memory page faults cpu
----- ----------- ------------------------ ------------ -----------
r b avm fre re pi po fr sr cy in sy cs us sy id wa
1 1 1464589 2826 0 0 0 157 173 0 624 14482 5437 33 2 64 1
0 0 1464589 2821 0 0 0 0 0 0 155 4067 1989 8 1 91 0
1 0 1464588 2818 0 0 0 0 0 0 265 5731 2123 10 1 89 0
$ en1: flags=5e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),PSEG,LARGESEND,CHAIN>
inet 192.168.111.1 netmask 0xffffffc0 broadcast 192.168.111.63
inet 172.19.11.13 netmask 0xffffffc0 broadcast 172.19.11.63
inet 172.19.11.11 netmask 0xffffffc0 broadcast 172.19.11.63
tcp_sendspace 131072 tcp_recvspace 65536 rfc1323 0
en2: flags=5e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),PSEG,LARGESEND,CHAIN>
inet 192.168.112.1 netmask 0xffffffc0 broadcast 192.168.112.63
tcp_sendspace 131072 tcp_recvspace 65536 rfc1323 0
lo0: flags=e08084b<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT>
inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
inet6 ::1/0
tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
$
[INFO ] centercoll.CollIBMWithCMD 2012-12-26 11:22:55,032 : -- do vmstat 2 3, result is null
java.lang.NullPointerException
at com.sitech.ismp.coll.centercoll.CollIBMWithCMD.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.main(Unknown Source)
[ERROR] centercoll.CollIBMWithCMD 2012-12-26 11:22:55,035 : Exception while getCpu!
java.lang.NullPointerException
at com.sitech.ismp.coll.centercoll.CollIBMWithCMD.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.getCpu(Unknown Source)
at com.sitech.ismp.coll.centercoll.CollIBMHost.main(Unknown Source)
-- os: linux
/bin/ping -c 1 -w 1 172.19.11.11
PING 172.19.11.11 (172.19.11.11) 56(84) bytes of data.
64 bytes from 172.19.11.11: icmp_seq=1 ttl=250 time=1.04 ms
*
*
*
*
*/