source: WorldVistAEHR/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDUTL5.m@ 1046

Last change on this file since 1046 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 8.2 KB
RevLine 
[613]1KMPDUTL5 ;OIFO/KAK - Obtain CPU Configuration;28 Feb 2002 ;2/17/04 10:56
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;;Mar 22, 2002
3 ;;
4CPU(ARRAY) ;-- get cpu configuration information
5 ;---------------------------------------------------------------------
6 ; ARRAY = passed back by reference
7 ; returns array with CPU information:
8 ; piece : information
9 ; ARRAY(nodename) = 1 : type of cpu
10 ; 2 : number of processors
11 ; 3 : processor speed
12 ; 4 : amount of memory
13 ;---------------------------------------------------------------------
14 ;
15 N ZV
16 ;
17 S ZV=$$MPLTF^KMPDUTL1
18 ;
19 S U="^"
20 I (ZV["DSM") D DSM(.ARRAY)
21 I (ZV["CVMS") D CVMS(.ARRAY,1)
22 I (ZV["CWINNT") D CWINNT(.ARRAY,1)
23 Q
24 ;
25DSM(CPUINFO) ;-- for DSM Platform
26 ;---------------------------------------------------------------------
27 ; CPUINFO = array passed back by reference - see CPU(ARRAY) above
28 ;---------------------------------------------------------------------
29 ;
30 N CLSTRMEM,CSID,CSIDARRY,NODE,NODEARRY,X
31 ;
32 S CLSTRMEM=$ZC(%GETSYI,"CLUSTER_MEMBER")
33 ;
34 ; not in cluster environment
35 I 'CLSTRMEM D Q
36 .S NODE=$ZC(%GETSYI,"NODENAME")
37 .S CPUINFO(NODE)=$ZC(%GETSYI,"HW_NAME")_U_$ZC(%GETSYI,"ACTIVECPU_CNT")
38 ;
39 ; in cluster environment
40 D CLSTR
41 S X="ERR^ZU",@^%ZOSF("TRAP")
42 S NODE=""
43 F S NODE=$O(NODEARRY(NODE)) Q:NODE="" D
44 .S CSID=NODEARRY(NODE)
45 .S CPUINFO(NODE)=$ZC(%GETSYI,"HW_NAME",CSID)_U_$ZC(%GETSYI,"ACTIVECPU_CNT",CSID)
46 Q
47CLSTR ; get %GETSYI using wild card to get CSID and NODENAME for all nodes
48 ;
49 N X
50 S X="ERRCLU^KMPDUTL5",@^%ZOSF("TRAP"),$ZE=""
51 S CSIDARRY($ZC(%GETSYI,"NODE_CSID",-1))=""
52 F S CSIDARRY($ZC(%GETSYI,"NODE_CSID",""))=""
53ERRCLU I $ZE'["NOMORENODE" ZQ
54 N CSID
55 S CSID=""
56 F S CSID=$O(CSIDARRY(CSID)) Q:CSID="" S NODEARRY($ZC(%GETSYI,"NODENAME",CSID))=CSID
57 Q
58 ;
59CVMS(CPUINFO,TYP) ;-- for Cache for OpenVMS Platform
60 ;---------------------------------------------------------------------
61 ; input: TYP = type of system information requested
62 ; 1 : cpu system information
63 ; 2 : operating system version information
64 ;
65 ; CPUINFO = array passed back by reference
66 ; : for TYP=1 see CPU(ARRAY) line tag above
67 ; : for TYP=2 CPUINFO(1)=os version
68 ;---------------------------------------------------------------------
69 ;
70 N DIR,FILE,LOG,TYPNM
71 ;
72 S TYPNM=$S(TYP=1:"CPU",TYP=2:"VER",1:"")
73 ;
74 S DIR=$ZU(12)
75 ;
76 ; cleanup log file
77 S LOG=DIR_"KMPDU"_TYPNM_".LOG"
78 O LOG:("R"):0 C LOG:("D")
79 ;
80 ; cleanup com file
81 S FILE=DIR_"KMPDU"_TYPNM_".COM"
82 O FILE:("R"):0 C FILE:("D")
83 ;
84 ; create com file quit on file creation error
85 Q:$$CREATE(FILE,TYP)<0
86 ;
87 ; run com file and create log file
88 I $ZF(-1,"",LOG,FILE)
89 C LOG
90 ;
91 ; parse log file
92 D PARSE(LOG,.CPUINFO,TYP)
93 ;
94 ; cleanup com file
95 O FILE:("R"):0 C FILE:("D")
96 ; cleanup log file
97 O LOG:("R"):0 C LOG:("D")
98 ;
99 Q
100 ;
101CWINNT(CPUINFO,TYP) ;-- for Cache for Windows NT Platform
102 ;---------------------------------------------------------------------
103 ; input: TYP = type of system information requested
104 ; 1 : cpu system information
105 ; 2 : operating system version information
106 ;
107 ; CPUINFO = array passed back by reference
108 ; : for TYP = 1 see CPU(ARRAY) line tag above
109 ; : for TYP = 2 CPUINFO(1)=os version
110 ;---------------------------------------------------------------------
111 ;
112 N DATA,FILE,NODE,OUT,X
113 ;
114 S DATA="",OUT=0
115 ;
116 ; $zu(110) = computername
117 S (FILE,NODE)=$ZU(110)
118 S CPUINFO(NODE)=""
119 ;
120 ; cleanup all report files
121 I $ZF(-1,"DEL "_FILE_"*.TXT")
122 ;
123 S FILE=FILE_".TXT"
124 ;
125 ; send system reort to file
126 ; switches: /s => summary report
127 ; /a => all report
128 ; /f => send to file named 'computername.TXT'
129 I $ZF(-1,"WINMSD /s /f")
130 ;
131 S X="EOF1",@^%ZOSF("TRAP")
132 ; append *eof* line to report file
133 O FILE:("WA"):0 I $T U FILE W !,"*EOF*" C FILE
134 ;
135 ; read from report file
136 O FILE:("R"):0
137 ;
138 I '$T C FILE:"D" Q
139 ;
140 U FILE
141 ;
142 ; TYP=1 => cpu information
143 I TYP=1 D
144 .F R X Q:X["*EOF*" D Q:OUT
145 ..; type of cpu
146 ..I X["Hardware Abstraction Layer:" S $P(DATA,U)=$$STRIP^KMPDUTL4($P(X,"Hardware Abstraction Layer:",2)) Q
147 ..; number of processors
148 ..I X["NUMBER_OF_PROCESSORS=" S $P(DATA,U,2)=$P(X,"NUMBER_OF_PROCESSORS=",2) Q
149 ..; processor speed - no information available
150 ..; amount of memory
151 ..I X["Physical Memory (K)" D Q
152 ...R X
153 ...I X["*EOF*" S OUT=1 Q
154 ...I X["Total:" S $P(DATA,U,4)=$$STRIP^KMPDUTL4($$COMMA^KMPDUTL4($P(X,"Total:",2)))\1024 Q
155 ..S CPUINFO(NODE)=DATA
156 ;
157 ; TYP=2 => os version
158 I TYP=2 D
159 .F R X Q:X["*EOF*" D Q:OUT
160 ..; version of operating system
161 ..I X["OS Version Report" D
162 ...F I=1:1:2 R X I X["*EOF*" S OUT=1 Q
163 ...S DATA=X
164 ...R X I X["*EOF*" S OUT=1 Q
165 ...S DATA=DATA_" "_X
166 ...S CPUINFO(1)=DATA
167 ;
168 C FILE:"D"
169 ;
170 Q
171 ;
172CREATE(FILE,TYP) ;-- function to create new com file
173 ;---------------------------------------------------------------------
174 ; input: FILE = name of file to create
175 ; TYP = type of system information requested
176 ; 1 : cpu system information
177 ; 2 : operating system version information
178 ;
179 ; returns: 1 successful file creation
180 ; -1 failure of file creation
181 ;---------------------------------------------------------------------
182 ;
183 N DIR,TYPNM
184 ;
185 S TYPNM=$S(TYP=1:"CPU",TYP=2:"VER",1:"")
186 ;
187 O FILE:("NWC"):0 Q:'$T -1
188 ;
189 U FILE
190 W "$! KMPDU"_TYPNM_".COM - Obtain System Configuration Information"
191 W "$!--------------------------------------------------------"
192 W "$! OIFO - CAPACITY PLANNING/KAK"
193 W "$! "_$P($T(+2)_";;",2,999)
194 W "$!--------------------------------------------------------"
195 W "$!"
196 ;
197 I TYP=2 D G TAGXIT
198 .W "$ write sys$output ""VERSION="" , f$getsyi(""VERSION"")"
199 ;
200 W "$ if f$getsyi(""CLUSTER_MEMBER"") .eqs. ""FALSE"" then goto NOT_CLUSTER"
201 W "$ CONTEXT = """""
202 W "$START:"
203 W "$ ID = f$csid(CONTEXT)"
204 W "$ if ID .eqs. """" then goto EXIT"
205 W "$ write sys$output ""NODE="" , f$getsyi(""NODENAME"",,ID)"
206 W "$ write sys$output ""TYPE="" , f$getsyi(""HW_NAME"",,ID)"
207 W "$ write sys$output ""CPU_CNT="" , f$getsyi(""ACTIVECPU_CNT"",,ID)"
208 W "$ write sys$output ""SPEED=n/a"""
209 W "$ write sys$output ""MEMSIZE="" , f$getsyi(""MEMSIZE"",,ID)"
210 W "$ goto START"
211 W "$NOT_CLUSTER:"
212 W "$ write sys$output ""NODE="" , f$getsyi(""NODENAME"")"
213 W "$ write sys$output ""TYPE="" , f$getsyi(""HW_NAME"")"
214 W "$ write sys$output ""CPU_CNT="" , f$getsyi(""ACTIVECPU_CNT"")"
215 W "$ write sys$output ""SPEED=n/a"""
216 W "$ write sys$output ""MEMSIZE="" , f$getsyi(""MEMSIZE"")"
217TAGXIT ;
218 W "$EXIT:"
219 W "$ write sys$output ""*EOF*"""
220 W "$ exit"
221 W "$!"
222 ;
223 C FILE
224 Q 1
225 ;
226PARSE(LOG,CPUARRY,TYP) ;-- parse log file data
227 ;---------------------------------------------------------------------
228 ; input: LOG = name of log file to parse
229 ; TYP = type of system information requested
230 ; 1 : cpu system information
231 ; 2 : operating system version information
232 ;
233 ; CPUARRY = passed back by reference
234 ; : for TYP=1 see CPU(ARRAY) line tag above
235 ; : for TYP=2 CPUINFO(1)=os version
236 ;---------------------------------------------------------------------
237 ;
238 N NODE,X
239 ;
240 S X="EOF",@^%ZOSF("TRAP"),NODE=""
241 K X S U="^"
242 ;
243 O LOG:("R")
244 U LOG
245 ;
246 I TYP=1 D
247 .F R X Q:X["*EOF*" I $E(X)'="$" I X["NODE=" D
248 ..I X["NODE=" S NODE=$P(X,"=",2)
249 ..F R X I $E(X)'="$" D Q:X["MEMSIZE="
250 ...; type of cpu
251 ...I X["TYPE=" S $P(CPUARRY(NODE),U)=$P(X,"=",2) Q
252 ...; number of processors
253 ...I X["CPU_CNT=" S $P(CPUARRY(NODE),U,2)=$P(X,"=",2) Q
254 ...; processor speed - no information available
255 ...I X["SPEED=" Q
256 ...; amount of memory in MB
257 ...I X["MEMSIZE=" S $P(CPUARRY(NODE),U,4)=$P(X,"=",2)/128 Q
258 ;
259 I TYP=2 D
260 .F R X Q:X["*EOF*" I $E(X)'="$" D
261 ..; version of operating system
262 ..I X["VERSION=" S CPUARRY(1)=$P(X,"=",2) Q
263 ;
264 C LOG
265 ;
266 S X="ERR^ZU",@^%ZOSF("TRAP")
267 Q
268 ;
269EOF ;-- end of file condition for CVMS
270 S X="ERR^ZU",@^%ZOSF("TRAP")
271 C LOG
272 Q
273 ;
274EOF1 ;-- end of file condition for CWINNT
275 S X="ERR^ZU",@^%ZOSF("TRAP")
276 C FILE:"D"
277 Q
278 ;
279CVMSVER() ;-- returns version of Cache for OpenVMS operating system
280 ;
281 N VER
282 ;
283 D CVMS(.VER,2)
284 Q $S($D(VER(1)):VER(1),1:"")
285 ;
286CWNTVER() ;-- returns version of Cache for Windows NT operating system
287 ;
288 N VER
289 ;
290 D CWINNT(.VER,2)
291 Q $S($D(VER(1)):VER(1),1:"")
Note: See TracBrowser for help on using the repository browser.