Example #1
0
    def enable_channel(self, sname, domain, cname, attributes):
        args = [
            self._DOMAIN_TO_OPTION[domain],
            '-s', sname,
        ]

        if attributes.mode is not None:
            args.append(self._CHANNEL_MODE_TO_OPTION[attributes.mode])

        if attributes.subbuf_size is not None:
            args += ['--subbuf-size', str(attributes.subbuf_size)]

        if attributes.subbuf_count is not None:
            args += ['--num-subbuf', str(attributes.subbuf_count)]

        if attributes.switch_timer_interval is not None:
            args += [
                '--switch-timer',
                str(utils.sec_to_usec(attributes.switch_timer_interval))
            ]

        if attributes.read_timer_interval is not None:
            args += [
                '--read-timer',
                str(utils.sec_to_usec(attributes.read_timer_interval))
            ]

        if attributes.output_type is not None:
            d = self._CHANNEL_OUTPUT_TYPE_TO_OPTION_TYPE
            args += ['--output', d[attributes.output_type]]

        if attributes.tracefile_size is not None:
            args += ['--tracefile-size', str(attributes.tracefile_size)]

        if attributes.tracefile_count is not None:
            args += ['--tracefile-count', str(attributes.tracefile_count)]

        if attributes.buffer_scheme is not None:
            bs = attributes.buffer_scheme
            args.append(self._CHANNEL_BUFFER_SCHEME_TO_OPTION[bs])

        args.append(cname)
        self._do_simple_success_command('enable-channel', args)
Example #2
0
    def set_domain_channel_attributes(self, domain, attr):
        # domain
        if domain == model.Domain.KERNEL:
            self._set_kernel_visibility()
        else:
            self._set_user_visibility()

        # mode
        if attr.mode == model.ChannelMode.DISCARD:
            self._discard_radio.click()
        else:
            self._overwrite_radio.click()

        # sub-buffer count and size
        self._subbuf_count_spinbox.setValue(attr.subbuf_count)
        b, prefix = utils.bytes_to_human_prefix(attr.subbuf_size)

        if b == math.floor(b):
            txt = '{}{}'.format(math.floor(b), prefix)
        else:
            txt = str(attr.subbuf_size)

        self._subbuf_size_edit.setText(txt)

        # output type
        if attr.output_type == model.ChannelOutputType.MMAP:
            self._mmap_radio.setChecked(True)
        else:
            self._splice_radio.setChecked(True)

        # buffer scheme
        if attr.buffer_scheme == model.ChannelBufferScheme.GLOBAL:
            self._global_radio.setChecked(True)
        elif attr.buffer_scheme == model.ChannelBufferScheme.PER_UID:
            self._per_uid_radio.setChecked(True)
        else:
            self._per_pid_radio.setChecked(True)

        # read timer interval
        if attr.read_timer_interval is not None:
            usec = utils.sec_to_usec(attr.read_timer_interval)
            self._read_timer_period_edit.setText(str(usec))
            self._read_timer_stopped_check.setChecked(False)
            self._read_timer_period_edit.setEnabled(True)
        else:
            self._read_timer_period_edit.setText('')
            self._read_timer_stopped_check.setChecked(True)
            self._read_timer_period_edit.setEnabled(False)

        # switch timer interval
        if attr.switch_timer_interval is not None:
            usec = utils.sec_to_usec(attr.switch_timer_interval)
            self._switch_timer_period_edit.setText(str(usec))
            self._switch_timer_stopped_check.setChecked(False)
            self._switch_timer_period_edit.setEnabled(True)
        else:
            self._switch_timer_period_edit.setText('')
            self._switch_timer_stopped_check.setChecked(True)
            self._switch_timer_period_edit.setEnabled(False)

        # trace files
        if attr.tracefile_size is not None:
            self._tracefile_ucount_msize_radio.click()
            self._tracefile_size_edit.setText(str(attr.tracefile_size))

            if attr.tracefile_count is not None:
                self._tracefile_mcount_msize_radio.click()
                self._tracefile_count_edit.setText(str(attr.tracefile_count))
        else:
            self._tracefile_ucount_usize_radio.click()