In daily development, we need to pay attention to the resource usage of .NET applications to troubleshoot problems and expand capacity.
CLRStats plug-in, a plug-in that counts the resource usage of .NET applications, including: CPU usage, GC, thread status, support to obtain status information through web requests (access path and authentication can be customized), and the data will be returned in JSON format.
GitHub address:The hyperlink login is visible.
In the tank:.NET Framework >= 4.5and.NET Core >= 2.0Frame
Obtain statistics through Ajax requests, displayed in a chart as shown below:
Installation
Taking the asp.net Core 3.1 project as an example, you can use Nuget to install it with the following command:
In the Startup class Configure method, add the following configuration:
app. UseCLRStatsDashboard(); After starting a project, you can view resource statistics by visiting the /clr directory of the website.
As shown below:
Advanced configuration
Custom access paths are supported, and the code is as follows:
To add the identity authentication function, identity authentication needs to inherit the IDashboardAuthorizationFilter class, and implement the Authorize method in it, the code is as follows:
To customize the access path and add authentication, in the Startup class Configure method, add the following configuration:
After the configuration is completed, enable the project, access the site /custom-link path, and the request header needs to carry the token parameter with the value of :test to access successfully.
Use the curl tool below on Windows to test with the following command:
As shown below:
Reference links:The hyperlink login is visible.
|