Giter Club home page Giter Club logo

insights-client's Introduction

Code Health

Red Hat Access Insights Client

Installing

On a RHEL7 box:

Make sure the build dependencies are installed:

    ./tests/install-build-requirements

If the script fails, try to install the build requirements by hand. If it fails because of subscription-manager, try 'subscription-manager register --auto-attach', or just try yum without subscription-manager.

Next build it.

make clean install

Next configure it.

  1. Edit /etc/insights-client/insights-client.conf

Some things you might want to change:

  1. User id, where YOUR_RHN_xxx is your RHN/Red Hat Portal username and password

    username=YOUR_RHN_USERNAME

    password=YOUR_RHN_PASSWORD

  2. What server to use, where DEVEL_SERVER_AND_PORT is whatever development insights server you have set up. If left default, the client will contact Red Hat's production server

    upload_url=http://DEVEL_SERVER_AND_PORT/r/insights/uploads

    collection_rules_url=http://DEVEL_SERVER_AND_PORT/v1/static/uploader.json

    gpg=False

  3. Random logging stuff,

    loglevel=DEBUG

    auto_config=False

    no_schedule=True

Next run some tests:

insights-client --verbose --register

./tests/test-containers
./tests/test-containers "python ./insights_client/__init__.py"

./tests/test-new-specs
./tests/test-conditional-docker

insights-client's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

insights-client's Issues

command not found

We can see below code in insights_client/insights_spec.py, In fact, the OSError will never be hit as the args = shlex.split(timeout_command) is executing timeout command. timeout is always existing in OS.
The design should be that the insights client should return nothing when command not found in the os.
But now we can see below line in file content for "command not found".

timeout: failed to run command `/usr/bin/ceph': No such file or directory

Code fragement:

        timeout_command = 'timeout %s %s' % (timeout_interval, self.command)

        # ensure consistent locale for collected command output
        cmd_env = {'LC_ALL': 'C'}
        args = shlex.split(timeout_command)

        # never execute this stuff
        if set.intersection(set(args), set(self.black_list)):
            raise RuntimeError("Command Blacklist")

        try:
            logger.debug('Executing: %s', args)
            proc0 = Popen(args, shell=False, stdout=PIPE, stderr=STDOUT,
                          bufsize=-1, env=cmd_env, close_fds=True)
        except OSError as err:

make the configuration file more flexible

add more parameters to /etc/redhat-access-insights/redhat-access-insights.conf.j2 template file, with e.g. a dictionary variable that contains the configs such as:

insight-client-config:
  loglevel: INFO
  proxy: http://myproxy:8888

Here are some examples how it could look like in the template file:

# Change log level, valid options DEBUG, INFO, WARNING, ERROR, CRITICAL. Default DEBUG
loglevel={{ insight-client-config.loglevel | default("DEBUG") }}

# URL for your proxy.  Example: http://user:[email protected]:8080
proxy={{ insight-client-config.proxy | default(omit) }}

Unexpected 'ps_aux' output.

Hi Richard,

When I was using 'redhat-access-insights', it seems that the collected data 'ps_aux' is not the result as it should be. Please kindly check the follows:

$ cat ./test-host1-20161207134651/insights_commands/ps_aux | wc -l
3
$ cat ./test-host1-20161207134651/insights_commands/ps_auxcww | wc -l
287
$ cat ./test-host2-20161207134705/insights_commands/ps_aux | wc -l
1
$ cat ./test-host2-20161207134705/insights_commands/ps_auxcww | wc -l
293

$ grep chrony */insights_commands/ps_*
test-host1-20161207134651/insights_commands/ps_auxcww:chrony    1204  0.0  0.0 115848   888 ?        S    Nov09   0:11 chronyd

$ cat ./test-host1-20161207134651/insights_commands/ps_aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
qemu      5611  2.9 34.8 17453640 11409204 ?   Sl   Nov09 1181:42 /usr/libexec/qemu-kvm -name guest=RHEL7-RHV4-MANAGER2,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-RHEL7-RHV4-MANAGER2/master-key.aes -machine pc-i440fx-rhel7.2.0,accel=kvm,usb=off,vmport=off -cpu Nehalem -m 16384 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid ac7471aa-65da-4e01-946b-4fb6b520ce96 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-1-RHEL7-RHV4-MANAGER2/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew -global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 -boot strict=on -device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,a!
 ddr=0x6.0x1 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 -drive file=/dev/kvm_images/RHEL7-RHV4-MANAGER2,format=raw,if=none,id=drive-virtio-disk0,cache=none,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=28,id=hostnet0,vhost=on,vhostfd=30 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:e0:80:9b,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0,bus=usb.0,port=1 -vnc 0.0.0.0:0 -device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 -msg timestamp=on
qemu      5629 14.6 26.5 9252308 8695204 ?     Sl   Nov09 5887:46 /usr/libexec/qemu-kvm -name guest=WIN7,debug-threads=on -S -object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-2-WIN7/master-key.aes -machine rhel6.2.0,accel=kvm,usb=off -m 8192 -realtime mlock=off -smp 8,sockets=2,cores=2,threads=2 -uuid a9a120c7-119d-b40b-8b93-0975dafb73dd -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-2-WIN7/monitor.sock,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime,driftfix=slew -no-shutdown -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive file=/dev/kvm_images/WIN7,format=raw,if=none,id=drive-virtio-disk0,cache=none,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -drive file=/dev/kvm_images/WIN7-D,format=raw,if=none,id=drive-virtio-disk1,cache=none,aio=native -device virtio-blk-pci,scsi=off,bus!
 =pci.0,addr=0x8,drive=drive-virtio-disk1,id=virtio-disk1 -drive if=none,id=drive-ide0-1-0,readonly=on -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=29,id=hostnet0 -device e1000,netdev=hostnet0,id=net0,mac=52:54:00:07:21:1b,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -device usb-tablet,id=input0,bus=usb.0,port=1 -vnc 0.0.0.0:1 -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,bus=pci.0,addr=0x2 -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on

$ cat ./test-host2-20161207134705/insights_commands/ps_aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

I can confirm this bug in my local system:


[myhost-20161208161424]# cat ./insights_commands/ps_auxcww | wc -l
205
[myhost-20161208161424]# cat ./insights_commands/ps_aux | wc -l
1

[myhost-20161208161424]# cat ./insights_commands/ps_aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

[myhost-20161208161424]# rpm -q redhat-access-insights
redhat-access-insights-1.0.11-0.el7.noarch

Can you please help to look into this issue? Thanks!

Regards,
Flos

insights registeration

Hello,

After unregistering a system, i cannot reregister. Nor even the force-reregister works. We're getting:

redhat-access-insights --register
This machine has been unregistered
Use --register if you would like to re-register this machine
Exiting

TODO: Fix unit tests

Lots of code changes & renaming the RPM has broken the unit tests. Need to fix this

insingts-client can not work with python-requests 2.11

Error message:

self.prepare_headers(headers)\n', ' File "/usr/lib/python2.7/site-packages/requests/models.py", line 409, in prepare_headers\n check_header_validity(header)\n', ' File "/usr/lib/python2.7/site-packages/requests/utils.py", line 800, in check_header_validity\n "not %s" % (value, type(value)))\n', "InvalidHeader: Header value 0.96 must be of type str or bytes, not <type 'float'>\n"]

Root Cause
Non-strings for header values is not accepted by Requests from 2.11
See the issue: psf/requests#3477

In our code, it is float for duration.

In https://github.com/redhataccess/insights-client/blob/master/insights_client/connection.py

Line 782-783
headers = {'x-rh-collection-time': duration}
upload = self.session.post(upload_url, files=files, headers=headers)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.