Skip to content

Commit

Permalink
minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Elkner committed Jan 25, 2022
1 parent d24b153 commit 9104419
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CC = $(USE_CC)
# For all others one needs to add corresponding rules.
OPTIMZE_cc ?= -xO3
OPTIMZE_gcc ?= -O3
#OPTIMZE ?= $(OPTIMZE_$(CC)) -DNDEBUG
OPTIMZE ?= $(OPTIMZE_$(CC)) -DNDEBUG

CFLAGS_cc = -xcode=pic32
CFLAGS_cc += -errtags -erroff=%none,E_UNRECOGNIZED_PRAGMA_IGNORED,E_ATTRIBUTE_UNKNOWN,E_NONPORTABLE_BIT_FIELD_TYPE -errwarn=%all -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1
Expand Down
4 changes: 2 additions & 2 deletions ipmi_sdr_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ sdr_unit2str(unit_t *u) {
return "percent"; // this is closer to prom names than '%'

len = strlen(sbase);
strncpy(idx, sbase, len);
strcpy(idx, sbase);
idx += len;

if (u->modifier_prefix == SDR_UNIT_MODIFIER_PREFIX_MUL) {
Expand All @@ -503,7 +503,7 @@ sdr_unit2str(unit_t *u) {
}

len = strlen(smod);
strncpy(idx, smod, len);
strcpy(idx, smod);
idx += len;
*idx = '\0';

Expand Down
8 changes: 6 additions & 2 deletions ipmimex.8
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ipmimex \- a metrics exporter for BMC
.B ipmimex
is a \fBm\fRetrics \fBex\fRporter for Board Management Controller (BMC)
and similar devices, which are directly accessible from the host running
this utility using the system'ss \fBI\fRntelligent \fBP\fRlatform
this utility using the system's \fBI\fRntelligent \fBP\fRlatform
\fBM\fRanagement \fBI\fRnterface (\fBIPMI\fR).
Collected data can be exposed via HTTP in Prometheus exposition format [1]
e.g. using the default endpoint URL
Expand Down Expand Up @@ -133,7 +133,11 @@ are know to have this bug.
Disable the overall scrapetime metrics (libprom collector), i.e. the time
elapsed when scraping all the required data. One needs to also disable
collecting scrapetimes of all other collectors before this option
gets honored.
gets honored. This is very helpful when one tries to determine the stats query
interval to use. E.g. Gigabyte BMCs are slow as hell - the overall scrapetime
intervall will show you something close to 2 seconds =8-(. So especially there
it is pretty important to unselect all sensors not needed using the exclude
options -X and -x.

.TP
.B \-N
Expand Down
8 changes: 4 additions & 4 deletions prom_ipmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ static const char *metric_unit[] = {
const char *
unit2prom(unit_t *u) {
// base + modifier + mprefix + '\0'
static char buf[2 * PROM_UNIT_MAX_STRLEN + 2 + 1];
static char buf[2 * PROM_UNIT_MAX_STRLEN + 5 + 1];
char *idx = buf;
int len;
size_t len;

const char *sbase = u->base == 0
? ""
Expand All @@ -310,7 +310,7 @@ unit2prom(unit_t *u) {
return "percent"; // this is closer to prom names than '%'

len = strlen(sbase);
strncpy(idx, sbase, len);
strcpy(idx, sbase);
idx += len;

if (u->modifier_prefix == SDR_UNIT_MODIFIER_PREFIX_MUL) {
Expand All @@ -322,7 +322,7 @@ unit2prom(unit_t *u) {
}

len = strlen(smod);
strncpy(idx, smod, len);
strcpy(idx, smod);
idx += len;
*idx = '\0';

Expand Down

0 comments on commit 9104419

Please sign in to comment.