//export zbx_module_item_list
func zbx_module_item_list() *C.ZBX_METRIC {
	metrics := make([]C.ZBX_METRIC, 3)

	metrics[0] = C.ZBX_METRIC{
		key:        C.CString("socket.send"),
		function:   C.agent_item_handler(unsafe.Pointer(C.socket_send)),
		flags:      C.CF_HAVEPARAMS,
		test_param: nil,
	}

	return &metrics[0]
}
Example #2
0
//export zbx_module_item_list
func zbx_module_item_list() *C.ZBX_METRIC {
	LogDebugf("Registering %d item handlers", len(itemHandlers))

	// route all item key calls through route_item()
	router := C.agent_item_handler(unsafe.Pointer(C.route_item))

	// create null-terminated array of C.ZBX_METRICS
	metrics := C.new_metric_list(C.size_t(len(itemHandlers))) // never freed
	for _, item := range itemHandlers {
		m := C.ZBX_METRIC{
			key:        C.CString(item.Key), // freed by Zabbix
			flags:      C.CF_HAVEPARAMS,
			function:   router,
			test_param: C.CString(item.TestParams), // freed by Zabbix
		} // freed by Go GC

		C.append_metric(metrics, &m)
	}

	return metrics
}