2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS net command
4 * FILE: base/applications/network/net/cmdStatistics.c
5 * PROGRAMMERS: Eric Kohl <eric.kohl@reactos.org>
14 DisplayServerStatistics(VOID
)
16 PSERVER_INFO_100 ServerInfo
= NULL
;
17 PSTAT_SERVER_0 StatisticsInfo
= NULL
;
18 LARGE_INTEGER LargeValue
;
19 FILETIME FileTime
, LocalFileTime
;
20 SYSTEMTIME SystemTime
;
22 INT nPaddedLength
= 35;
23 NET_API_STATUS Status
;
25 Status
= NetServerGetInfo(NULL
, 100, (PBYTE
*)&ServerInfo
);
26 if (Status
!= NERR_Success
)
29 Status
= NetStatisticsGet(NULL
,
33 (LPBYTE
*)&StatisticsInfo
);
34 if (Status
!= NERR_Success
)
37 PrintMessageStringV(4624, ServerInfo
->sv100_name
);
38 ConPrintf(StdOut
, L
"\n\n");
40 RtlSecondsSince1970ToTime(StatisticsInfo
->sts0_start
,
42 FileTime
.dwLowDateTime
= LargeValue
.u
.LowPart
;
43 FileTime
.dwHighDateTime
= LargeValue
.u
.HighPart
;
44 FileTimeToLocalFileTime(&FileTime
, &LocalFileTime
);
45 FileTimeToSystemTime(&LocalFileTime
, &SystemTime
);
47 wHour
= SystemTime
.wHour
;
57 PrintMessageString(4600);
58 ConPrintf(StdOut
, L
" %d/%d/%d %d:%02d %s\n\n\n",
59 SystemTime
.wMonth
, SystemTime
.wDay
, SystemTime
.wYear
,
60 wHour
, SystemTime
.wMinute
,
61 (SystemTime
.wHour
>= 1 && SystemTime
.wHour
< 13) ? L
"AM" : L
"PM");
63 PrintPaddedMessageString(4601, nPaddedLength
);
64 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->sts0_sopens
);
66 PrintPaddedMessageString(4602, nPaddedLength
);
67 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->sts0_stimedout
);
69 PrintPaddedMessageString(4603, nPaddedLength
);
70 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->sts0_serrorout
);
72 LargeValue
.u
.LowPart
= StatisticsInfo
->sts0_bytessent_low
;
73 LargeValue
.u
.HighPart
= StatisticsInfo
->sts0_bytessent_high
;
74 PrintPaddedMessageString(4604, nPaddedLength
);
75 ConPrintf(StdOut
, L
"%I64u\n", LargeValue
.QuadPart
/ 1024);
77 LargeValue
.u
.LowPart
= StatisticsInfo
->sts0_bytesrcvd_low
;
78 LargeValue
.u
.HighPart
= StatisticsInfo
->sts0_bytesrcvd_high
;
79 PrintPaddedMessageString(4605, nPaddedLength
);
80 ConPrintf(StdOut
, L
"%I64u\n", LargeValue
.QuadPart
/ 1024);
82 PrintPaddedMessageString(4606, nPaddedLength
);
83 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->sts0_avresponse
);
85 PrintPaddedMessageString(4610, nPaddedLength
);
86 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->sts0_syserrors
);
88 PrintPaddedMessageString(4612, nPaddedLength
);
89 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->sts0_permerrors
);
91 PrintPaddedMessageString(4611, nPaddedLength
);
92 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->sts0_pwerrors
);
94 PrintPaddedMessageString(4608, nPaddedLength
);
95 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->sts0_fopens
);
97 PrintPaddedMessageString(4613, nPaddedLength
);
98 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->sts0_devopens
);
100 PrintPaddedMessageString(4609, nPaddedLength
);
101 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->sts0_jobsqueued
);
103 PrintMessageString(4620);
104 ConPrintf(StdOut
, L
"\n");
106 ConPrintf(StdOut
, L
" ");
107 PrintPaddedMessageString(4621, nPaddedLength
- 2);
108 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->sts0_bigbufneed
);
110 ConPrintf(StdOut
, L
" ");
111 PrintPaddedMessageString(4622, nPaddedLength
- 2);
112 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->sts0_reqbufneed
);
115 if (StatisticsInfo
!= NULL
)
116 NetApiBufferFree(StatisticsInfo
);
118 if (ServerInfo
!= NULL
)
119 NetApiBufferFree(ServerInfo
);
127 DisplayWorkstationStatistics(VOID
)
129 PWKSTA_INFO_100 WorkstationInfo
= NULL
;
130 PSTAT_WORKSTATION_0 StatisticsInfo
= NULL
;
131 LARGE_INTEGER LargeValue
;
132 FILETIME FileTime
, LocalFileTime
;
133 SYSTEMTIME SystemTime
;
135 INT nPaddedLength
= 47;
136 NET_API_STATUS Status
;
138 Status
= NetWkstaGetInfo(NULL
,
140 (PBYTE
*)&WorkstationInfo
);
141 if (Status
!= NERR_Success
)
144 Status
= NetStatisticsGet(NULL
,
148 (LPBYTE
*)&StatisticsInfo
);
149 if (Status
!= NERR_Success
)
152 PrintMessageStringV(4623, WorkstationInfo
->wki100_computername
);
153 ConPrintf(StdOut
, L
"\n\n");
155 RtlSecondsSince1970ToTime(StatisticsInfo
->StatisticsStartTime
.u
.LowPart
,
157 FileTime
.dwLowDateTime
= LargeValue
.u
.LowPart
;
158 FileTime
.dwHighDateTime
= LargeValue
.u
.HighPart
;
159 FileTimeToLocalFileTime(&FileTime
, &LocalFileTime
);
160 FileTimeToSystemTime(&LocalFileTime
, &SystemTime
);
162 wHour
= SystemTime
.wHour
;
172 PrintMessageString(4600);
173 ConPrintf(StdOut
, L
" %d/%d/%d %d:%02d %s\n\n\n",
174 SystemTime
.wMonth
, SystemTime
.wDay
, SystemTime
.wYear
,
175 wHour
, SystemTime
.wMinute
,
176 (SystemTime
.wHour
>= 1 && SystemTime
.wHour
< 13) ? L
"AM" : L
"PM");
178 PrintPaddedMessageString(4630, nPaddedLength
);
179 ConPrintf(StdOut
, L
"%I64u\n", StatisticsInfo
->BytesReceived
.QuadPart
);
181 PrintPaddedMessageString(4631, nPaddedLength
);
182 ConPrintf(StdOut
, L
"%I64u\n", StatisticsInfo
->SmbsReceived
.QuadPart
);
184 PrintPaddedMessageString(4632, nPaddedLength
);
185 ConPrintf(StdOut
, L
"%I64u\n", StatisticsInfo
->BytesTransmitted
.QuadPart
);
187 PrintPaddedMessageString(4633, nPaddedLength
);
188 ConPrintf(StdOut
, L
"%I64u\n", StatisticsInfo
->SmbsTransmitted
.QuadPart
);
190 PrintPaddedMessageString(4634, nPaddedLength
);
191 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->ReadOperations
);
193 PrintPaddedMessageString(4635, nPaddedLength
);
194 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->WriteOperations
);
196 PrintPaddedMessageString(4636, nPaddedLength
);
197 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->RawReadsDenied
);
199 PrintPaddedMessageString(4637, nPaddedLength
);
200 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->RawWritesDenied
);
202 PrintPaddedMessageString(4638, nPaddedLength
);
203 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->NetworkErrors
);
205 PrintPaddedMessageString(4639, nPaddedLength
);
206 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->CoreConnects
+
207 StatisticsInfo
->Lanman20Connects
+
208 StatisticsInfo
->Lanman21Connects
+
209 StatisticsInfo
->LanmanNtConnects
);
211 PrintPaddedMessageString(4640, nPaddedLength
);
212 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->Reconnects
);
214 PrintPaddedMessageString(4641, nPaddedLength
);
215 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->ServerDisconnects
);
217 PrintPaddedMessageString(4642, nPaddedLength
);
218 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->Sessions
);
220 PrintPaddedMessageString(4643, nPaddedLength
);
221 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->HungSessions
);
223 PrintPaddedMessageString(4644, nPaddedLength
);
224 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->FailedSessions
);
226 PrintPaddedMessageString(4645, nPaddedLength
);
227 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->InitiallyFailedOperations
+
228 StatisticsInfo
->FailedCompletionOperations
);
230 PrintPaddedMessageString(4646, nPaddedLength
);
231 ConPrintf(StdOut
, L
"%lu\n", StatisticsInfo
->UseCount
);
233 PrintPaddedMessageString(4647, nPaddedLength
);
234 ConPrintf(StdOut
, L
"%lu\n\n", StatisticsInfo
->FailedUseCount
);
237 if (StatisticsInfo
!= NULL
)
238 NetApiBufferFree(StatisticsInfo
);
240 if (WorkstationInfo
!= NULL
)
241 NetApiBufferFree(WorkstationInfo
);
253 BOOL bServer
= FALSE
;
254 BOOL bWorkstation
= FALSE
;
256 for (i
= 2; i
< argc
; i
++)
258 if (_wcsicmp(argv
[i
], L
"server") == 0)
260 if (bWorkstation
== FALSE
)
265 if (_wcsicmp(argv
[i
], L
"workstation") == 0)
267 if (bServer
== FALSE
)
272 if (_wcsicmp(argv
[i
], L
"help") == 0)
274 /* Print short syntax help */
275 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
276 PrintNetMessage(MSG_STATISTICS_SYNTAX
);
280 if (_wcsicmp(argv
[i
], L
"/help") == 0)
282 /* Print full help text*/
283 ConResPuts(StdOut
, IDS_GENERIC_SYNTAX
);
284 PrintNetMessage(MSG_STATISTICS_SYNTAX
);
285 PrintNetMessage(MSG_STATISTICS_HELP
);
292 result
= DisplayServerStatistics();
294 else if (bWorkstation
)
296 result
= DisplayWorkstationStatistics();
300 PrintMessageString(4379);
301 ConPuts(StdOut
, L
"\n");
302 ConPuts(StdOut
, L
" Server\n");
303 ConPuts(StdOut
, L
" Workstation\n");
304 ConPuts(StdOut
, L
"\n");
308 PrintErrorMessage(ERROR_SUCCESS
);