diff options
author | luk3yx <luk3yx@users.noreply.github.com> | 2022-03-19 17:12:19 +1300 |
---|---|---|
committer | luk3yx <luk3yx@users.noreply.github.com> | 2022-03-19 17:12:19 +1300 |
commit | fcd3e87793f44c20c92bdadb4c12c4915b7b411e (patch) | |
tree | db08580af3351d9ec18ba92f94dd120056101fb5 /debug.py | |
download | lurklite-commands-fcd3e87793f44c20c92bdadb4c12c4915b7b411e.tar.gz lurklite-commands-fcd3e87793f44c20c92bdadb4c12c4915b7b411e.zip |
Initial public commit
Diffstat (limited to 'debug.py')
-rw-r--r-- | debug.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/debug.py b/debug.py new file mode 100644 index 0000000..e888014 --- /dev/null +++ b/debug.py @@ -0,0 +1,18 @@ +import time, subprocess + +def get_free_ram(): + output = subprocess.check_output(('free', '-h')) + return output.split(b'\n', 2)[1].rsplit(b' ', 1)[-1].decode('utf-8') + +@register_command('collectgarbage', requires_admin=True) +def collectgarbage(irc, hostmask, is_admin, args): + import gc + ram = get_free_ram() + t1 = time.time() + gc.collect() + irc.msg(args[0], f'Done in {time.time() - t1} seconds.\n' + f'Previous ram usage: {ram}, current RAM usage: {get_free_ram()}') + +@register_command('get_free_ram', requires_admin=True) +def get_free_ram_cmd(irc, hostmask, is_admin, args): + irc.msg(args[0], f'Free RAM: {get_free_ram()}') |