1. Get CPU Utilization
The typedef struct CPU_PACKED //defines a CPU occupy structure body
{
char name[20]; Defines a char-type array name with 20 elements
unsigned int user; Defines a user unsigned int of unsigned type int nice
; Defines a nice unsigned int system of unsigned int types
; Defines a system unsigned int idle wi
The examples in this article describe how JavaScript obtains current CPU usage. Share to everyone for your reference, specific as follows:
To get the current system CPU usage, if you allow an HTA, you can use the following code to get the current CPU usage (more accurate)
First, reference the System.Management; then imports system.management in the code;
The following functions rely primarily on WMI implementations
Get the hard drive serial number
The code is as follows
Copy Code
Dim Cmicwmi as New System.Management.ManagementObjectSearcher ("SELECT * from Win32_DiskDrive")Dim Uint32 as UInt32For each cmicwmiobj as ManagementObject in Cmicwmi.getUint32 = cmicwmiobj ("signature")NextTextBo
:~/mybash$ Cat/proc/meminfo
memtotal:3593316 KB
memfree:2145916 KB
buffers:93372 KB
cached:684864 KB
swapcached:0 KB
active:706564 KB
inactive:554052 KB
Active (anon): 483996 KB
Inactive (anon): 178388 KB
Active (file): 222568 KB
Inactive (file): 375664 KB
。。 。 。。。
Here's how to get the information you need in Python programming.
1, get the information of the
supported the theGetMessage ("number of render targets supported", SystemInfo.supportedRenderTargetCount.ToString ());94 the the the 98 About - 101 102 103 104 the //Output106 107Messagetext.text =info. ToString ();108 109 } the 111 the 113 //Update is called once per frame the the voidUpdate () the 117 {118 119 //Exit - 121 if(Input.getkeyup ("Escape"))122 123 {124 the 126 127 if(Input.getkeyup ("Escape")) - 129
Linux system uses Python to get CPU information script sharing
The code is as follows:
#!/usr/bin/env PythonFrom __future__ import print_functionFrom collections Import OrdereddictImport Pprint
Def CPUinfo ():"Return The information in/proc/cpuinfoAs a dictionary in the following format:cpu_info[' proc0 ']={...}cpu_info[' Proc1 ']={...}'''Cpuinfo=ordereddict ()Procinfo=ordereddict ()
Nprocs = 0With open (
Using system;using system.collections.generic;using system.linq;using system.management;using System.Text;namespace formular{//Need to introduce System.Management.dllThis class is used to record computer hardware information to prevent malicious damageC # Get Computer hardware information (CPU, NIC, hard disk, memory, etc.)
Linux system uses Python to get CPU information script sharing
Copy Code code as follows:
#!/usr/bin/env Python
From __future__ import print_function
From collections Import Ordereddict
Import Pprint
Def CPUinfo ():"" Return the information In/proc/cpuinfoAs a dictionary in the following format:cpu_info[' proc0 ']={...}cpu_info[' Proc1 ']={...}'''Cpuinfo=ordereddict ()Procinfo=ordereddic
Recently, a project has been done to get the CPU and memory usage of the machine. Spent some time searching the internet and doing some tests. summed up, basically 2 ways: one is to use WMI (2 kinds), the other is to use performance counter.
1. Use WMI to create connection to the computer passing username and password. Once The connection is created, query the cpu
First introduce the service and then call the
This paper is reproduced from http://blog.sina.com.cn/s/blog_7eeb43210101hf7f.html
public class Computer {public static string CpuID;//1.cpu serial number public static string MacAddress;//2. Mac serial number public static string DiskID; 3. Hard disk ID public static string ipaddress; 4.ip address public static string loginusername; 5. Login username public static string ComputerName; 6. Computer name
First, the service is introduced and then calledThis article is reproduced from http://blog.sina.com.cn/s/blog_7eeb43210101hf7f.html Public classComputer { Public Static stringCpuID;//1.cpu Serial Number Public Static stringMacAddress;//2.mac Serial Number Public Static stringDiskID;//3. Hard Drive ID Public Static stringIpAddress;//4.ip Address Public Static stringLoginusername;//5. Login User name Public Sta
We can get the information we need in/proc/cpuinfo.
1. The current CPU model
[root@ localhost ~]# cat/proc/cpuinfo |grep ' model name ' |uniq
Model NAME:AMD Opteron (tm) Processor 6140
2. Current CPU operating mode
[Root@localhost tmp]# getconf Long_bit
32
Indicates that the current CPU is running in 32-bit envi
Ref
Https://www.slideshare.net/alanrenouf/vsphere-apis-for-performance-monitoring
https://groups.google.com/ Forum/#!topic/pysphere/z1k8kkshtze
Https://groups.google.com/forum/#!topic/pysphere/jjUGi-0WqyE
HTTPS ://github.com/codekoala/pysphere/blob/master/pysphere/vi_performance_manager.py
To be continue
Every month, there are always two days, need to organize the monthly virtual machine running state, of which, the most unbearable is, from the Vsphere interface to each virtual machine
()
if __name__ = = ' __main__ ':
Main ()
Print Platform.system ()
Print Platform.release ()
Print platform.version ()
Print Platform.platform ()
Print Platform.machine ()
Example two:
Because I'm not using much, I only get CPU, memory, and hard drives, and if I need additional resources, please refer to MSDN.
Copy Code code as follows:
Import OS
Import Win32API
Import Win32con
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.