static void print_header(const SaNtfNotificationHeaderT *notificationHeader, SaNtfSubscriptionIdT subscriptionId, SaNtfNotificationTypeT notificationType) { char tmpObj[SA_MAX_NAME_LENGTH + 1]; if (verbose) { printf("notificationID = %d\n", (int)*(notificationHeader->notificationId)); printf("subscriptionId = %u\n", (unsigned int)subscriptionId); } /* Event type */ printf("eventType = "); print_event_type(*notificationHeader->eventType, notificationType); if (verbose) printf("notificationObject.length = %u\n", notificationHeader->notificationObject->length); strncpy(tmpObj, (char *)notificationHeader->notificationObject->value, notificationHeader->notificationObject->length); tmpObj[notificationHeader->notificationObject->length] = '\0'; printf("notificationObject = \"%s\"\n", tmpObj); strncpy(tmpObj, (char *)notificationHeader->notifyingObject->value, notificationHeader->notifyingObject->length); tmpObj[notificationHeader->notifyingObject->length] = '\0'; if (verbose) printf("notifyingObject.length = %u\n", notificationHeader->notifyingObject->length); printf("notifyingObject = \"%s\"\n", tmpObj); /* Notification Class ID in compact dot notation */ if (notificationHeader->notificationClassId->vendorId == SA_NTF_VENDOR_ID_SAF) { printf("notificationClassId = SA_NTF_VENDOR_ID_SAF.%s.%u (0x%x)\n", sa_services_list[notificationHeader->notificationClassId->majorId], notificationHeader->notificationClassId->minorId, notificationHeader->notificationClassId->minorId); } else { printf("notificationClassId = %u.%u.%u (0x%x)\n", notificationHeader->notificationClassId->vendorId, notificationHeader->notificationClassId->majorId, notificationHeader->notificationClassId->minorId, notificationHeader->notificationClassId->minorId); } if (verbose) printf("eventTime = %lld\n", *notificationHeader->eventTime); if (notificationHeader->lengthAdditionalText > 0) printf("additionalText = \"%s\"\n", notificationHeader->additionalText); }
/* * disable_events * * Disabling event using the lttng API. */ static int disable_events(char *session_name) { int ret = CMD_SUCCESS, warn = 0, command_ret = CMD_SUCCESS; int enabled = 1, success = 1; char *event_name, *channel_name = NULL; struct lttng_domain dom; struct lttng_event event; memset(&dom, 0, sizeof(dom)); /* Create lttng domain */ if (opt_kernel) { dom.type = LTTNG_DOMAIN_KERNEL; } else if (opt_userspace) { dom.type = LTTNG_DOMAIN_UST; } else if (opt_jul) { dom.type = LTTNG_DOMAIN_JUL; } else if (opt_log4j) { dom.type = LTTNG_DOMAIN_LOG4J; } else if (opt_python) { dom.type = LTTNG_DOMAIN_PYTHON; } else { /* Checked by the caller. */ assert(0); } channel_name = opt_channel_name; handle = lttng_create_handle(session_name, &dom); if (handle == NULL) { ret = -1; goto error; } /* Mi print the channel and open the events element */ if (lttng_opt_mi) { ret = mi_lttng_writer_open_element(writer, config_element_channel); if (ret) { ret = CMD_ERROR; goto end; } ret = mi_lttng_writer_write_element_string(writer, config_element_name, print_channel_name(channel_name)); if (ret) { ret = CMD_ERROR; goto end; } /* Open events element */ ret = mi_lttng_writer_open_element(writer, config_element_events); if (ret) { ret = CMD_ERROR; goto end; } } memset(&event, 0, sizeof(event)); /* Set default loglevel to any/unknown */ event.loglevel = -1; /* opt_event_type contain the event type to disable at this point */ event.type = opt_event_type; if (opt_disable_all) { command_ret = lttng_disable_event_ext(handle, &event, channel_name, NULL); if (command_ret < 0) { ERR("%s", lttng_strerror(command_ret)); enabled = 1; success = 0; } else { enabled = 0; success = 1; MSG("All %s events of type %s are disabled in channel %s", get_domain_str(dom.type), print_event_type(opt_event_type), print_channel_name(channel_name)); } if (lttng_opt_mi) { ret = mi_print_event("*", enabled, success); if (ret) { ret = CMD_ERROR; goto error; } } } else { /* Strip event list */ event_name = strtok(opt_event_list, ","); while (event_name != NULL) { DBG("Disabling event %s", event_name); strncpy(event.name, event_name, sizeof(event.name)); event.name[sizeof(event.name) - 1] = '\0'; command_ret = lttng_disable_event_ext(handle, &event, channel_name, NULL); if (command_ret < 0) { ERR("%s of type %s : %s (channel %s, session %s)", event_name, print_event_type(opt_event_type), lttng_strerror(command_ret), command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ? print_raw_channel_name(channel_name) : print_channel_name(channel_name), session_name); warn = 1; success = 0; /* * If an error occurred we assume that the event is still * enabled. */ enabled = 1; } else { MSG("%s %s of type %s disabled in channel %s for session %s", get_domain_str(dom.type), event_name, print_event_type(opt_event_type), print_channel_name(channel_name), session_name); success = 1; enabled = 0; } if (lttng_opt_mi) { ret = mi_print_event(event_name, enabled, success); if (ret) { ret = CMD_ERROR; goto error; } } /* Next event */ event_name = strtok(NULL, ","); } } end: if (lttng_opt_mi) { /* Close events element and channel element */ ret = mi_lttng_close_multi_element(writer, 2); if (ret) { ret = CMD_ERROR; } } error: /* if there is already an error preserve it */ if (warn && !ret) { ret = CMD_WARNING; } /* Overwrite ret if an error occurred */ ret = command_ret ? command_ret : ret; lttng_destroy_handle(handle); return ret; }
static void print_header(const SaNtfNotificationHeaderT * notificationHeader, SaNtfSubscriptionIdT subscriptionId, SaNtfNotificationTypeT notificationType) { static char time[32]; if (verbose) { printf("notificationID = %d\n", (int)*(notificationHeader->notificationId)); printf("subscriptionId = %u\n", (unsigned int)subscriptionId); } /* Event type */ printf("eventType = "); print_event_type(*notificationHeader->eventType, notificationType); if (verbose) printf("notificationObject.length = %zu\n", strlen(saAisNameBorrow(notificationHeader->notificationObject))); printf("notificationObject = \"%s\"\n", saAisNameBorrow(notificationHeader->notificationObject)); if (verbose) printf("notifyingObject.length = %zu\n", strlen(saAisNameBorrow(notificationHeader->notifyingObject))); printf("notifyingObject = \"%s\"\n", saAisNameBorrow(notificationHeader->notifyingObject)); /* Notification Class ID in compact dot notation */ if (notificationHeader->notificationClassId->vendorId == SA_NTF_VENDOR_ID_SAF) { printf("notificationClassId = SA_NTF_VENDOR_ID_SAF.%s.%u " "(0x%x)\n", sa_services_list[notificationHeader-> notificationClassId->majorId], notificationHeader->notificationClassId->minorId, notificationHeader->notificationClassId->minorId); } else { printf("notificationClassId = %u.%u.%u (0x%x)\n", notificationHeader->notificationClassId->vendorId, notificationHeader->notificationClassId->majorId, notificationHeader->notificationClassId->minorId, notificationHeader->notificationClassId->minorId); } if (verbose) { time_t time_in_secs = *notificationHeader->eventTime/SA_TIME_ONE_SECOND; /*Print time in human readable form also .*/ (void)strftime(time, sizeof(time), "%a %b %d %T %Z %Y", localtime(&time_in_secs)); printf("eventTime = %lld (%s)\n",*notificationHeader->eventTime, time); } if (verbose) printf("lengthAdditionalText = %u\n", notificationHeader->lengthAdditionalText); if (notificationHeader->lengthAdditionalText > 0) printf("additionalText = \"%s\"\n", notificationHeader->additionalText); }