[NET] Improve the NET STATISTICS command

- Add resource strings for the NET STATISTICS SERVER command.
- Convert and display the 'statistics since' time.
This commit is contained in:
Eric Kohl 2018-04-10 21:32:30 +02:00
parent 30eb3859f4
commit 2e60a17e8b
9 changed files with 235 additions and 35 deletions

View file

@ -6,6 +6,8 @@
*/
#include "net.h"
#include <rtltypes.h>
#include <rtlfuncs.h>
static
INT
@ -14,6 +16,10 @@ DisplayServerStatistics(VOID)
PSERVER_INFO_100 ServerInfo = NULL;
PSTAT_SERVER_0 StatisticsInfo = NULL;
LARGE_INTEGER LargeValue;
FILETIME FileTime, LocalFileTime;
SYSTEMTIME SystemTime;
WORD wHour;
INT nPaddedLength = 33;
NET_API_STATUS Status;
Status = NetServerGetInfo(NULL, 100, (PBYTE*)&ServerInfo);
@ -28,35 +34,77 @@ DisplayServerStatistics(VOID)
if (Status != NERR_Success)
goto done;
ConResPrintf(StdOut, IDS_STATISTICS_SERVER_NAME, ServerInfo->sv100_name);
ConResPrintf(StdOut, IDS_STATISTICS_SRV_NAME, ServerInfo->sv100_name);
printf("Statistik since %lu\n\n\n", StatisticsInfo->sts0_start);
RtlSecondsSince1970ToTime(StatisticsInfo->sts0_start,
&LargeValue);
FileTime.dwLowDateTime = LargeValue.u.LowPart;
FileTime.dwHighDateTime = LargeValue.u.HighPart;
FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
FileTimeToSystemTime(&LocalFileTime, &SystemTime);
printf("Sessions accepted %lu\n", StatisticsInfo->sts0_sopens);
printf("Sessions timed-out %lu\n", StatisticsInfo->sts0_stimedout);
printf("Sessions errored-out %lu\n\n", StatisticsInfo->sts0_serrorout);
wHour = SystemTime.wHour;
if (wHour == 0)
{
wHour = 12;
}
else if (wHour > 12)
{
wHour = wHour - 12;
}
ConResPrintf(StdOut, IDS_STATISTICS_SINCE,
SystemTime.wMonth, SystemTime.wDay, SystemTime.wYear,
wHour, SystemTime.wMinute,
(SystemTime.wHour >= 1 && SystemTime.wHour < 13) ? L"AM" : L"PM");
PrintPaddedResourceString(IDS_STATISTICS_SRV_SESACCEPT, nPaddedLength);
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_sopens);
PrintPaddedResourceString(IDS_STATISTICS_SRV_SESSTIME, nPaddedLength);
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_stimedout);
PrintPaddedResourceString(IDS_STATISTICS_SRV_SESSERROR, nPaddedLength);
ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_serrorout);
LargeValue.u.LowPart = StatisticsInfo->sts0_bytessent_low;
LargeValue.u.HighPart = StatisticsInfo->sts0_bytessent_high;
printf("Kilobytes sent %I64u\n", LargeValue.QuadPart / 1024);
PrintPaddedResourceString(IDS_STATISTICS_SRV_KBSENT, nPaddedLength);
ConPrintf(StdOut, L"%I64u\n", LargeValue.QuadPart / 1024);
LargeValue.u.LowPart = StatisticsInfo->sts0_bytesrcvd_low;
LargeValue.u.HighPart = StatisticsInfo->sts0_bytesrcvd_high;
printf("Kilobytes received %I64u\n\n", LargeValue.QuadPart / 1024);
PrintPaddedResourceString(IDS_STATISTICS_SRV_KBRCVD, nPaddedLength);
ConPrintf(StdOut, L"%I64u\n", LargeValue.QuadPart / 1024);
printf("Mean response time (msec) %lu\n\n", StatisticsInfo->sts0_avresponse);
PrintPaddedResourceString(IDS_STATISTICS_SRV_MRESPTIME, nPaddedLength);
ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_avresponse);
printf("System errors %lu\n", StatisticsInfo->sts0_syserrors);
printf("Permission violations %lu\n", StatisticsInfo->sts0_permerrors);
printf("Password violations %lu\n\n", StatisticsInfo->sts0_pwerrors);
PrintPaddedResourceString(IDS_STATISTICS_SRV_SYSERRORS, nPaddedLength);
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_syserrors);
printf("Files accessed %lu\n", StatisticsInfo->sts0_fopens);
printf("Communication devices accessed %lu\n", StatisticsInfo->sts0_devopens);
printf("Print jobs spooled %lu\n\n", StatisticsInfo->sts0_jobsqueued);
PrintPaddedResourceString(IDS_STATISTICS_SRV_PMERRORS, nPaddedLength);
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_permerrors);
printf("Times buffers exhausted\n\n");
printf(" Big buffers %lu\n", StatisticsInfo->sts0_bigbufneed);
printf(" Request buffers %lu\n\n", StatisticsInfo->sts0_reqbufneed);
PrintPaddedResourceString(IDS_STATISTICS_SRV_PWERRORS, nPaddedLength);
ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_pwerrors);
PrintPaddedResourceString(IDS_STATISTICS_SRV_FILES, nPaddedLength);
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_fopens);
PrintPaddedResourceString(IDS_STATISTICS_SRV_DEVICES, nPaddedLength);
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_devopens);
PrintPaddedResourceString(IDS_STATISTICS_SRV_JOBS, nPaddedLength);
ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_jobsqueued);
ConResPuts(StdOut, IDS_STATISTICS_SRV_BUFFERS);
PrintPaddedResourceString(IDS_STATISTICS_SRV_BIGBUFFERS, nPaddedLength);
ConPrintf(StdOut, L"%lu\n", StatisticsInfo->sts0_bigbufneed);
PrintPaddedResourceString(IDS_STATISTICS_SRV_REQBUFFERS, nPaddedLength);
ConPrintf(StdOut, L"%lu\n\n", StatisticsInfo->sts0_reqbufneed);
done:
if (StatisticsInfo != NULL)
@ -75,6 +123,10 @@ DisplayWorkstationStatistics(VOID)
{
PWKSTA_INFO_100 WorkstationInfo = NULL;
PSTAT_WORKSTATION_0 StatisticsInfo = NULL;
LARGE_INTEGER LargeValue;
FILETIME FileTime, LocalFileTime;
SYSTEMTIME SystemTime;
WORD wHour;
NET_API_STATUS Status;
Status = NetWkstaGetInfo(NULL,
@ -91,9 +143,28 @@ DisplayWorkstationStatistics(VOID)
if (Status != NERR_Success)
goto done;
ConResPrintf(StdOut, IDS_STATISTICS_WORKSTATION_NAME, WorkstationInfo->wki100_computername);
ConResPrintf(StdOut, IDS_STATISTICS_WKS_NAME, WorkstationInfo->wki100_computername);
printf("Statistik since %I64u\n\n\n", StatisticsInfo->StatisticsStartTime.QuadPart);
RtlSecondsSince1970ToTime(StatisticsInfo->StatisticsStartTime.u.LowPart,
&LargeValue);
FileTime.dwLowDateTime = LargeValue.u.LowPart;
FileTime.dwHighDateTime = LargeValue.u.HighPart;
FileTimeToLocalFileTime(&FileTime, &LocalFileTime);
FileTimeToSystemTime(&LocalFileTime, &SystemTime);
wHour = SystemTime.wHour;
if (wHour == 0)
{
wHour = 12;
}
else if (wHour > 12)
{
wHour = wHour - 12;
}
ConResPrintf(StdOut, IDS_STATISTICS_SINCE,
SystemTime.wMonth, SystemTime.wDay, SystemTime.wYear,
wHour, SystemTime.wMinute, (SystemTime.wHour >= 1 && SystemTime.wHour < 13) ? L"AM" : L"PM");
printf("Bytes received %I64u\n", StatisticsInfo->BytesReceived.QuadPart);
printf("Server Message Blocks (SMBs) received %I64u\n", StatisticsInfo->SmbsReceived.QuadPart);

View file

@ -193,8 +193,24 @@ service can stop others. Some services cannot be stopped.\n\n"
IDS_STATISTICS_TEXT "Statistics are available for the following services:\n\n\
Server\n Workstation\n\n"
IDS_STATISTICS_SERVER_NAME "Server statistics for \\\\%s\n\n"
IDS_STATISTICS_WORKSTATION_NAME "Workstation statistics for \\\\%s\n\n"
IDS_STATISTICS_SINCE "Statistics since %d/%d/%d %d:%d %s\n\n\n"
IDS_STATISTICS_SRV_NAME "Server statistics for \\\\%s\n\n\n"
IDS_STATISTICS_SRV_SESACCEPT "Sessions accepted"
IDS_STATISTICS_SRV_SESSTIME "Sessions timed-out"
IDS_STATISTICS_SRV_SESSERROR "Sessions errored-out"
IDS_STATISTICS_SRV_KBSENT "Kilobytes sent"
IDS_STATISTICS_SRV_KBRCVD "Kilobytes received"
IDS_STATISTICS_SRV_MRESPTIME "Mean response time (msec)"
IDS_STATISTICS_SRV_SYSERRORS "System errors"
IDS_STATISTICS_SRV_PMERRORS "Permission violations"
IDS_STATISTICS_SRV_PWERRORS "Password violations"
IDS_STATISTICS_SRV_FILES "Files accessed"
IDS_STATISTICS_SRV_DEVICES "Communication devices accessed"
IDS_STATISTICS_SRV_JOBS "Print jobs spooled"
IDS_STATISTICS_SRV_BUFFERS "Times buffers exhausted\n\n"
IDS_STATISTICS_SRV_BIGBUFFERS " Big buffers"
IDS_STATISTICS_SRV_REQBUFFERS " Request buffers"
IDS_STATISTICS_WKS_NAME "Workstation statistics for \\\\%s\n\n\n"
IDS_USER_ACCOUNTS "User accounts for \\\\%s"
IDS_USER_NAME "User name"

View file

@ -194,8 +194,24 @@ service can stop others. Some services cannot be stopped.\n\n"
IDS_STATISTICS_TEXT "Statistics are available for the following services:\n\n\
Server\n Workstation\n\n"
IDS_STATISTICS_SERVER_NAME "Server statistics for \\\\%s\n\n"
IDS_STATISTICS_WORKSTATION_NAME "Workstation statistics for \\\\%s\n\n"
IDS_STATISTICS_SINCE "Statistics since %d/%d/%d %d:%d %s\n\n\n"
IDS_STATISTICS_SRV_NAME "Server statistics for \\\\%s\n\n\n"
IDS_STATISTICS_SRV_SESACCEPT "Sessions accepted"
IDS_STATISTICS_SRV_SESSTIME "Sessions timed-out"
IDS_STATISTICS_SRV_SESSERROR "Sessions errored-out"
IDS_STATISTICS_SRV_KBSENT "Kilobytes sent"
IDS_STATISTICS_SRV_KBRCVD "Kilobytes received"
IDS_STATISTICS_SRV_MRESPTIME "Mean response time (msec)"
IDS_STATISTICS_SRV_SYSERRORS "System errors"
IDS_STATISTICS_SRV_PMERRORS "Permission violations"
IDS_STATISTICS_SRV_PWERRORS "Password violations"
IDS_STATISTICS_SRV_FILES "Files accessed"
IDS_STATISTICS_SRV_DEVICES "Communication devices accessed"
IDS_STATISTICS_SRV_JOBS "Print jobs spooled"
IDS_STATISTICS_SRV_BUFFERS "Times buffers exhausted\n\n"
IDS_STATISTICS_SRV_BIGBUFFERS " Big buffers"
IDS_STATISTICS_SRV_REQBUFFERS " Request buffers"
IDS_STATISTICS_WKS_NAME "Workstation statistics for \\\\%s\n\n\n"
IDS_USER_ACCOUNTS "Cuentas de usuario en \\\\%s"
IDS_USER_NAME "Nombre de usuario"

View file

@ -197,8 +197,24 @@ service can stop others. Some services cannot be stopped.\n\n"
IDS_STATISTICS_TEXT "Statistics are available for the following services:\n\n\
Server\n Workstation\n\n"
IDS_STATISTICS_SERVER_NAME "Server statistics for \\\\%s\n\n"
IDS_STATISTICS_WORKSTATION_NAME "Workstation statistics for \\\\%s\n\n"
IDS_STATISTICS_SINCE "Statistics since %d/%d/%d %d:%d %s\n\n\n"
IDS_STATISTICS_SRV_NAME "Server statistics for \\\\%s\n\n\n"
IDS_STATISTICS_SRV_SESACCEPT "Sessions accepted"
IDS_STATISTICS_SRV_SESSTIME "Sessions timed-out"
IDS_STATISTICS_SRV_SESSERROR "Sessions errored-out"
IDS_STATISTICS_SRV_KBSENT "Kilobytes sent"
IDS_STATISTICS_SRV_KBRCVD "Kilobytes received"
IDS_STATISTICS_SRV_MRESPTIME "Mean response time (msec)"
IDS_STATISTICS_SRV_SYSERRORS "System errors"
IDS_STATISTICS_SRV_PMERRORS "Permission violations"
IDS_STATISTICS_SRV_PWERRORS "Password violations"
IDS_STATISTICS_SRV_FILES "Files accessed"
IDS_STATISTICS_SRV_DEVICES "Communication devices accessed"
IDS_STATISTICS_SRV_JOBS "Print jobs spooled"
IDS_STATISTICS_SRV_BUFFERS "Times buffers exhausted\n\n"
IDS_STATISTICS_SRV_BIGBUFFERS " Big buffers"
IDS_STATISTICS_SRV_REQBUFFERS " Request buffers"
IDS_STATISTICS_WKS_NAME "Workstation statistics for \\\\%s\n\n\n"
IDS_USER_ACCOUNTS "Conturi de utilizator pentru \\\\%s"
IDS_USER_NAME "Nume utilizator"

View file

@ -193,8 +193,24 @@ service can stop others. Some services cannot be stopped.\n\n"
IDS_STATISTICS_TEXT "Statistics are available for the following services:\n\n\
Server\n Workstation\n\n"
IDS_STATISTICS_SERVER_NAME "Server statistics for \\\\%s\n\n"
IDS_STATISTICS_WORKSTATION_NAME "Workstation statistics for \\\\%s\n\n"
IDS_STATISTICS_SINCE "Statistics since %d/%d/%d %d:%d %s\n\n\n"
IDS_STATISTICS_SRV_NAME "Server statistics for \\\\%s\n\n\n"
IDS_STATISTICS_SRV_SESACCEPT "Sessions accepted"
IDS_STATISTICS_SRV_SESSTIME "Sessions timed-out"
IDS_STATISTICS_SRV_SESSERROR "Sessions errored-out"
IDS_STATISTICS_SRV_KBSENT "Kilobytes sent"
IDS_STATISTICS_SRV_KBRCVD "Kilobytes received"
IDS_STATISTICS_SRV_MRESPTIME "Mean response time (msec)"
IDS_STATISTICS_SRV_SYSERRORS "System errors"
IDS_STATISTICS_SRV_PMERRORS "Permission violations"
IDS_STATISTICS_SRV_PWERRORS "Password violations"
IDS_STATISTICS_SRV_FILES "Files accessed"
IDS_STATISTICS_SRV_DEVICES "Communication devices accessed"
IDS_STATISTICS_SRV_JOBS "Print jobs spooled"
IDS_STATISTICS_SRV_BUFFERS "Times buffers exhausted\n\n"
IDS_STATISTICS_SRV_BIGBUFFERS " Big buffers"
IDS_STATISTICS_SRV_REQBUFFERS " Request buffers"
IDS_STATISTICS_WKS_NAME "Workstation statistics for \\\\%s\n\n\n"
IDS_USER_ACCOUNTS "Учетные записи пользователей для \\\\%s"
IDS_USER_NAME "Имя пользователя"

View file

@ -193,8 +193,24 @@ service can stop others. Some services cannot be stopped.\n\n"
IDS_STATISTICS_TEXT "Statistics are available for the following services:\n\n\
Server\n Workstation\n\n"
IDS_STATISTICS_SERVER_NAME "Server statistics for \\\\%s\n\n"
IDS_STATISTICS_WORKSTATION_NAME "Workstation statistics for \\\\%s\n\n"
IDS_STATISTICS_SINCE "Statistics since %d/%d/%d %d:%d %s\n\n\n"
IDS_STATISTICS_SRV_NAME "Server statistics for \\\\%s\n\n\n"
IDS_STATISTICS_SRV_SESACCEPT "Sessions accepted"
IDS_STATISTICS_SRV_SESSTIME "Sessions timed-out"
IDS_STATISTICS_SRV_SESSERROR "Sessions errored-out"
IDS_STATISTICS_SRV_KBSENT "Kilobytes sent"
IDS_STATISTICS_SRV_KBRCVD "Kilobytes received"
IDS_STATISTICS_SRV_MRESPTIME "Mean response time (msec)"
IDS_STATISTICS_SRV_SYSERRORS "System errors"
IDS_STATISTICS_SRV_PMERRORS "Permission violations"
IDS_STATISTICS_SRV_PWERRORS "Password violations"
IDS_STATISTICS_SRV_FILES "Files accessed"
IDS_STATISTICS_SRV_DEVICES "Communication devices accessed"
IDS_STATISTICS_SRV_JOBS "Print jobs spooled"
IDS_STATISTICS_SRV_BUFFERS "Times buffers exhausted\n\n"
IDS_STATISTICS_SRV_BIGBUFFERS " Big buffers"
IDS_STATISTICS_SRV_REQBUFFERS " Request buffers"
IDS_STATISTICS_WKS_NAME "Workstation statistics for \\\\%s\n\n\n"
IDS_USER_ACCOUNTS "\\\\%s için kullanıcı hesapları"
IDS_USER_NAME "Kullanıcı adı"

View file

@ -193,8 +193,24 @@ service can stop others. Some services cannot be stopped.\n\n"
IDS_STATISTICS_TEXT "Statistics are available for the following services:\n\n\
Server\n Workstation\n\n"
IDS_STATISTICS_SERVER_NAME "Server statistics for \\\\%s\n\n"
IDS_STATISTICS_WORKSTATION_NAME "Workstation statistics for \\\\%s\n\n"
IDS_STATISTICS_SINCE "Statistics since %d/%d/%d %d:%d %s\n\n\n"
IDS_STATISTICS_SRV_NAME "Server statistics for \\\\%s\n\n\n"
IDS_STATISTICS_SRV_SESACCEPT "Sessions accepted"
IDS_STATISTICS_SRV_SESSTIME "Sessions timed-out"
IDS_STATISTICS_SRV_SESSERROR "Sessions errored-out"
IDS_STATISTICS_SRV_KBSENT "Kilobytes sent"
IDS_STATISTICS_SRV_KBRCVD "Kilobytes received"
IDS_STATISTICS_SRV_MRESPTIME "Mean response time (msec)"
IDS_STATISTICS_SRV_SYSERRORS "System errors"
IDS_STATISTICS_SRV_PMERRORS "Permission violations"
IDS_STATISTICS_SRV_PWERRORS "Password violations"
IDS_STATISTICS_SRV_FILES "Files accessed"
IDS_STATISTICS_SRV_DEVICES "Communication devices accessed"
IDS_STATISTICS_SRV_JOBS "Print jobs spooled"
IDS_STATISTICS_SRV_BUFFERS "Times buffers exhausted\n\n"
IDS_STATISTICS_SRV_BIGBUFFERS " Big buffers"
IDS_STATISTICS_SRV_REQBUFFERS " Request buffers"
IDS_STATISTICS_WKS_NAME "Workstation statistics for \\\\%s\n\n\n"
IDS_USER_ACCOUNTS "\\\\%s 的用户帐户"
IDS_USER_NAME "用户名"

View file

@ -193,8 +193,24 @@ service can stop others. Some services cannot be stopped.\n\n"
IDS_STATISTICS_TEXT "Statistics are available for the following services:\n\n\
Server\n Workstation\n\n"
IDS_STATISTICS_SERVER_NAME "Server statistics for \\\\%s\n\n"
IDS_STATISTICS_WORKSTATION_NAME "Workstation statistics for \\\\%s\n\n"
IDS_STATISTICS_SINCE "Statistics since %d/%d/%d %d:%d %s\n\n\n"
IDS_STATISTICS_SRV_NAME "Server statistics for \\\\%s\n\n\n"
IDS_STATISTICS_SRV_SESACCEPT "Sessions accepted"
IDS_STATISTICS_SRV_SESSTIME "Sessions timed-out"
IDS_STATISTICS_SRV_SESSERROR "Sessions errored-out"
IDS_STATISTICS_SRV_KBSENT "Kilobytes sent"
IDS_STATISTICS_SRV_KBRCVD "Kilobytes received"
IDS_STATISTICS_SRV_MRESPTIME "Mean response time (msec)"
IDS_STATISTICS_SRV_SYSERRORS "System errors"
IDS_STATISTICS_SRV_PMERRORS "Permission violations"
IDS_STATISTICS_SRV_PWERRORS "Password violations"
IDS_STATISTICS_SRV_FILES "Files accessed"
IDS_STATISTICS_SRV_DEVICES "Communication devices accessed"
IDS_STATISTICS_SRV_JOBS "Print jobs spooled"
IDS_STATISTICS_SRV_BUFFERS "Times buffers exhausted\n\n"
IDS_STATISTICS_SRV_BIGBUFFERS " Big buffers"
IDS_STATISTICS_SRV_REQBUFFERS " Request buffers"
IDS_STATISTICS_WKS_NAME "Workstation statistics for \\\\%s\n\n\n"
IDS_USER_ACCOUNTS "使用者帳戶 \\\\%s"
IDS_USER_NAME "使用者名稱"

View file

@ -111,8 +111,25 @@
#define IDS_LOCALGROUP_MEMBERS 303
#define IDS_STATISTICS_TEXT 320
#define IDS_STATISTICS_SERVER_NAME 321
#define IDS_STATISTICS_WORKSTATION_NAME 322
#define IDS_STATISTICS_SINCE 321
#define IDS_STATISTICS_SRV_NAME 322
#define IDS_STATISTICS_SRV_SESACCEPT 323
#define IDS_STATISTICS_SRV_SESSTIME 324
#define IDS_STATISTICS_SRV_SESSERROR 325
#define IDS_STATISTICS_SRV_KBSENT 326
#define IDS_STATISTICS_SRV_KBRCVD 327
#define IDS_STATISTICS_SRV_MRESPTIME 328
#define IDS_STATISTICS_SRV_SYSERRORS 329
#define IDS_STATISTICS_SRV_PMERRORS 330
#define IDS_STATISTICS_SRV_PWERRORS 331
#define IDS_STATISTICS_SRV_FILES 332
#define IDS_STATISTICS_SRV_DEVICES 333
#define IDS_STATISTICS_SRV_JOBS 334
#define IDS_STATISTICS_SRV_BUFFERS 335
#define IDS_STATISTICS_SRV_BIGBUFFERS 336
#define IDS_STATISTICS_SRV_REQBUFFERS 337
#define IDS_STATISTICS_WKS_NAME 342
#define IDS_USER_ACCOUNTS 449
#define IDS_USER_NAME 450