added uptime, but id does not work with hours. will fix later

This commit is contained in:
neersighted 2012-03-30 09:03:34 -07:00
parent 1a436f87bf
commit a49009c53c
3 changed files with 20 additions and 7 deletions

View File

@ -25,13 +25,13 @@ Unzip the resulting file, and continue to read this document.
## Install
Before you can run the bot, you need to install a few Python modules. These are `lXML`, `BeautifulSoup`, `MyGengo`, and `HTTPlib2`. These can be installed with PIP (The Python package manager):
Before you can run the bot, you need to install a few Python modules. These are `lXML`, `BeautifulSoup`, `psutil`, and `HTTPlib2`. These can be installed with PIP (The Python package manager):
`sudo pip install lxml`
`sudo pip install beautifulsoup`
`sudo pip install mygengo`
`sudo pip install psutil`
`sudo pip install httplib2`
@ -93,7 +93,7 @@ They can both be found in [#CloudBot](irc://irc.esper.net/cloudbot "Connect via
CloudBot runs on **Python** *2.7.x*. It is developed on **Debian** *Wheezy/Testing* and **Ubuntu** *11.10* with **Python** *2.7.2*.
It **requires Python modules** `lXML`, `BeautifulSoup`, `Enchant`, `MyGengo`, and `HTTPlib2`.
It **requires Python modules** `lXML`, `BeautifulSoup`, `Enchant`, `psutil`, and `HTTPlib2`.
The programs `screen` or `daemon` are recomended for the wrapper to run optimaly.

View File

@ -28,7 +28,7 @@ def stop(inp, nick=None, conn=None):
else:
conn.cmd("QUIT", ["Killed by %s." % nick])
time.sleep(5)
subprocess.call(["./cloudbot", "stop"])
os.execl(["./cloudbot", "stop"])
@hook.command(autohelp=False, adminonly=True)
def restart(inp, nick=None, conn=None):

View File

@ -1,9 +1,10 @@
import os
import re
import time
import psutil
import platform
from util import hook
def replace(text, wordDic):
rc = re.compile('|'.join(map(re.escape, wordDic)))
@ -24,9 +25,9 @@ def checkProc(checked_stats):
def mem(inp):
".mem -- Displays the bot's current memory usage."
if os.name == 'posix':
checked_stats = 'Threads VmRSS VmSize VmPeak VmStk'
checked_stats = 'Threads VmRSS VmSize VmPeak VmStk VmData'
stats = checkProc(checked_stats)
pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size'}
pretty_names = {'Threads': 'Active Threads', 'VmRSS': 'Real Memory', 'VmSize': 'Allocated Memory', 'VmPeak': 'Peak Allocated Memory', 'VmStk': 'Stack Size', 'VmData': 'Heap Size'}
stats = replace(stats, pretty_names)
return stats
@ -40,6 +41,18 @@ def mem(inp):
return 'error: operating system not currently supported'
@hook.command("up", autohelp=False)
@hook.command(autohelp=False)
def uptime(inp):
proc = psutil.Process(os.getpid())
up_time = proc.create_time
up_time = time.time() - up_time
up_time = time.localtime(up_time)
up_time = time.strftime("Uptime: %M:%S", up_time)
return up_time
@hook.command("system", autohelp=False)
@hook.command(autohelp=False)
def sys(inp):