Skip to content

Commit 574e6fc

Browse files
committed
pmdadm: small updates to dmcrypt metrics units, logic
On re-review of dmcrypt updates, noticed none of the units were reflecting recent changes (via test 657). The way PMDA_PMUNITS works is in order to set scale (eg PM_COUNT_ONE/PM_SPACE_BYTES), the dimention must also be set (most often to 1). A few places the metrics are clearly discrete (constant) values, so I updated these as well. Finally, noticed strtrim could be simplified further (the while loop does the job of the initial nul check) so changed that too.
1 parent 4cda202 commit 574e6fc

3 files changed

Lines changed: 47 additions & 44 deletions

File tree

qa/657.out

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,70 +241,70 @@ Whether the crypt device is active
241241

242242
dmcrypt.type PMID: 129.6.1 [Crypt device type]
243243
Data Type: string InDom: 129.6 0x20400006
244-
Semantics: instant Units: none
244+
Semantics: discrete Units: none
245245
Help:
246246
Crypt device type
247247
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value "LUKS2"
248248

249249
dmcrypt.cipher PMID: 129.6.2 [Cipher used for the crypt device]
250250
Data Type: string InDom: 129.6 0x20400006
251-
Semantics: instant Units: none
251+
Semantics: discrete Units: none
252252
Help:
253253
Cipher used for the crypt device
254254
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value "aes-xts-plain64"
255255

256256
dmcrypt.keysize PMID: 129.6.3 [Keysize for the crypt device]
257257
Data Type: 32-bit unsigned int InDom: 129.6 0x20400006
258-
Semantics: instant Units: none
258+
Semantics: discrete Units: none
259259
Help:
260260
Keysize for the crypt device
261261
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value 512
262262

263263
dmcrypt.key_location PMID: 129.6.4 [Decryption key location for the crypt device]
264264
Data Type: string InDom: 129.6 0x20400006
265-
Semantics: instant Units: none
265+
Semantics: discrete Units: none
266266
Help:
267267
Decryption key location for the crypt device
268268
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value "keyring"
269269

270270
dmcrypt.device PMID: 129.6.5 [The crypt device]
271271
Data Type: string InDom: 129.6 0x20400006
272-
Semantics: instant Units: none
272+
Semantics: discrete Units: none
273273
Help:
274274
The crypt device
275275
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value "/dev/nvme0n1p3"
276276

277277
dmcrypt.sector_size PMID: 129.6.6 [Sector size for the crypt device]
278278
Data Type: 32-bit unsigned int InDom: 129.6 0x20400006
279-
Semantics: instant Units: none
279+
Semantics: discrete Units: byte
280280
Help:
281281
Sector size for the crypt device
282282
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value 512
283283

284284
dmcrypt.offset PMID: 129.6.7 [Offset for the crypt device]
285285
Data Type: 64-bit unsigned int InDom: 129.6 0x20400006
286-
Semantics: instant Units: none
286+
Semantics: instant Units: Kbyte
287287
Help:
288288
Offset for the crypt device
289289
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value 32768
290290

291291
dmcrypt.offset_bytes PMID: 129.6.8 [Offset in bytes for the crypt device]
292292
Data Type: 64-bit unsigned int InDom: 129.6 0x20400006
293-
Semantics: instant Units: none
293+
Semantics: instant Units: byte
294294
Help:
295295
Offset in bytes for the crypt device
296296
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value 16777216
297297

298298
dmcrypt.size PMID: 129.6.9 [Crypt device size]
299299
Data Type: 64-bit unsigned int InDom: 129.6 0x20400006
300-
Semantics: instant Units: none
300+
Semantics: instant Units: Kbyte
301301
Help:
302302
Crypt device size
303303
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value 996853760
304304

305305
dmcrypt.size_bytes PMID: 129.6.10 [Crypt device size in bytes]
306306
Data Type: 64-bit unsigned int InDom: 129.6 0x20400006
307-
Semantics: instant Units: none
307+
Semantics: instant Units: byte
308308
Help:
309309
Crypt device size in bytes
310310
inst [0 or "luks-4456fe89-d09e-416f-8721-bedb66abda85"] value 510389125120

src/pmdas/dm/dmcrypt.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,11 @@ static char *dm_setup_cryptsetup;
3131
* trim this out from the output to make comparisons easier.
3232
*/
3333
char
34-
*strtrim(char* str) {
35-
// Check for empty String
36-
if(*str == 0) // All spaces
37-
return str;
38-
39-
// Trim leading space
40-
while(isspace((unsigned char)*str)) str++;
41-
34+
*strtrim(char* str)
35+
{
36+
/* trim leading space */
37+
while (isspace((unsigned char)*str))
38+
str++;
4239
return str;
4340
}
4441

@@ -48,7 +45,7 @@ dm_crypt_fetch(int item, struct crypt_stats *crypt_stats, pmAtomValue *atom)
4845
if (item < 0 || item >= NUM_CRYPT_STATS)
4946
return PM_ERR_PMID;
5047

51-
switch(item) {
48+
switch (item) {
5249
case CRYPT_ACTIVE:
5350
atom->ul = crypt_stats->active;
5451
break;
@@ -177,11 +174,14 @@ dm_refresh_crypt(const char *name, struct crypt_stats *crypt_stats)
177174
if (sts <= 0)
178175
return sts;
179176
if (sts == 2000)
180-
pmNotifyErr(LOG_ERR, "dm_refresh_crypt: pipe (%s %s) terminated with unknown error\n", dm_setup_cryptsetup, name);
177+
pmNotifyErr(LOG_ERR, "%s: pipe (%s %s) terminated with unknown error\n",
178+
__FUNCTION__, dm_setup_cryptsetup, name);
181179
else if (sts > 1000)
182-
pmNotifyErr(LOG_ERR, "dm_refresh_crypt: pipe (%s %s) terminated with signal %d\n", dm_setup_cryptsetup, name, sts - 1000);
180+
pmNotifyErr(LOG_ERR, "%s: pipe (%s %s) terminated with signal %d\n",
181+
__FUNCTION__, dm_setup_cryptsetup, name, sts - 1000);
183182
else
184-
pmNotifyErr(LOG_ERR, "dm_refresh_crypt: pipe (%s %s) terminated with exit status %d\n", dm_setup_cryptsetup, name, sts);
183+
pmNotifyErr(LOG_ERR, "%s: pipe (%s %s) terminated with exit status %d\n",
184+
__FUNCTION__, dm_setup_cryptsetup, name, sts);
185185

186186
return PM_ERR_GENERIC;
187187
}
@@ -242,11 +242,14 @@ dm_crypt_instance_refresh(void)
242242
if (sts <= 0)
243243
return sts;
244244
if (sts == 2000)
245-
pmNotifyErr(LOG_ERR, "dm_crypt_instance_refresh: pipe (%s) terminated with unknown error\n", dm_setup_dmsetup);
245+
pmNotifyErr(LOG_ERR, "%s: pipe (%s) terminated with unknown error\n",
246+
__FUNCTION__, dm_setup_dmsetup);
246247
else if (sts > 1000)
247-
pmNotifyErr(LOG_ERR, "dm_crypt_instance_refresh: pipe (%s) terminated with signal %d\n", dm_setup_dmsetup, sts - 1000);
248+
pmNotifyErr(LOG_ERR, "%s: pipe (%s) terminated with signal %d\n",
249+
__FUNCTION__, dm_setup_dmsetup, sts - 1000);
248250
else
249-
pmNotifyErr(LOG_ERR, "dm_crypt_instance_refresh: pipe (%s) terminated with exit status %d\n", dm_setup_dmsetup, sts);
251+
pmNotifyErr(LOG_ERR, "%s: pipe (%s) terminated with exit status %d\n",
252+
__FUNCTION__, dm_setup_dmsetup, sts);
250253

251254
return PM_ERR_GENERIC;
252255
}

src/pmdas/dm/pmda.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,55 +1043,55 @@ static pmdaMetric metrictable[] = {
10431043
{ .m_desc = {
10441044
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_ACTIVE),
10451045
PM_TYPE_U32, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1046-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1046+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10471047
{ .m_desc = {
10481048
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_TYPE),
1049-
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1050-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1049+
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_DISCRETE,
1050+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10511051
{ .m_desc = {
10521052
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_CIPHER),
1053-
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1054-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1053+
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_DISCRETE,
1054+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10551055
{ .m_desc = {
10561056
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_KEYSIZE),
1057-
PM_TYPE_U32, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1058-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1057+
PM_TYPE_U32, DM_CRYPT_INDOM, PM_SEM_DISCRETE,
1058+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10591059
{ .m_desc = {
10601060
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_KEY_LOCATION),
1061-
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1062-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1061+
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_DISCRETE,
1062+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10631063
{ .m_desc = {
10641064
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_DEVICE),
1065-
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1066-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1065+
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_DISCRETE,
1066+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10671067
{ .m_desc = {
10681068
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_SECTOR_SIZE),
1069-
PM_TYPE_U32, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1070-
PMDA_PMUNITS(0,0,0,PM_SPACE_BYTE,0,PM_COUNT_ONE) }, },
1069+
PM_TYPE_U32, DM_CRYPT_INDOM, PM_SEM_DISCRETE,
1070+
PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
10711071
{ .m_desc = {
10721072
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_OFFSET),
10731073
PM_TYPE_U64, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1074-
PMDA_PMUNITS(0,0,0,PM_SPACE_BYTE,0,PM_COUNT_ONE) }, },
1074+
PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, },
10751075
{ .m_desc = {
10761076
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_OFFSET_BYTES),
10771077
PM_TYPE_U64, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1078-
PMDA_PMUNITS(0,0,0,PM_SPACE_BYTE,0,PM_COUNT_ONE) }, },
1078+
PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
10791079
{ .m_desc = {
10801080
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_SIZE),
10811081
PM_TYPE_U64, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1082-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1082+
PMDA_PMUNITS(1,0,0,PM_SPACE_KBYTE,0,0) }, },
10831083
{ .m_desc = {
10841084
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_SIZE_BYTES),
10851085
PM_TYPE_U64, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1086-
PMDA_PMUNITS(0,0,0,PM_SPACE_BYTE,0,PM_COUNT_ONE) }, },
1086+
PMDA_PMUNITS(1,0,0,PM_SPACE_BYTE,0,0) }, },
10871087
{ .m_desc = {
10881088
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_MODE),
10891089
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1090-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1090+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10911091
{ .m_desc = {
10921092
PMDA_PMID(CLUSTER_DM_CRYPT, CRYPT_FLAGS),
10931093
PM_TYPE_STRING, DM_CRYPT_INDOM, PM_SEM_INSTANT,
1094-
PMDA_PMUNITS(0,0,0,0,0,PM_COUNT_ONE) }, },
1094+
PMDA_PMUNITS(0,0,0,0,0,0) }, },
10951095
};
10961096

10971097
static pmdaIndom indomtable[] = {

0 commit comments

Comments
 (0)