-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsc.py
executable file
·103 lines (86 loc) · 3.3 KB
/
sc.py
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
#! /usr/bin/python3
# SC Python Script
# Use to help anaylize supportconfig files
import sys
import argparse
import re
parser = argparse.ArgumentParser('sc.py')
parser.add_argument('-v', action='store_true', help='print verbose output')
parser.add_argument('-p', action='store_true', help='print information about service performance (i.e. # of cpus, sar data, etc)')
args = parser.parse_args()
#Boot History
text2find = "syslog-ng starting up |origin\ software=\"rsyslogd\""
file2open = "messages.txt"
try:
for line in open(file2open, 'r'):
if re.search(text2find, line):
print('\u001b[1mBoot History: \u001b[0m' + line.rstrip())
except IOError:
print('\u001b[1mMemory: \u001b[0m Error reading ' + file2open)
#OOM-KILLER
text2find ="invoked oom-killer"
file2open = "messages.txt"
file2open2 = "boot.txt"
try:
for line in open(file2open, 'r'):
if re.search(text2find, line):
print('\u001b[1mOut Of Memory Errors: \u001b[0m' + line.rstrip())
for line in open(file2open2, 'r'):
if re.search(text2find, line):
print('\u001b[1mOut Of Memory Errors: \u001b[0m')
continue
if re.search(text2find, line):
print(line.rstrip())
except IOError:
print('\u001b[1mMemory: \u001b[0m Error reading ' + file2open)
#Display OS
text2find = 'PRETTY_NAME'
try:
for line in open('basic-environment.txt', 'r'):
if re.search(text2find, line):
print('\u001b[1mOS Version: \u001b[0m' + re.findall(r'"(.*?)"', line)[0])
except IOError:
print('\u001b[1mOS Version: \u001b[0m Error reading basic-environment.txt')
#Display Kernel Version
try:
with open('basic-environment.txt', 'r') as searchfile:
for line in searchfile:
if 'GNU/Linux' in line:
print("\u001b[1mKernel Version: \u001b[0m" + line.split()[2])
except IOError:
print('\u001b[1mKernel Version: \u001b[0m Error reading basic-environment.txt')
try:
with open('basic-health-check.txt', 'r') as searchfile:
for line in searchfile:
if '/usr/bin/free' in line:
print("\u001b[1mMemory: \u001b[0m \n" + next(searchfile, '').strip() + "\n" + next(searchfile, '').strip() + "\n" + next(searchfile, '').strip() + "\n" + next(searchfile, '').strip())
except IOError:
print('\u001b[1mArchitecture: \u001b[0m Error reading basic-environment.txt')
#Display Architecture
text2find = 'Linux'
try:
for line in open('basic-environment.txt', 'r'):
if re.search(text2find, line):
print('\u001b[1mArchitecture: \u001b[0m' + str(line.split()[12]))
break
except IOError:
print('\u001b[1mMemory: \u001b[0m Error reading basic-environment.txt')
#Display Patch Status
text2find = 'patches needed'
try:
for line in open('updates.txt', 'r'):
if re.search(text2find, line):
print('\u001b[1mPatches Needed: \u001b[0m' + line.rstrip())
break
except IOError:
print('\u001b[1mMemory: \u001b[0m Error reading messages.txt')
#Display Core Dumps
text2find = 'vmcore'
file2open = 'crash.txt'
try:
for line in open(file2open, 'r'):
if re.search(text2find, line):
print('\u001b[1mKernel Core Dumps: \u001b[0m' + line.rstrip())
break
except IOError:
print('\u001b[1mMemory: \u001b[0m Error reading ' + file2open)