This repository has been archived by the owner on Jun 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog2db.pl
129 lines (103 loc) · 4.74 KB
/
log2db.pl
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
#! /usr/bin/perl -w
#
# Author: Sravan Bhamidipati @bsravanin
# License: MIT License http://www.opensource.org/licenses/mit-license.php
# Courtesy: Symantec Corporation http://www.symantec.com
# Date: 29th November, 2011
# Purpose: Modify a known log type into a text database.
# DONE: esxtop iostat mpstat netstat pidstat prstat sar slabinfo top typeperf vmstat vrstat vxfsstatBCache vxfsstatICache vxfsstatFile vxmemstat vxrlink vxrlinkE vxrlinkStatus vxrvg vxstat
# TODO: sarasc
use strict;
use log2db;
use File::Basename;
use Switch;
if (scalar(@ARGV) != 3) {die "Usage: $0 <esxtop|iostat|mpstat|netstat|pidstat|prstat|sar|slabinfo|top|typeperf|vmstat|vrstat|vxfsstatBCache|vxfsstatFile|vxfsstatICache|vxmemstat|vxrlink|vxrlinkE|vxrlinkStatus|vxrvg|vxstat> <logPath> <dbPath>\n"}
my ($logType, $logPath, $tablePath) = ($ARGV[0], $ARGV[1], $ARGV[2]);
my $saveDir = dirname($tablePath);
switch ($logType) {
case 'esxtop' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyTypeperf($logPath, $tablePath);
}
case 'iostat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyIostat($logPath, $tablePath);
}
case 'mpstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifySolstat($logPath, $tablePath);
}
case 'netstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyNetstat($logPath, $tablePath);
}
case 'pidstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifySysstat($logPath, $tablePath);
}
case 'prstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifySolstat($logPath, $tablePath);
}
case 'sar' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifySysstat($logPath, $tablePath);
}
case 'slabinfo' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifySlabinfo($logPath, $tablePath);
}
case 'top' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyTop($logPath, $tablePath);
}
case 'typeperf' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyTypeperf($logPath, $tablePath);
}
case 'vmstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVmstat($logPath, $tablePath);
}
case 'vrstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVrstat($logPath, $tablePath);
}
case 'vxfsstatBCache' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVxfsstatBCache($logPath, $tablePath);
}
case 'vxfsstatFile' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVxfsstatAll($logPath, $tablePath);
}
case 'vxfsstatICache' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVxfsstatICache($logPath, $tablePath);
}
case 'vxmemstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVvrstat($logPath, $tablePath);
}
case 'vxrlink' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVvrstat($logPath, $tablePath);
}
case 'vxrlinkE' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVxrlinkE($logPath, $tablePath);
}
case 'vxrlinkStatus' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVxrlinkStatus($logPath, $tablePath);
}
case 'vxrvg' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVvrstat($logPath, $tablePath);
}
case 'vxstat' {
if (! -d $saveDir) {mkpath ($saveDir) || warn "Directory $saveDir already exists or can't be created: $!\n"}
&modifyVxstat($logPath, $tablePath);
}
else {die "Please verify the spelling of $logType.\nUsage: $0 <esxtop|iostat|mpstat|netstat|pidstat|prstat|sar|slabinfo|top|typeperf|vmstat|vrstat|vxfsstatBCache|vxfsstatFile|vxfsstatICache|vxmemstat|vxrlink|vxrlinkE|vxrlinkStatus|vxrvg|vxstat> <logPath> <dbPath>\n"}
}