117
114
OPENVSWITCH_DEFAULT_CONTROLLER = '/etc/default/openvswitch-controller'
118
115
OPENVSWITCH_CONF_DB = '@DBDIR@/conf.db'
119
116
OPENVSWITCH_VSWITCHD_PID = '@RUNDIR@/ovs-vswitchd.pid'
120
COLLECTD_LOGS_DIR = '/var/lib/collectd/rrd'
121
117
VAR_LOG_DIR = '/var/log/'
122
118
VAR_LOG_CORE_DIR = '/var/log/core'
123
X11_LOGS_DIR = VAR_LOG_DIR
124
X11_LOGS_RE = re.compile(r'.*/Xorg\..*$')
125
X11_AUTH_DIR = '/root/'
126
X11_AUTH_RE = re.compile(r'.*/\.((Xauthority)|(serverauth\.[0-9]*))$')
127
119
YUM_LOG = '/var/log/yum.log'
128
120
YUM_REPOS_DIR = '/etc/yum.repos.d'
129
PAM_DIR = '/etc/pam.d'
130
KRB5_CONF = '/etc/krb5.conf'
133
123
# External programs
214
198
CAP_XML_ELEMENT = 'capability'
218
201
CAP_BOOT_LOADER = 'boot-loader'
219
CAP_COLLECTD_LOGS = 'collectd-logs'
220
202
CAP_DISK_INFO = 'disk-info'
221
CAP_FIRSTBOOT = 'firstboot'
222
203
CAP_HARDWARE_INFO = 'hardware-info'
223
CAP_HDPARM_T = 'hdparm-t'
224
CAP_HIGH_AVAILABILITY = 'high-availability'
225
204
CAP_KERNEL_INFO = 'kernel-info'
226
205
CAP_LOSETUP_A = 'loopback-devices'
227
206
CAP_MULTIPATH = 'multipath'
228
207
CAP_NETWORK_CONFIG = 'network-config'
229
208
CAP_NETWORK_STATUS = 'network-status'
209
CAP_OPENVSWITCH_LOGS = 'ovs-system-logs'
232
210
CAP_PROCESS_LIST = 'process-list'
233
CAP_PERSISTENT_STATS = 'persistent-stats'
234
211
CAP_SYSTEM_LOGS = 'system-logs'
235
212
CAP_SYSTEM_SERVICES = 'system-services'
236
CAP_VNCTERM = 'vncterm'
239
CAP_X11_AUTH = 'X11-auth'
254
229
cap_sizes[key] = 0
257
cap(CAP_BLOBS, PII_NO, max_size=5*MB)
258
232
cap(CAP_BOOT_LOADER, PII_NO, max_size=3*KB,
260
cap(CAP_COLLECTD_LOGS, PII_MAYBE, max_size=50*MB,
262
234
cap(CAP_DISK_INFO, PII_MAYBE, max_size=50*KB,
264
cap(CAP_FIRSTBOOT, PII_YES, min_size=60*KB, max_size=80*KB)
265
236
cap(CAP_HARDWARE_INFO, PII_MAYBE, max_size=30*KB,
267
cap(CAP_HDPARM_T, PII_NO, min_size=0, max_size=5*KB,
268
min_time=20, max_time=90, checked=False, hidden=True)
269
cap(CAP_HIGH_AVAILABILITY, PII_MAYBE, max_size=5*MB)
270
238
cap(CAP_KERNEL_INFO, PII_MAYBE, max_size=120*KB,
272
240
cap(CAP_LOSETUP_A, PII_MAYBE, max_size=KB, max_time=5)
275
243
cap(CAP_NETWORK_CONFIG, PII_IF_CUSTOMIZED,
276
244
min_size=0, max_size=40*KB)
277
cap(CAP_NETWORK_STATUS, PII_YES, max_size=50*KB,
245
cap(CAP_NETWORK_STATUS, PII_YES, max_size=50*MB,
279
cap(CAP_PAM, PII_NO, max_size=50*KB)
280
cap(CAP_PERSISTENT_STATS, PII_MAYBE, max_size=50*MB,
247
cap(CAP_OPENVSWITCH_LOGS, PII_MAYBE, max_size=-1,
282
249
cap(CAP_PROCESS_LIST, PII_YES, max_size=30*KB,
284
cap(CAP_SYSTEM_LOGS, PII_MAYBE, max_size=50*MB,
251
cap(CAP_SYSTEM_LOGS, PII_MAYBE, max_size=200*MB,
286
253
cap(CAP_SYSTEM_SERVICES, PII_NO, max_size=5*KB,
288
cap(CAP_VNCTERM, PII_MAYBE, checked = False)
289
cap(CAP_WLB, PII_NO, max_size=3*MB,
291
cap(CAP_X11_LOGS, PII_NO, max_size=100*KB)
292
cap(CAP_X11_AUTH, PII_NO, max_size=100*KB)
293
255
cap(CAP_YUM, PII_IF_CUSTOMIZED, max_size=10*KB,
361
323
t = str(func).split()
362
324
data[label] = {'cap': cap, 'func': func}
326
def log_output(cap, logs, newest_first=False):
328
file_output(cap, logs)
330
['%s.%d' % (f, n) for n in range(1, log_days+1) for f in logs], \
331
newest_first=newest_first)
333
['%s.%d.gz' % (f, n) for n in range(1, log_days+1) for f in logs], \
334
newest_first=newest_first)
364
336
def collect_data():
365
337
process_lists = {}
426
398
(options, params) = getopt.gnu_getopt(
427
399
argv, 'sy', ['capabilities', 'silent', 'yestoall', 'entries=',
428
400
'output=', 'outfd=', 'outfile=', 'all', 'unlimited',
401
'debug', 'ovs', 'log-days='])
430
402
except getopt.GetoptError, opterr:
431
403
print >>sys.stderr, opterr
523
498
cmd_output(CAP_BOOT_LOADER, [LS, '-lR', '/boot'])
524
499
cmd_output(CAP_BOOT_LOADER, [MD5SUM, BOOT_KERNEL, BOOT_INITRD], label='vmlinuz-initrd.md5sum')
526
tree_output(CAP_COLLECTD_LOGS, COLLECTD_LOGS_DIR)
527
501
cmd_output(CAP_DISK_INFO, [FDISK, '-l'])
528
502
file_output(CAP_DISK_INFO, [PROC_PARTITIONS, PROC_MOUNTS])
529
503
file_output(CAP_DISK_INFO, [FSTAB, ISCSI_CONF, ISCSI_INITIATOR])
530
504
cmd_output(CAP_DISK_INFO, [DF, '-alT'])
531
505
cmd_output(CAP_DISK_INFO, [DF, '-alTi'])
532
for d in disk_list():
533
cmd_output(CAP_DISK_INFO, [HDPARM, '-I', '/dev/%s' % d])
534
506
if len(pidof('iscsid')) != 0:
535
507
cmd_output(CAP_DISK_INFO, [ISCSIADM, '-m', 'node'])
536
cmd_output(CAP_DISK_INFO, [VGSCAN])
537
cmd_output(CAP_DISK_INFO, [PVS])
538
cmd_output(CAP_DISK_INFO, [VGS])
539
cmd_output(CAP_DISK_INFO, [LVS])
540
file_output(CAP_DISK_INFO, [LVM_CACHE, LVM_CONFIG])
541
508
cmd_output(CAP_DISK_INFO, [LS, '-R', '/sys/class/scsi_host'])
542
509
cmd_output(CAP_DISK_INFO, [LS, '-R', '/sys/class/scsi_disk'])
543
510
cmd_output(CAP_DISK_INFO, [LS, '-R', '/sys/class/fc_transport'])
544
511
cmd_output(CAP_DISK_INFO, [SG_MAP, '-x'])
545
512
func_output(CAP_DISK_INFO, 'scsi-hosts', dump_scsi_hosts)
546
cmd_output(CAP_DISK_INFO, [LVDISPLAY, '--map'])
548
514
file_output(CAP_HARDWARE_INFO, [PROC_CPUINFO, PROC_MEMINFO, PROC_IOPORTS, PROC_INTERRUPTS])
549
515
cmd_output(CAP_HARDWARE_INFO, [DMIDECODE])
552
518
file_output(CAP_HARDWARE_INFO, [PROC_USB_DEV, PROC_SCSI])
553
519
file_output(CAP_HARDWARE_INFO, [SYSCONFIG_HWCONF])
554
520
cmd_output(CAP_HARDWARE_INFO, [LS, '-lR', '/dev'])
557
for d in disk_list():
558
cmd_output(CAP_HDPARM_T, [HDPARM, '-tT', '/dev/%s' % d])
560
523
file_output(CAP_KERNEL_INFO, [PROC_VERSION, PROC_MODULES, PROC_DEVICES,
561
524
PROC_FILESYSTEMS, PROC_CMDLINE])
596
559
if os.path.islink('/sys/class/net/%s/device' % p) and int(t) == 1:
598
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, p])
599
561
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, '-S', p])
600
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, '-k', p])
601
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, '-i', p])
602
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, '-c', p])
562
if not p.startswith('vif') and not p.startswith('tap'):
563
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, p])
564
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, '-k', p])
565
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, '-i', p])
566
cmd_output(CAP_NETWORK_STATUS, [ETHTOOL, '-c', p])
604
568
cmd_output(CAP_NETWORK_STATUS,
605
569
[TC, '-s', '-d', 'class', 'show', 'dev', p])
627
tree_output(CAP_PAM, PAM_DIR)
628
file_output(CAP_PAM, [KRB5_CONF])
630
591
cmd_output(CAP_PROCESS_LIST, [PS, 'wwwaxf', '-eo', 'pid,tty,stat,time,nice,psr,pcpu,pmem,nwchan,wchan:25,args'], label='process-tree')
631
592
func_output(CAP_PROCESS_LIST, 'fd_usage', fd_usage)
633
logs = ([ VAR_LOG_DIR + x for x in
634
[ 'crit.log', 'kern.log', 'daemon.log', 'user.log',
635
'syslog', 'messages', 'secure', 'debug', 'dmesg', 'boot' ]]
636
+ [ OPENVSWITCH_LOG_DIR + x for x in
637
[ 'ovs-vswitchd.log', 'ovsdb-server.log',
638
'ovs-xapi-sync.log', 'ovs-monitor-ipsec.log', 'ovs-ctl.log' ]])
639
file_output(CAP_SYSTEM_LOGS, logs)
640
file_output(CAP_SYSTEM_LOGS,
641
[ '%s.%d' % (f, n) for n in range(20) for f in logs ])
642
file_output(CAP_SYSTEM_LOGS,
643
[ '%s.%d.gz' % (f, n) for n in range(20) for f in logs ])
594
system_logs = ([ VAR_LOG_DIR + x for x in
595
['crit.log', 'kern.log', 'daemon.log', 'user.log',
596
'syslog', 'messages', 'secure', 'debug', 'dmesg', 'boot']])
597
ovs_logs = ([ OPENVSWITCH_LOG_DIR + x for x in
598
['ovs-vswitchd.log', 'ovsdb-server.log',
599
'ovs-xapi-sync.log', 'ovs-monitor-ipsec.log', 'ovs-ctl.log']])
600
log_output(CAP_SYSTEM_LOGS, system_logs)
601
log_output(CAP_OPENVSWITCH_LOGS, ovs_logs)
645
603
if not os.path.exists('/var/log/dmesg') and not os.path.exists('/var/log/boot'):
646
604
cmd_output(CAP_SYSTEM_LOGS, [DMESG])
648
606
cmd_output(CAP_SYSTEM_SERVICES, [CHKCONFIG, '--list'])
650
tree_output(CAP_X11_LOGS, X11_LOGS_DIR, X11_LOGS_RE)
651
tree_output(CAP_X11_AUTH, X11_AUTH_DIR, X11_AUTH_RE)
652
608
tree_output(CAP_SYSTEM_LOGS, VAR_LOG_CORE_DIR)
654
610
file_output(CAP_YUM, [YUM_LOG])
738
def find_tapdisk_logs():
739
return glob.glob('/var/log/blktap/*.log*')
741
def generate_tapdisk_logs():
742
for pid in pidof('tapdisk'):
744
os.kill(pid, SIGUSR1)
745
output_ts("Including logs for tapdisk process %d" % pid)
748
# give processes a second to write their logs
751
def clean_tapdisk_logs():
752
for filename in find_tapdisk_logs():
758
def filter_db_pii(str, state):
759
if 'in_secret_table' not in state:
760
state['in_secret_table'] = False
762
if str.startswith('<table ') and 'name="secret"' in str:
763
state['in_secret_table'] = True
764
elif str.startswith('</table>'):
765
state['in_secret_table'] = False
767
if state['in_secret_table'] and str.startswith("<row"): # match only on DB rows
768
str = re.sub(r'(value=")[^"]+(")', r'\1REMOVED\2', str)
771
692
def dump_scsi_hosts(cap):
773
694
l = os.listdir('/sys/class/scsi_host')
935
856
if el.tagName == "files":
936
857
newest_first = getBoolAttr(el, 'newest_first')
937
file_output(dir, getText(el.childNodes).split(),
938
newest_first=newest_first)
858
if el.getAttribute("type") == "logs":
859
log_output(dir, getText(el.childNodes).split(),
860
newest_first=newest_first)
862
file_output(dir, getText(el.childNodes).split(),
863
newest_first=newest_first)
939
864
elif el.tagName == "directory":
940
865
pattern = el.getAttribute("pattern")
941
866
if pattern == '': pattern = None