Merge lp:~jontai/openvista-gtm-integration/bug701554 into lp:openvista-gtm-integration

Proposed by Derek_
Status: Needs review
Proposed branch: lp:~jontai/openvista-gtm-integration/bug701554
Merge into: lp:openvista-gtm-integration
Diff against target: 636 lines (+603/-7)
2 files modified
kids/XU_80_1510.KID (+556/-0)
mumps/MSCZJOBS.m (+47/-7)
To merge this branch: bzr merge lp:~jontai/openvista-gtm-integration/bug701554
Reviewer Review Type Date Requested Status
jeff.apple Approve
Review via email: mp+54723@code.launchpad.net
To post a comment you must log in.
Revision history for this message
jeff.apple (jeff-apple) wrote :

I haven't tested this, but it seems just fine.

review: Approve

Unmerged revisions

150. By Jon Tai

add patch number to second line of routine

149. By Jon Tai

add KIDS build with updated MSCZJOBS routine

148. By Jon Tai

refactor the netstat call so it's in its own subroutine and will only be called once per call of %SS

147. By Jon Tai

first pass at calling netstat to get the local port number

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'kids/XU_80_1510.KID'
2--- kids/XU_80_1510.KID 1970-01-01 00:00:00 +0000
3+++ kids/XU_80_1510.KID 2011-03-24 16:18:29 +0000
4@@ -0,0 +1,556 @@
5+KIDS Distribution saved on Jan 11, 2011@11:23:04
6+artf10950 - %SS port number fix
7+**KIDS**:XU*8.0*1510^
8+
9+**INSTALL NAME**
10+XU*8.0*1510
11+"BLD",7341,0)
12+XU*8.0*1510^KERNEL^0^3110111^n
13+"BLD",7341,4,0)
14+^9.64PA^^
15+"BLD",7341,6.3)
16+2
17+"BLD",7341,"ABPKG")
18+n
19+"BLD",7341,"KRN",0)
20+^9.67PA^8989.52^19
21+"BLD",7341,"KRN",.4,0)
22+.4
23+"BLD",7341,"KRN",.401,0)
24+.401
25+"BLD",7341,"KRN",.402,0)
26+.402
27+"BLD",7341,"KRN",.403,0)
28+.403
29+"BLD",7341,"KRN",.5,0)
30+.5
31+"BLD",7341,"KRN",.84,0)
32+.84
33+"BLD",7341,"KRN",3.6,0)
34+3.6
35+"BLD",7341,"KRN",3.8,0)
36+3.8
37+"BLD",7341,"KRN",9.2,0)
38+9.2
39+"BLD",7341,"KRN",9.8,0)
40+9.8
41+"BLD",7341,"KRN",9.8,"NM",0)
42+^9.68A^1^1
43+"BLD",7341,"KRN",9.8,"NM",1,0)
44+MSCZJOBS^^0^B46514052
45+"BLD",7341,"KRN",9.8,"NM","B","MSCZJOBS",1)
46+
47+"BLD",7341,"KRN",19,0)
48+19
49+"BLD",7341,"KRN",19.1,0)
50+19.1
51+"BLD",7341,"KRN",101,0)
52+101
53+"BLD",7341,"KRN",409.61,0)
54+409.61
55+"BLD",7341,"KRN",771,0)
56+771
57+"BLD",7341,"KRN",870,0)
58+870
59+"BLD",7341,"KRN",8989.51,0)
60+8989.51
61+"BLD",7341,"KRN",8989.52,0)
62+8989.52
63+"BLD",7341,"KRN",8994,0)
64+8994
65+"BLD",7341,"KRN","B",.4,.4)
66+
67+"BLD",7341,"KRN","B",.401,.401)
68+
69+"BLD",7341,"KRN","B",.402,.402)
70+
71+"BLD",7341,"KRN","B",.403,.403)
72+
73+"BLD",7341,"KRN","B",.5,.5)
74+
75+"BLD",7341,"KRN","B",.84,.84)
76+
77+"BLD",7341,"KRN","B",3.6,3.6)
78+
79+"BLD",7341,"KRN","B",3.8,3.8)
80+
81+"BLD",7341,"KRN","B",9.2,9.2)
82+
83+"BLD",7341,"KRN","B",9.8,9.8)
84+
85+"BLD",7341,"KRN","B",19,19)
86+
87+"BLD",7341,"KRN","B",19.1,19.1)
88+
89+"BLD",7341,"KRN","B",101,101)
90+
91+"BLD",7341,"KRN","B",409.61,409.61)
92+
93+"BLD",7341,"KRN","B",771,771)
94+
95+"BLD",7341,"KRN","B",870,870)
96+
97+"BLD",7341,"KRN","B",8989.51,8989.51)
98+
99+"BLD",7341,"KRN","B",8989.52,8989.52)
100+
101+"BLD",7341,"KRN","B",8994,8994)
102+
103+"BLD",7341,"MSC")
104+/home/jon/XU_80_1510.KID
105+"BLD",7341,"MSCOM")
106+artf10950 - %SS port number fix
107+"BLD",7341,"QUES",0)
108+^9.62^^
109+"MBREQ")
110+0
111+"PKG",3,-1)
112+1^1
113+"PKG",3,0)
114+KERNEL^XU^SIGN-ON, SECURITY, MENU DRIVER, DEVICES, TASKMAN^
115+"PKG",3,20,0)
116+^9.402P^^
117+"PKG",3,22,0)
118+^9.49I^1^1
119+"PKG",3,22,1,0)
120+8.0^3040115^2960606^1
121+"PKG",3,22,1,"PAH",1,0)
122+1510^3110111
123+"QUES","XPF1",0)
124+Y
125+"QUES","XPF1","??")
126+^D REP^XPDH
127+"QUES","XPF1","A")
128+Shall I write over your |FLAG| File
129+"QUES","XPF1","B")
130+YES
131+"QUES","XPF1","M")
132+D XPF1^XPDIQ
133+"QUES","XPF2",0)
134+Y
135+"QUES","XPF2","??")
136+^D DTA^XPDH
137+"QUES","XPF2","A")
138+Want my data |FLAG| yours
139+"QUES","XPF2","B")
140+YES
141+"QUES","XPF2","M")
142+D XPF2^XPDIQ
143+"QUES","XPI1",0)
144+YO
145+"QUES","XPI1","??")
146+^D INHIBIT^XPDH
147+"QUES","XPI1","A")
148+Want KIDS to INHIBIT LOGONs during the install
149+"QUES","XPI1","B")
150+NO
151+"QUES","XPI1","M")
152+D XPI1^XPDIQ
153+"QUES","XPM1",0)
154+PO^VA(200,:EM
155+"QUES","XPM1","??")
156+^D MG^XPDH
157+"QUES","XPM1","A")
158+Enter the Coordinator for Mail Group '|FLAG|'
159+"QUES","XPM1","B")
160+
161+"QUES","XPM1","M")
162+D XPM1^XPDIQ
163+"QUES","XPO1",0)
164+Y
165+"QUES","XPO1","??")
166+^D MENU^XPDH
167+"QUES","XPO1","A")
168+Want KIDS to Rebuild Menu Trees Upon Completion of Install
169+"QUES","XPO1","B")
170+NO
171+"QUES","XPO1","M")
172+D XPO1^XPDIQ
173+"QUES","XPZ1",0)
174+Y
175+"QUES","XPZ1","??")
176+^D OPT^XPDH
177+"QUES","XPZ1","A")
178+Want to DISABLE Scheduled Options, Menu Options, and Protocols
179+"QUES","XPZ1","B")
180+NO
181+"QUES","XPZ1","M")
182+D XPZ1^XPDIQ
183+"QUES","XPZ2",0)
184+Y
185+"QUES","XPZ2","??")
186+^D RTN^XPDH
187+"QUES","XPZ2","A")
188+Want to MOVE routines to other CPUs
189+"QUES","XPZ2","B")
190+NO
191+"QUES","XPZ2","M")
192+D XPZ2^XPDIQ
193+"RTN")
194+1
195+"RTN","MSCZJOBS")
196+0^1^B46514052
197+"RTN","MSCZJOBS",1,0)
198+MSCZJOBS ;JKT/MSC ;OpenVista System status; 11 JAN 2011 - 1122
199+"RTN","MSCZJOBS",2,0)
200+ ;;8.0;KERNEL;**1501,1510**;5/20/2009
201+"RTN","MSCZJOBS",3,0)
202+ ;
203+"RTN","MSCZJOBS",4,0)
204+ALL D SS() Q
205+"RTN","MSCZJOBS",5,0)
206+THIS N FILTERS S FILTERS(1)="I^"_$$CURRENT^ZCD() D SS(.FILTERS) Q
207+"RTN","MSCZJOBS",6,0)
208+ ;
209+"RTN","MSCZJOBS",7,0)
210+INT ;Interactive -- ask for filters, then do SS in a loop
211+"RTN","MSCZJOBS",8,0)
212+ N FILTERS,QUIT S FILTERS=0,QUIT=0
213+"RTN","MSCZJOBS",9,0)
214+ F D Q:QUIT
215+"RTN","MSCZJOBS",10,0)
216+ . N DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,U
217+"RTN","MSCZJOBS",11,0)
218+ . S DIR(0)="SAO^J:PID/$J;P:PORT NUMBER;I:INSTANCE NAME;R:RUNNING ROUTINE;Z:ZLINKED ROUTINE;U:USER;D:IDENTITY"
219+"RTN","MSCZJOBS",12,0)
220+ . S DIR("A")="Select FILTER: "
221+"RTN","MSCZJOBS",13,0)
222+ . S DIR("?")="Optionally select criteria to filter processes by."
223+"RTN","MSCZJOBS",14,0)
224+ . D ^DIR
225+"RTN","MSCZJOBS",15,0)
226+ . I $G(DTOUT)!$G(DUOUT) S QUIT=2 Q ; exit program
227+"RTN","MSCZJOBS",16,0)
228+ . I (Y="") S QUIT=1 Q ; exit loop
229+"RTN","MSCZJOBS",17,0)
230+ . N FILTER S FILTER=Y
231+"RTN","MSCZJOBS",18,0)
232+ . ;
233+"RTN","MSCZJOBS",19,0)
234+ . N DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,U
235+"RTN","MSCZJOBS",20,0)
236+ . D:FILTER="J"
237+"RTN","MSCZJOBS",21,0)
238+ . . S DIR(0)="NAO"
239+"RTN","MSCZJOBS",22,0)
240+ . . S DIR("A")=" PID/$J: "
241+"RTN","MSCZJOBS",23,0)
242+ . . S DIR("?")="If a numeric process ID ($J) is entered here, only processes with that process ID will be displayed."
243+"RTN","MSCZJOBS",24,0)
244+ . D:FILTER="P"
245+"RTN","MSCZJOBS",25,0)
246+ . . S DIR(0)="NAO"
247+"RTN","MSCZJOBS",26,0)
248+ . . S DIR("A")=" PORT NUMBER: "
249+"RTN","MSCZJOBS",27,0)
250+ . . S DIR("?")="If a numeric port number is entered here, only processes listening on that port or connected to that port will be displayed."
251+"RTN","MSCZJOBS",28,0)
252+ . D:FILTER="I"
253+"RTN","MSCZJOBS",29,0)
254+ . . S DIR(0)="FOU"
255+"RTN","MSCZJOBS",30,0)
256+ . . S DIR("A")=" INSTANCE NAME"
257+"RTN","MSCZJOBS",31,0)
258+ . . S DIR("?")="If an instance name is entered here, only processes running in that instance will be displayed."
259+"RTN","MSCZJOBS",32,0)
260+ . D:FILTER="R"
261+"RTN","MSCZJOBS",33,0)
262+ . . S DIR(0)="FOU"
263+"RTN","MSCZJOBS",34,0)
264+ . . S DIR("A")=" RUNNING ROUTINE"
265+"RTN","MSCZJOBS",35,0)
266+ . . S DIR("?")="If a routine name is entered here, only processes running that routine will be displayed."
267+"RTN","MSCZJOBS",36,0)
268+ . D:FILTER="Z"
269+"RTN","MSCZJOBS",37,0)
270+ . . S DIR(0)="FOU"
271+"RTN","MSCZJOBS",38,0)
272+ . . S DIR("A")=" ZLINKED ROUTINE"
273+"RTN","MSCZJOBS",39,0)
274+ . . S DIR("?")="If a routine name is entered here, only processes that have previously loaded (ZLINK'd) that routine will be displayed."
275+"RTN","MSCZJOBS",40,0)
276+ . D:FILTER="U"
277+"RTN","MSCZJOBS",41,0)
278+ . . S DIR(0)="FOU"
279+"RTN","MSCZJOBS",42,0)
280+ . . S DIR("A")=" USER"
281+"RTN","MSCZJOBS",43,0)
282+ . . S DIR("?")="If a Linux username is entered here, only processes that are running under that user will be displayed."
283+"RTN","MSCZJOBS",44,0)
284+ . D:FILTER="D"
285+"RTN","MSCZJOBS",45,0)
286+ . . S DIR(0)="FOU"
287+"RTN","MSCZJOBS",46,0)
288+ . . S DIR("A")=" IDENTITY"
289+"RTN","MSCZJOBS",47,0)
290+ . . S DIR("?")="If an OpenVista user's name is entered here, only processes that are running under that user will be displayed."
291+"RTN","MSCZJOBS",48,0)
292+ . D ^DIR Q:$G(DTOUT)!$G(DUOUT)!(Y="")
293+"RTN","MSCZJOBS",49,0)
294+ . S FILTERS($I(FILTERS))=FILTER_"^"_Y
295+"RTN","MSCZJOBS",50,0)
296+ Q:QUIT=2
297+"RTN","MSCZJOBS",51,0)
298+ ;
299+"RTN","MSCZJOBS",52,0)
300+ N QUIT S QUIT=0
301+"RTN","MSCZJOBS",53,0)
302+ F D Q:QUIT
303+"RTN","MSCZJOBS",54,0)
304+ . D SS(.FILTERS)
305+"RTN","MSCZJOBS",55,0)
306+ . N DIR,X,Y,DTOUT,DUOUT,DIRUT,DIROUT,U
307+"RTN","MSCZJOBS",56,0)
308+ . S DIR(0)="SA^U:UPDATE;Q:QUIT"
309+"RTN","MSCZJOBS",57,0)
310+ . S DIR("A")="Action: "
311+"RTN","MSCZJOBS",58,0)
312+ . S DIR("B")="UPDATE"
313+"RTN","MSCZJOBS",59,0)
314+ . D ^DIR
315+"RTN","MSCZJOBS",60,0)
316+ . I Y'="U" S QUIT=1 Q
317+"RTN","MSCZJOBS",61,0)
318+ Q
319+"RTN","MSCZJOBS",62,0)
320+ ;
321+"RTN","MSCZJOBS",63,0)
322+SS(FILTERS) ;Print GT.M mumps processes
323+"RTN","MSCZJOBS",64,0)
324+ ;
325+"RTN","MSCZJOBS",65,0)
326+ Q:$G(^%ZOSF("OS"))'["GT.M"
327+"RTN","MSCZJOBS",66,0)
328+ ;
329+"RTN","MSCZJOBS",67,0)
330+ D INTRPT^MSCZJOBU("*") H .5
331+"RTN","MSCZJOBS",68,0)
332+ ;
333+"RTN","MSCZJOBS",69,0)
334+ N DATETIME S DATETIME=$$HTE^XLFDT($H)
335+"RTN","MSCZJOBS",70,0)
336+ W #!,?28,"OpenVista System Status"
337+"RTN","MSCZJOBS",71,0)
338+ W !,?(40-($L(DATETIME)/2)\1),DATETIME
339+"RTN","MSCZJOBS",72,0)
340+ W !!,?1,"PID/$J",?9,"%CPU",?15,"Device",?32,"Instance",?42,"Routine",?52,"User",?66,"Identity"
341+"RTN","MSCZJOBS",73,0)
342+ ;
343+"RTN","MSCZJOBS",74,0)
344+ N MSC S MSC="^TMP(""MSCZJOB1"",$J)" K @MSC
345+"RTN","MSCZJOBS",75,0)
346+ D JOBEXAM^MSCZJOBU(MSC)
347+"RTN","MSCZJOBS",76,0)
348+ N NETSTAT S NETSTAT=0
349+"RTN","MSCZJOBS",77,0)
350+ N PID S PID=""
351+"RTN","MSCZJOBS",78,0)
352+ F S PID=$O(@MSC@(PID)) Q:PID="" D
353+"RTN","MSCZJOBS",79,0)
354+ . ; evaluate filters; AND different filter types, but if more than one criteria is given of the same type, use OR
355+"RTN","MSCZJOBS",80,0)
356+ . N MATCH,TYPE,QUIT S QUIT=0
357+"RTN","MSCZJOBS",81,0)
358+ . N FILTER S FILTERS="" F S FILTERS=$O(FILTERS(FILTERS)) Q:FILTERS="" S FILTER=FILTERS(FILTERS) D
359+"RTN","MSCZJOBS",82,0)
360+ . . S TYPE=$P(FILTER,"^")
361+"RTN","MSCZJOBS",83,0)
362+ . . I '$D(MATCH(TYPE)) S MATCH(TYPE)=0
363+"RTN","MSCZJOBS",84,0)
364+ . . I TYPE="J" S:PID=$P(FILTER,"^",2) MATCH(TYPE)=1 Q
365+"RTN","MSCZJOBS",85,0)
366+ . . I TYPE="P" S:$P($$DEVICE(PID),",")=$P(FILTER,"^",2) MATCH(TYPE)=1 Q
367+"RTN","MSCZJOBS",86,0)
368+ . . I TYPE="I" S:$$INSTANCE(PID)=$P(FILTER,"^",2) MATCH(TYPE)=1 Q
369+"RTN","MSCZJOBS",87,0)
370+ . . I TYPE="R" S:$$ROUTINE(PID)=$P(FILTER,"^",2) MATCH(TYPE)=1 Q
371+"RTN","MSCZJOBS",88,0)
372+ . . I TYPE="Z" S:$D(@MSC@(PID,"RTN",$P(FILTER,"^",2))) MATCH(TYPE)=1 Q
373+"RTN","MSCZJOBS",89,0)
374+ . . I TYPE="U" S:$$USER(PID)=$P(FILTER,"^",2) MATCH(TYPE)=1 Q
375+"RTN","MSCZJOBS",90,0)
376+ . . I TYPE="D" S:$$IDENT(PID)=$P(FILTER,"^",2) MATCH(TYPE)=1 Q
377+"RTN","MSCZJOBS",91,0)
378+ . S TYPE="" F S TYPE=$O(MATCH(TYPE)) Q:TYPE="" I 'MATCH(TYPE) S QUIT=1 Q
379+"RTN","MSCZJOBS",92,0)
380+ . I QUIT Q
381+"RTN","MSCZJOBS",93,0)
382+ .
383+"RTN","MSCZJOBS",94,0)
384+ . ; print line of output for this process
385+"RTN","MSCZJOBS",95,0)
386+ . W !,$$PID(PID)
387+"RTN","MSCZJOBS",96,0)
388+ . W ?9,$$PCPU(PID)
389+"RTN","MSCZJOBS",97,0)
390+ . W ?15,$$DEVICE(PID)
391+"RTN","MSCZJOBS",98,0)
392+ . W ?32,$$INSTANCE(PID)
393+"RTN","MSCZJOBS",99,0)
394+ . W ?42,$$ROUTINE(PID)
395+"RTN","MSCZJOBS",100,0)
396+ . W ?52,$$USER(PID)
397+"RTN","MSCZJOBS",101,0)
398+ . W ?66,$$IDENT(PID)
399+"RTN","MSCZJOBS",102,0)
400+ K @MSC
401+"RTN","MSCZJOBS",103,0)
402+ ;
403+"RTN","MSCZJOBS",104,0)
404+ W !! ZSY "uptime"
405+"RTN","MSCZJOBS",105,0)
406+ Q
407+"RTN","MSCZJOBS",106,0)
408+ ;
409+"RTN","MSCZJOBS",107,0)
410+PID(PID) ;Return process ID formatted for display
411+"RTN","MSCZJOBS",108,0)
412+ Q $J(PID,7)_$S($J=PID:"*",1:"")
413+"RTN","MSCZJOBS",109,0)
414+ ;
415+"RTN","MSCZJOBS",110,0)
416+PCPU(PID) ;Return CPU usage
417+"RTN","MSCZJOBS",111,0)
418+ Q $J($G(@MSC@(PID,"PCPU")),4)
419+"RTN","MSCZJOBS",112,0)
420+ ;
421+"RTN","MSCZJOBS",113,0)
422+DEVICE(PID) ;Return device
423+"RTN","MSCZJOBS",114,0)
424+ N PRI S PRI=$$FIND(PID,"I","$PRINCIPAL")
425+"RTN","MSCZJOBS",115,0)
426+ Q:PRI'="0" PRI ; FIXME: this could probably be more general
427+"RTN","MSCZJOBS",116,0)
428+ ;
429+"RTN","MSCZJOBS",117,0)
430+ ; look at devices for listening or connected sockets
431+"RTN","MSCZJOBS",118,0)
432+ N SOCK,DEV S SOCK=$$FIND(PID,"D"," SOCKET[0]"),DEV=""
433+"RTN","MSCZJOBS",119,0)
434+ I $P(SOCK," ",3)="LISTENING" D
435+"RTN","MSCZJOBS",120,0)
436+ . S DEV=$$FINDSOCK("PORT")_",LISTENING"
437+"RTN","MSCZJOBS",121,0)
438+ I $P(SOCK," ",3)="CONNECTED" D
439+"RTN","MSCZJOBS",122,0)
440+ . N LOCAL S LOCAL=$$FINDSOCK("LOCAL")
441+"RTN","MSCZJOBS",123,0)
442+ . I LOCAL'="" S DEV=$P(LOCAL,"@",2)_",CONNECTED" Q
443+"RTN","MSCZJOBS",124,0)
444+ . ;
445+"RTN","MSCZJOBS",125,0)
446+ . ; If the local port info is not available, we have to look up the
447+"RTN","MSCZJOBS",126,0)
448+ . ; remote port in netstat to figure out the local port. This happens
449+"RTN","MSCZJOBS",127,0)
450+ . ; on single listeners (listeners that stop listening once they get a
451+"RTN","MSCZJOBS",128,0)
452+ . ; connection). See LP #701554.
453+"RTN","MSCZJOBS",129,0)
454+ . N REMOTE S REMOTE=$TR($$FINDSOCK("REMOTE"),"@",":")
455+"RTN","MSCZJOBS",130,0)
456+ . D NETSTAT
457+"RTN","MSCZJOBS",131,0)
458+ . S LOCAL=$G(NETSTAT(REMOTE))
459+"RTN","MSCZJOBS",132,0)
460+ . I LOCAL'="" S DEV=$P(LOCAL,":",$L(LOCAL,":"))_",CONNECTED" Q
461+"RTN","MSCZJOBS",133,0)
462+ Q DEV
463+"RTN","MSCZJOBS",134,0)
464+ ;
465+"RTN","MSCZJOBS",135,0)
466+FINDSOCK(KEY) ;Find a key in the SOCK line, private to DEVICE()
467+"RTN","MSCZJOBS",136,0)
468+ Q $P($P(SOCK," "_KEY_"=",2)," ")
469+"RTN","MSCZJOBS",137,0)
470+ ;
471+"RTN","MSCZJOBS",138,0)
472+NETSTAT ;Call netstat, private to DEVICE()
473+"RTN","MSCZJOBS",139,0)
474+ Q:NETSTAT ; if netstat has been run already, don't run it again
475+"RTN","MSCZJOBS",140,0)
476+ N PIPE,%I,LINE,I,PIECE,LOCAL,REMOTE
477+"RTN","MSCZJOBS",141,0)
478+ S PIPE="pipe",%I=$I
479+"RTN","MSCZJOBS",142,0)
480+ O PIPE:(COMMAND="netstat -n -A inet":READONLY)::"PIPE"
481+"RTN","MSCZJOBS",143,0)
482+ U PIPE
483+"RTN","MSCZJOBS",144,0)
484+ F R LINE Q:LINE="" D
485+"RTN","MSCZJOBS",145,0)
486+ . ;
487+"RTN","MSCZJOBS",146,0)
488+ . ; Iterate over the pieces (delimited by spaces)
489+"RTN","MSCZJOBS",147,0)
490+ . ; Put the first piece that has a ":" in it into LOCAL
491+"RTN","MSCZJOBS",148,0)
492+ . ; Put the second piece that has a ":" in it into REMOTE
493+"RTN","MSCZJOBS",149,0)
494+ . S LOCAL="",REMOTE=""
495+"RTN","MSCZJOBS",150,0)
496+ . F I=1:1:$L(LINE," ") S PIECE=$P(LINE," ",I) D Q:REMOTE'=""
497+"RTN","MSCZJOBS",151,0)
498+ . . Q:$P(PIECE,":",2)="" ; no colon, not an address
499+"RTN","MSCZJOBS",152,0)
500+ . . I LOCAL="" S LOCAL=PIECE Q
501+"RTN","MSCZJOBS",153,0)
502+ . . I REMOTE="" S REMOTE=PIECE Q
503+"RTN","MSCZJOBS",154,0)
504+ . ;
505+"RTN","MSCZJOBS",155,0)
506+ . ; Build a dictionary of remote => local for easy lookup later
507+"RTN","MSCZJOBS",156,0)
508+ . I REMOTE'="" S NETSTAT(REMOTE)=LOCAL
509+"RTN","MSCZJOBS",157,0)
510+ U %I
511+"RTN","MSCZJOBS",158,0)
512+ C PIPE
513+"RTN","MSCZJOBS",159,0)
514+ S NETSTAT=1 ; set flag to indicate that netstat has been run
515+"RTN","MSCZJOBS",160,0)
516+ Q
517+"RTN","MSCZJOBS",161,0)
518+ ;
519+"RTN","MSCZJOBS",162,0)
520+INSTANCE(PID) ;Return name of OpenVista instance
521+"RTN","MSCZJOBS",163,0)
522+ N ZG S ZG=$$FIND(PID,"I","$ZGBLDIR")
523+"RTN","MSCZJOBS",164,0)
524+ Q $P(ZG,"/",$L(ZG,"/")-2)
525+"RTN","MSCZJOBS",165,0)
526+ ;
527+"RTN","MSCZJOBS",166,0)
528+ROUTINE(PID) ;Return routine
529+"RTN","MSCZJOBS",167,0)
530+ Q $P($$FIND(PID,"V","%ZPOS"),"^",2)
531+"RTN","MSCZJOBS",168,0)
532+ ;
533+"RTN","MSCZJOBS",169,0)
534+USER(PID) ;Return Linux user
535+"RTN","MSCZJOBS",170,0)
536+ Q $G(@MSC@(PID,"USER"))
537+"RTN","MSCZJOBS",171,0)
538+ ;
539+"RTN","MSCZJOBS",172,0)
540+IDENT(PID) ;Return OpenVista user
541+"RTN","MSCZJOBS",173,0)
542+ N DUZ S DUZ=+$$FIND(PID,"V","DUZ")
543+"RTN","MSCZJOBS",174,0)
544+ N ZG S ZG=$$FIND(PID,"I","$ZGBLDIR")
545+"RTN","MSCZJOBS",175,0)
546+ Q $P($G(^|ZG|VA(200,DUZ,0)),"^")
547+"RTN","MSCZJOBS",176,0)
548+ ;
549+"RTN","MSCZJOBS",177,0)
550+FIND(PID,ARR,KEY) ;Return the value of a key in one of the ZSHOW arrays
551+"RTN","MSCZJOBS",178,0)
552+ N I,X S I="",X=""
553+"RTN","MSCZJOBS",179,0)
554+ F S I=$O(@MSC@(PID,ARR,I)) Q:'I I $P(@MSC@(PID,ARR,I),KEY_"=")="" S X=$TR($P(@MSC@(PID,ARR,I),"=",2,999),"""") Q
555+"RTN","MSCZJOBS",180,0)
556+ Q X
557+"VER")
558+8.0^22.0
559+**END**
560+**END**
561
562=== modified file 'mumps/MSCZJOBS.m'
563--- mumps/MSCZJOBS.m 2010-07-30 19:25:44 +0000
564+++ mumps/MSCZJOBS.m 2011-03-24 16:18:29 +0000
565@@ -1,5 +1,5 @@
566-MSCZJOBS ;JKT/MSC ;OpenVista System status; 30 JUL 2010 - 1225
567- ;;8.0;KERNEL;**1501**;5/20/2009
568+MSCZJOBS ;JKT/MSC ;OpenVista System status; 11 JAN 2011 - 1122
569+ ;;8.0;KERNEL;**1501,1510**;5/20/2009
570 ;
571 ALL D SS() Q
572 THIS N FILTERS S FILTERS(1)="I^"_$$CURRENT^ZCD() D SS(.FILTERS) Q
573@@ -73,6 +73,7 @@
574 ;
575 N MSC S MSC="^TMP(""MSCZJOB1"",$J)" K @MSC
576 D JOBEXAM^MSCZJOBU(MSC)
577+ N NETSTAT S NETSTAT=0
578 N PID S PID=""
579 F S PID=$O(@MSC@(PID)) Q:PID="" D
580 . ; evaluate filters; AND different filter types, but if more than one criteria is given of the same type, use OR
581@@ -113,11 +114,50 @@
582 N PRI S PRI=$$FIND(PID,"I","$PRINCIPAL")
583 Q:PRI'="0" PRI ; FIXME: this could probably be more general
584 ;
585- ; look at devices for sockets
586- N SOCK S SOCK=$$FIND(PID,"D"," SOCKET[0]")
587- I $P(SOCK," ",3)="LISTENING" Q $P($P(SOCK," PORT=",2)," ")_",LISTENING"
588- I $P(SOCK," ",3)="CONNECTED" Q $P($P($P(SOCK," LOCAL=",2)," "),"@",2)_",CONNECTED"
589- Q ""
590+ ; look at devices for listening or connected sockets
591+ N SOCK,DEV S SOCK=$$FIND(PID,"D"," SOCKET[0]"),DEV=""
592+ I $P(SOCK," ",3)="LISTENING" D
593+ . S DEV=$$FINDSOCK("PORT")_",LISTENING"
594+ I $P(SOCK," ",3)="CONNECTED" D
595+ . N LOCAL S LOCAL=$$FINDSOCK("LOCAL")
596+ . I LOCAL'="" S DEV=$P(LOCAL,"@",2)_",CONNECTED" Q
597+ . ;
598+ . ; If the local port info is not available, we have to look up the
599+ . ; remote port in netstat to figure out the local port. This happens
600+ . ; on single listeners (listeners that stop listening once they get a
601+ . ; connection). See LP #701554.
602+ . N REMOTE S REMOTE=$TR($$FINDSOCK("REMOTE"),"@",":")
603+ . D NETSTAT
604+ . S LOCAL=$G(NETSTAT(REMOTE))
605+ . I LOCAL'="" S DEV=$P(LOCAL,":",$L(LOCAL,":"))_",CONNECTED" Q
606+ Q DEV
607+ ;
608+FINDSOCK(KEY) ;Find a key in the SOCK line, private to DEVICE()
609+ Q $P($P(SOCK," "_KEY_"=",2)," ")
610+ ;
611+NETSTAT ;Call netstat, private to DEVICE()
612+ Q:NETSTAT ; if netstat has been run already, don't run it again
613+ N PIPE,%I,LINE,I,PIECE,LOCAL,REMOTE
614+ S PIPE="pipe",%I=$I
615+ O PIPE:(COMMAND="netstat -n -A inet":READONLY)::"PIPE"
616+ U PIPE
617+ F R LINE Q:LINE="" D
618+ . ;
619+ . ; Iterate over the pieces (delimited by spaces)
620+ . ; Put the first piece that has a ":" in it into LOCAL
621+ . ; Put the second piece that has a ":" in it into REMOTE
622+ . S LOCAL="",REMOTE=""
623+ . F I=1:1:$L(LINE," ") S PIECE=$P(LINE," ",I) D Q:REMOTE'=""
624+ . . Q:$P(PIECE,":",2)="" ; no colon, not an address
625+ . . I LOCAL="" S LOCAL=PIECE Q
626+ . . I REMOTE="" S REMOTE=PIECE Q
627+ . ;
628+ . ; Build a dictionary of remote => local for easy lookup later
629+ . I REMOTE'="" S NETSTAT(REMOTE)=LOCAL
630+ U %I
631+ C PIPE
632+ S NETSTAT=1 ; set flag to indicate that netstat has been run
633+ Q
634 ;
635 INSTANCE(PID) ;Return name of OpenVista instance
636 N ZG S ZG=$$FIND(PID,"I","$ZGBLDIR")

Subscribers

People subscribed via source and target branches