blob: a8baac1ff93fc067fae76f8d09e3dd878e189c78 [file] [log] [blame]
Matteo Scandoloaca86652017-08-08 13:05:27 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
AyumuUeha76a01bc2017-05-18 13:34:13 +090019/**
20 * gatData - Gat pppoe client ppp0 info
21 */
22module.exports.get=function(result){
23 var ipA; var rxP; var rxB; var txP; var txB; var temp;
24 if(result.indexOf("inet addr") > 0 )
25 {
26 ipA = result.slice(result.indexOf("inet addr:")+10,result.indexOf("P-t-P:")-1);
27 }
28 else
29 {
30 console.log("Have not been established ppp0 network interface!");
31 }
32
33 if(result.indexOf("RX packets") > 0 )
34 {
35 rxP = result.slice(result.indexOf("RX packets:")+11,result.indexOf("errors:")-1);
36 }
37 if(result.indexOf("TX packets") > 0 )
38 {
39 temp = result.slice(result.indexOf("errors:") + 1,result.indexOf("MB"));
40 txP = temp.slice(temp.indexOf("TX packets:")+11,temp.indexOf("errors:")-1);
41 }
42 if(result.indexOf("RX bytes") > 0 )
43 {
44 rxB = result.slice(result.indexOf("RX bytes:")+9,result.indexOf(" ("));
45 }
46 if(result.indexOf("TX bytes:") > 0 )
47 {
48 temp = result.slice(result.indexOf(")")+1,result.indexOf("\n\n"));
49 console.log("temp:"+temp);
50 txB = temp.slice(temp.indexOf("TX bytes:")+9,temp.indexOf(" ("));
51 console.log(txB);
52 }
53
54
55 var data = {
56 "ip": ipA,
57 "rx-packets": rxP,
58 "tx-packets": txP,
59 "rx-bytes": rxB,
60 "tx-bytes": txB
61 };
62 return data;
63}