[root@mysql8 python]# cat getLinuxInfo.py #!/usr/bin/env python import subprocess def uname_func(): uname = "uname" uname_arg = "-a" print "Gathing system information with %s command:/n" % uname subprocess.call([uname,uname_arg]) def disk_f
#!/usr/bin/env python
import subprocess
def uname_func():
uname = "uname"
uname_arg = "-a"
print "Gathing system information with %s command:/n" % uname
subprocess.call([uname,uname_arg])
def disk_func():
diskspace = "df"
diskspace_arg = "-h"
print "Gathering diskspace information %s command:/n" % diskspace
subprocess.call([diskspace, diskspace_arg])
def main():
uname_func()
disk_func()
if __name__ == "__main__":
main()[root@mysql8 python]# python getLinuxInfo.py
Gathing system information with uname command:
Linux mysql8 3.10.0-1160.el7.x86_64 #1 SMP Tue Aug 18 14:50:17 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
Gathering diskspace information df command:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.7M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/rhel-root 91G 6.5G 85G 8% /
/dev/sda1 1014M 140M 875M 14% /boot
tmpfs 799M 0 799M 0% /run/user/0
版权声明:本文为博主原创文章,未经博主允许不得转载。
Linux,oracle