1 Star 0 Fork 36

刘宗禹/pcp

forked from src-openEuler/pcp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0000-Fix-some-options-and-syntax-errors.patch 9.53 KB
一键复制 编辑 原始数据 按行查看 历史
jpzhang187 提交于 2020-09-16 10:36 . Fix some options and syntax errors
diff --git a/src/pcp/collectl/pcp-collectl.py b/src/pcp/collectl/pcp-collectl.py
index 3cff1f9..58b8c64 100755
--- a/src/pcp/collectl/pcp-collectl.py
+++ b/src/pcp/collectl/pcp-collectl.py
@@ -841,7 +841,7 @@ class _Options(object):
opts = pmapi.pmOptions()
opts.pmSetOptionCallback(self.option_callback)
opts.pmSetOverrideCallback(self.override)
- opts.pmSetShortOptions("vp:a:c:f:R:i:s:h:?")
+ opts.pmSetShortOptions("Vvp:a:c:f:R:i:s:h:?")
opts.pmSetLongOptionText("")
opts.pmSetLongOptionText("Interactive: pcp collectl [-h HOST] [options]")
opts.pmSetLongOptionText("Read PCP archive: pcp collectl -a ARCHIVE [options]")
diff --git a/src/pcp/dmcache/pcp-dmcache.py b/src/pcp/dmcache/pcp-dmcache.py
index cd88ed4..29eb0ec 100755
--- a/src/pcp/dmcache/pcp-dmcache.py
+++ b/src/pcp/dmcache/pcp-dmcache.py
@@ -155,7 +155,7 @@ class DmCachePrinter(pmcc.MetricGroupPrinter):
if __name__ == '__main__':
try:
- options = pmapi.pmOptions('iR:?')
+ options = pmapi.pmOptions('ViR:?')
options.pmSetShortUsage('[options] [device ...]')
options.pmSetOptionCallback(option)
options.pmSetLongOptionHeader('Options')
diff --git a/src/pcp/dstat/pcp-dstat.py b/src/pcp/dstat/pcp-dstat.py
index c178874..cdd7991 100755
--- a/src/pcp/dstat/pcp-dstat.py
+++ b/src/pcp/dstat/pcp-dstat.py
@@ -727,7 +727,7 @@ class DstatTool(object):
# opts.pmSetLongOption('zones', 0, None, '', 'enable zoneinfo stats')
opts.pmSetLongOptionText('')
opts.pmSetLongOption('list', 0, None, '', 'list all available plugins')
- opts.pmSetLongOption('plugin', 0, None, '', 'enable external plugin by name, see --list')
+ opts.pmSetLongOption('<plugin-name>', 0, None, '', 'enable external plugin by name, see --list')
opts.pmSetLongOptionText('')
opts.pmSetLongOption('all', 0, 'a', '', 'equals -cdngy (default)')
opts.pmSetLongOption('full', 0, 'f', '', 'automatically expand -C, -D, -I, -N and -S lists')
@@ -785,7 +785,7 @@ class DstatTool(object):
self.disklist = sorted([x for x in insts if x != 'total'])
if 'total' in insts:
self.disklist.append('total')
- elif opt in ['--filesystem']:
+ elif opt in ['filesystem']:
self.plugins.append('fs')
elif opt in ['g']:
self.plugins.append('page')
diff --git a/src/pcp/iostat/pcp-iostat.py b/src/pcp/iostat/pcp-iostat.py
index bc716c2..b3a810c 100755
--- a/src/pcp/iostat/pcp-iostat.py
+++ b/src/pcp/iostat/pcp-iostat.py
@@ -165,11 +165,11 @@ class IostatReport(pmcc.MetricGroupPrinter):
if "t" in IostatOptions.xflag:
heading = ('# Timestamp', 'Device',rrqmspace, 'rrqm/s',wrqmspace, 'wrqm/s',precision+5, 'r/s',precision+4,\
'w/s',precision+6, 'rkB/s',precision+6, 'wkB/s', avgrqszspace,'avgrq-sz',precision+6, 'avgqu-sz',precision+5, \
- 'await',precision+5, 'r_await', precision+5,'w_await',utilspace, '%util')
+ 'await_t',precision+5, 'r_await', precision+5,'w_await',utilspace, '%util')
else:
heading = ('# Device',rrqmspace, 'rrqm/s',wrqmspace, 'wrqm/s',precision+5, 'r/s',precision+4, 'w/s'\
,precision+6, 'rkB/s',precision+6, 'wkB/s', avgrqszspace,'avgrq-sz',precision+6, 'avgqu-sz',precision+5,\
- 'await',awaitspace, 'r_await',awaitspace, 'w_await',utilspace, '%util')
+ 'await_t',awaitspace, 'r_await',awaitspace, 'w_await',utilspace, '%util')
print(headfmt % heading)
if p_rrqm == {} or p_wrqm == {} or p_r == {} or p_w == {} or \
@@ -205,7 +205,7 @@ class IostatReport(pmcc.MetricGroupPrinter):
# total active time in seconds (same units as dt)
tot_active = (float)(c_avactive[inst] - p_avactive[inst]) / 1000.0
- avgrqsz = avgqsz = await = r_await = w_await = util = 0.0
+ avgrqsz = avgqsz = await_t = r_await = w_await = util = 0.0
# average request size units are KB (sysstat reports in units of sectors)
if tot_ios:
@@ -214,9 +214,9 @@ class IostatReport(pmcc.MetricGroupPrinter):
# average queue length
avgqsz = (float)((c_ractive[inst] - p_ractive[inst]) + (c_wactive[inst] - p_wactive[inst])) / dt / 1000.0
- # await, r_await, w_await
+ # await_t, r_await, w_await
if tot_ios:
- await = ((c_ractive[inst] - p_ractive[inst]) + (c_wactive[inst] - p_wactive[inst])) / tot_ios
+ await_t = ((c_ractive[inst] - p_ractive[inst]) + (c_wactive[inst] - p_wactive[inst])) / tot_ios
if tot_rios:
r_await = (c_ractive[inst] - p_ractive[inst]) / tot_rios
@@ -229,7 +229,7 @@ class IostatReport(pmcc.MetricGroupPrinter):
util = 100.0 * tot_active / dt
device = inst # prepare name for printing
- badcounters = rrqm < 0 or wrqm < 0 or r < 0 or w < 0 or await < 0 or avgrqsz < 0 or avgqsz < 0 or util < 0
+ badcounters = rrqm < 0 or wrqm < 0 or r < 0 or w < 0 or await_t < 0 or avgrqsz < 0 or avgqsz < 0 or util < 0
if "t" in IostatOptions.xflag:
if badcounters:
@@ -250,7 +250,7 @@ class IostatReport(pmcc.MetricGroupPrinter):
if not IostatOptions.Gflag:
print(valfmt % (timestamp, device,rrqmspace, precision, rrqm,wrqmspace,precision, wrqm,precision+5,precision,\
r,precision+4,precision, w,precision+6,precision, rkb,precision+6,precision, wkb, avgrqszspace,precision+1 ,avgrqsz,\
- avgrqszspace,precision+1, avgqsz,precision+5,precision, await,awaitspace,precision, r_await,awaitspace,precision,\
+ avgrqszspace,precision+1, avgqsz,precision+5,precision, await_t,awaitspace,precision, r_await,awaitspace,precision,\
w_await,utilspace,precision, util))
else:
if badcounters:
@@ -270,7 +270,7 @@ class IostatReport(pmcc.MetricGroupPrinter):
if not IostatOptions.Gflag:
print(valfmt % (device,rrqmspace, precision, rrqm,wrqmspace,precision, wrqm,precision+5,precision, r,precision+4,\
precision, w,precision+6,precision, rkb,precision+6,precision, wkb,\
- avgrqszspace,precision+1 ,avgrqsz,avgrqszspace,precision+1, avgqsz,precision+5,precision, await,awaitspace,precision,\
+ avgrqszspace,precision+1 ,avgrqsz,avgrqszspace,precision+1, avgqsz,precision+5,precision, await_t,awaitspace,precision,\
r_await,awaitspace,precision, w_await,utilspace,precision, util))
if IostatOptions.Gflag and not badcounters:
@@ -282,7 +282,7 @@ class IostatReport(pmcc.MetricGroupPrinter):
aggr_wkb = aggregate(aggr, aggr_wkb, wkb)
aggr_avgrqsz = aggregate(aggr, aggr_avgrqsz, avgrqsz)
aggr_avgqsz = aggregate(aggr, aggr_avgqsz, avgqsz)
- aggr_await = aggregate(aggr, aggr_await, await)
+ aggr_await = aggregate(aggr, aggr_await, await_t)
aggr_r_await = aggregate(aggr, aggr_r_await, r_await)
aggr_w_await = aggregate(aggr, aggr_w_await, w_await)
aggr_util = aggregate(aggr, aggr_util, util)
diff --git a/src/pmlogconf/pmlogconf.sh b/src/pmlogconf/pmlogconf.sh
index 44f5099..af2bf37 100755
--- a/src/pmlogconf/pmlogconf.sh
+++ b/src/pmlogconf/pmlogconf.sh
@@ -161,7 +161,7 @@ _split()
$PCP_AWK_PROG <$tmp/ctl '
BEGIN { out = "'"$tmp/head"'" }
/DO NOT UPDATE THE FILE ABOVE/ { seen = 1 }
-seen == 0 && /^\#\? [^:]*:[ynx]:/ { print >"'"$tmp/tag"'"
+seen == 0 && /^#\? [^:]*:[ynx]:/ { print >"'"$tmp/tag"'"
out = "'"$tmp/tail"'"
seen = 1
next
@@ -180,8 +180,8 @@ _update()
$PCP_AWK_PROG <$tmp/in >$tmp/ctl '
/DO NOT UPDATE THE FILE ABOVE/ { tail = 1 }
tail == 1 { print; next }
-/^\#\+ [^:]*:[ynx]:/ { sub(/\+/, "?", $1); print; skip = 1; next }
-skip == 1 && /^\#----/ { skip = 0; next }
+/^#\+ [^:]*:[ynx]:/ { sub(/\+/, "?", $1); print; skip = 1; next }
+skip == 1 && /^#----/ { skip = 0; next }
skip == 1 { next }
{ print }'
diff --git a/src/pmprobe/pmprobe.c b/src/pmprobe/pmprobe.c
index dcf1567..d6d7ab5 100644
--- a/src/pmprobe/pmprobe.c
+++ b/src/pmprobe/pmprobe.c
@@ -63,7 +63,7 @@ overrides(int opt, pmOptions *opts)
static pmOptions opts = {
.flags = PM_OPTFLAG_STDOUT_TZ,
- .short_options = "a:b:D:efh:IiK:Ln:FO:VvZ:z?",
+ .short_options = "a:b:D:defh:IiK:Ln:FO:VvZ:z?",
.long_options = longopts,
.short_usage = "[options] [metricname ...]",
.override = overrides,
diff --git a/src/pmstat/pmstat.c b/src/pmstat/pmstat.c
index c4f9881..b3986d7 100644
--- a/src/pmstat/pmstat.c
+++ b/src/pmstat/pmstat.c
@@ -371,6 +371,10 @@ main(int argc, char *argv[])
case 'x': /* extended CPU reporting */
extraCpuStats = 1;
break;
+ case 'V':
+ pmprintf("%s version %s\n", pmGetProgname(), PCP_VERSION);
+ opts.flags |= PM_OPTFLAG_EXIT;
+ break;
default:
opts.errors++;
break;
@@ -387,7 +391,7 @@ main(int argc, char *argv[])
opts.errors++;
}
- if (opts.errors) {
+ if (opts.errors || (opts.flags & PM_OPTFLAG_EXIT)) {
pmUsageMessage(&opts);
exit(1);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lzy_387655/pcp.git
[email protected]:lzy_387655/pcp.git
lzy_387655
pcp
pcp
master

搜索帮助