Win10远程桌面账号正确但连接失败的解决方法(使用微软AzureAD的账号)
百度到的那些改组策略之类的完全没用,花了一个小时左右,终于在谷歌找到了答案!
https://community.spiceworks.com/topic/2048258-logon-attempt-failed-via-remote-desktop-in-windows-10
需要修改RDP文件。
添加这一行:enablecredsspsupport:i:0
百度到的那些改组策略之类的完全没用,花了一个小时左右,终于在谷歌找到了答案!
https://community.spiceworks.com/topic/2048258-logon-attempt-failed-via-remote-desktop-in-windows-10
需要修改RDP文件。
添加这一行:enablecredsspsupport:i:0
subprocess.Popen
去调用snmpwalk
命令来收集交换机状态数据。snmpwalk
的并发量来提高收集速度的时候,我发现CPU是限制我的监控系统的瓶颈。监控系统状态 | us | sy | id | loadavg | snmpwalk平均进程数 | python进程占用CPU |
---|---|---|---|---|---|---|
未启动 | 1.2 | 0.6 | 98 | 1.48 | 不存在 | 不存在 |
启动后 | 16 | 29 | 49 | 3.42 | 26 | 50%~70% |
import threading
import time
import subprocess
def snmp(a):
time.sleep(5)
print(a)
for a in range(1,249):
threading.Thread(target=snmp,args=(a,), name=a).start()
print("Thread Start:",a)
import threading
import time
import subprocess
def snmp(a):
time.sleep(5)
subprocess.Popen(["echo",str(a),], bufsize=0, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
for a in range(1,101):
threading.Thread(target=snmp,args=(a,), name=a).start()
print("Thread Start:",a)
subprocess.Popen
执行时,sy瞬间飙高,us约16%,sy约65%。strace
来统计系统调用。对于上面的Popen开销测试代码,我先运行,然后在sleep(5)的时候迅速地把python的pid记下,运行strace命令,等python代码运行结束后,就会给出结果。这里的结果如下:strace: Process 28984 attached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 2.033028 16942 120 51 futex
0.00 0.000000 0 6 close
0.00 0.000000 0 1 brk
0.00 0.000000 0 1 rt_sigaction
0.00 0.000000 0 1 madvise
------ ----------- ----------- --------- --------- ----------------
100.00 2.033028 129 51 total
strace: Process 29205 attached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
99.92 374.189481 33959 11019 3144 futex
0.02 0.082074 9 8745 pread64
0.02 0.072160 7 11008 fcntl64
0.02 0.058213 6 9592 fstat64
0.01 0.030947 4 7494 5498 stat64
0.00 0.012808 512 25 wait4
0.00 0.009980 322 31 read
0.00 0.007934 12 665 lstat64
0.00 0.005470 260 21 _llseek
0.00 0.001788 81 22 write
0.00 0.001008 1 1338 666 open
0.00 0.000507 9 57 mmap2
0.00 0.000379 1 665 getcwd
0.00 0.000300 0 666 getpid
0.00 0.000282 0 729 close
0.00 0.000000 0 7 7 ioctl
0.00 0.000000 0 2 munmap
0.00 0.000000 0 1 1 sigreturn
0.00 0.000000 0 56 clone
0.00 0.000000 0 56 mprotect
0.00 0.000000 0 1 rt_sigaction
------ ----------- ----------- --------- --------- ----------------
100.00 374.473331 52200 9316 total
man futex
看一下: The futex() system call provides a method for waiting until a certain
condition becomes true. It is typically used as a blocking construct
in the context of shared-memory synchronization. When using futexes,
the majority of the synchronization operations are performed in user
space. A user-space program employs the futex() system call only when
it is likely that the program has to block for a longer time until the
condition becomes true. Other futex() operations can be used to wake
any processes or threads waiting for a particular condition.
pip3 install netsnmp-py3
进行安装。项目地址:https://github.com/xstaticxgpx/netsnmp-py3数据 | us | sy | id | loadavg | python占用CPU | 扫描一栋楼所需时间 |
---|---|---|---|---|---|---|
优化前 | 20 | 40 | 32 | 3.51 | 50%~90% | 约6分5秒 |
优化后 | 14 | 9 | 74 | 1.09 | 70% | 约3分23秒 |
netsnmp-py3
提供的函数来代替Popen执行snmp命令。rpm -q 软件名称
查询已安装的软件的包名rpm -qa
查询所有已安装的RPM包rpm -qf 文件路径
查询文件所在的包名rpm -ql 软件名称
查询软件的RPM包中文件的安装路径(如rpm -ql wireshark| grep bin
查找wireshark安装的可执行文件的路径)rpm -qi 软件名称
查询已安装的软件包的信息rpm -qpi RPM包路径
查询(未安装的)RPM包的信息rpm -i RPM包路径
安装RPM包-i
install,安装-v
verbose,显示安装过程的详细信息-h
hash,用#
显示进度条(100%为20个#
)rpm -ivh RPM包路径
安装RPM包,显示详细信息,显示进度条rpm -U RPM包路径
升级rpm -Uvh RPM包路径
升级,显示详细信息,显示进度条rpm -e 软件名称
卸载软件yum list installed
列出安装的软件yum list all
列出所有软件yum list 软件名称
列出软件yum info 软件名称
查询软件信息yum grouplist
列出包组yum groupinfo 包组名称
查询包组信息yum install 软件名称
安装软件yum -y install 软件名称
安装软件,所有选项默认yesyum groupinstall 包组名称
安装包组yum update 软件名称
升级软件yum groupupdate 包组名称
升级包组yum remove 软件名称
卸载软件yum groupremove 包组名称
卸载包组