qlogic sanbox monitoring from zabbix server (hexadecimal values have spaces)

By thomas, 22 March, 2010
While attempting to monitor traffic on a qlogic Sanbox 5602 I noticed that the traffic (connUnitPortStatCountTxObjects) was being returned as a hexadecimal value with spaces in it (e.g. Hex-STRING: 00 00 00 00 01 4F E1 1B). Zabbix was complaining about an invalid type of returned data because of the spaces. I wrote the following simple patch to remove the spaces (I know it could be done simpler but I just needed a quick fix).
diff -up zabbix-1.8.1/src/libs/zbxcommon/misc.c.spaces zabbix-1.8.1/src/libs/zbxcommon/misc.c --- zabbix-1.8.1/src/libs/zbxcommon/misc.c.spaces 2010-03-19 10:57:07.000000000 -0400 +++ zabbix-1.8.1/src/libs/zbxcommon/misc.c 2010-03-22 10:31:36.000000000 -0400 @@ -1322,7 +1322,7 @@ int is_uhex(char *str) for (; '\0' != *str; str++) { - if ((*str '0' || *str > '9') && (*str 'a' || *str > 'f') && (*str 'A' || *str > 'F')) + if ((*str '0' || *str > '9') && (*str 'a' || *str > 'f') && (*str 'A' || *str > 'F') && (*str != ' ')) break; res = SUCCEED; diff -up zabbix-1.8.1/src/libs/zbxsysinfo/sysinfo.c.spaces zabbix-1.8.1/src/libs/zbxsysinfo/sysinfo.c --- zabbix-1.8.1/src/libs/zbxsysinfo/sysinfo.c.spaces 2010-03-19 11:03:16.000000000 -0400 +++ zabbix-1.8.1/src/libs/zbxsysinfo/sysinfo.c 2010-03-22 10:23:53.000000000 -0400 @@ -587,6 +587,19 @@ int set_result_type(AGENT_RESULT *result case ITEM_DATA_TYPE_HEXADECIMAL: if (SUCCEED == is_uhex(c)) { + /* remove spaces */ + int hex_i=0,hex_j; + while(c[hex_i]) { + if (c[hex_i] == ' ') { + hex_j = hex_i; + while(c[hex_j]) { + c[hex_j] = c[hex_j+1]; + ++hex_j; + } + } + ++hex_i; + } + ZBX_HEX2UINT64(value_uint64, c); SET_UI64_RESULT(result, value_uint64); ret = SUCCEED;
After patching I was able to monitor the individual port stats (e.g. for the first port .1.3.6.1.3.94.4.5.1.4.16.0.0.192.221.19.34.253.0.0.0.0.0.0.0.0.1)