Skip to content

Commit

Permalink
Print SFP Optical counters
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Oct 18, 2016
1 parent fe638d0 commit 5c0adb5
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Oct-18-2016:
3.39: - print SFP optical counters
Oct-17-2016:
3.38: - fix pcap_file_header.snaplen
- drop "-z pad" option
Expand Down
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME

/* Define to the home page for this package. */
#undef PACKAGE_URL

/* Define to the version of this package. */
#undef PACKAGE_VERSION

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
AC_PREREQ(2.57)
AC_INIT(src/sflowtool.c)
PACKAGE=sflowtool
VERSION=3.38
VERSION=3.39
AM_INIT_AUTOMAKE($PACKAGE,$VERSION)
AM_CONFIG_HEADER(config.h)
AC_CONFIG_SRCDIR([src/sflow.h])
Expand Down
2 changes: 1 addition & 1 deletion sflowtool.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary: tool to ascii-print or forward sFlow datagrams
Name: sflowtool
Version: 3.38
Version: 3.39
Release: 1%{?dist}
License: http://www.inmon.com/technology/sflowlicense.txt
Group: Productivity/Networking/Diagnostic
Expand Down
29 changes: 29 additions & 0 deletions src/sflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,33 @@ typedef struct {

#define SFL_MAX_PORTNAME_LEN 255

/* Optical SFP/QSFP metrics */
/* opaque = counter_data; enterprise = 0; format = 10 */

typedef struct {
uint32_t lane_index; /* index of lane in module - starting from 1 */
uint32_t tx_bias_current; /* microamps */
uint32_t tx_power; /* microwatts */
uint32_t tx_power_min; /* microwatts */
uint32_t tx_power_max; /* microwatts */
uint32_t tx_wavelength; /* nanometers */
uint32_t rx_power; /* microwatts */
uint32_t rx_power_min; /* microwatts */
uint32_t rx_power_max; /* microwatts */
uint32_t rx_wavelength; /* nanometers */
} SFLLane;

#define XDRSIZ_LANE_COUNTERS 40

typedef struct {
uint32_t module_id;
uint32_t module_total_lanes; /* total lanes in module */
uint32_t module_supply_voltage; /* millivolts */
int32_t module_temperature; /* signed - in oC / 1000 */
uint32_t num_lanes; /* number of active lane structs to come */
SFLLane *lanes;
} SFLSFP_counters;

/* Counters data */

enum SFLCounters_type_tag {
Expand All @@ -1459,6 +1486,7 @@ enum SFLCounters_type_tag {
SFLCOUNTERS_VLAN = 5,
SFLCOUNTERS_80211 = 6,
SFLCOUNTERS_LACP = 7,
SFLCOUNTERS_SFP = 10,
SFLCOUNTERS_PROCESSOR = 1001,
SFLCOUNTERS_RADIO = 1002,
SFLCOUNTERS_PORTNAME = 1005,
Expand Down Expand Up @@ -1528,6 +1556,7 @@ typedef union _SFLCounters_type {
SFLVdi_counters vdi;
SFLLACP_counters lacp;
SFLPortName portName;
SFLSFP_counters sfp;
} SFLCounters_type;

typedef struct _SFLCounters_sample_element {
Expand Down
29 changes: 29 additions & 0 deletions src/sflowtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -3808,6 +3808,34 @@ static void readCounters_LACP(SFSample *sample)
sf_log_next32(sample, "markerResponsePDUsTx");
}

/*_________________----------------------------__________________
_________________ readCounters_SFP __________________
-----------------____________________________------------------
*/

static void readCounters_SFP(SFSample *sample)
{
uint32_t num_lanes,ll;
sf_log_next32(sample, "sfp_module_id");
sf_log_next32(sample, "sfp_module_total_lanes");
sf_log_next32(sample, "sfp_module_supply_voltage");
sf_log_next32(sample, "sfp_module_temperature");
num_lanes = getData32(sample);
sf_log(sample, "sfp_module_active_lanes %u\n", num_lanes);
for(ll=0; ll < num_lanes; ll++) {
sf_log(sample, "sfp_lane_index.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_tx_bias_current_uA.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_tx_power_uW.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_tx_power_min_uW.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_tx_power_max_uW.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_tx_wavelength_nM.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_rx_power_uW.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_rx_power_min_uW.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_rx_power_max_uW.%u %u\n", ll, getData32(sample));
sf_log(sample, "sfp_lane_rx_wavelength_nM.%u %u\n", ll, getData32(sample));
}
}

/*_________________---------------------------__________________
_________________ readCountersSample_v2v4 __________________
-----------------___________________________------------------
Expand Down Expand Up @@ -3906,6 +3934,7 @@ static void readCountersSample(SFSample *sample, int expanded)
case SFLCOUNTERS_VLAN: readCounters_vlan(sample); break;
case SFLCOUNTERS_80211: readCounters_80211(sample); break;
case SFLCOUNTERS_LACP: readCounters_LACP(sample); break;
case SFLCOUNTERS_SFP: readCounters_SFP(sample); break;
case SFLCOUNTERS_PROCESSOR: readCounters_processor(sample); break;
case SFLCOUNTERS_RADIO: readCounters_radio(sample); break;
case SFLCOUNTERS_PORTNAME: readCounters_portName(sample); break;
Expand Down

0 comments on commit 5c0adb5

Please sign in to comment.