ReactOS  0.4.12-dev-714-gfaac916
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 */
268  PrintNetMessage(MSG_STATISTICS_SYNTAX);
269  return 0;
270  }
271 
272  if (_wcsicmp(argv[i], L"/help") == 0)
273  {
274  /* Print full help text*/
276  PrintNetMessage(MSG_STATISTICS_SYNTAX);
277  PrintNetMessage(MSG_STATISTICS_HELP);
278  return 0;
279  }
280  }
281 
282  if (bServer)
283  {
285  }
286  else if (bWorkstation)
287  {
289  }
290  else
291  {
293  }
294 
295  if (result == 0)
297 
298  return result;
299 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDS_STATISTICS_TEXT
Definition: resource.h:45
static INT DisplayWorkstationStatistics(VOID)
VOID PrintNetMessage(DWORD dwMessage)
Definition: main.c:149
#define argv
Definition: mplay32.c:18
int32_t INT
Definition: typedefs.h:56
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 IDS_GENERIC_SYNTAX
Definition: resource.h:118
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:1250
static VOID PrintErrorMessage(DWORD dwError)
Definition: at.c:308
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)

◆ 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 
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 }
DWORD sts0_avresponse
Definition: lmstats.h:25
#define IDS_STATISTICS_SRV_KBRCVD
Definition: resource.h:52
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:46
#define IDS_STATISTICS_SRV_BIGBUFFERS
Definition: resource.h:61
NET_API_STATUS WINAPI NetStatisticsGet(_In_ LPWSTR server, _In_ LPWSTR service, _In_ DWORD level, _In_ DWORD options, _Out_ LPBYTE *bufptr)
Definition: misc.c:55
DWORD sts0_stimedout
Definition: lmstats.h:16
#define IDS_STATISTICS_SRV_SESSERROR
Definition: resource.h:50
#define IDS_STATISTICS_SRV_JOBS
Definition: resource.h:59
DWORD sts0_pwerrors
Definition: lmstats.h:18
#define IDS_STATISTICS_SRV_KBSENT
Definition: resource.h:51
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:56
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:49
DWORD sts0_reqbufneed
Definition: lmstats.h:26
#define IDS_STATISTICS_SRV_SYSERRORS
Definition: resource.h:54
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:57
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:1250
#define IDS_STATISTICS_SRV_NAME
Definition: resource.h:47
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:52
#define IDS_STATISTICS_SRV_PMERRORS
Definition: resource.h:55
WORD wHour
Definition: winbase.h:874
DWORD sts0_fopens
Definition: lmstats.h:12
DWORD sts0_start
Definition: lmstats.h:11
struct _LARGE_INTEGER::@2190 u
#define IDS_STATISTICS_SRV_SESACCEPT
Definition: resource.h:48
DWORD sts0_jobsqueued
Definition: lmstats.h:14
#define StdOut
Definition: stream.h:76
#define IDS_STATISTICS_SRV_DEVICES
Definition: resource.h:58
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:60
LONGLONG QuadPart
Definition: typedefs.h:112
#define IDS_STATISTICS_SRV_REQBUFFERS
Definition: resource.h:62
#define IDS_STATISTICS_SRV_MRESPTIME
Definition: resource.h:53

Referenced by cmdStatistics().

◆ DisplayWorkstationStatistics()

static INT DisplayWorkstationStatistics ( VOID  )
static

Definition at line 122 of file cmdStatistics.c.

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 
134  100,
135  (PBYTE*)&WorkstationInfo);
136  if (Status != NERR_Success)
137  goto done;
138 
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:63
#define IDS_STATISTICS_WKS_SESSIONS
Definition: resource.h:76
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:74
NTSYSAPI VOID NTAPI RtlSecondsSince1970ToTime(_In_ ULONG SecondsSince1970, _Out_ PLARGE_INTEGER Time)
#define IDS_STATISTICS_WKS_FAILUSECOUNT
Definition: resource.h:81
#define IDS_STATISTICS_SINCE
Definition: resource.h:46
#define IDS_STATISTICS_WKS_READOPS
Definition: resource.h:68
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:55
LARGE_INTEGER SmbsReceived
Definition: lmstats.h:66
DWORD FailedUseCount
Definition: lmstats.h:102
#define IDS_STATISTICS_WKS_WRITEOPS
Definition: resource.h:69
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:66
#define IDS_STATISTICS_WKS_READDENIED
Definition: resource.h:70
#define IDS_STATISTICS_WKS_FAILSESSIONS
Definition: resource.h:78
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define IDS_STATISTICS_WKS_WRITEDENIED
Definition: resource.h:71
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:64
static const WCHAR L[]
Definition: oid.c:1250
#define IDS_STATISTICS_WKS_USECOUNT
Definition: resource.h:80
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:77
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:52
DWORD CoreConnects
Definition: lmstats.h:95
WORD wHour
Definition: winbase.h:874
#define IDS_STATISTICS_WKS_SMBSTRANS
Definition: resource.h:67
#define IDS_STATISTICS_WKS_SMBSRCVD
Definition: resource.h:65
DWORD RawWritesDenied
Definition: lmstats.h:90
struct _LARGE_INTEGER::@2190 u
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:75
#define IDS_STATISTICS_WKS_NETWORKERROR
Definition: resource.h:72
DWORD NetworkErrors
Definition: lmstats.h:91
BYTE * PBYTE
Definition: pedump.c:66
#define IDS_STATISTICS_WKS_FAILEDOPS
Definition: resource.h:79
#define IDS_STATISTICS_WKS_CONNECTS
Definition: resource.h:73
DWORD dwLowDateTime
Definition: mapidefs.h:65
DWORD FailedCompletionOperations
Definition: lmstats.h:78
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by cmdStatistics().