Using libnrm in your C applications =================================== See the :doc:`Complete C API` for more information. 1. Initialize NRM and create a client ------------------------------------- To make code report progress to NRM, we need to: - Include the library:: # include - Declare :ref:`nrm_client`, :ref:`nrm_scope`, and :ref:`nrm_sensor` structures:: nrm_client_t *client; nrm_scope_t *scope; nrm_sensor_t *sensor; - Initialize NRM, create a client for connecting to ``nrmd``:: nrm_init(NULL, NULL); static char *upstream_uri = "tcp://127.0.0.1"; static int pub_port = 2345; static int rpc_port = 3456; nrm_client_create(&client, upstream_uri, pub_port, rpc_port); 1. Determine measurements, create scopes and sensors ---------------------------------------------------- - Create a ``nrm_scope`` structure **for each** measurement to report, and add them to the client. If only reporting a single measurement:: char *scope_name = "my.scope.name"; scope = nrm_scope_create(scope_name); nrm_client_add_scope(client, scope); However, if reporting multiple measurements, create an array of scopes, e.g.:: nrm_scope_t *nrm_scopes[NUM_MEASUREMENTS]; char *scope_name; for (int i=0; i # include # include int main() { int i, num_logical_cpus, measurement; nrm_client_t *client; nrm_scope_t *scope; nrm_sensor_t *sensor; nrm_time_t timestamp; static char *upstream_uri = "tcp://127.0.0.1"; static int pub_port = 2345; static int rpc_port = 3456; char *sensor_name = "example-measure"; char *scope_name = "my.scope.name"; nrm_init(NULL, NULL); nrm_client_create(&client, upstream_uri, pub_port, rpc_port); scope = nrm_scope_create(scope_name); sensor = nrm_sensor_create(sensor_name); nrm_client_add_scope(client, scope); nrm_client_add_sensor(client, sensor); num_logical_cpus = example_get_num_logical_cpus(); for (int i=0; i` for more information.