Skip to content

Commit

Permalink
error count in snmp
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Oct 13, 2024
1 parent 3bcca70 commit 74faa26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,18 +566,21 @@ void server::handler()
if (ifr != IFR_OK && ifr != IFR_CONNECTION) { // something wrong with the received PDU?
DOLOG(logging::ll_debug, "server::handler", endpoint, "invalid PDU");

is->iscsiInstSsnFormatErrors++;

std::optional<uint8_t> reason;

if (ifr == IFR_INVALID_FIELD || ifr == IFR_IO_ERROR || ifr == IFR_MISC)
if (ifr == IFR_INVALID_FIELD || ifr == IFR_IO_ERROR || ifr == IFR_MISC) {
is->iscsiInstSsnFormatErrors++;
reason = 0x09;
else if (ifr == IFR_DIGEST)
}
else if (ifr == IFR_DIGEST) {
is->iscsiInstSsnDigestErrors++;
reason = 0x02;
}
else if (ifr == IFR_INVALID_COMMAND)
reason = 0x05;
else
else {
DOLOG(logging::ll_error, "server::handler", endpoint, "internal error, IFR %d not known", ifr);
}

std::optional<blob_t> reject = generate_reject_pdu(*pdu, reason);
if (reject.has_value() == false) {
Expand Down
1 change: 1 addition & 0 deletions server.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ typedef struct
uint32_t iscsiSsnCmdPDUs; // 1.3.6.1.2.1.142.1.10.2.1.1
uint32_t iscsiInstSsnFailures; // 1.3.6.1.2.1.142.1.1.1.1.10
uint32_t iscsiInstSsnFormatErrors; // 1.3.6.1.2.1.142.1.1.2.1.3
uint32_t iscsiInstSsnDigestErrors; // 1.3.6.1.2.1.142.1.1.2.1.1
uint64_t iscsiSsnTxDataOctets; // 1.3.6.1.2.1.142.1.10.2.1.3
uint64_t iscsiSsnRxDataOctets; // 1.3.6.1.2.1.142.1.10.2.1.4
uint32_t iscsiTgtLoginAccepts; // 1.3.6.1.2.1.142.1.6.2.1.1
Expand Down
1 change: 1 addition & 0 deletions snmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void init_snmp(snmp **const snmp_, snmp_data **const snmp_data_, io_stats_t *con
(*snmp_data_)->register_oid("1.3.6.1.2.1.142.1.10.2.1.1", new snmp_data_type_stats_uint32_t(&is->iscsiSsnCmdPDUs));
(*snmp_data_)->register_oid("1.3.6.1.2.1.142.1.6.2.1.1", new snmp_data_type_stats_uint32_t(&is->iscsiTgtLoginAccepts));
(*snmp_data_)->register_oid("1.3.6.1.2.1.142.1.6.3.1.1", new snmp_data_type_stats_uint32_t(&is->iscsiTgtLogoutNormals));
(*snmp_data_)->register_oid("1.3.6.1.2.1.142.1.1.2.1.1", new snmp_data_type_stats_uint32_t(&is->iscsiInstSsnDigestErrors));
(*snmp_data_)->register_oid("1.3.6.1.2.1.142.1.10.2.1.3", new snmp_data_type_stats(snmp_integer::snmp_integer_type::si_counter64, &is->iscsiSsnTxDataOctets));
(*snmp_data_)->register_oid("1.3.6.1.2.1.142.1.10.2.1.4", new snmp_data_type_stats(snmp_integer::snmp_integer_type::si_counter64, &is->iscsiSsnRxDataOctets));
(*snmp_data_)->register_oid("1.3.6.1.2.1.142.1.1.2.1.3", new snmp_data_type_stats_uint32_t(&is->iscsiInstSsnFormatErrors));
Expand Down

0 comments on commit 74faa26

Please sign in to comment.