-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.py
More file actions
64 lines (53 loc) · 2.08 KB
/
Copy pathrunner.py
File metadata and controls
64 lines (53 loc) · 2.08 KB
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
#!/usr/bin/env python3
#
# FILE: runner.py
#
#
# DESCRIPTION: Manage rules
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# AUTHOR: Twinkll Sisodia
# COMPANY: Red Hat
# VERSION: 1.0
# CREATED: 08/21/2020
# ===============================================================================
import argparse
import os
import subprocess
import sys
parser = argparse.ArgumentParser(description='Manage rules')
parser.add_argument('-c', '--count',
metavar='count', action='count',
required=True, add_help=True)
parser.add_argument('-fc', '--failed-count',
action='store',
required=True)
args = parser.parse_args()
#add rules ---- check if count is valid
if (args.count>1):
print("Count -",sys.argv)
# --- execute ping command with -c
exitCode = os.system(f'ping -c {args.count} google.com')
if exitCode == 0:
print("Success")
# --- Success tracing
print("Tracing Successful execution --------------------------------------------------------\n")
pingParsing = os.system(f'pingparsing google.com -c {args.count}')
debug = os.system(f'ping -c {args.count} -d google.com ')
print(pingParsing)
print(debug)
else:
# --- while failed count is less than 2, it will execute till condition become false
while args.failed >= 2:
exitCode = os.system(f'ping -c {args.count} google.com')
# --- Failed execution tracing
print("ExitCode ----- \n",exitCode)
print("Tracing memory usage of failed execution -----------------------------------------------------------\n")
# --- using strace for system tracing
sysTrace = os.system(f'strace ping -c {args.count} google.com')
print("Tracing Failed execution -----------------------------------------------------------\n")
pingParsing = os.system(f'pingparsing google.com -c {args.count}')
print(sysTrace)
print(pingParsing)