Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No telemetry transmission #20

Open
mariusz1602 opened this issue Apr 28, 2022 · 2 comments
Open

No telemetry transmission #20

mariusz1602 opened this issue Apr 28, 2022 · 2 comments

Comments

@mariusz1602
Copy link

In RAW DATA and Overview - no telemetry data.

In RaspberryPi it only displays:

pi@raspberrypi:~ $ cd client
pi@raspberrypi:/client $ source ./.venv/bin/activate
(04_iot_central) pi@raspberrypi:
/client $ python raspberry_pi_client.py
Press Q to quit
Sending reported property: {'remaining_disk_space': '19G'}

Errors are displayed when the program is interrupted by Q.

Press Q to quit
q
Quitting...
Traceback (most recent call last):
File "/home/pi/client/raspberry_pi_client.py", line 296, in
asyncio.run(main())
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/pi/client/raspberry_pi_clie

nt.py", line 288, in main
await asyncio.gather(telemetry_loop, reported_loop)
File "/home/pi/client/raspberry_pi_client.py", line 161, in send_telemetry
payload = f'{{"cpu_temp": {get_current_cpu_temp()}, "cpu_freq": {get_cpu_frequency_statistics()["current"]}, "cpu_usage": {get_cpu_usage()}, "ram_usage": {get_memory_statistics()["used"]}}}'
File "/home/pi/client/raspberry_pi_client.py", line 91, in get_cpu_usage
return float(cpu_usage)

ValueError: could not convert string to float: ''
Task was destroyed but it is pending!

Please, can you tell me where this error came from ?
"line 91, in get_cpu_usage
return float(cpu_usage)**
ValueError: could not convert string to float: ''"

About, Commands - works ok.

raw_data
Overwiew

@mariusz1602
Copy link
Author

That was a problem:
#get CPU usage
def get_cpu_usage():
cpu_usage = str(os.popen("top -n1 | awk '/Cpu(s):/ {print $2}'").readline().strip())
return float(cpu_usage)

When I commented on this, the telemetry transmission works. so something wrong in the definition of reading CPU.

@mariusz1602
Copy link
Author

mariusz1602 commented May 4, 2022

This work:
def get_cpu_usage():
cpu_usage = str(os.popen("top -n1 | awk '/%CPU:/ {print $3 + $5}' | tr ',' '.'").readline().strip())
return float(cpu_usage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant