Hi, an example in python 2.7 (for Python 3 you need to add e.g. errors='ignore' to the parameters of the Popen call to get the proper kind of text stream as output. import subprocess import csv mmlsfileset = subprocess.Popen(['/usr/lpp/mmfs/bin/mmlsfileset', args.filesystem, '-Y'], stdout=subprocess.PIPE) reader = csv.DictReader(mmlsfileset.stdout, delimiter=':') filesets=[] for row in reader: if row['status'] == 'Linked': filesets.append({'name':row['filesetName'], 'linkdir':urllib.unquote(row['path'])}) mmlsfileset.wait() ----- Original Message -----
From: "Billich Heinrich Rainer (ID SD)" <heinrich.billich@id.ethz.ch> To: "gpfsug main discussion list" <gpfsug-discuss@spectrumscale.org> Sent: Wednesday, 27 May, 2020 10:41:11 Subject: [gpfsug-discuss] Parse -Y command output
Hello,
I wonder if any python or bash functions exist to parse the output of mm-command's -Y format, i.e. colon-separated with HEADER rows. I would be nice to convert the output to a python list of named tuples or even better pandas dataframe. I would like to access the values by column name and row index. This would allow to do quick scripts or reports easily. Imagine using a jupyter notebook to dig into mmrepquota or mmlsdisk output, even doing charts, ..., easily.
I know the ReST interface does exisit, which I could call to get the data in Json format, but to parse the Y-format seems much less cumbersome and allows to collect the data at one time and process it later.
If you have other suggestions please let me know. What I would like to get: A list of NSDs which shows the connection to vdisk-set. Vdisk, recovery group and ESS system for each NSD. To get this I need to merge at least two tables. A list of user of fileset quota values highlighting those having non-default vaulues or close to the limit. The ability to get the data quickly in an uniform way into some tool, preferably python, to do analysis or formatting.
Cheers,
Heiner
_______________________________________________ gpfsug-discuss mailing list gpfsug-discuss at spectrumscale.org http://gpfsug.org/mailman/listinfo/gpfsug-discuss
