ReactOS 0.4.16-dev-297-gc569aee
cmdStatistics.c File Reference
#include "net.h"
#include <rtltypes.h>
#include <rtlfuncs.h>
Include dependency graph for cmdStatistics.c:

Go to the source code of this file.

Functions

static INT DisplayServerStatistics (VOID)
 
static INT DisplayWorkstationStatistics (VOID)
 
INT cmdStatistics (INT argc, WCHAR **argv)
 

Function Documentation

◆ cmdStatistics()

INT cmdStatistics ( INT  argc,
WCHAR **  argv 
)

Definition at line 248 of file cmdStatistics.c.

251{
252 INT i, result = 0;
253 BOOL bServer = FALSE;
254 BOOL bWorkstation = FALSE;
255
256 for (i = 2; i < argc; i++)
257 {
258 if (_wcsicmp(argv[i], L"server") == 0)
259 {
260 if (bWorkstation == FALSE)
261 bServer = TRUE;
262 continue;
263 }
264
265 if (_wcsicmp(argv[i], L"workstation") == 0)
266 {
267 if (bServer == FALSE)
268 bWorkstation = TRUE;
269 continue;
270 }
271
272 if (_wcsicmp(argv[i], L"help") == 0)
273 {
274 /* Print short syntax help */
275 PrintMessageString(4381);
276 ConPuts(StdOut, L"\n");
277 PrintNetMessage(MSG_STATISTICS_SYNTAX);
278 return 0;
279 }
280
281 if (_wcsicmp(argv[i], L"/help") == 0)
282 {
283 /* Print full help text*/
284 PrintMessageString(4381);
285 ConPuts(StdOut, L"\n");
286 PrintNetMessage(MSG_STATISTICS_SYNTAX);
287 PrintNetMessage(MSG_STATISTICS_HELP);
288 return 0;
289 }
290 }
291
292 if (bServer)
293 {
295 }
296 else if (bWorkstation)
297 {
299 }
300 else
301 {
302 PrintMessageString(4379);
303 ConPuts(StdOut, L"\n");
304 ConPuts(StdOut, L" Server\n");
305 ConPuts(StdOut, L" Workstation\n");
306 ConPuts(StdOut, L"\n");
307 }
308
309 if (result == 0)
311
312 return result;
313}
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
#define StdOut
Definition: fc.c:14
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:239
VOID PrintMessageString(DWORD dwMessage)
Definition: main.c:120
static INT DisplayServerStatistics(VOID)
Definition: cmdStatistics.c:14
static INT DisplayWorkstationStatistics(VOID)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
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
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
int32_t INT
Definition: typedefs.h:58

◆ DisplayServerStatistics()

static INT DisplayServerStatistics ( VOID  )
static

Definition at line 14 of file cmdStatistics.c.

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 WORD wHour;
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
47 wHour = SystemTime.wHour;
48 if (wHour == 0)
49 {
50 wHour = 12;
51 }
52 else if (wHour > 12)
53 {
54 wHour = wHour - 12;
55 }
56
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");
62
63 PrintPaddedMessageString(4601, nPaddedLength);
64 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_sopens);
65
66 PrintPaddedMessageString(4602, nPaddedLength);
67 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_stimedout);
68
69 PrintPaddedMessageString(4603, nPaddedLength);
70 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_serrorout);
71
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);
76
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);
81
82 PrintPaddedMessageString(4606, nPaddedLength);
83 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_avresponse);
84
85 PrintPaddedMessageString(4610, nPaddedLength);
86 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_syserrors);
87
88 PrintPaddedMessageString(4612, nPaddedLength);
89 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_permerrors);
90
91 PrintPaddedMessageString(4611, nPaddedLength);
92 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_pwerrors);
93
94 PrintPaddedMessageString(4608, nPaddedLength);
95 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_fopens);
96
97 PrintPaddedMessageString(4613, nPaddedLength);
98 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_devopens);
99
100 PrintPaddedMessageString(4609, nPaddedLength);
101 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_jobsqueued);
102
103 PrintMessageString(4620);
104 ConPrintf(StdOut, L"\n");
105
106 ConPrintf(StdOut, L" ");
107 PrintPaddedMessageString(4621, nPaddedLength - 2);
108 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_bigbufneed);
109
110 ConPrintf(StdOut, L" ");
111 PrintPaddedMessageString(4622, nPaddedLength - 2);
112 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_reqbufneed);
113
114done:
115 if (StatisticsInfo != NULL)
116 NetApiBufferFree(StatisticsInfo);
117
118 if (ServerInfo != NULL)
119 NetApiBufferFree(ServerInfo);
120
121 return 0;
122}
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
VOID PrintPaddedMessageString(DWORD dwMessage, INT nPaddedLength)
Definition: main.c:143
VOID PrintMessageStringV(DWORD dwMessage,...)
Definition: main.c:93
#define NULL
Definition: types.h:112
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
unsigned short WORD
Definition: ntddk_ex.h:93
Status
Definition: gdiplustypes.h:25
#define NERR_Success
Definition: lmerr.h:5
#define SERVICE_SERVER
Definition: lmsname.h:7
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
BYTE * PBYTE
Definition: pedump.c:66
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
WORD wYear
Definition: winbase.h:930
WORD wMonth
Definition: winbase.h:931
WORD wHour
Definition: winbase.h:934
WORD wMinute
Definition: winbase.h:935
WORD wDay
Definition: winbase.h:933
unsigned char * LPBYTE
Definition: typedefs.h:53
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2302 u

Referenced by cmdStatistics().

◆ DisplayWorkstationStatistics()

static INT DisplayWorkstationStatistics ( VOID  )
static

Definition at line 127 of file cmdStatistics.c.

128{
129 PWKSTA_INFO_100 WorkstationInfo = NULL;
130 PSTAT_WORKSTATION_0 StatisticsInfo = NULL;
131 LARGE_INTEGER LargeValue;
132 FILETIME FileTime, LocalFileTime;
133 SYSTEMTIME SystemTime;
134 WORD wHour;
135 INT nPaddedLength = 47;
137
139 100,
140 (PBYTE*)&WorkstationInfo);
141 if (Status != NERR_Success)
142 goto done;
143
146 0,
147 0,
148 (LPBYTE*)&StatisticsInfo);
149 if (Status != NERR_Success)
150 goto done;
151
152 PrintMessageStringV(4623, WorkstationInfo->wki100_computername);
153 ConPrintf(StdOut, L"\n\n");
154
155 RtlSecondsSince1970ToTime(StatisticsInfo->StatisticsStartTime.u.LowPart,
156 &LargeValue);
157 FileTime.dwLowDateTime = LargeValue.u.LowPart;
158 FileTime.dwHighDateTime = LargeValue.u.HighPart;
159 FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
160 FileTimeToSystemTime(&LocalFileTime, &SystemTime);
161
162 wHour = SystemTime.wHour;
163 if (wHour == 0)
164 {
165 wHour = 12;
166 }
167 else if (wHour > 12)
168 {
169 wHour = wHour - 12;
170 }
171
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");
177
178 PrintPaddedMessageString(4630, nPaddedLength);
179 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->BytesReceived.QuadPart);
180
181 PrintPaddedMessageString(4631, nPaddedLength);
182 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->SmbsReceived.QuadPart);
183
184 PrintPaddedMessageString(4632, nPaddedLength);
185 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->BytesTransmitted.QuadPart);
186
187 PrintPaddedMessageString(4633, nPaddedLength);
188 ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->SmbsTransmitted.QuadPart);
189
190 PrintPaddedMessageString(4634, nPaddedLength);
191 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->ReadOperations);
192
193 PrintPaddedMessageString(4635, nPaddedLength);
194 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->WriteOperations);
195
196 PrintPaddedMessageString(4636, nPaddedLength);
197 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->RawReadsDenied);
198
199 PrintPaddedMessageString(4637, nPaddedLength);
200 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->RawWritesDenied);
201
202 PrintPaddedMessageString(4638, nPaddedLength);
203 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->NetworkErrors);
204
205 PrintPaddedMessageString(4639, nPaddedLength);
206 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->CoreConnects +
207 StatisticsInfo->Lanman20Connects +
208 StatisticsInfo->Lanman21Connects +
209 StatisticsInfo->LanmanNtConnects);
210
211 PrintPaddedMessageString(4640, nPaddedLength);
212 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->Reconnects);
213
214 PrintPaddedMessageString(4641, nPaddedLength);
215 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->ServerDisconnects);
216
217 PrintPaddedMessageString(4642, nPaddedLength);
218 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->Sessions);
219
220 PrintPaddedMessageString(4643, nPaddedLength);
221 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->HungSessions);
222
223 PrintPaddedMessageString(4644, nPaddedLength);
224 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->FailedSessions);
225
226 PrintPaddedMessageString(4645, nPaddedLength);
227 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->InitiallyFailedOperations +
228 StatisticsInfo->FailedCompletionOperations);
229
230 PrintPaddedMessageString(4646, nPaddedLength);
231 ConPrintf(StdOut, L"%lu\n", StatisticsInfo->UseCount);
232
233 PrintPaddedMessageString(4647, nPaddedLength);
234 ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->FailedUseCount);
235
236done:
237 if (StatisticsInfo != NULL)
238 NetApiBufferFree(StatisticsInfo);
239
240 if (WorkstationInfo != NULL)
241 NetApiBufferFree(WorkstationInfo);
242
243 return 0;
244}
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
NET_API_STATUS WINAPI NetWkstaGetInfo(_In_ LPWSTR servername, _In_ DWORD level, _Out_ LPBYTE *bufptr)
Definition: wksta_new.c:868

Referenced by cmdStatistics().