| Conditions | 3 |
| Total Lines | 35 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import psutil |
||
| 9 | @guild_command(name="panel") |
||
| 10 | async def panel_command(self) -> Embed: |
||
| 11 | """Panel status command.""" |
||
| 12 | mb: int = 1024 ** 2 |
||
| 13 | |||
| 14 | vm = psutil.virtual_memory() |
||
| 15 | cpu_freq = psutil.cpu_freq() |
||
| 16 | cpu_percent = psutil.cpu_percent() |
||
| 17 | disk = psutil.disk_usage('../app/cogs') |
||
| 18 | |||
| 19 | stats = { |
||
| 20 | 'ram': ( |
||
| 21 | 100 * (vm.used / vm.total), |
||
| 22 | f'{(vm.total / mb) / 1000:,.3f}', |
||
| 23 | 'Gb' |
||
| 24 | ), |
||
| 25 | 'cpu': ( |
||
| 26 | cpu_percent, |
||
| 27 | f"{cpu_freq.current / 1000:.1f}`/`{cpu_freq.max / 1000:.1f}", |
||
| 28 | 'Ghz' |
||
| 29 | ), |
||
| 30 | 'disk': ( |
||
| 31 | 100 * (disk.used / disk.total), |
||
| 32 | f'{disk.total / mb:,.0f}', 'Mb' |
||
| 33 | ) |
||
| 34 | } |
||
| 35 | |||
| 36 | return Embed( |
||
| 37 | title="Panel Stats", |
||
| 38 | description="The pincer_bot is hosted on a private vps." |
||
| 39 | ).add_fields( |
||
| 40 | stats.items(), |
||
| 41 | map_title=lambda name: name.upper(), |
||
| 42 | map_values=lambda percent, info, unit: ( |
||
| 43 | f"> `{percent:.3f}` **%**\n- `{info}` **{unit}**" |
||
| 44 | ) |
||
| 49 |