Can some one help me with below scenario i have lot of files in a folder in linux
where i have files with data like usually that data is per host and i will try to use nfs and key
add the size_total and say total value is this much but abc.com can we in multiple other files like example it can be part of 3 servers and raj.com can be part of 2 servers wat i'm doing now is
1856757743616+3078632562688,ioo.com but i'm supposed to do some thing like 1856757743616/3 + 3078632562688/2,ioo.com and say nas size of the ioo.com is 1856757743616/3 + 3078632562688/2.
i have also mentioned my code at the end can some one help with this
ioo.com
{"device": "abc.com:/ind", "fstype": "nfs", "mount": "/ind", "size_total": 1856757743616, "uuid": "N/A"}
{"device": "raj.com", "fstype": "nfs", "mount": "/rakesh", "size_total": 3078632562688, "uuid": "N/A"}]}
where i have files with data like usually that data is per host and i will try to use nfs and key
add the size_total and say total value is this much but abc.com can we in multiple other files like example it can be part of 3 servers and raj.com can be part of 2 servers wat i'm doing now is
1856757743616+3078632562688,ioo.com but i'm supposed to do some thing like 1856757743616/3 + 3078632562688/2,ioo.com and say nas size of the ioo.com is 1856757743616/3 + 3078632562688/2.
i have also mentioned my code at the end can some one help with this
ioo.com
{"device": "abc.com:/ind", "fstype": "nfs", "mount": "/ind", "size_total": 1856757743616, "uuid": "N/A"}
{"device": "raj.com", "fstype": "nfs", "mount": "/rakesh", "size_total": 3078632562688, "uuid": "N/A"}]}
path = '/home/raj/nfsstorage' valid_fs = ['nfs','NFS'] extensions = ['.com'] my_sql_data = list()This is my present code
for file in os.listdir(path) : vendor_total_size = 0L for extension in extensions: if file.endswith(extension): with open(file) as json_file: data = json.load(json_file) data_1 = data['ansible_facts'] size_tuple = {} my_sql_json = {} for j in range (0, len (data_1['ansible_mounts'])): key = data_1['ansible_mounts'][j]['fstype'] if(key in valid_fs): hostname = file siz_num = (data_1['ansible_mounts'][j]['size_total']) if siz_num is None: continue elif siz_num: vendor_total_size = vendor_total_size + siz_num / 1073741824 size_tuple[key] = vendor_total_size