- 论坛徽章:
- 3
|
本帖最后由 tomer 于 2014-11-27 14:46 编辑
- [root@VM ~]# more 11.txt
- Server03 1 936914594 198618649901541f 460019906205067f 1411040000442b0800 4158 6076 6 ;
- Server03 3 936914596 198618649901541f 460019906205067f 1411040000442b0800 4158 6076 5 ;
- Server01 3 936914596 198618649901541f 460019906205067f 1411040000442b0800 4158 6076 5 ;
复制代码
- [root@VM ~]# more tjlj.py
- #!/usr/bin/python
- import sys
- import re
- import string
- if len(sys.argv) < 3:
- print("usage:",sys.argv[0],"filename servernumber")
- sys.exit()
- up=0
- down=0
- f=open(sys.argv[1],"r")
- for i in f:
- arr=i.split()
- if sys.argv[2]==arr[1]:
- up+=float(arr[6])
- down+=float(arr[7])
- print("servernumber",sys.argv[2],"upflow is:",up)
- print("servernumber",sys.argv[2],"downflow is:",down)
- f.close()
复制代码
- [root@VM ~]# ./tjlj.py 11.txt 3
- servernumber 3 upflow is: 8316.0
- servernumber 3 downflow is: 12152.0
复制代码 |
|