I am beginner in the python, I am writing a python script to verify the utilization of each mount point is above the threshold or not. I am able invoke the shell command and save the output to a variable. But I am not able to use the variable to split the fields, check the utilization is above the threshold and report the fault
/dev/mapper/system-root 20G 18G 1.4G 93% /
udev 3.9G 248K 3.9G 1% /dev
tmpfs 3.9G 68K 3.9G 1% /dev/shm
/dev/sda1 251M 71M 167M 30% /boot
/dev/mapper/system-oracle 128G 43G 79G 36% /opt/app/oracle
/dev/mapper/system-tmp 5.5G 677M 4.5G 13% /tmp
/dev/mapper/system-log 3.0G 140M 2.7G 5% /var/log
/dev/mapper/system-varsog 20G 654M 19G 4% /var/sog
/dev/mapper/system-backup 50G 24G 24G 50% /var/sog/backups
I want to store field 5 and field 6 in an associative array and validate the Field 5 with threshold and report if it is above the threshold value.
I used below script to store the shell command output and now I need to process by splitting its Fields but I am not able to store it in array as it is multidimensional, So should I need to use For Loop to store in different array.
It is very easy to do in shell ,awk and perl but it seems to be very difficult python.
>>> import sys, os, time, threading, subprocess,datetime
>>> diskinfo_raw = subprocess.Popen("df -h", shell=True,stdout=subprocess.PIPE)
>>> output = diskinfo_raw.communicate()[0]
>>> print output
Please help me with an idea or reference please. I have explored option with loadtxt
option but I don't want to store the values in the file and again read it.