Skip to content
This repository was archived by the owner on May 19, 2022. It is now read-only.

Commit 7ef7435

Browse files
committed
Make SEL logging a config option.
1 parent 740e8b5 commit 7ef7435

5 files changed

Lines changed: 29 additions & 25 deletions

File tree

Crate.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,37 +158,37 @@ int crate__parse_sel_cb(ipmi_sel_ctx_t ctx, void *cb_crate)
158158

159159
int rv;
160160

161-
#ifdef PRINT_SEL
162-
/*
163-
* Print out Event String for debug/testing
164-
*/
161+
if (crate->log_sel) {
162+
/*
163+
* Print out Event String for debug/testing
164+
*/
165165

166-
// FreeIPMI Library TRACE build option override
167-
//
168-
// Really, lets just not get this stupid error message.
169-
// We NEVER care.
170-
//int olderr = dup(2);
171-
//close(2);
172-
//open("/dev/null", O_WRONLY);
166+
// FreeIPMI Library TRACE build option override
167+
//
168+
// Really, lets just not get this stupid error message.
169+
// We NEVER care.
170+
//int olderr = dup(2);
171+
//close(2);
172+
//open("/dev/null", O_WRONLY);
173173

174-
char eventstring[1024];
175-
rv = ipmi_sel_parse_read_record_string(ctx,
174+
char eventstring[1024];
175+
rv = ipmi_sel_parse_read_record_string(ctx,
176176
"%i: %d %t: %T sensor %s %k: %e",
177177
NULL,
178178
0,
179179
eventstring,
180180
1024,
181181
IPMI_SEL_STRING_FLAGS_VERBOSE|IPMI_SEL_STRING_FLAGS_OUTPUT_NOT_AVAILABLE|IPMI_SEL_STRING_FLAGS_IGNORE_UNAVAILABLE_FIELD);
182182

183-
// And restore stderr before going ANY farther.
184-
//dup2(olderr, 2);
185-
//close(olderr);
183+
// And restore stderr before going ANY farther.
184+
//dup2(olderr, 2);
185+
//close(olderr);
186186

187-
if (rv < 0)
188-
RETMSG(-1, "ipmi_sel_parse_read_record_string() failed: (%d) %s", ipmi_sel_ctx_errnum(ctx), ipmi_sel_ctx_strerror(ipmi_sel_ctx_errnum(ctx)));
189-
if (rv >= 0)
190-
mprintf("C%d: %s\n", CRATE_NO, eventstring);
191-
#endif
187+
if (rv < 0)
188+
RETMSG(-1, "ipmi_sel_parse_read_record_string() failed: (%d) %s", ipmi_sel_ctx_errnum(ctx), ipmi_sel_ctx_strerror(ipmi_sel_ctx_errnum(ctx)));
189+
if (rv >= 0)
190+
mprintf("C%d: SEL Entry: %s\n", CRATE_NO, eventstring);
191+
}
192192

193193
uint16_t record_id;
194194
rv = ipmi_sel_parse_read_record_id(ctx, NULL, 0, &record_id);

Crate.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Crate {
4545
char *pass;
4646
uint8_t ipmi15_authentication_type;
4747
std::string description;
48+
bool log_sel;
4849

4950
TaskQueue::taskid_t selscan_id;
5051
TaskQueue::taskid_t sdrscan_id;
@@ -69,8 +70,8 @@ class Crate {
6970
void *cb_data);
7071

7172
public:
72-
Crate(uint8_t number, enum Mfgr MCH, std::string ip, const char *user, const char *pass, uint8_t ipmi15_authentication_type, std::string description)
73-
: number(number), MCH(MCH), ip(ip), ipmi15_authentication_type(ipmi15_authentication_type), description(description), selscan_id(0), sdrscan_id(0), selscan_lastclr(0), selscan_nextent(0), force_sdr_scan(false), sdr_scan_retries(0), sendmessage_seq(0) {
73+
Crate(uint8_t number, enum Mfgr MCH, std::string ip, const char *user, const char *pass, uint8_t ipmi15_authentication_type, std::string description, bool log_sel)
74+
: number(number), MCH(MCH), ip(ip), ipmi15_authentication_type(ipmi15_authentication_type), description(description), log_sel(log_sel), selscan_id(0), sdrscan_id(0), selscan_lastclr(0), selscan_nextent(0), force_sdr_scan(false), sdr_scan_retries(0), sendmessage_seq(0) {
7475
memset(&this->ctx, 0, sizeof(this->ctx));
7576
memset(&this->cards, 0, sizeof(this->cards));
7677
memset(&this->sdrfile, 0, sizeof(this->sdrfile));

sysmgr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ int main(int argc, char *argv[])
285285
CFG_INT_CB(const_cast<char *>("authtype"), 0, CFGF_NONE, cfg_parse_authtype),
286286
CFG_INT_CB(const_cast<char *>("mch"), 0, CFGF_NONE, cfg_parse_MCH),
287287
CFG_BOOL(const_cast<char *>("enabled"), cfg_true, CFGF_NONE),
288+
CFG_BOOL(const_cast<char *>("log_sel"), cfg_false, CFGF_NONE),
288289
CFG_END()
289290
};
290291

@@ -347,7 +348,7 @@ int main(int argc, char *argv[])
347348
const char *user = cfg_getstr(cfgcrate, "username");
348349
const char *pass = cfg_getstr(cfgcrate, "password");
349350

350-
Crate *crate = new Crate(i+1, MCH, cfg_getstr(cfgcrate, "host"), (user[0] ? user : NULL), (pass[0] ? pass : NULL), cfg_getint(cfgcrate, "authtype"), cfg_getstr(cfgcrate, "description"));
351+
Crate *crate = new Crate(i+1, MCH, cfg_getstr(cfgcrate, "host"), (user[0] ? user : NULL), (pass[0] ? pass : NULL), cfg_getint(cfgcrate, "authtype"), cfg_getstr(cfgcrate, "description"), (cfg_getbool(cfgcrate, "log_sel") == cfg_true));
351352

352353
bool enabled = (cfg_getbool(cfgcrate, "enabled") == cfg_true);
353354
if (enabled)

sysmgr.example.tmpl.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ crate {
2626
password = "vadatech"
2727
authtype = none # NONE MD2 MD5 STRAIGHT_PASSWORD_KEY
2828
description = "Left Crate"
29+
log_sel = false
2930
}
3031

3132
crate {
@@ -35,6 +36,7 @@ crate {
3536
password = "vadatech"
3637
authtype = none
3738
description = "Right Crate"
39+
log_sel = false
3840
enabled = false
3941
}
4042

@@ -45,6 +47,7 @@ crate {
4547
password = ""
4648
authtype = none
4749
description = "Spare Crate"
50+
log_sel = false
4851
enabled = false
4952
}
5053

sysmgr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#undef DEBUG_ONESHOT
88
#undef DEBUG_OUTPUT
99
#undef DEBUG_SOCKET_FLOW
10-
#undef PRINT_SEL
1110
#define ABSOLUTE_HOTSWAP // Check sensor value, not event data.
1211

1312
#define CONFIG_PATH "/etc/sysmgr"

0 commit comments

Comments
 (0)