X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/b79721eec298caeaedf33fbfe401c8ada1876791..591964e837ca06bef75e99a022dbb09582488f51:/modules/resources.py diff --git a/modules/resources.py b/modules/resources.py index abd2c35..35feebd 100644 --- a/modules/resources.py +++ b/modules/resources.py @@ -19,8 +19,9 @@ modstop = lib.modstop # module code import resource -@lib.hook('ram', needchan=False, glevel=lib.MANAGER) -def cmd_ram(bot, user, chan, realtarget, *args): +@lib.hook(needchan=False, glevel=lib.MANAGER) +@lib.help(None, "show RAM usage") +def ram(bot, user, chan, realtarget, *args): if chan is not None and realtarget == chan.name: replyto = chan else: replyto = user @@ -29,10 +30,11 @@ def cmd_ram(bot, user, chan, realtarget, *args): except: res = resource.getrusage(resource.RUSAGE_SELF) - bot.msg(replyto, "Memory usage (MiB): %r" % (res.ru_maxrss/1024.0)) + bot.fastmsg(replyto, "Memory usage (MiB): %r" % (res.ru_maxrss/1024.0)) -@lib.hook('resources', needchan=False, glevel=lib.MANAGER) -def cmd_resources(bot, user, chan, realtarget, *args): +@lib.hook(needchan=False, glevel=lib.MANAGER) +@lib.help(None, "show resource usage") +def resources(bot, user, chan, realtarget, *args): if chan is not None and realtarget == chan.name: replyto = chan else: replyto = user @@ -41,16 +43,16 @@ def cmd_resources(bot, user, chan, realtarget, *args): except: res = resource.getrusage(resource.RUSAGE_SELF) - bot.msg(replyto, "Resource usage:") - for i, v in [ + bot.slowmsg(replyto, "Resource usage:") + for i, v in ( ('utime (s)', res.ru_utime), ('stime (s)', res.ru_stime), - ('memory (MiB)', (res.ru_maxrss/1024.0)) + ('memory (MiB)', (res.ru_maxrss/1024.0)), ('I/O (blocks)', res.ru_inblock+res.ru_oublock), ('page faults', res.ru_majflt), ('signals', res.ru_nsignals), ('context switches (voluntary)', res.ru_nvcsw), ('context switches (involuntary)', res.ru_nivcsw), - ]: - bot.msg(replyto, "- %s: %r" % (i, v)) - bot.msg(replyto, "EOL.") + ): + bot.slowmsg(replyto, "- %s: %r" % (i, v)) + bot.slowmsg(replyto, "EOL.")