ReactOS  0.4.11-dev-946-g431643b
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 240 of file cmdStatistics.c.

243 {
244  INT i, result = 0;
245  BOOL bServer = FALSE;
246  BOOL bWorkstation = FALSE;
247 
248  for (i = 2; i < argc; i++)
249  {
250  if (_wcsicmp(argv[i], L"server") == 0)
251  {
252  if (bWorkstation == FALSE)
253  bServer = TRUE;
254  continue;
255  }
256 
257  if (_wcsicmp(argv[i], L"workstation") == 0)
258  {
259  if (bServer == FALSE)
260  bWorkstation = TRUE;
261  continue;
262  }
263 
264  if (_wcsicmp(argv[i], L"help") == 0)
265  {
266  /* Print short syntax help */
269  return 0;
270  }
271 
272  if (_wcsicmp(argv[i], L"/help") == 0)
273  {
274  /* Print full help text*/
279  return 0;
280  }
281  }
282 
283  if (bServer)
284  {
285  result = DisplayServerStatistics();
286  }
287  else if (bWorkstation)
288  {
289  result = DisplayWorkstationStatistics();
290  }
291  else
292  {
294  }
295 
296  if (result == 0)
298 
299  return result;
300 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define IDS_STATISTICS_TEXT
Definition: resource.h:129
static INT DisplayWorkstationStatistics(VOID)
int32_t INT
Definition: typedefs.h:56
static char ** argv
Definition: ServiceArgs.c:11
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define IDS_GENERIC_SYNTAX
Definition: resource.h:202
#define IDS_STATISTICS_HELP_2
Definition: resource.h:72
unsigned int BOOL
Definition: ntddk_ex.h:94
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_ERROR_NO_ERROR
Definition: resource.h:208
#define IDS_STATISTICS_SYNTAX
Definition: resource.h:70
static INT DisplayServerStatistics(VOID)
Definition: cmdStatistics.c:14
#define StdOut
Definition: stream.h:76
GLuint64EXT * result
Definition: glext.h:11304
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define IDS_STATISTICS_HELP_1
Definition: resource.h:71

◆ DisplayServerStatistics()

static INT DisplayServerStatistics ( VOID  )
static

Definition at line 14 of file cmdStatistics.c.

Referenced by cmdStatistics().

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 
29  Status = NetStatisticsGet(NULL,
31  0,
32  0,
33  (LPBYTE*)&StatisticsInfo);
34  if (Status != NERR_Success)
35  goto done;
36 
38 
39  RtlSecondsSince1970ToTime(StatisticsInfo->sts0_start,
40  &LargeValue);
41  FileTime.dwLowDateTime = LargeValue.u.LowPart;
42  FileTime.dwHighDateTime = LargeValue.u.HighPart;
43  FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
44  FileTimeToSystemTime(&LocalFileTime, &SystemTime);
45 
46  wHour = SystemTime.wHour;
47  if (wHour == 0)
48  {
49  wHour = 12;
50  }
51  else if (wHour > 12)
52  {
53  wHour = wHour - 12;
54  }
55 
57  SystemTime.wMonth, SystemTime.wDay, SystemTime.wYear,
58  wHour, SystemTime.wMinute,
59  (SystemTime.wHour >= 1 && SystemTime.wHour < 13) ? L"AM" : L"PM");
60 
62  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_sopens);
63 
65  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_stimedout);
66 
68  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_serrorout);
69 
70  LargeValue.u.LowPart = StatisticsInfo->sts0_bytessent_low;
71  LargeValue.u.HighPart = StatisticsInfo->sts0_bytessent_high;
73  ConPrintf(StdOut, L"%I64u\n", LargeValue.QuadPart / 1024);
74 
75  LargeValue.u.LowPart = StatisticsInfo->sts0_bytesrcvd_low;
76  LargeValue.u.HighPart = StatisticsInfo->sts0_bytesrcvd_high;
78  ConPrintf(StdOut, L"%I64u\n", LargeValue.QuadPart / 1024);
79 
81  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_avresponse);
82 
84  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_syserrors);
85 
87  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_permerrors);
88 
90  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_pwerrors);
91 
93  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_fopens);
94 
96  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_devopens);
97 
99  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_jobsqueued);
100 
102 
104  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_bigbufneed);
105 
107  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_reqbufneed);
108 
109 done:
110  if (StatisticsInfo != NULL)
111  NetApiBufferFree(StatisticsInfo);
112 
113  if (ServerInfo != NULL)
114  NetApiBufferFree(ServerInfo);
115 
116  return 0;
117 }
struct _LARGE_INTEGER::@2193 u
DWORD sts0_avresponse
Definition: lmstats.h:25
#define IDS_STATISTICS_SRV_KBRCVD
Definition: resource.h:136
DWORD sts0_devopens
Definition: lmstats.h:13
WORD wMonth
Definition: winbase.h:871
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#define IDS_STATISTICS_SINCE
Definition: resource.h:130
#define IDS_STATISTICS_SRV_BIGBUFFERS
Definition: resource.h:145
NET_API_STATUS WINAPI NetStatisticsGet(_In_ LPWSTR server, _In_ LPWSTR service, _In_ DWORD level, _In_ DWORD options, _Out_ LPBYTE *bufptr)
Definition: misc.c:23
DWORD sts0_stimedout
Definition: lmstats.h:16
#define IDS_STATISTICS_SRV_SESSERROR
Definition: resource.h:134
#define IDS_STATISTICS_SRV_JOBS
Definition: resource.h:143
DWORD sts0_pwerrors
Definition: lmstats.h:18
#define IDS_STATISTICS_SRV_KBSENT
Definition: resource.h:135
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:211
int32_t INT
Definition: typedefs.h:56
#define SERVICE_SERVER
Definition: lmsname.h:7
DWORD sts0_syserrors
Definition: lmstats.h:20
#define NERR_Success
Definition: lmerr.h:5
#define IDS_STATISTICS_SRV_PWERRORS
Definition: resource.h:140
DWORD dwHighDateTime
Definition: mapidefs.h:66
WORD wYear
Definition: winbase.h:870
unsigned char * LPBYTE
Definition: typedefs.h:52
LPWSTR sv100_name
Definition: lmserver.h:13
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
WORD wMinute
Definition: winbase.h:875
smooth NULL
Definition: ftsmooth.c:416
DWORD sts0_bytesrcvd_low
Definition: lmstats.h:23
#define IDS_STATISTICS_SRV_SESSTIME
Definition: resource.h:133
DWORD sts0_reqbufneed
Definition: lmstats.h:26
#define IDS_STATISTICS_SRV_SYSERRORS
Definition: resource.h:138
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
DWORD sts0_serrorout
Definition: lmstats.h:17
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
DWORD sts0_bigbufneed
Definition: lmstats.h:27
#define IDS_STATISTICS_SRV_FILES
Definition: resource.h:141
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
unsigned short WORD
Definition: ntddk_ex.h:93
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
DWORD sts0_permerrors
Definition: lmstats.h:19
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_STATISTICS_SRV_NAME
Definition: resource.h:131
DWORD sts0_bytessent_low
Definition: lmstats.h:21
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
DWORD sts0_bytessent_high
Definition: lmstats.h:22
Status
Definition: gdiplustypes.h:24
WORD wDay
Definition: winbase.h:873
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
VOID PrintPaddedResourceString(UINT uID, INT nPaddedLength)
Definition: main.c:51
#define IDS_STATISTICS_SRV_PMERRORS
Definition: resource.h:139
WORD wHour
Definition: winbase.h:874
DWORD sts0_fopens
Definition: lmstats.h:12
DWORD sts0_start
Definition: lmstats.h:11
#define IDS_STATISTICS_SRV_SESACCEPT
Definition: resource.h:132
DWORD sts0_jobsqueued
Definition: lmstats.h:14
#define StdOut
Definition: stream.h:76
#define IDS_STATISTICS_SRV_DEVICES
Definition: resource.h:142
DWORD sts0_sopens
Definition: lmstats.h:15
DWORD sts0_bytesrcvd_high
Definition: lmstats.h:24
BYTE * PBYTE
Definition: pedump.c:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
#define IDS_STATISTICS_SRV_BUFFERS
Definition: resource.h:144
LONGLONG QuadPart
Definition: typedefs.h:112
#define IDS_STATISTICS_SRV_REQBUFFERS
Definition: resource.h:146
#define IDS_STATISTICS_SRV_MRESPTIME
Definition: resource.h:137

◆ DisplayWorkstationStatistics()

static INT DisplayWorkstationStatistics ( VOID  )
static

Definition at line 122 of file cmdStatistics.c.

Referenced by cmdStatistics().

123 {
124  PWKSTA_INFO_100 WorkstationInfo = NULL;
125  PSTAT_WORKSTATION_0 StatisticsInfo = NULL;
126  LARGE_INTEGER LargeValue;
127  FILETIME FileTime, LocalFileTime;
128  SYSTEMTIME SystemTime;
129  WORD wHour;
130  INT nPaddedLength = 47;
132 
133  Status = NetWkstaGetInfo(NULL,
134  100,
135  (PBYTE*)&WorkstationInfo);
136  if (Status != NERR_Success)
137  goto done;
138 
139  Status = NetStatisticsGet(NULL,
141  0,
142  0,
143  (LPBYTE*)&StatisticsInfo);
144  if (Status != NERR_Success)
145  goto done;
146 
148 
149  RtlSecondsSince1970ToTime(StatisticsInfo->StatisticsStartTime.u.LowPart,
150  &LargeValue);
151  FileTime.dwLowDateTime = LargeValue.u.LowPart;
152  FileTime.dwHighDateTime = LargeValue.u.HighPart;
153  FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
154  FileTimeToSystemTime(&LocalFileTime, &SystemTime);
155 
156  wHour = SystemTime.wHour;
157  if (wHour == 0)
158  {
159  wHour = 12;
160  }
161  else if (wHour > 12)
162  {
163  wHour = wHour - 12;
164  }
165 
167  SystemTime.wMonth, SystemTime.wDay, SystemTime.wYear,
168  wHour, SystemTime.wMinute, (SystemTime.wHour >= 1 && SystemTime.wHour < 13) ? L"AM" : L"PM");
169 
171  ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->BytesReceived.QuadPart);
172 
174  ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->SmbsReceived.QuadPart);
175 
177  ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->BytesTransmitted.QuadPart);
178 
180  ConPrintf(StdOut, L"%I64u\n", StatisticsInfo->SmbsTransmitted.QuadPart);
181 
183  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->ReadOperations);
184 
186  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->WriteOperations);
187 
189  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->RawReadsDenied);
190 
192  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->RawWritesDenied);
193 
195  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->NetworkErrors);
196 
198  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->CoreConnects +
199  StatisticsInfo->Lanman20Connects +
200  StatisticsInfo->Lanman21Connects +
201  StatisticsInfo->LanmanNtConnects);
202 
204  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->Reconnects);
205 
207  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->ServerDisconnects);
208 
210  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->Sessions);
211 
213  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->HungSessions);
214 
216  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->FailedSessions);
217 
219  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->InitiallyFailedOperations +
220  StatisticsInfo->FailedCompletionOperations);
221 
223  ConPrintf(StdOut, L"%lu\n", StatisticsInfo->UseCount);
224 
226  ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->FailedUseCount);
227 
228 done:
229  if (StatisticsInfo != NULL)
230  NetApiBufferFree(StatisticsInfo);
231 
232  if (WorkstationInfo != NULL)
233  NetApiBufferFree(WorkstationInfo);
234 
235  return 0;
236 }
#define IDS_STATISTICS_WKS_NAME
Definition: resource.h:147
#define IDS_STATISTICS_WKS_SESSIONS
Definition: resource.h:160
struct _LARGE_INTEGER::@2193 u
LARGE_INTEGER StatisticsStartTime
Definition: lmstats.h:64
DWORD FailedSessions
Definition: lmstats.h:93
WORD wMonth
Definition: winbase.h:871
#define IDS_STATISTICS_WKS_RECONNECTS
Definition: resource.h:158
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#define IDS_STATISTICS_WKS_FAILUSECOUNT
Definition: resource.h:165
#define IDS_STATISTICS_SINCE
Definition: resource.h:130
#define IDS_STATISTICS_WKS_READOPS
Definition: resource.h:152
DWORD InitiallyFailedOperations
Definition: lmstats.h:77
NET_API_STATUS WINAPI NetStatisticsGet(_In_ LPWSTR server, _In_ LPWSTR service, _In_ DWORD level, _In_ DWORD options, _Out_ LPBYTE *bufptr)
Definition: misc.c:23
LARGE_INTEGER SmbsReceived
Definition: lmstats.h:66
DWORD FailedUseCount
Definition: lmstats.h:102
#define IDS_STATISTICS_WKS_WRITEOPS
Definition: resource.h:153
LARGE_INTEGER SmbsTransmitted
Definition: lmstats.h:72
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:211
LARGE_INTEGER BytesReceived
Definition: lmstats.h:65
int32_t INT
Definition: typedefs.h:56
#define SERVICE_SERVER
Definition: lmsname.h:7
#define NERR_Success
Definition: lmerr.h:5
DWORD dwHighDateTime
Definition: mapidefs.h:66
WORD wYear
Definition: winbase.h:870
unsigned char * LPBYTE
Definition: typedefs.h:52
#define IDS_STATISTICS_WKS_BYTESTRANS
Definition: resource.h:150
#define IDS_STATISTICS_WKS_READDENIED
Definition: resource.h:154
#define IDS_STATISTICS_WKS_FAILSESSIONS
Definition: resource.h:162
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_STATISTICS_WKS_WRITEDENIED
Definition: resource.h:155
WORD wMinute
Definition: winbase.h:875
smooth NULL
Definition: ftsmooth.c:416
DWORD LanmanNtConnects
Definition: lmstats.h:98
DWORD WriteOperations
Definition: lmstats.h:84
DWORD Lanman21Connects
Definition: lmstats.h:97
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
unsigned short WORD
Definition: ntddk_ex.h:93
DWORD RawReadsDenied
Definition: lmstats.h:89
#define IDS_STATISTICS_WKS_BYTESRCVD
Definition: resource.h:148
static const WCHAR L[]
Definition: oid.c:1087
#define IDS_STATISTICS_WKS_USECOUNT
Definition: resource.h:164
NET_API_STATUS WINAPI NetWkstaGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: wksta.c:472
Status
Definition: gdiplustypes.h:24
DWORD ServerDisconnects
Definition: lmstats.h:99
#define IDS_STATISTICS_WKS_HUNGSESSIONS
Definition: resource.h:161
WORD wDay
Definition: winbase.h:873
LARGE_INTEGER BytesTransmitted
Definition: lmstats.h:71
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
DWORD ReadOperations
Definition: lmstats.h:79
VOID PrintPaddedResourceString(UINT uID, INT nPaddedLength)
Definition: main.c:51
DWORD CoreConnects
Definition: lmstats.h:95
WORD wHour
Definition: winbase.h:874
#define IDS_STATISTICS_WKS_SMBSTRANS
Definition: resource.h:151
#define IDS_STATISTICS_WKS_SMBSRCVD
Definition: resource.h:149
DWORD RawWritesDenied
Definition: lmstats.h:90
DWORD Lanman20Connects
Definition: lmstats.h:96
#define StdOut
Definition: stream.h:76
LPWSTR wki100_computername
Definition: lmwksta.h:66
#define IDS_STATISTICS_WKS_DISCONNECTS
Definition: resource.h:159
#define IDS_STATISTICS_WKS_NETWORKERROR
Definition: resource.h:156
DWORD NetworkErrors
Definition: lmstats.h:91
BYTE * PBYTE
Definition: pedump.c:66
#define IDS_STATISTICS_WKS_FAILEDOPS
Definition: resource.h:163
#define IDS_STATISTICS_WKS_CONNECTS
Definition: resource.h:157
DWORD dwLowDateTime
Definition: mapidefs.h:65
DWORD FailedCompletionOperations
Definition: lmstats.h:78
LONGLONG QuadPart
Definition: typedefs.h:112