progress / iceberg

A collection of code, utilities, and guides from real-world customer engagements.
Other
12 stars 7 forks source link

Using "locks" option, database column is too short. #22

Closed c3rberus closed 1 year ago

c3rberus commented 1 year ago

When using the "locks" option, the database output is trimmed and when there are multiple databases at play, its not known what database is being referenced.

locks:
     [echo] Code Release: 2023-08-07T13:35:46.788
     [echo]
     [echo] DLC Home: /usr3/dlc
     [echo] OpenEdge Version: 12.2.12
   [PCTRun]
   [PCTRun] Scanning for Table Locks from connected PASN clients...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]     Getting lock stats for xxxxx...
   [PCTRun]
   [PCTRun] Usr#        User            Domain          Tenant          Database                Table           Flags                   PID     SessionID
   [PCTRun] 4         admin@default.lo                                  /usr3/xxxxdbs/                                               20775274         69
   [PCTRun] 5         admin@default.lo                                  /usr3/xxxxdbs/                                               20775274         70
   [PCTRun] 6                                                           /usr3/xxxxdbs/                                               15466794         45
   [PCTRun] 7         mirde@xxxx.com                                    /usr3/xxxxdbs/                                               15466794         43
   [PCTRun] 9         admin@default.lo                                  /usr3/xxxxdbs/                                               15466794         44
   [PCTRun] 20                                                          /usr3/xxxxdbs/                                               20775274         71
   [PCTRun] 3         admin@default.lo                                  /usr3/xxxxdbs/                                               20775274         69
   [PCTRun] 8         admin@default.lo                                  /usr3/xxxxdbs/                                               15466794         44
   [PCTRun] 19                                                          /usr3/xxxxdbs/                                               20775274         71
   [PCTRun]
   [PCTRun] traininga MSAgent PID 15466794:
   [PCTRun]
   [PCTRun]     Call Stack for Session ID #43:
   [PCTRun]             xxxxx.p

BUILD SUCCESSFUL
Total time: 3 seconds

Looks like it's trying to output the full path, and even though the full path to the database is short, it only prints partial output of the path and not the database name itself.

I suggest dropping the path, and only including the db name.

Looks like there is already a function to figure out the database logical name at the start of the script (Getting lock stats for ....), one could use that instead of the full path.

c3rberus commented 1 year ago

Just to add, I tried different terminal window size thinking that may make a difference (using PuTTY), no effect.

DustinGrau-PSC commented 1 year ago

Thank you for the added use-case. This would be due to the fixed column widths in use, and string formatting, so the width of the display would not affect the columns. If you were to provide a maximum length of your longest database path and the size of the longest domain name in use, that would help to identify the right approach to expanding the display information. My worry in showing only the database name without a path could result in confusion if an application connects to multiple, identical database names and only the path could reveal the true location.

DustinGrau-PSC commented 1 year ago

I'm looking at vastly expanding the column sizes as the initial fix for this, as I don't feel that space should be as constrained as it was initially. You can always adjust your terminal window size (as you even tried) should this not fit on the screen by default.

mockup

DustinGrau-PSC commented 1 year ago

I've just updated the tools with wider column widths. This may be overkill, but should handle the case of a -db connection with a long path name.