准备工作 环境:Ubuntu 14.04 32bit 工具:dnspython 对应的shell工具:nslookup dig等 dns预备知识: 常用资源记录RR(Resource Records)类型 A记录: 主机名–> IP地址 MX记录: 定义邮件服务器域名 CNAME: 域名间映射 PTR: IP地址 –>主机名(反向解析) 更详细介绍参考博文《 [DNS]常见资源记录定义(Resource Record) 》 用法举例 查询A记录 import dns.resolver domain = raw_input(‘input an domain:’) A = dns.resolver.query(domain, ‘A’) for i in A.response.answer: for j in i.items: if ‘address’ in dir(j): print j.address else: print ‘failed to […]

环境:ubuntu 14.04 32bit 工具:psutil 对应的shell工具:ps top lsof netstat ifconfig who df kill nice free ionice iostat iotop uptime pidof tty taskset pmap 安装: 采用pip可以安装pip install psutil。(注意需要安装python-dev: sudo apt-get install python-dev) 用法举例: 获取信息 cpu信息: psutil.cpu_times() #cpu完整信息 psutil.cpu_count(logical=False) #cpu物理个数 logical默认为True即cpu逻辑个数 内存信息: mem = psutil.virtual_memory() <!–more–> print mem.total print mem.free print mem.swap_memory() # sswap分区信息 磁盘信息 网络信息 其他信息 进程管理 […]