Skip to content

Monitor usage Windows server 2016

Performance monitor

  1. open Server Manager
  2. goto ToolsPerformance Monitor

Logged in users

Start Powershell

PS C:\Windows\system32> Get-WinEvent -filterHashtable @{LogName='Security'; Id=4624; Level=0} | Where-Object { $_.Properties[8].Value -eq 10} | Select-Object -Property TimeCreated, @{ Name = 'TargetUserName'; Expression = { $_.Properties[5].Value } }

Save the output to srv266_logins.txt and use the following Python script to show the histograms and frequency plots:

import pandas as pd
import matplotlib.pyplot as plt

data=pd.read_fwf("srv266_logins.txt")
data=data.drop(0)
data[['date','time']]=data.TimeCreated.str.split(n=1, expand=True)
data.drop(columns=['TimeCreated', 'time'])
data['date']=pd.to_datetime(data.date)

data.hist(xrot='90',bins=90)
plt.ylabel('number of logins/day')
plt.savefig('histogram_day', bbox_inches='tight')

data.hist(xrot='90',bins=12)
plt.ylabel('number of logins/week')
plt.savefig('histogram_week', bbox_inches='tight')

data['TargetUserName'].value_counts().plot(kind='bar')
plt.ylabel('number of logins in 3 months')
plt.savefig('frequency', bbox_inches='tight')