#!/usr/bin/env python from subprocess import Popen, PIPE def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdout.read() return data def getDmi(): p = Popen(['dmidecode'], stdout=PIPE) data = p.stdout.read() …
#!/usr/bin/env python from subprocess import PIPE,Popen import re def getIfconfig(): p = Popen(['ifconfig'],stdout=PIPE) data = p.stdout.read().split('\n\n') return [i for i in data if i and not i.startswith('lo')] def parseIfconfig(data): re_devname…
#!/usr/bin/env python from subprocess import Popen, PIPE def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdout.read().split('\n\n') return [i for i in data if i and not i.startswith('lo')] def parseIfconfig(data):…
#!/usr/bin/env python from subprocess import PIPE,Popen def getDmi(): p = Popen(['dmidecode'],stdout=PIPE) data = p.stdout.read() return data def parseDmi(data): lines = [] line_in = False dmi_list = [i for i in data.split('\n') if i] for line in dmi…
#!/usr/bin/env python import os from subprocess import PIPE,Popen def getPids(): p = Popen(['pidof','httpd'],stdout=PIPE,stderr=PIPE) pids = p.stdout.read().split() return pids def parsePidFile(pids): http_sum = 0 for i in pids: fn = os.path.join('/p…
使用正则表达式收集主机信息 #!/usr/bin/env python from subprocess import Popen, PIPE import re def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdout.read().split('\n\n') return [i for i in data if i and not i.startswith('…
在网上找了一些MYSQL C API编程的文章,看了后认为还是写的不够充分,依据自己经验写了这篇<The MySQL C API 编程实例>,希望对须要调用到MYSQL的C的API的朋友有所帮助,附例中的环境为RedHat 在这篇文章里,我们将学会怎么使用MySQL 的C APIs(Application Programming Interfaces 编程接口).为了非常好地了解这篇文章,您须要具备下面前提知识: C语言变量 C语言函数 C语言指针 简单介绍 C APIs包括在mysqlcli…
linux下socket编程实例一.基本socket函数Linux系统是通过提供套接字(socket)来进行网络编程的.网络的socket数据传输是一种特殊的I/O,socket也是一种文件描述符.socket也有一个类似于打开文件的函数:socket(),调用socket(),该函数返回一个整型的socket的描述符,随后的连接建立.数据传输等操作也都是通过该socket实现.1.socket函数syntax: int socket(int domain, int type, int prot…