Univention Bugzilla – Bug 33792
UMC printer quota: displaying the quota takes very long if there are many users
Last modified: 2016-04-27 17:31:58 CEST
univention-printserver/umc/python/printers/__init__.py runs /usr/bin/pkusers --list to get all users and than repykota -P printer user for every user to get the print quota settings for a printer. This takes a very long time if there are many users (1200). Better run repykota -P printer once and parse the output, which contains the quota settings for all users. -> repykota -P printer2 Report für user Kontingent auf Drucker printer2 () Schonfrist: 7 Tage Preis pro Auftrag: 3.000 Preis pro Seite: 1.000 User overcharge used soft hard balance grace total paid warn ----------------------------------------------------------------------------------------------- test1 -Q 1.0 3 10 20 -12.00 3 0.00 0 test2 -Q 1.0 4 10 20 -16.00 4 0.00 0 Gesamt : 7 0.00 Real : 6
Ticket: #2013121721002391
Happened now again, in a UCS@School environment. Ticket#2016041521000208
AFAIK there is no real version "UNSTABLE". Setting Version to 4.0 because that's what is used in the last mentioned ticket (probably also valid for 4.1, but I didn't test that).
first we need a patch for the customer, that fixes the long access time in the UMC module
Created attachment 7607 [details] umc-printers.patch apply patch with: -> patch -p1 /usr/share/pyshared/univention/management/console/modules/printers/__init__.py umc-printers.patch -> /etc/init.d/univention-management-console-server restart
Modified list_quota() in printers/__init__.py. repykota can't be used here (truncates usernames after 15 characters). Instead the PyKotaTool and pykota.reporter python libs are used to generate a html report (with full usernames, repykota does not support html reports). lxml.html is used to parse the html ouput. univention-printserver: r68843 YAML: univention-printserver.yaml
The patch works and is much faster. But in case postgres is down the error message is the following: """ Die Anfrage konnte nicht ausgeführt werden. Fehlernachricht des Servers: Die Verbindung zur Print-Quota Postgres Datenbank konnte nicht hergestellt werden: konnte nicht mit dem Server verbinden: Verbindungsaufbau abgelehnt Läuft der Server auf dem Host »localhost« (::1) und akzeptiert er TCP/IP-Verbindungen auf Port 5432? konnte nicht mit dem Server verbinden: Verbindungsaufbau abgelehnt Läuft der Server auf dem Host »localhost« (127.0.0.1) und akzeptiert er TCP/IP-Verbindungen auf Port 5432? --- the most probable cause of your problem is that PostgreSQL is down, or doesn't accept incoming connections because you didn't configure it as explained in PyKota's documentation. """ → The message contains duplicated sentences and blames the user, that's not good. Please only log the exception to MODULE.error() but don't expose it to the user. The first sentence is enough. Maybe add 'Please make sure the postgres service is running and reachable.'.
Created attachment 7617 [details] suggestions
(In reply to Florian Best from comment #8) > Created attachment 7617 [details] > suggestions OK, And another thing, reportTool.deferredInit() calls os.seteuid(pykota), so after opening the quota page the umc process is owned by the pykota user, this is not good. Added a "finally: reportTool.regainPriv()" after the pykota stuff.
Created attachment 7624 [details] umc-printers.patch new version of the patch with fixed pykota call (reportTool.regainPriv())
(In reply to Felix Botner from comment #10) > Created attachment 7624 [details] > umc-printers.patch OK > new version of the patch with fixed pykota call (reportTool.regainPriv()) OK: owner of the process is set back to "0".
<http://errata.software-univention.de/ucs/4.1/160.html>