-
Notifications
You must be signed in to change notification settings - Fork 0
/
syslog-all.sno
152 lines (111 loc) · 3.5 KB
/
syslog-all.sno
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
* Usage:
* syslog-call.sno <infile> <upfile> <speedfile>
* infile - raw syslog ADSL and PPPoE lines
* upfile - graph data for DSL and PPPoE uptime
* speedfile - graph data for up/down speed, SNR and attenuation
argv = ARRAY('0:9')
i = 0
first_arg = HOST(3)
argv[i] = HOST(2, first_arg - 1)
get_args
arg = HOST(2, first_arg + i) :F(args_done)
i = i + 1
argv[i] = arg :(get_args)
args_done
argc = i + 1
* Get the argument
EQ(argc,4) :S(args_ok)
TERMINAL = 'Usage: syslog-call.sno <infile> <upfile> '
+ '<speedfile>' :(END)
args_ok
INPUT('rawdat',9,'',argv[1])
OUTPUT('updownout',10,'',argv[2])
OUTPUT('speedout',11,'',argv[3])
* Process the data
*
* DSL failure is reported with 'Modem Shut Down from ADSL Phy Layer'
* DSL restart is reported with 'States=SHOWTIME'
* All failures lead to 'WAN 1 is down'
* All recoveries lead to 'WAN 1 is up'
*
* All lines begin with a date and time stamp of the form:
* MMM DD HH:MM:SS
date_pat = POS(0) LEN(3) . mon ' ' LEN(2) . day ' '
+ LEN(2) . hour ':' LEN(2) . min ':'
+ LEN(2) . sec
* patern to match SHOWTIME data (values may be negative)
digits = '-0123456789'
show_pat = 'UpSpeed='
+ SPAN(digits) . speed_up BREAK(digits)
+ SPAN(digits) . speed_down BREAK(digits)
+ SPAN(digits) . snr BREAK(digits)
+ SPAN(digits) . atten
* Values for DSL and PPPoE up
d_up = 4
d_do = 1
p_up = 9
p_do = 6
dsl_state = d_up
ppp_state = p_up
* Count of failures
dsl_down_cnt = 0
ppp_down_cnt = 0
next_line
prev_line = line
line = rawdat :F(data_done)
line 'Modem Shut Down from ADSL Phy Layer' :S(dsl_down)
line 'States=SHOWTIME' :S(dsl_up)
line 'WAN 1 is down' :S(ppp_down)
line 'WAN 1 is up' :S(ppp_up)
:(next_line)
* DSL failure
dsl_down
new_dsl_state = NE(dsl_state,d_do) d_do :F(next_line)
new_ppp_state = ppp_state
dsl_down_cnt = dsl_down_cnt + 1 :(dat_out)
dsl_up
new_dsl_state = NE(dsl_state,d_up) d_up :F(show_only)
new_ppp_state = ppp_state :(dat_out)
ppp_down
new_ppp_state = NE(ppp_state,p_do) p_do :F(next_line)
new_dsl_state = dsl_state
ppp_down_cnt = ppp_down_cnt + 1 :(dat_out)
ppp_up
new_ppp_state = NE(ppp_state,p_up) p_up :F(next_line)
new_dsl_state = dsl_state :(dat_out)
* Output some data. If we get here, something has changed. We reject
* January dates.
dat_out
line date_pat
IDENT(mon,'Jan') :S(next_line)
day ' ' = '0'
date = '2017-' mon '-' day '/' hour ':' min ':' sec
* Up-time/down-time data
updownout = date CHAR(9) dsl_state CHAR(9) ppp_state
updownout = date CHAR(9) new_dsl_state CHAR(9) new_ppp_state
* Update the states
dsl_state = new_dsl_state
ppp_state = new_ppp_state
* Optionally SHOWTIME data
show_out
line show_pat :F(next_line)
speedout = date CHAR(9) speed_up CHAR(9) speed_down
+ CHAR(9) snr CHAR(9) atten :(next_line)
* Not exactly tidy, but for the case where we have a SHOWTIME line, bt
* other data has not changed, we need to generate the date and then just
* put out the speed data.
show_only
line date_pat
IDENT(mon,'Jan') :S(next_line)
day ' ' = '0'
date = '2017-' mon '-' day '/' hour ':' min ':' sec :(show_out)
* All done. We can put out one final line for the up time/down time
* graph and note the total number of failures.
data_done
prev_line date_pat
day ' ' = '0'
date = '2017-' mon '-' day '/' hour ':' min ':' sec
updownout = date CHAR(9) dsl_state CHAR(9) ppp_state
OUTPUT = 'Total DSL failures: ' dsl_down_cnt
OUTPUT = 'Total PPPoE failures: ' ppp_down_cnt
END