xrmx / uwsgitop Goto Github PK
View Code? Open in Web Editor NEWtop-like app for monitoring uWSGI instances
License: MIT License
top-like app for monitoring uWSGI instances
License: MIT License
A tiny bug (but disturbing at first), when one tries to lookup the stats of an idle emperor, having no vassals yet:
$ sudo uwsgitop uwsgi-emperor-stats.sock
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 171, in
vassal_spaces = max([len(v['id']) for v in dd['vassals']])
ValueError: max() arg is an empty sequence
cat << EOF | tee uwsgi2.ini
[uwsgi]
#socket = /var/run/uwsgi.sock
# http = :9090
http = :5050
chmod-socket = 777
chdir = /workspace/app
module = config.wsgi:application
master = true
processes = 8
threads = 2
vacuum = true
harakiri = 30
max-requests = 10000
stats = :9202
memory-report = true
enable-threads = true
logger = internalservererror file:/tmp/uwsgi-errors.log
# auto-reading of POST content
# required when client sent HTTP POST request, but body
# wan't read by app as he does not have permission for
# this action
post-buffering = 1
uid = 1000
gid = 1000
# Graceful reload
touch-reload = uwsgi-reload
master-fifo = uwsgi-fifo
EOF
uwsgi --ini uwsgi2.ini
for i in {1..5}; do curl http://localhost:5050/admin/login/ &>/dev/null; done
uwsgi-2.0.19.1 - Fri Feb 5 22:03:13 2021 - req: 22 - RPS: 36559 - lq: 0 - tx: 47.6K
node: - cwd: /workspace/app - uid: 1000 - gid: 1000 - masterpid: 1220
WID % PID REQ RPS EXC SIG STATUS AVG RSS VSZ TX ReSpwn HC RunT LastSpwn
8 100.0 1238 22 36559 0 0 idle 6ms 98.3M 624.7M 47.6K 1 0 717.66 21:57:03
1 0.0 1224 0 0 0 0 idle 0ms 0 0 0 1 0 0.0 21:57:03
2 0.0 1226 0 0 0 0 idle 0ms 0 0 0 1 0 0.0 21:57:03
3 0.0 1228 0 0 0 0 idle 0ms 0 0 0 1 0 0.0 21:57:03
4 0.0 1230 0 0 0 0 idle 0ms 0 0 0 1 0 0.0 21:57:03
5 0.0 1232 0 0 0 0 idle 0ms 0 0 0 1 0 0.0 21:57:03
6 0.0 1234 0 0 0 0 idle 0ms 0 0 0 1 0 0.0 21:57:03
7 0.0 1236 0 0 0 0 idle 0ms 0 0 0 1 0 0.0 21:57:03
So it always increments the very first process with WID 8, but all others are staying 0.
So if I increase the number of curl requests to let's say
for i in {1..5}; do curl http://localhost:5050/admin/login/ &>/dev/null; done
then I do get process with 2 processes (visible at Linux top 98% one and around 17% another) doing the work, while all others are staying iddle with 0% CPU utilization, but still uwsgitop shows 0 for everyone but WID 8.
Am I missing something?
Running uwsgitop and then clicking on 'a' means not all information may be displayed. This is because if the number of lines generated exceeds the height of the screen, there is no way of scrolling to the bottom.
https://pypi.python.org/pypi/uwsgitop is at version 0.8, uploaded in February...
The dependency on argparse
requires it on all Python 2 versions:
Lines 15 to 17 in 423ab88
However argparse is part of the standard library in Python 2.7. The dependency should be
install_requires=[
'argparse;python_version<"2.7"',
],
This would prevent pip install
from complaining like this:
...
Found existing installation: argparse 1.2.1
Not uninstalling argparse at /usr/lib/python2.7, as it is in the standard library.
Can't uninstall 'argparse'. No files were found to uninstall.
...
I tried to use uwsgitop on a serial console of my test system. The console has $TERM
set to vt102
by default, which causes uwsgitop to crash:
# echo $TERM
vt102
# uwsgitop /run/uwsgi/myapp.stats
Traceback (most recent call last):
File "/usr/bin/uwsgitop", line 66, in <module>
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
error: init_pair() returned ERR
When I use emperor parameters to start the uwsgi server, can I watch multiple uwsgi instance in uwsgitop?
WID % PID REQ RPS EXC SIG STATUS AVG RSS VSZ TX RunT
1 0.0 4452 0 0 0 0 idle 0ms 0 0 0 0q
I want to save the output of uwsgitop
at a certain time into a text, so that I can use some scripts to analyze the state of uwsgi at a certain time.
I know that the top
command can get a static result using top -n 1
But I don't know how to do with uwsgitop.
While running uwsgitop, resizing the window causes the process to crash, due to a socket error (line 141: [Errno 4] Interrupted system call).
This is on OS X / python 2.7.
In development environment, uwsgi applications are run in reloadable mode. (ie, py-autoreload=1). But, when I use uwsgitop along with it, uwsgitop fails with urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
on every reload.
Is it possible to catch this exception and retry to connect after a few seconds by introducing a re-loadable mode in uwsgitop ?
I get the following error when trying to run uwsgitop with python3.X:
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 110, in
js += data
TypeError: Can't convert 'bytes' object to str implicitly
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 112, in
raise Exception("unable to get uWSGI statistics")
Exception: unable to get uWSGI statistics
got this exception when execute the command:uwsgitop http://127.0.0.1:9191.
is that because I use Python3.6 ? and how to solove this ? thanks.
I get:
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 149, in <module>
screen.addstr(pos, 0, " %s\t%d" % (vassal['id'].ljust(vassal_spaces), vassal['pid']))
error: addstr() returned ERR
Think it could be some problem with curses being confused about the size of the terminal it has available? http://ubuntuforums.org/showthread.php?t=457689
I don't see any processes/rows in the output of uwsgitop command:
uwsgi-1.2.3-debian - Wed May 24 19:56:30 2017 - req: 0 - RPS: 0 - lq: 0 - tx: 0
node: vm9037 - cwd: /home/archivis/public_html/archivis2/source - uid: 0 - gid: 0 - masterpid: 2878
WID % PID REQ RPS EXC SIG STATUS AVG RSS VSZ TX ReSpwn HC RunT LastSpwn
config:
[uwsgi]
plugins = python
master = true
processes = 10
socket = /tmp/uwsgi_archivis2_archivuj_sk.sock
stats = /tmp/uwsgi_archivis2_archivuj_sk_stats.sock
memory-report = true
chmod-socket = 666
chdir = /home/archivis/public_html/archivis2/source
module = archivis.wsgi.archivuj
home = /home/archivis/environment
vacuum = true
pidfile = /tmp/uwsgi_archivis2_archivuj_sk.pid
logto = /home/archivis/logs/uwsgi_archivis2_archivuj_sk.log
LC_ALL = en_US.UTF-8
LANG = en_US.UTF-8
;catch-exceptions = true
Any ideas? Thank you in advance.
uWSGI = "2.0.19.1"
uwsgitop = "^0.11.0"
and uwsgi.ini config:
memory-report = true
but the rss value always 0,
"rss":0,
"vsz":0,
"uss":0,
"pss":0,
someone occured ?
Hi,
We are running multiple apps on a host with uwsgi emperor mode and I'm interested in running uwsgitop.
/usr/local/bin/uwsgi -s :3031 --emperor-stats /usr/local/uwsgi/emperor-stats.socket --udp 172.18.5.1:2222 --snmp --snmp-community public --enable-metrics --emperor /usr/local/uwsgi/vassals/ --emperor-tyrant --pidfile /var/run/uwsgi.pid --vacuum --daemonize /var/log/uwsgi.log
I then run uwsgitop with:
uwsgitop /usr/local/uwsgi/emperor-stats.socket
but the only thing shown is a list of the apps/vassals and their PIDs, e.g.:
uwsgi-1.9.19-dev - Wed Nov 13 10:34:55 2013 - emperor: [u'/usr/uwsgi/vassals'] - tyrant: 1
node: myhost - cwd: /usr/uwsgi/vassals - uid: 0 - gid: 0 - masterpid: 17778
VASSAL PID
site01.xml 17779
someapp.xml 17780
foo.xml 17781
bar.xml 17782
Perhaps I'm starting the uwsgi server with the wrong options? We are working on collecting stats via snmp as well, so not sure if that's messing things up. Thanks for the help.
uWSGI (2.0.12)
uwsgitop (0.9)
Using either python34 or python27 I get the following:
[root@blackbox nginx]# uwsgitop /home/idbill/flask/toystore.sock
Traceback (most recent call last):
File "/bin/uwsgitop", line 171, in <module>
dd = json.loads(js)
File "/usr/lib64/python2.7/site-packages/simplejson/__init__.py", line 516, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib64/python2.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
(venv)[idbill@blackbox flask]$ uwsgitop toystore.sock
Traceback (most recent call last):
File "/home/idbill/flask/venv/bin/uwsgitop", line 171, in <module>
dd = json.loads(js)
File "/opt/rh/rh-python34/root/usr/lib64/python3.4/site-packages/simplejson/__init__.py", line 505, in loads
return _default_decoder.decode(s)
File "/opt/rh/rh-python34/root/usr/lib64/python3.4/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/opt/rh/rh-python34/root/usr/lib64/python3.4/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
(venv)[idbill@blackbox flask]$
Could you consider adding support for reading the address from an environment variable, like UWSGITOP_ADDRESS
, so that you could define the address beforehand and then be able to just run uwsgitop
rather than remember the full path to the socket each time you want to run uwsgitop
?
Hi,
I have uwsgi running a stats server as follows -
stats = /tmp/uwsgi-statsock
uwsgitop is started as - uwsgitop /tmp/uwsgi-statsock
It loads up just fine and I see the 4 uwsgi processes.
However when I access the app via the browser, uwsgitop exists with the following message.
easilydo_executor@ip-10-112-249-191:~$ uwsgitop /tmp/uwsgi-statsock
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 95, in
dd = json.loads(js)
File "/usr/local/lib/python2.7/dist-packages/simplejson/init.py", line 451, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 406, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 424, in raw_decode
obj, end = self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Invalid control character at: line 12 column 46 (char 722)
I re-ran uwsgi with stats on a network socket. Same problem - but slightly different error message
easilydo_executor@ip-10-112-249-191:~$ uwsgitop 127.0.0.1:9091
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 95, in
dd = json.loads(js)
File "/usr/local/lib/python2.7/dist-packages/simplejson/init.py", line 451, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 406, in decode
obj, end = self.raw_decode(s)
File "/usr/local/lib/python2.7/dist-packages/simplejson/decoder.py", line 424, in raw_decode
obj, end = self.scan_once(s, idx=_w(s, idx).end())
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte
In this line:
https://github.com/xrmx/uwsgitop/blob/master/uwsgitop#L271
we check for rss == 0, and if true the color of the curses pair is set to red.
Unfortunately if no memory-reporting is enabled, rss is always 0
I found so odd that this obvious mistake lives so old that I'm asked myself if this is a thing to remember where the shell is from or nobody use this handy remote monitoring feature. But I feel this is one, so ... :)
$ uwsgitop remote-hostname:9191
displays
uwsgi-2.0.2 ............
node: local-hostname ...
This may be patched simply like this :
diff --git a/uwsgitop b/uwsgitop
index 2aacdaf..5ab2f7c 100644
--- a/uwsgitop
+++ b/uwsgitop
@@ -199 +199 @@ while True:
- screen.addstr(1, 0, "node: %s %s %s %s %s" % (socket.gethostname(), cwd, uid, gid, masterpid))
+ screen.addstr(1, 0, "node: %s %s %s %s %s" % (addr_tuple[0] or socket.gethostname(), cwd, uid, gid, masterpid))
regards
First time I tried uwsgitop, I got this error :
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 61, in
curses.curs_set(0)
error: curs_set() returned ERR
I think you should try catch line 61 because it's not always possible to change the visibility of the cursor.
Same problem here : https://bugs.launchpad.net/ubuntu/+source/kdebase/+bug/368670
unbit says:
we should add k,m,g, t ... suffix to req too (and make %.2f approximation for RunT)
https://github.com/unbit/uwsgitop/blob/master/LICENSE says that you're using the MIT license. Could you also link to this in setup.py? I.e. license="MIT"?
OS : Debian 11 ( bullseye )
uWSGI version : 2.0.19.1-7.1
app configuration
[uwsgi]
module = test:create_app()
master = true
enable-threads = true
processes = 1
listen = 800
thunder-lock = true
lazy-apps = true
no-orphans = true
die-on-term = true
stats = 127.0.0.1:9191
plugin = python3
socket = /run/uwsgi/app/test/socket
chmod-socket = 600
uid = www-data
gid = www-data
vacuum = true
log-4xx = True
log-5xx = True
py-tracebacker = /tmp/tbsocket
Then when trying to use uwsgitop
$ uwsgitop http://127.0.0.1:9191
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 162, in main
r = urllib2.urlopen(addr)
File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.9/urllib/request.py", line 517, in open
response = self._open(req, data)
File "/usr/lib/python3.9/urllib/request.py", line 534, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/usr/lib/python3.9/urllib/request.py", line 494, in _call_chain
result = func(*args)
File "/usr/lib/python3.9/urllib/request.py", line 1375, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/lib/python3.9/urllib/request.py", line 1350, in do_open
r = h.getresponse()
File "/usr/lib/python3.9/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/lib/python3.9/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.9/http/client.py", line 289, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: {
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 331, in <module>
main()
File "/usr/local/bin/uwsgitop", line 179, in main
raise Exception("unable to get uWSGI statistics")
Exception: unable to get uWSGI statistics
When using uWSGI with the gevent loop with many async cores running on a single worker, uwsgitop will show statistics for the one worker only, which is not very useful.
It should be possible to display status of the async cores too.
A "picture" tells more than words:
6 45.5 54736 39032695 12 0 0 idle 14ms 0 0 71.0G 1 0 24469m 11:27:02
5 17.5 54734 15012872 4 0 0 idle 37ms 0 0 28.0G 1 0 10254m 11:27:02
1 9.9 54728 8511127 0 0 0 idle 17ms 0 0 15.0G 1 0 5622m 11:27:02
2 9.7 54729 8303945 1 0 0 idle 10ms 0 0 15.0G 1 0 5308m 11:27:02
4 9.0 54731 7739046 8 0 0 idle 42ms 0 0 14.0G 1 0 5437m 11:27:02
3 8.3 54730 7153563 1 0 0 idle 24ms 0 0 13.0G 1 0 5017m 11:27:02
0 0.0 0 0 0 0 0 cheap 0ms 0 0 0 0 0 0 --:--:--
So first two lines , where req count column has one digit more than the others shifts following columns but not the case for the rows with one digit less. Results in inconsistent view and hard to compare screen.
When I try to install uwsgitop
in a Ubuntu docker container:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
This is what I get:
# pip install uwsgitop
Collecting uwsgitop
Downloading https://files.pythonhosted.org/packages/8a/7a/9501084f6d2739b8a7d35ef5fb9cb539edb6e0a0d559366598b82bb7a96e/uwsgitop-0.11.tar.gz
Complete output from command python setup.py egg_info:
error in uwsgitop setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected version spec in argparse;python_version<"3" at ;python_version<"3"
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-HeNQon/uwsgitop/
Tested on pip==18.1
Please note that pip install "uwsgitop==0.10"
works fine.
Execute the command "uwsgitop uwsgi/uwsgi.status" to monitor my web performance status, the following problems occur:
"Traceback (most recent call last):
File "/webSite/ProjectVenv/CHYBlog/bin/uwsgitop", line 331, in
Main()
File "/webSite/ProjectVenv/CHYBlog/bin/uwsgitop", line 166, in main
S.connect(addr)
ConnectionRefusedError: [Errno 111] Connection refused
”
what should I do
when i run uwsgitop uwsgistats.socket,a error come:
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 5, in <module>
pkg_resources.run_script('uwsgitop==0.9', 'uwsgitop')
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 528, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1401, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/uwsgitop-0.9-py2.7.egg/EGG-INFO/scripts/uwsgitop", line 84, in <module>
error: use_default_colors() returned ERR
$ uwsgitop http://127.0.0.1:9191
Traceback (most recent call last):
File "/usr/local/bin/uwsgitop", line 167, in
js = r.read().decode('utf8', 'ignore')
File "/usr/lib/python2.7/socket.py", line 355, in read
data = self._sock.recv(rbufsize)
File "/usr/lib/python2.7/httplib.py", line 612, in read
s = self.fp.read(amt)
File "/usr/lib/python2.7/httplib.py", line 1416, in read
return s + self._file.read(amt - len(s))
File "/usr/lib/python2.7/socket.py", line 384, in read
data = self._sock.recv(left)
error: [Errno 104] Connection reset by peer
My runtime is python2.7.12
so how to fix it, thanks.
Initially the server runs fine but I get a connection reset by peer whenever I refresh a page on the server:
Traceback (most recent call last):
File "/bin/uwsgitop", line 167, in <module>
js = r.read().decode('utf8', 'ignore')
File "/usr/lib64/python2.7/socket.py", line 351, in read
data = self._sock.recv(rbufsize)
File "/usr/lib64/python2.7/httplib.py", line 602, in read
s = self.fp.read(amt)
File "/usr/lib64/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
error: [Errno 104] Connection reset by peer
uwsgi version 2.0.14
python version 2.7.5
All running on CentOS 7.2.1511 (Core)
It would be nice to show the date of the latest reload and the uptime
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.