1.1 CPU占用率

本文详细介绍了用于监控Windows系统性能的多个API,包括获取系统运行时间、线程睡眠、等待单一对象状态变化等功能函数,以及获取处理器信息和设置线程亲和性等高级功能。

下面是一些了解当前线程/进程/系统效能的API,所有描述来自MSDN文档,具体如下:

注意每个函数对应的头文件和相应的lib.



DWORD GetTickCount(void);
/*
Header: Winbase.h, include Windows.h
Link Library: Kernel32.lib
DLL: Dernel32.dll
Details:
The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. To obtain the system timer resolution, use the GetSystemTimeAdjustment function.
Remarks:
The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days.


Example Code:
The following example demonstrates how to use a this function to wait for a time interval to pass. Due to the nature of unsigned arithmetic, this code works correctly if the return value wraps one time. If the difference between the two calls to GetTickCount is more than 49.7 days, the return value could wrap more than one time and this code will not work.


DWORD dwStart = GetTickCount();
if( GetTickCount() - dwStart >= TIMELIMIT )
    Cancel();
*/

void Sleep(DWORD dwMilliseconds);
/*
Header: Winbase.h, include Windows.h
Library: Kernel32.lib
DLL: Kernel32.dll

Details:
This function suspends the execution of the current thread for a specified interval.
Parameters:
Specifies the time, in milliseconds, for which to suspend execution.
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If no other threads of equal priority are ready to run, the function returns immediately, and the thread continues execution.
A value of INFINITE causes an infinite delay.


Remarks:
You have to be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you have a thread that uses Sleep with infinite delay, the system will deadlock. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx, rather than Sleep.
*/

DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
/*
Header: Winbase.h, include Windows.h
Library: Kernel32.lib
DLL: Kernel32.dll

Details:
The WaitForSingleObject function returns when the specified object is in the signaled state or the time-out interval elapses.


Parameters:
hHandle:
Handle to the object. If this handle is closed while the wait is still pending, the function's behavior is undefined.
dwMilliseconds:
Time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.

Return Values:
If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values.
WAIT_ABANDONED:当hHandle为mutex时,如果拥有mutex的线程在结束时没有释放核心对象会引发此返回值。
WAIT_OBJECT_0:核心对象已被激活
WAIT_TIMEOUT:等待超时
WAIT_FAILED:出现错误,可通过GetLastError得到错误代码

Remarks:
The WaitForSingleObject function checks the current state of the specified object. If the object's state is nonsignaled, the calling thread enters the wait state. It uses no processor time while waiting for the object state to become signaled or the time-out interval to elapse.
The function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one.
*/

HRESULT GetProcessorInfo(WORD* pwProcessorArchitectureOut, WORD* pwProcessorLevelOut);
/*
DLL: Clcfgsrv.dll
Details:
The GetProcessorInfo method retrieves the processor information for the node.

Parameters:
pwProcessorArchitectureOut: Processor architecture information.
pwProcessorLevelOut: Processor level information.
*/

DWORD_PTR SetThreadAffinityMask(HANDLE hThread, DWORD_PTR dwThreadAffinityMask);
/*
Header: Winbase.h, include Windows.h
DLL: Kernel32.dll
Library: Kernel32.lib

Details:
The SetThreadAffinityMask function sets a processor affinity mask for the specified thread.

Return Values:
If the function succeeds, the return value is the thread's previous affinity mask. Windows Me/98/95: The return value is 1. To succeed, hThread must be valid and dwThreadAffinityMask must be 1.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks:
A thread affinity mask is a bit vector in which each bit represents the processors that a thread is allowed to run on.
A thread affinity mask must be a proper subset of the process affinity mask for the containing process of a thread. A thread is only allowed to run on the processors its process is allowed to run on.
*/

DWORD timeGetTime(VOID);
/*
Header: Mmsystem.h, include Windows.h
Library: Winmm.lib

Details:
The timeGetTime function retrieves the system time, in milliseconds. The system time is the time elapsed since Windows was started.

Remarks:
The only difference between this function and the timeGetSystemTime function is that timeGetSystemTime uses the MMTIME structure to return the system time. The timeGetTime function has less overhead than timeGetSystemTime.
Note that the value returned by the timeGetTime function is a DWORD value. The return value wraps around to 0 every 2^32 milliseconds, which is about 49.71 days. This can cause problems in code that directly uses the timeGetTime return value in computations, particularly where the value is used to control code execution. You should always use the difference between two timeGetTime return values in computations.
*/

MMRESULT timeGetSystemTime(LPMMTIME pmmt, UINT cbmmt);
/*
Header: Mmsystem.h, include Windows.h
Library: Winmm.lib

Details:
The timeGetSystemTime function retrieves the system time, in milliseconds. The system time is the time elapsed since Windows was started. This function works very much like the timeGetTime function. See timeGetTime for details of these functions' operation.

Parameters:
pmmt:  Pointer to an MMTIME structure.
cbmmt: Size, in bytes, of the MMTIME structure.

Return Values:
Returns TIMERR_NOERROR. The system time is returned in the ms member of the MMTIME structure.
*/

在使用Windows.h中定义:
typedef unsigned long  DWORD;
typedef unsigned char  BYTE;
typedef unsigned short WORD;
typedef unsigned int UINT;

 

basetsd.h

 

typedef signed __int64  INT64

typedef unsigned __int64  UINT64

 

下载前可以先看下教程 https://pan.quark.cn/s/a426667488ae 标题“仿淘宝jquery图片左右切换带数字”揭示了这是一个关于运用jQuery技术完成的图片轮播机制,其特色在于具备淘宝在线平台普遍存在的图片切换表现,并且在整个切换环节中会展示当前图片的序列号。 此类功能一般应用于电子商务平台的产品呈现环节,使用户可以便捷地查看多张商品的照片。 说明中的“NULL”表示未提供进一步的信息,但我们可以借助标题来揣摩若干核心的技术要点。 在构建此类功能时,开发者通常会借助以下技术手段:1. **jQuery库**:jQuery是一个应用广泛的JavaScript框架,它简化了HTML文档的遍历、事件管理、动画效果以及Ajax通信。 在此项目中,jQuery将负责处理用户的点击动作(实现左右切换),并且制造流畅的过渡效果。 2. **图片轮播扩展工具**:开发者或许会采用现成的jQuery扩展,例如Slick、Bootstrap Carousel或个性化的轮播函数,以达成图片切换的功能。 这些扩展能够辅助迅速构建功能完善的轮播模块。 3. **即时数字呈现**:展示当前图片的序列号,这需要通过JavaScript或jQuery来追踪并调整。 每当图片切换时,相应的数字也会同步更新。 4. **CSS美化**:为了达成淘宝图片切换的视觉效果,可能需要设计特定的CSS样式,涵盖图片的排列方式、过渡效果、点状指示器等。 CSS3的动画和过渡特性(如`transition`和`animation`)在此过程中扮演关键角色。 5. **事件监测**:运用jQuery的`.on()`方法来监测用户的操作,比如点击左右控制按钮或自动按时间间隔切换。 根据用户的交互,触发相应的函数来执行...
垃圾实例分割数据集 一、基础信息 • 数据集名称:垃圾实例分割数据集 • 图片数量: 训练集:7,000张图片 验证集:426张图片 测试集:644张图片 • 训练集:7,000张图片 • 验证集:426张图片 • 测试集:644张图片 • 分类类别: 垃圾(Sampah) • 垃圾(Sampah) • 标注格式:YOLO格式,包含实例分割的多边形点坐标,适用于实例分割任务。 • 数据格式:图片文件 二、适用场景 • 智能垃圾检测系统开发:数据集支持实例分割任务,帮助构建能够自动识别和分割图像中垃圾区域的AI模型,适用于智能清洁机器人、自动垃圾桶等应用。 • 环境监控与管理:集成到监控系统中,用于实时检测公共区域的垃圾堆积,辅助环境清洁和治理决策。 • 计算机视觉研究:支持实例分割算法的研究和优化,特别是在垃圾识别领域,促进AI在环保方面的创新。 • 教育与实践:可用于高校或培训机构的AI课程,作为实例分割技术的实践数据集,帮助学生理解计算机视觉应用。 三、数据集优势 • 精确的实例分割标注:每个垃圾实例都使用详细的多边形点进行标注,确保分割边界准确,提升模型训练效果。 • 数据多样性:包含多种垃圾物品实例,覆盖不同场景,增强模型的泛化能力和鲁棒性。 • 格式兼容性强:YOLO标注格式易于与主流深度学习框架集成,如YOLO系列、PyTorch等,方便研究人员和开发者使用。 • 实际应用价值:直接针对现实世界的垃圾管理需求,为自动化环保解决方案提供可靠数据支持,具有重要的社会意义。
### 检查和分析华三核心交换机的CPU使用情况 华三(H3C)核心交换机的CPU使用情况是评估网络设备性能和稳定性的重要指标。高CPU利用率可能导致交换机响应变慢、丢包甚至设备崩溃。因此,定期监控和分析H3C核心交换机的CPU使用情况对于网络维护至关重要。 #### 1. 检查H3C核心交换机的CPU利用率 可以通过命令行界面(CLI)或网络管理软件(如iMC)来检查H3C交换机的CPU使用情况。 ##### 使用CLI检查CPU利用率 在H3C交换机的CLI中,可以使用以下命令查看当前CPU利用率: ```bash display cpu usage ``` 该命令将输出类似以下信息: ``` System CPU usage: User time: 25% System time: 10% Nice time: 0% Idle time: 65% I/O wait time: 0% IRQ time: 2% SoftIRQ time: 1% Steal time: 0% Guest time: 0% CPU utilization: 35% ``` 其中,`CPU utilization` 表示当前CPU的总体使用率。如果该值持续高于80%,则可能需要进一步分析是否存在性能瓶颈。 ##### 使用SNMP监控CPU利用率 还可以通过SNMP协议使用网络管理工具(如Cacti、Zabbix或PRTG)定期轮询交换机的CPU使用情况,从而实现长期监控和告警功能。 H3C交换机的OID `1.3.6.1.4.1.25506.2.1.1.1.1.7` 表示CPU利用率(不同型号可能略有差异)。 #### 2. 分析CPU使用情况 如果发现CPU利用率过高,可以使用以下命令进一步分析具体原因: ##### 查看当前运行的任务 ```bash display process cpu-usage ``` 该命令将列出当前占用CPU资源最多的进程,例如: ``` CPU usage of each process: PID CPU usage Process name ----------------------------------- 1024 15% ospfd 2048 10% bgpd 3072 5% sshd ``` 通过分析这些进程,可以判断是否为路由协议、安全服务或其他应用导致CPU负载升高。 ##### 查看接口统计信息 ```bash display interface ``` 此命令可以帮助识别是否有接口因高流量或错误包导致CPU负载增加,例如频繁的错误包处理会增加CPU负担。 ##### 查看日志信息 ```bash display logbuffer ``` 查看系统日志,识别是否有异常事件或频繁告警导致CPU负载升高。 #### 3. 优化CPU利用率 - **升级固件和配置优化**:确保交换机运行的是最新版本的固件,并优化配置,避免不必要的服务启用。 - **限制特定服务的资源使用**:如ACL、NetStream、IPSec等高消耗服务,应合理配置其使用范围和策略。 - **启用QoS策略**:对异常流量进行限速,防止恶意攻击或异常流量占用过多CPU资源。 - **使用硬件加速**:某些H3C交换机支持硬件转发功能,应尽量将转发任务交给硬件处理,减少CPU负担。 #### 4. 使用网络管理工具进行长期监控 推荐使用H3C iMC、Zabbix、SolarWinds等工具进行长期监控和趋势分析,以便及时发现潜在问题并优化网络性能。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值