ReactOS 0.4.16-dev-1946-g52006dd
cmdStatistics.c
Go to the documentation of this file.
1/*
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>
6 */
7
8#include "net.h"
9#include <rtltypes.h>
10#include <rtlfuncs.h>
11
12static
13INT
15{
16 PSERVER_INFO_100 ServerInfo = NULL;
17 PSTAT_SERVER_0 StatisticsInfo = NULL;
18 LARGE_INTEGER LargeValue;
19 FILETIME FileTime, LocalFileTime;
20 SYSTEMTIME SystemTime;
21 WCHAR DateBuffer[32], TimeBuffer[32];
22 INT nPaddedLength = 35;
24
25 Status = NetServerGetInfo(NULL, 100, (PBYTE*)&ServerInfo);
26 if (Status != NERR_Success)
27 goto done;
28
31 0,
32 0,
33 (LPBYTE*)&StatisticsInfo);
34 if (Status != NERR_Success)
35 goto done;
36
37 PrintMessageStringV(4624, ServerInfo->sv100_name);
38 ConPrintf(StdOut, L"\n\n");
39
41 &LargeValue);
42 FileTime.dwLowDateTime = LargeValue.u.LowPart;
43 FileTime.dwHighDateTime = LargeValue.u.HighPart;
44 FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
45 FileTimeToSystemTime(&LocalFileTime, &SystemTime);
46
49 &SystemTime,
50 NULL,
51 DateBuffer,
52 ARRAYSIZE(DateBuffer));
53
55 0,
56 &SystemTime,
57 NULL,
58 TimeBuffer,
59 ARRAYSIZE(TimeBuffer));
60
62 ConPrintf(StdOut, L" %s %s\n\n\n", DateBuffer, TimeBuffer);
63
64 PrintPaddedMessageString(4601, nPaddedLength);
65 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_sopens);
66
67 PrintPaddedMessageString(4602, nPaddedLength);
68 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_stimedout);
69
70 PrintPaddedMessageString(4603, nPaddedLength);
71 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_serrorout);
72
73 LargeValue.u.LowPart = StatisticsInfo->sts0_bytessent_low;
74 LargeValue.u.HighPart = StatisticsInfo->sts0_bytessent_high;
75 PrintPaddedMessageString(4604, nPaddedLength);
76 ConPrintf(StdOut, L"%I64u\n", LargeValue.QuadPart / 1024);
77
78 LargeValue.u.LowPart = StatisticsInfo->sts0_bytesrcvd_low;
79 LargeValue.u.HighPart = StatisticsInfo->sts0_bytesrcvd_high;
80 PrintPaddedMessageString(4605, nPaddedLength);
81 ConPrintf(StdOut, L"%I64u\n", LargeValue.QuadPart / 1024);
82
83 PrintPaddedMessageString(4606, nPaddedLength);
84 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_avresponse);
85
86 PrintPaddedMessageString(4610, nPaddedLength);
87 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_syserrors);
88
89 PrintPaddedMessageString(4612, nPaddedLength);
90 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_permerrors);
91
92 PrintPaddedMessageString(4611, nPaddedLength);
93 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_pwerrors);
94
95 PrintPaddedMessageString(4608, nPaddedLength);
96 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_fopens);
97
98 PrintPaddedMessageString(4613, nPaddedLength);
99 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_devopens);
100
101 PrintPaddedMessageString(4609, nPaddedLength);
102 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_jobsqueued);
103
104 PrintMessageString(4620);
105 ConPrintf(StdOut, L"\n");
106
107 ConPrintf(StdOut, L" ");
108 PrintPaddedMessageString(4621, nPaddedLength - 2);
109 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_bigbufneed);
110
111 ConPrintf(StdOut, L" ");
112 PrintPaddedMessageString(4622, nPaddedLength - 2);
113 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_reqbufneed);
114
115done:
116 if (StatisticsInfo != NULL)
117 NetApiBufferFree(StatisticsInfo);
118
119 if (ServerInfo != NULL)
120 NetApiBufferFree(ServerInfo);
121
122 return 0;
123}
124
125
126static
127INT
129{
130 PWKSTA_INFO_100 WorkstationInfo = NULL;
131 PSTAT_WORKSTATION_0 StatisticsInfo = NULL;
132 LARGE_INTEGER LargeValue;
133 FILETIME FileTime, LocalFileTime;
134 SYSTEMTIME SystemTime;
135 WCHAR DateBuffer[32], TimeBuffer[32];
136 INT nPaddedLength = 47;
138
140 100,
141 (PBYTE*)&WorkstationInfo);
142 if (Status != NERR_Success)
143 goto done;
144
147 0,
148 0,
149 (LPBYTE*)&StatisticsInfo);
150 if (Status != NERR_Success)
151 goto done;
152
153 PrintMessageStringV(4623, WorkstationInfo->wki100_computername);
154 ConPrintf(StdOut, L"\n\n");
155
156 RtlSecondsSince1970ToTime(StatisticsInfo->StatisticsStartTime.u.LowPart,
157 &LargeValue);
158 FileTime.dwLowDateTime = LargeValue.u.LowPart;
159 FileTime.dwHighDateTime = LargeValue.u.HighPart;
160 FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
161 FileTimeToSystemTime(&LocalFileTime, &SystemTime);
162
165 &SystemTime,
166 NULL,
167 DateBuffer,
168 ARRAYSIZE(DateBuffer));
169
171 0,
172 &SystemTime,
173 NULL,
174 TimeBuffer,
175 ARRAYSIZE(TimeBuffer));
176
177 PrintMessageString(4600);
178 ConPrintf(StdOut, L" %s %s\n\n\n", DateBuffer, TimeBuffer);
179
180 PrintPaddedMessageString(4630, nPaddedLength);
181 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->BytesReceived.QuadPart);
182
183 PrintPaddedMessageString(4631, nPaddedLength);
184 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->SmbsReceived.QuadPart);
185
186 PrintPaddedMessageString(4632, nPaddedLength);
187 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->BytesTransmitted.QuadPart);
188
189 PrintPaddedMessageString(4633, nPaddedLength);
190 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->SmbsTransmitted.QuadPart);
191
192 PrintPaddedMessageString(4634, nPaddedLength);
193 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->ReadOperations);
194
195 PrintPaddedMessageString(4635, nPaddedLength);
196 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->WriteOperations);
197
198 PrintPaddedMessageString(4636, nPaddedLength);
199 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->RawReadsDenied);
200
201 PrintPaddedMessageString(4637, nPaddedLength);
202 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->RawWritesDenied);
203
204 PrintPaddedMessageString(4638, nPaddedLength);
205 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->NetworkErrors);
206
207 PrintPaddedMessageString(4639, nPaddedLength);
208 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->CoreConnects +
209 StatisticsInfo->Lanman20Connects +
210 StatisticsInfo->Lanman21Connects +
211 StatisticsInfo->LanmanNtConnects);
212
213 PrintPaddedMessageString(4640, nPaddedLength);
214 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->Reconnects);
215
216 PrintPaddedMessageString(4641, nPaddedLength);
217 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->ServerDisconnects);
218
219 PrintPaddedMessageString(4642, nPaddedLength);
220 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->Sessions);
221
222 PrintPaddedMessageString(4643, nPaddedLength);
223 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->HungSessions);
224
225 PrintPaddedMessageString(4644, nPaddedLength);
226 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->FailedSessions);
227
228 PrintPaddedMessageString(4645, nPaddedLength);
229 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->InitiallyFailedOperations +
230 StatisticsInfo->FailedCompletionOperations);
231
232 PrintPaddedMessageString(4646, nPaddedLength);
233 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->UseCount);
234
235 PrintPaddedMessageString(4647, nPaddedLength);
236 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->FailedUseCount);
237
238done:
239 if (StatisticsInfo != NULL)
240 NetApiBufferFree(StatisticsInfo);
241
242 if (WorkstationInfo != NULL)
243 NetApiBufferFree(WorkstationInfo);
244
245 return 0;
246}
247
248
249INT
251 INT argc,
252 WCHAR **argv)
253{
254 INT i, result = 0;
255 BOOL bServer = FALSE;
256 BOOL bWorkstation = FALSE;
257
258 for (i = 2; i < argc; i++)
259 {
260 if (_wcsicmp(argv[i], L"server") == 0)
261 {
262 if (bWorkstation == FALSE)
263 bServer = TRUE;
264 continue;
265 }
266
267 if (_wcsicmp(argv[i], L"workstation") == 0)
268 {
269 if (bServer == FALSE)
270 bWorkstation = TRUE;
271 continue;
272 }
273
274 if (_wcsicmp(argv[i], L"help") == 0)
275 {
276 /* Print short syntax help */
277 PrintMessageString(4381);
278 ConPuts(StdOut, L"\n");
279 PrintNetMessage(MSG_STATISTICS_SYNTAX);
280 return 0;
281 }
282
283 if (_wcsicmp(argv[i], L"/help") == 0)
284 {
285 /* Print full help text*/
286 PrintMessageString(4381);
287 ConPuts(StdOut, L"\n");
288 PrintNetMessage(MSG_STATISTICS_SYNTAX);
289 PrintNetMessage(MSG_STATISTICS_HELP);
290 return 0;
291 }
292 }
293
294 if (bServer)
295 {
297 }
298 else if (bWorkstation)
299 {
301 }
302 else
303 {
304 PrintMessageString(4379);
305 ConPuts(StdOut, L"\n");
306 ConPuts(StdOut, L" Server\n");
307 ConPuts(StdOut, L" Workstation\n");
308 ConPuts(StdOut, L"\n");
309 }
310
311 if (result == 0)
313
314 return result;
315}
static int argc
Definition: ServiceArgs.c:12
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:239
VOID PrintPaddedMessageString(DWORD dwMessage, INT nPaddedLength)
Definition: main.c:143
VOID PrintMessageStringV(DWORD dwMessage,...)
Definition: main.c:93
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:120
static INT DisplayServerStatistics(VOID)
Definition: cmdStatistics.c:14
static INT DisplayWorkstationStatistics(VOID)
INT cmdStatistics(INT argc, WCHAR **argv)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetStatisticsGet(_In_ LPWSTR server, _In_ LPWSTR service, _In_ DWORD level, _In_ DWORD options, _Out_ LPBYTE *bufptr)
Definition: misc.c:55
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1089
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:989
#define NERR_Success
Definition: lmerr.h:5
#define SERVICE_SERVER
Definition: lmsname.h:7
#define SERVICE_WORKSTATION
Definition: lmsname.h:4
#define argv
Definition: mplay32.c:18
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#define LOCALE_USER_DEFAULT
BYTE * PBYTE
Definition: pedump.c:66
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
Deprecated header file that includes net_sockets.h.
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
LPWSTR sv100_name
Definition: lmserver.h:13
DWORD sts0_bytessent_high
Definition: lmstats.h:22
DWORD sts0_bytesrcvd_high
Definition: lmstats.h:24
DWORD sts0_avresponse
Definition: lmstats.h:25
DWORD sts0_pwerrors
Definition: lmstats.h:18
DWORD sts0_sopens
Definition: lmstats.h:15
DWORD sts0_reqbufneed
Definition: lmstats.h:26
DWORD sts0_stimedout
Definition: lmstats.h:16
DWORD sts0_bytessent_low
Definition: lmstats.h:21
DWORD sts0_start
Definition: lmstats.h:11
DWORD sts0_jobsqueued
Definition: lmstats.h:14
DWORD sts0_devopens
Definition: lmstats.h:13
DWORD sts0_bytesrcvd_low
Definition: lmstats.h:23
DWORD sts0_bigbufneed
Definition: lmstats.h:27
DWORD sts0_permerrors
Definition: lmstats.h:19
DWORD sts0_syserrors
Definition: lmstats.h:20
DWORD sts0_serrorout
Definition: lmstats.h:17
DWORD sts0_fopens
Definition: lmstats.h:12
DWORD NetworkErrors
Definition: lmstats.h:91
DWORD Lanman20Connects
Definition: lmstats.h:96
DWORD FailedSessions
Definition: lmstats.h:93
DWORD Lanman21Connects
Definition: lmstats.h:97
LARGE_INTEGER StatisticsStartTime
Definition: lmstats.h:64
LARGE_INTEGER SmbsTransmitted
Definition: lmstats.h:72
DWORD InitiallyFailedOperations
Definition: lmstats.h:77
DWORD RawWritesDenied
Definition: lmstats.h:90
DWORD CoreConnects
Definition: lmstats.h:95
DWORD LanmanNtConnects
Definition: lmstats.h:98
DWORD RawReadsDenied
Definition: lmstats.h:89
LARGE_INTEGER BytesReceived
Definition: lmstats.h:65
DWORD FailedUseCount
Definition: lmstats.h:102
DWORD WriteOperations
Definition: lmstats.h:84
DWORD ReadOperations
Definition: lmstats.h:79
DWORD ServerDisconnects
Definition: lmstats.h:99
DWORD FailedCompletionOperations
Definition: lmstats.h:78
LARGE_INTEGER BytesTransmitted
Definition: lmstats.h:71
LARGE_INTEGER SmbsReceived
Definition: lmstats.h:66
LPWSTR wki100_computername
Definition: lmwksta.h:66
unsigned char * LPBYTE
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2479 u
#define DATE_SHORTDATE
Definition: winnls.h:209
NET_API_STATUS WINAPI NetWkstaGetInfo(_In_ LPWSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr)
Definition: wksta_new.c:868
__wchar_t WCHAR
Definition: xmlstorage.h:180