| 197 | return data |
| 198 | |
| 199 | def process_for_create(self, get): |
| 200 | is_java_process = True |
| 201 | search = '' |
| 202 | |
| 203 | if hasattr(get, "is_java_process"): |
| 204 | is_java_process = get.is_java_process.strip() |
| 205 | if is_java_process in ("0", 0, False, "false"): |
| 206 | is_java_process = False |
| 207 | else: |
| 208 | is_java_process = True |
| 209 | if hasattr(get, "search"): |
| 210 | search = get.search.strip() |
| 211 | |
| 212 | res = [] |
| 213 | rep_bt_tomcat = re.compile(r"(/usr/local/bttomcat/.*)|(/www/server/(bt_)?tomcat(_web)?/.*)/jsvc") |
| 214 | rep_not_use = re.compile( |
| 215 | r"php|system|crond|NetworkManager|uwsgi|dotnet|bash|/www/server/tamper|mysql|nginx|httpd|tail|python|sshd" |
| 216 | ) |
| 217 | if is_java_process: |
| 218 | target_list = utils.jps() |
| 219 | all_spring_project_pid = self.all_spring_project_pid() |
| 220 | for pid in target_list: |
| 221 | if pid in all_spring_project_pid: |
| 222 | continue |
| 223 | try: |
| 224 | p = psutil.Process(pid) |
| 225 | if search and not (search in p.name() or search in ' '.join(p.cmdline())): # 有搜索条件,但不符合搜索条件 |
| 226 | continue |
| 227 | if rep_bt_tomcat.search(p.exe()): |
| 228 | continue |
| 229 | res.append( |
| 230 | { |
| 231 | "pid": pid, |
| 232 | "name": p.name(), |
| 233 | "exe": p.exe(), |
| 234 | "cmdline": p.cmdline(), |
| 235 | "username": p.username(), |
| 236 | "create_time:": p.create_time(), |
| 237 | "status": p.status(), |
| 238 | } |
| 239 | ) |
| 240 | except: |
| 241 | continue |
| 242 | |
| 243 | return res |
| 244 | |
| 245 | # 若未选择java进程, 则在所有进程中搜索 |
| 246 | for i in psutil.process_iter(["pid", "name", "exe", "cmdline", "username", "create_time", "status"]): |
| 247 | if not i.exe(): |
| 248 | continue |
| 249 | if rep_not_use.search(i.exe()): |
| 250 | continue |
| 251 | if search and not (search in i.name() or search in ' '.join(i.cmdline())): # 有搜索条件, 但不符合搜索条件 |
| 252 | continue |
| 253 | if rep_bt_tomcat.search(i.exe()): |
| 254 | continue |
| 255 | try: |
| 256 | res.append( |