|
描述:现有一名为detail.txt的文本文件,文件格式见detail.txt附件
1、文件以空行分割为不同的部分,每一部分开始于时间如:Fri Dec 5 17:46:15 2003,结束于空行
2、没部分可能包含但不限于:
NAS-IP-Address(IP地址)
User-Name(用户名)
Called-Station-Id(被叫号码)
Calling-Station-Id(主叫号码)
Acct-Status-Type(计费状态类型:取值范围:Start,Stop)
Connection_ID(唯一标识)
Connect_Time(连接时间)
Acct-Input-Octets(流入字节数)
Acct-Output-Octets(流出字节数)
Acct-Session-Time(时长)
Timestamp(时间戳)
要求:
0、用UNIX下的C语言编写程序
1、提取Acct-Status-Type取值为Stop的部分
2、按用户名User-Name统计每个用户的时长Acct-Session-Time
3、按用户名User-Name统计每个用户的流量Acct-Input-Octets和Acct-Output-Octets
4、将统计结果存入文件,文件格式要求清除的表示每个用户的总时长,流入量总计,流出量总计,总流量
5、文件要有所有用户的总时长,流入量总计,流出量总计,总流量
附件:detail
Fri Dec 5 17:46:15 2003
NAS-IP-Address = 192.168.217.131
NAS-Port-Type = Async
User-Name = "777777777777"
Called-Station-Id = "2620"
Calling-Station-Id = "3640"
Acct-Status-Type = Stop
Service-Type = Login-User
Gateway_Name = "h323-gw-id=3640."
Connection_ID = "h323-conf-id=A69F7477 D20411DB 0 24B28A08"
Incoming_Connect_ID = "h323-incoming-conf-id=A69F7477 D20411DB 0 24B28A08"
Call_Direction = "h323-call-origin=originate"
Call_Type = "h323-call-type=VoIP"
Setup_Time = "h323-setup-time=*03:01:29.337 UTC Mon Mar 8 1993"
Connect_Time = "h323-connect-time=*03:01:30.703 UTC Mon Mar 8 1993"
Disconnect_Time = "h323-disconnect-time=*03:01:36.053 UTC Mon Mar 8 1993"
Disconnect_Cause = "h323-disconnect-cause=10"
Voice_Quality = "h323-voice-quality=0"
Remote_Gateway_ID = "h323-remote-address=192.168.217.132"
Acct-Session-Id = "0000062A"
Acct-Input-Octets = 5592
Acct-Output-Octets = 1663
Acct-Input-Packets = 282
Acct-Output-Packets = 87
Acct-Session-Time = 5
Incoming_Connect_ID = "subscriber=RegularLine"
Incoming_Connect_ID = "pre-bytes-in=0"
Incoming_Connect_ID = "pre-bytes-out=0"
Incoming_Connect_ID = "pre-paks-in=0"
Incoming_Connect_ID = "pre-paks-out=0"
Incoming_Connect_ID = "nas-rx-speed=0"
Incoming_Connect_ID = "nas-tx-speed=0"
Acct-Delay-Time = 0
Timestamp = 1070617575
Mon Dec 8 10:43:58 2003
NAS-IP-Address = 192.168.217.131
NAS-Port-Type = Async
User-Name = "777777777777"
Called-Station-Id = "2620"
Calling-Station-Id = "3640"
Acct-Status-Type = Stop
Service-Type = Login-User
Gateway_Name = "h323-gw-id=3640."
Connection_ID = "h323-conf-id=A69F7477 D20411E7 0 32A2F528"
Incoming_Connect_ID = "h323-incoming-conf-id=A69F7477 D20411E7 0 32A2F528"
Call_Direction = "h323-call-origin=originate"
Call_Type = "h323-call-type=VoIP"
Setup_Time = "h323-setup-time=*19:59:19.253 UTC Wed Mar 10 1993"
Connect_Time = "h323-connect-time=*19:59:23.125 UTC Wed Mar 10 1993"
Disconnect_Time = "h323-disconnect-time=*19:59:31.249 UTC Wed Mar 10 1993"
Disconnect_Cause = "h323-disconnect-cause=10"
Voice_Quality = "h323-voice-quality=0"
Remote_Gateway_ID = "h323-remote-address=192.168.217.132"
Acct-Session-Id = "0000062E"
Acct-Input-Octets = 6293
Acct-Output-Octets = 622
Acct-Input-Packets = 318
Acct-Output-Packets = 34
Acct-Session-Time = 8
Incoming_Connect_ID = "subscriber=RegularLine"
Incoming_Connect_ID = "pre-bytes-in=0"
Incoming_Connect_ID = "pre-bytes-out=0"
Incoming_Connect_ID = "pre-paks-in=0"
Incoming_Connect_ID = "pre-paks-out=0"
Incoming_Connect_ID = "nas-rx-speed=0"
Incoming_Connect_ID = "nas-tx-speed=0"
Acct-Delay-Time = 0
Timestamp = 1070851438
-------------------------------------------------------------------------------------
--------------------谢谢个位高手了,明天给俺个提示吧!------------------------ |
|