Skip to content

Commit

Permalink
Add fcstat -e exporter for FC error counters
Browse files Browse the repository at this point in the history
  • Loading branch information
thorhs committed Feb 20, 2022
1 parent 8eb5c2e commit 9ab46d0
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build/mounts.o: mounts.cpp node_exporter_aix.hpp
build/vmstat_v.o: vmstat_v.cpp
g++ -Wall -Werror -fmax-errors=5 -fconcepts -std=c++17 -pthread -lperfstat -DUSE_STANDALONE_ASIO -DASIO_STANDALONE -DASIO_HAS_PTHREADS -D PROG_VERSION="\"$(GIT_VERSION)\"" -c -o build/vmstat_v.o vmstat_v.cpp

build/collectors.o: collectors.cpp generated/diskpaths.cpp generated/diskadapters.cpp generated/memory_pages.cpp generated/memory.cpp generated/cpus.cpp generated/disks.cpp generated/netinterfaces.cpp generated/netadapters.cpp generated/netbuffers.cpp generated/partition.cpp node_exporter_aix.hpp
build/collectors.o: collectors.cpp generated/diskpaths.cpp generated/diskadapters.cpp generated/memory_pages.cpp generated/memory.cpp generated/cpus.cpp generated/disks.cpp generated/netinterfaces.cpp generated/netadapters.cpp generated/netbuffers.cpp generated/partition.cpp generated/fcstats.cpp node_exporter_aix.hpp
g++ -Wall -Werror -fmax-errors=5 -fconcepts -std=c++17 -pthread -lperfstat -DUSE_STANDALONE_ASIO -DASIO_STANDALONE -DASIO_HAS_PTHREADS -c -o build/collectors.o collectors.cpp

generated/%s.cpp: data_sources/%.multiple scripts/generate_multiple.ksh templates/generate_multiple.template
Expand Down
11 changes: 11 additions & 0 deletions collectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ void gather_filesystems(std::ostream& response, const std::string& static_labels
}
}

/*
// Workaround the fact that the structure and function are not called the same
int perfstat_fcstat(perfstat_id_t *name,
perfstat_diskadapter_t* userbuff,
int sizeof_userbuff,
int desired_number) {
perfstat_virtualdiskadapter(name, userbuff, sizeof_userbuff, desired_number);
}
*/

#include "generated/diskadapters.cpp"
#include "generated/diskpaths.cpp"
#include "generated/memory_pages.cpp"
Expand All @@ -153,3 +163,4 @@ void gather_filesystems(std::ostream& response, const std::string& static_labels
#include "generated/netadapters.cpp"
#include "generated/netbuffers.cpp"
#include "generated/partition.cpp"
#include "generated/fcstats.cpp"
22 changes: 22 additions & 0 deletions data_sources/fcstat.multiple
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name id PortWWN:hex PortFcId:hex
strcpy(firstfcstat.name, FIRST_VFCHOST)
counter InputRequests Number of Input Requests
counter OutputRequests Number of Output Requests
counter InputBytes Number of Input Bytes
counter OutputBytes Number of Output Bytes
counter NoDMAResourceCnt Count of DMA failures due to no DMA Resource available
counter NoCmdResourceCnt Count of failures to allocate a command due to no command resource available
counter TxFrames Number of frames transmitted
counter TxWords Fiber Channel Kbytes transmitted
counter RxFrames Number of Frames Received.
counter RxWords Fiber Channel Kbytes Received
counter LIPCount Count of LIP(Loop Initialization Protocol) Events received in case we have FC-AL (arbitrated loop - a FC topology)
counter NOSCount Count of NOS(Not_Operational) Events. This indicates a link failure state. Count is number of times such events occurred. high level, this just indicates that we lost connection to FC network.
counter ErrorFrames Number of frames received with the CRC Error
counter DumpedFrames Number of lost frames
counter LinkFailureCount Count of Link failures
counter LossofSyncCount Count of loss of sync
counter LossofSignal Count of loss of Signal.
counter PrimitiveSeqProtocolErrCount number of times a primitive sequence was in error.
counter InvalidTxWordCount Count of Invalid Transmission words received
counter InvalidCRCCount Count of CRC Errors in a Received Frame
4 changes: 3 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ int usage(int c) {
std::cout << " -P partition statistics" << std::endl;
std::cout << " -f filesystem statistics" << std::endl;
std::cout << " -v vmstat -v statistics" << std::endl;
std::cout << " -F fc adapter statistics" << std::endl;

return 1;
}
Expand All @@ -41,7 +42,7 @@ int main(int argc, char **argv) {

int flags = 0, port = 9100;

while((c = getopt(argc, argv, "p:CcADPMmdiabpfvh?")) != EOF) {
while((c = getopt(argc, argv, "p:CcADPMmdiabpfvFh?")) != EOF) {
switch(c) {
case 'p': port = std::stoi(optarg); break;
case 'C': flags |= PART_COMPAT; break;
Expand All @@ -57,6 +58,7 @@ int main(int argc, char **argv) {
case 'P': flags |= PART_PARTITION; break;
case 'f': flags |= PART_FILESYSTEMS; break;
case 'v': flags |= PART_VMSTAT_V; break;
case 'F': flags |= PART_FCSTAT_E; break;
case 'h': usage(c); return 0; break;
case '?': usage(c); return 0; break;
default:
Expand Down
3 changes: 2 additions & 1 deletion node_exporter_aix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define PART_PARTITION (1<<10)
#define PART_FILESYSTEMS (1<<11)
#define PART_VMSTAT_V (1<<11)

#define PART_FCSTAT_E (1<<12)

extern int start_server(int port, int flags);

Expand All @@ -34,6 +34,7 @@ extern void gather_netbuffers(std::ostream& response, const std::string& static_
extern void gather_partition(std::ostream& response, const std::string& static_labels);
extern void gather_filesystems(std::ostream& response, const std::string& static_labels);
extern void gather_vmstat_v(std::ostream& response, const std::string& static_labels);
extern void gather_fcstats(std::ostream& response, const std::string& static_labels);

struct mountpoint {
std::string mountpoint;
Expand Down
20 changes: 17 additions & 3 deletions scripts/generate_multiple.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@ struct_name=$1
input="data_sources/$1.multiple"
output="$2"

sed -n 1p $input | read name_field id_struct label
sed -n 1p $input | read name_field id_struct labels
sed -n 2p $input | read initializer

if [ -z "$label" ]; then
if [ -z "$label"s ]; then
label="DELETE"
fi
sed "s/STRUCT_NAME/$struct_name/g; s/NAME_FIELD/$name_field/g; s/ID_STRUCT/$id_struct/g; s/INITIALIZER/$initializer/g; s/LABEL/$label/g; /DELETE/d" templates/generate_multiple.template > $output
/opt/freeware/bin/sed -n "0,/LABEL/{s/STRUCT_NAME/$struct_name/g; s/NAME_FIELD/$name_field/g; s/ID_STRUCT/$id_struct/g; s/INITIALIZER/$initializer/g; /LABEL/d; p}" templates/generate_multiple.template > $output

for label in $labels; do
echo $label | sed 's/:/ /' | read label format
if [ -z "$format" ]; then
format_start=""
format_end=""
else
format_start="std::$format << "
format_end="<< std::dec "
fi
/opt/freeware/bin/sed -n "/LABEL/{s/LABEL/$label/g; s/STRUCT_NAME/$struct_name/g; s/FORMAT_START/$format_start/; s/FORMAT_END/$format_end/; p}" templates/generate_multiple.template >> $output
done

/opt/freeware/bin/sed -n "/LABEL/,\${s/STRUCT_NAME/$struct_name/g; s/NAME_FIELD/$name_field/g; s/ID_STRUCT/$id_struct/g; s/INITIALIZER/$initializer/g; /LABEL/d; p}" templates/generate_multiple.template >> $output

tail -n +3 $input | sed "s/\"/'/g" | while read type name desc; do
echo "\toutput_${struct_name}_stat_mode(response, static_labels, \"aix_${struct_name}_${name}\", \"${type}\", \"${desc}\", ${struct_name}s, ${struct_name}_count, [](perfstat_${struct_name}_t& ${struct_name}) { return ${struct_name}.${name}; });" >> $output
Expand Down
1 change: 1 addition & 0 deletions server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ int start_server(int port, int flags) {
if(flags & PART_PARTITION) gather_partition(output, static_labels);
if(flags & PART_FILESYSTEMS) gather_filesystems(output, static_labels);
if(flags & PART_VMSTAT_V) gather_vmstat_v(output, static_labels);
if(flags & PART_FCSTAT_E) gather_fcstats(output, static_labels);

auto outstr = output.str();
*response << "HTTP/1.1 200 OK\r\nContent-Length: " << outstr.length() << "\r\n\r\n"
Expand Down
2 changes: 1 addition & 1 deletion templates/generate_multiple.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ void output_STRUCT_NAME_stat_mode(std::ostream& response, const std::string& sta

for(size_t i=0; i<STRUCT_NAME_count; i++) {
response << name << "{STRUCT_NAME=\"" << STRUCT_NAMEs[i].NAME_FIELD << "\",";
response << "LABEL=\"" << STRUCT_NAMEs[i].LABEL << "\",";
response << "LABEL=\"" << FORMAT_START STRUCT_NAMEs[i].LABEL FORMAT_END << "\",";
response << static_labels << "} " << func(STRUCT_NAMEs[i]) << std::endl;
}
}
Expand Down

0 comments on commit 9ab46d0

Please sign in to comment.