Skip to content

Commit

Permalink
some logging for high usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Serafadam committed Feb 28, 2024
1 parent 3c23bbc commit ad298b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rae_hw/scripts/sys_info_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,22 @@ def on_shutdown(self, state: LifecycleState) -> TransitionCallbackReturn:

def timer_callback(self):
cpu = psutil.cpu_percent()
if cpu > 90:
self.get_logger().warn(f'CPU usage is {cpu}%')
mem = psutil.virtual_memory().percent
if mem > 90:
self.get_logger().warn(f'Memory usage is {mem}%')
temp = psutil.sensors_temperatures()
net = psutil.net_io_counters()
disk = psutil.disk_usage('/').percent
self._cpu_pub.publish(Float32(data=cpu))
self._mem_pub.publish(Float32(data=mem))
self._disk_pub.publish(Float32(data=disk))
if not self._mock:
self._temp_pub.publish(Temperature(temperature=temp['bq27441_0'][0].current))
curr_temp = temp['bq27441_0'][0].current
if curr_temp > 50:
self.get_logger().warn(f'Temperature is {curr_temp}°C')
self._temp_pub.publish(Temperature(temperature=curr_temp))

mbs_up = (net.bytes_sent - self._prev_bytes_sent) / 1024 / 1024
mbs_down = (net.bytes_recv - self._prev_bytes_recv) / 1024 / 1024
Expand Down

0 comments on commit ad298b5

Please sign in to comment.