PP-483: As a user or admin, I would like qstat to return a full job attribute list with 1 line per job attribute, so that I can more easily use tools like grep to find the information I am looking for regarding my jobs

Hi Jon,
This page is not accessible. Can you update the link if you have moved the page?

It would also be useful if we could do a wide output that did not cut off the job name if it was longer then the 15 or so characters when I do a qstat -aw.

It looks like the page was restricted some how. It is now no longer restricted.

FYI:
I tried this , this works great
qstat -f | column -t -x -c 20

Hi Jon,
I don’t get what’s the use of adding an additional option whose effect will be visible only when certain attributes values is greater than 78 characters. If none of the attributes have value greater than 78 character , the output for both qstat -f and qstat -f1 will be same. To me -1 doesn’t look very meaningful either, since attributes are already shown in new line.

I feel we should extend -f option to accept an optional argument like “pretty” or “wide” and keep one of them as default. Where option “pretty” will trim and add new line to values greater than 78, whereas option “wide” will not.

Adding an option like -1 gives an idea that it can be used with other existing option of qstat, which I don’t think is intended in this requirement otherwise it should be added in the EDD.

eg. like what happens if user runs : qstat -1 job.id.

Regards
Dilip

Hi @dilip-krishnan,

This option will be helpful while parsing the job information. You can refer this link in the forum where the same requirement is demanded. The question of -1 over other options is debatable. But I would prefer -1 as list command uses this.(ls -1).
-1 list one file per line (from ls man page)
Our requirement is similar to this as we list one job attribute per line.
The EDD also explains that "-1" is used in conjunction with "-f".

Hi @nithinj,
I understand the requirement and it’s importance. And my understanding is that we want to provide user
qstat -f output without word wrapping. As per convention -1 option prints related information in single line hence this can misguide the user, since user can expect output of “qstat -f1” to print each individual job and its related information in a single line.

In general -1 option in command is for single line and not for word wrapping. If we use -1 with “qstat -f” to addressed this requirement, then it will be inconsistent with existing behaviour of “qstat -s1” and “qstat -n1” ( which print each job related information in single line) and other linux commands like ls,dir.

I feel better approach would be to extend existing -f option of qstat, to accept an argument to avoid word wrapping.
eg. “qstat -f wide”

I think that is a good suggestion, since -1 does indeed already have a different meaning for other qstat options. Rather than “wide”, though, what about using the existing “-w”? Currently qstat -fw has no official function (it is not shown as a supported combination of options in the usage). In practice it appears to produce the same output as qstat -aw.

Hi Scott,
qstat -fw is not documented, but existing implementation doesn’t throw usage error when qstat -fw is used. So
I am not sure if that is expected behaviour or a bug.

But yeah qstat -fw looks more meaningful for this requirement.

Regards
Dilip

I agree with what Dilip is suggesting. -1 does have a different meaning within qstat itself that each line belongs to a job instead of an attribute.
With respect to the usage of ‘w’, there is some non-functional code in qstat that sets a value but doesnt use it in any way, so there is no usage error printed…
I have a different suggestion for the option though. How about providing a long format option like --wrap or --no-wrap and having one of them as a default.

The available options in qstat are all simple one letter. IMHO qstat -fw will be the right candidate as -w doesn’t have any defined behavior when used with -f.

mostly, the long options have an associated short option, my suggestion was to have -fw for short and --wrap or --no-wrap as the long option. For that you will have to use getopt_long() instead of getopt().
However, if you are not willing to go that way, ok for me…

Thanks, @prakashcv13. I will update the EDD to reflect the same, to use qstat -fw instead of qstat -f1 option to print the attributes without wrapping them.

I don’t see benefit in adding a new --wrap option. If we introduced --wrap and/or --no-wrap and mapped them to the use of -w it would confuse the meaning of the existing -w, which means “w as in wide”. Since “w as in wide” makes sense in the -fw case we are discussing, so I’d like to see us just go with that.

to me wrap/no-wrap is more intuitive as if we wrap the value or we or we dont. However, it is your call.

One thing to point out is that getopt_long() is not POSIX. It’s a GNU extension. Now that we only support linux, this might be OK. We should make this decision knowing the consequences of not being able to go back and supporting other OSes.

We should add the following line to the spec file if we rely on GNU extensions like getopt_long()…

Requires: glibc >= 2.2

Specifically, is this extension available for Windows?

That is a very good question, Ian. Everything I found online says even getopt() isn’t supported on windows. I checked our source code and indeed we have our own version of getopt() for windows. If we were to use getopt_long(), we’d need a version of that as well.

Bhroam

The EDD link has been updated: https://pbspro.atlassian.net/wiki/display/PD/PP-483%3A+PP-484%3A+PP-485%3A+Enhance+output+of+qstat+to+make+it+more+admin+and+script+friendly