SIGAR 和 PTQL
Hyperic HQ 采用 Sigar采集系统信息。在HQ的配置中,包含了大量与SIGAR有关的配置信息,例如对Tomcat监控,采用了直连进程方式,而不是 JMX连接串方式。
SIGAR(System Information Gatherer And Reporter),中文名是系统信息收集和报表工具。是一个开源的工具,提供了跨平台的系统信息收集的API,可以收集的信息包括:
1.操作系统的信息,
包括:dataModel、cpuEndian、name、version、arch、machine、description、patchLevel、vendor、vendorVersion、vendorName、vendorCodeName
2.CPU信息,
包括:基本信息(vendor、model、mhz、cacheSize)和统计信息(user、sys、idle、nice、wait)
3.内存信息,
物理内存和交换内存的总数、使用数、剩余数;RAM的大小
4.进程信息,
包括每个进程的内存、CPU占用数、状态、参数、句柄等。
5.文件系统信息,
包括名称、容量、剩余数、使用数、分区类型等
6.网络接口信息,
包括基本信息和统计信息。
7.网络路由和链接表信息。
SIGAR有自己的查询语言 PTQL (Process Table Query Language),列出一些常用的示例:
权威信息 https://support.hyperic.com/display/SIGAR/PTQL
% java -jar sigar.jar
PTQL Syntax
PTQL Queries must be in the following format:
Class.Attribute.operator=value
Enclose the query in quotes if it contains any spaces. For example:
sigar> ps "Exe.Name.ct=Program Files"
Where:
- Class is the name of the Sigar class minus the Proc prefix.
- Attribute is an attribute of the given Class, index into an array or key in a Map class.
- operator is one of the following for String values:
- eq - Equal to value
- ne - Not Equal to value
- ew - Ends with value
- sw - Starts with value
- ct - Contains value (substring)
- re - Regular expression value matches
operator is one of the following for numeric values: - eq - Equal to value
- ne - Not Equal to value
- gt - Greater than value
- ge - Greater than or equal value
- lt - Less than value
- le - Less than or equal value
Multiple queries must delimited by a comma.
PTQL Attributes
- Pid.Pid - The process ID/li>
- Pid.PidFile - File containing the process ID
- Pid.Service - Windows Service name used to pid from the service manage
- State.Name - Base name of the process executable
- CredName.User - User Name of the process owner
- CredName.Group - Group Name of the process owner
- Cred.Uid - User ID of the process owner
- Cred.Gid - Group ID of the process owner
- Cred.Euid - Effective User ID of the process owner
- Cred.Egid - Effective Group ID of the process owner
- Exe.Name - Full path name of the process executable
- Exe.Cwd - Current Working Directory of the process
- Args.* - Command line argument passed to the process
- Env.* - Environment variable within the process
- Modules.* - Shared library loaded within the process