-
Notifications
You must be signed in to change notification settings - Fork 0
/
forti-mem-mon.expect
158 lines (149 loc) · 2.84 KB
/
forti-mem-mon.expect
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
#!/usr/bin/expect
#
set prompt "#"
set buffersize 2097152
set counter 1
# spawn SSH connection
while 1 {
set timestamp [timestamp -format %c]
puts "$timestamp - Loop run $counter"
spawn ssh admin@fortigate
#
# Mem & CPU check
#
expect $prompt
# Changing the output to standard to avoid pressing space to view more
send "config system console\n"
expect $prompt
sleep 1
send "set output standard\n"
expect $prompt
sleep 1
send "end\n"
expect $prompt
sleep 1
# Single output commands
send "diag autoupdate versions\n"
expect $prompt
sleep 1
send "diag debug crashlog read\n"
expect $prompt
sleep 10
send "diagnose sys flash list\n"
expect $prompt
sleep 1
# Commands that will loop until the script is disabled
# infinite loop
#while 1 {
# memory & CPU
send "get sys status\n"
expect $prompt
sleep 1
send "get sys perf status\n"
expect $prompt
sleep 1
send "get sys ha stat\n"
expect $prompt
sleep 1
send "get sys performance firewall statistics\n"
expect $prompt
sleep 1
send "get system session status\n"
expect $prompt
sleep 1
send "get system arp\n"
expect $prompt
sleep 1
send "get router info routing-table all\n"
expect $prompt
sleep 1
send "get router info kernel\n"
expect $prompt
sleep 1
send "fnsysctl cat /proc/stat\n"
expect $prompt
sleep 1
send "fnsysctl cat /proc/interrupts\n"
expect $prompt
sleep 1
send "fnsysctl cat /proc/softirq\n"
expect $prompt
sleep 1
send "fnsysctl cat /proc/net/snmp\n"
expect $prompt
sleep 1
send "fnsysctl df -h\n"
expect $prompt
sleep 1
# Diagnose commands
send "diagnose hardware sysinfo memory\n"
expect $prompt
sleep 1
send "diagnose hardware sysinfo slab\n"
expect $prompt
sleep 1
send "diagnose hardware sysinfo shm\n"
expect $prompt
sleep 1
send "diagnose hardware deviceinfo disk\n"
expect $prompt
sleep 1
send "diagnose hardware sysinfo conserve\n"
expect $prompt
sleep 1
send "diagnose snmp ip frags\n"
expect $prompt
sleep 1
send "diagnose sys cmdb info\n"
sleep 1
send "diagnose sys vd list\n"
sleep 1
send "diagnose firewall iprope state\n"
expect $prompt
sleep 1
send "diagnose sys session full-stat\n"
expect $prompt
sleep 1
send "diagnose sys session stat\n"
expect $prompt
sleep 1
send "diagnose ip arp list\n"
expect $prompt
sleep 1
send "diagnose ip address list\n"
expect $prompt
sleep 1
send "diagnose ip route list\n"
expect $prompt
sleep 1
send "diagnose sys top-fd\n"
expect $prompt
close
sleep 1
spawn ssh admin@fortigate
expect $prompt
send "diagnose sys mpstat 1 5\n"
expect $prompt
close
sleep 1
spawn ssh admin@fortigate
expect $prompt
send "diagnose sys top 1 20 3\n"
expect $prompt
close
sleep 1
spawn ssh admin@fortigate
expect $prompt
send "diagnose sys top-mem\n"
expect $prompt
sleep 1
close
puts \n########################
incr counter
# Following sleep waits 300 seconds before starting the loop again
sleep 300
#}
#expect -re {closed|error|disconnect}
#send_user "Connection lost. Trying a new one..."
#sleep 5
}