(self)
| 38 | # /Stats entry point |
| 39 | @helper.encodeResponse |
| 40 | def actionStats(self): |
| 41 | import gc |
| 42 | import sys |
| 43 | from Ui import UiRequest |
| 44 | from Crypt import CryptConnection |
| 45 | import main |
| 46 | |
| 47 | |
| 48 | hpy = None |
| 49 | if self.get.get("size") == "1": # Calc obj size |
| 50 | try: |
| 51 | import guppy |
| 52 | hpy = guppy.hpy() |
| 53 | except: |
| 54 | pass |
| 55 | self.sendHeader() |
| 56 | |
| 57 | if "Multiuser" in PluginManager.plugin_manager.plugin_names and not config.multiuser_local: |
| 58 | yield "This function is disabled on this proxy" |
| 59 | return |
| 60 | |
| 61 | s = time.time() |
| 62 | |
| 63 | # Style |
| 64 | yield """ |
| 65 | <style> |
| 66 | * { font-family: monospace } |
| 67 | table td, table th { text-align: right; padding: 0px 10px } |
| 68 | .connections td { white-space: nowrap } |
| 69 | .serving-False { opacity: 0.3 } |
| 70 | </style> |
| 71 | """ |
| 72 | |
| 73 | # Memory |
| 74 | yield "rev%s | " % config.rev |
| 75 | yield "%s | " % main.file_server.ip_external_list |
| 76 | yield "Port: %s | " % main.file_server.port |
| 77 | yield "IP Network: %s | " % main.file_server.supported_ip_types |
| 78 | yield "Opened: %s | " % main.file_server.port_opened |
| 79 | yield "Crypt: %s, TLSv1.3: %s | " % (CryptConnection.manager.crypt_supported, CryptConnection.ssl.HAS_TLSv1_3) |
| 80 | yield "In: %.2fMB, Out: %.2fMB | " % ( |
| 81 | float(main.file_server.bytes_recv) / 1024 / 1024, |
| 82 | float(main.file_server.bytes_sent) / 1024 / 1024 |
| 83 | ) |
| 84 | yield "Peerid: %s | " % main.file_server.peer_id |
| 85 | yield "Time correction: %.2fs" % main.file_server.getTimecorrection() |
| 86 | |
| 87 | try: |
| 88 | import psutil |
| 89 | process = psutil.Process(os.getpid()) |
| 90 | mem = process.get_memory_info()[0] / float(2 ** 20) |
| 91 | yield "Mem: %.2fMB | " % mem |
| 92 | yield "Threads: %s | " % len(process.threads()) |
| 93 | yield "CPU: usr %.2fs sys %.2fs | " % process.cpu_times() |
| 94 | yield "Files: %s | " % len(process.open_files()) |
| 95 | yield "Sockets: %s | " % len(process.connections()) |
| 96 | yield "Calc size <a href='?size=1'>on</a> <a href='?size=0'>off</a>" |
| 97 | except Exception: |
nothing calls this directly
no test coverage detected