async def hostinfo(self, ctx): """List info about the bot's host environment.""" message = await ctx.channel.send('Gathering info...') # cpuCores = psutil.cpu_count(logical=False) # cpuThred = psutil.cpu_count() cpuThred = os.cpu_count() cpuUsage = psutil.cpu_percent(interval=1) memStats = psutil.virtual_memory() memPerc = memStats.percent memUsed = memStats.used memTotal = memStats.total memUsedGB = "{0:.1f}".format(((memUsed / 1024) / 1024) / 1024) memTotalGB = "{0:.1f}".format(((memTotal / 1024) / 1024) / 1024) currentOS = platform.platform() system = platform.system() release = platform.release() version = platform.version() processor = platform.processor() botMember = DisplayName.memberForID(self.bot.user.id, ctx.message.guild) botName = DisplayName.name(botMember) currentTime = int(time.time()) timeString = ReadableTime.getReadableTimeBetween( self.startTime, currentTime) pythonMajor = sys.version_info.major pythonMinor = sys.version_info.minor pythonMicro = sys.version_info.micro pythonRelease = sys.version_info.releaselevel pyBit = struct.calcsize("P") * 8 process = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], shell=False, stdout=subprocess.PIPE) git_head_hash = process.communicate()[0].strip() threadString = 'thread' if not cpuThred == 1: threadString += 's' msg = '***{}\'s*** **Home:**\n'.format(botName) msg += '```\n' msg += 'OS : {}\n'.format(currentOS) msg += 'Hostname : {}\n'.format(platform.node()) msg += 'Language : Python {}.{}.{} {} ({} bit)\n'.format( pythonMajor, pythonMinor, pythonMicro, pythonRelease, pyBit) msg += 'Commit : {}\n\n'.format(git_head_hash.decode("utf-8")) msg += ProgressBar.center( '{}% of {} {}'.format(cpuUsage, cpuThred, threadString), 'CPU') + '\n' msg += ProgressBar.makeBar(int(round(cpuUsage))) + "\n\n" msg += ProgressBar.center( '{} ({}%) of {}GB used'.format(memUsedGB, memPerc, memTotalGB), 'RAM') + '\n' msg += ProgressBar.makeBar(int(round(memPerc))) + "\n\n" msg += '{} uptime```'.format(timeString) await message.edit(content=msg)
async def hostinfo(self, ctx): """Informasi host bot.""" message = await ctx.channel.send('Gathering info...') # cpuCores = psutil.cpu_count(logical=False) # cpuThred = psutil.cpu_count() cpuThred = os.cpu_count() cpuUsage = psutil.cpu_percent(interval=1) memStats = psutil.virtual_memory() memPerc = memStats.percent memUsed = memStats.used memTotal = memStats.total memUsedGB = "{0:.1f}".format(((memUsed / 1024) / 1024) / 1024) memTotalGB = "{0:.1f}".format(((memTotal / 1024) / 1024) / 1024) currentOS = platform.platform() system = platform.system() release = platform.release() version = platform.version() processor = platform.processor() botMember = DisplayName.memberForID(self.bot.user.id, ctx.message.guild) botName = DisplayName.name(botMember) currentTime = int(time.time()) timeString = ReadableTime.getReadableTimeBetween( self.startTime, currentTime) pythonMajor = sys.version_info.major pythonMinor = sys.version_info.minor pythonMicro = sys.version_info.micro pythonRelease = sys.version_info.releaselevel pyBit = struct.calcsize("P") * 8 process = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], shell=False, stdout=subprocess.PIPE) git_head_hash = process.communicate()[0].strip() threadString = 'thread' if not cpuThred == 1: threadString += 's' msg = '```\n' msg += 'OS : {}\n'.format(currentOS) msg += 'Hostname : {}\n'.format(platform.node()) msg += 'Language : Python {}.{}.{} {} ({} bit)\n\n'.format( pythonMajor, pythonMinor, pythonMicro, pythonRelease, pyBit) msg += 'Commit : {}\n\n'.format(git_head_hash.decode("utf-8")) CPU = ProgressBar.center( '{}% of {} {}'.format(cpuUsage, cpuThred, threadString), 'CPU') + '\n' #CPU += ProgressBar.makeBar(int(round(cpuUsage))) RAM = ProgressBar.center( '{} ({}%) of {}GB used'.format(memUsedGB, memPerc, memTotalGB), 'RAM') + '\n\n' #RAM += ProgressBar.makeBar(int(round(memPerc))) msg += '{} uptime```'.format(timeString) em = discord.Embed( color=0XFF8C00, description="**Owner**\n```\n[ACX] NvStar#9110\n```\n" "**Version**\n```\n3.282.0\n```\n" "**Informasi standar**\n```\nOS : Ubuntu 18.04 x86 LTS\nHostname: {}\nLanguage: Python {}.{}.{}.{} ({}bit)\nCPU : {}% of {} {}\nRAM : {} ({}%) of {}GB used\n```\n" "**Uptime**\n```\n{}\n```".format(platform.node(), pythonMajor, pythonMinor, pythonMicro, pythonRelease, pyBit, cpuUsage, cpuThred, threadString, memUsedGB, memPerc, memTotalGB, timeString)) em.set_author( name="Informasi host", icon_url= "https://cdn.discordapp.com/attachments/518118753226063887/725569194304733435/photo.jpg" ) em.set_footer(text="{}#{}".format(ctx.author.name, ctx.author.discriminator), icon_url="{}".format(ctx.author.avatar_url)) await message.edit(embed=em)