本节为您介绍如何使用Connection
对象的方法检查数据库服务器统计信息。
Stats()
获取数据库服务器的统计信息。
参数:
RequestConfig
(可选):请求配置。
返回值:
DatabaseStats
:获取到的服务器统计信息。
using System.Security.Cryptography.X509Certificates;
using System.Xml.Linq;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using UltipaService;
using UltipaSharp;
using UltipaSharp.api;
using UltipaSharp.configuration;
using UltipaSharp.connection;
using UltipaSharp.exceptions;
using UltipaSharp.structs;
using UltipaSharp.utils;
using Logger = UltipaSharp.utils.Logger;
using Property = UltipaSharp.structs.Property;
using Schema = UltipaSharp.structs.Schema;
class Program
{
static async Task Main(string[] args)
{
// 设置连接
// URI 示例:Hosts=new[]{"mqj4zouys.us-east-1.cloud.ultipa.com:60010"}
var myconfig = new UltipaConfig()
{
Hosts = new[] { "192.168.1.85:60061", "192.168.1.86:60061", "192.168.1.87:60061" },
Username = "***",
Password = "***",
};
// 建立与数据库的连接
var ultipa = new Ultipa(myconfig);
// 配置请求
RequestConfig requestConfig = new RequestConfig() { UseMaster = true };
// 服务器信息
var res = await ultipa.Stats();
Console.WriteLine("CPU usage: " + res.CpuUsage);
Console.WriteLine("Memory usage: " + res.MemUsage);
Console.WriteLine("Expiration date: " + res.ExpiredDate);
Console.WriteLine("CPU cores: " + res.CpuCores);
Console.WriteLine("Company: " + res.Company);
Console.WriteLine("Server type: " + res.ServerType);
Console.WriteLine("Version: " + res.Version);
}
}
CPU usage: 11.535199
Memory usage: 10702.644531
Expiration date: Thu Dec 26 23:59:59 2024
CPU cores: 80
Company: ultipa
Server type: CT
Version: htap_beta.4.5.7-b4.5.0-tv-ui