• prometheus 监控之 进程监控(processexporter)


    :http:http://www.github.com/ncabatoff/process-exporter
    exporter下载:https://github.com/ncabatoff/process-exporter/releases/download/v0.4.0/process-exporter-0.4.0.linux-amd64.tar.gz
    1. [xxx@trade1 ~]$ process-exporter --help
    2. Usage of process-exporter:
    3. -children
    4. if a proc is tracked, track with it any children that aren't part of their own group (default true) -config.path string path to YAML config file -debug log debugging information to stdout -man print manual -namemapping string comma-seperated list, alternating process name and capturing regex to apply to cmdline -once-to-stdout-delay duration Don't bind, just wait this much time, print the metrics once to stdout, and exit
    5. -procfs string
    6. path to read proc data from (default "/proc")
    7. -procnames string
    8. comma-seperated list of process names to monitor
    9. -recheck
    10. recheck process names on each scrape
    11. -web.listen-address string
    12. Address on which to expose metrics and web interface. (default ":9256")
    13. -web.telemetry-path string
    14. Path under which to expose metrics. (default "/metrics")
    配置

    选择要监视的进程并将它的分组,提供命令行参数或者使用YAML配置文件。

    为了避免与命令行YAML元素混淆,我们将 /proc//cmdline的空分隔内容引用为 array argv[] 。

    process_names 中的每个项目都提供了识别和命名过程的诀窍。 可选 name 标记定义用于命名匹配进程的模板;如果没有指定,name 默认为 { {.ExeBase}} 。

    可用的模板变量:

    { {.Comm}} 包含原始可执行文件的basename,/proc//stat 中的换句话说,2nd 字段
    { {.ExeBase}} 包含可执行文件的basename
    { {.ExeFull}} 包含可执行文件的完全限定路径
    { {.Matches}} 映射包含应用命令行tlb所产生的所有匹配项
    process_names 中的每个项必须包含一个或者多个选择器( 。comm,exe 或者 cmdline ) ;如果存在多个选择器,则它们都必须匹配。 每个选择器都是符合进程。argv[0] 或者 cmdline的comm的一个字符串列表,用于应用于 命令行的正则表达式。

    对于 comm 和 exe,字符串列表是 an,表示任何匹配任何字符串的进程都将被添加到项的组中。

    对于 cmdline,regex的列表是一个,也就是说它们都必须匹配。 regexp中的任何捕获组都必须使用 ?P 选项为捕获指定名称,该名称用于填充 .Matches 。

    进程只能属于一个组: 即使多个项目匹配,文件中列出的第一个也会胜出。

    其他性能提示:在cmdline子句中添加exe或者comm子句,这样在执行名不匹配时避免执行 regexp 。

    以下配置是监控所有的进程
    1. [xxx@trade1 bin]$ cat config.yml
    2. process_names:
    3. - name: "{ {.Comm}}"
    4. cmdline:
    5. - '.+'

    启动process-exporter:

    1. process-exporter -config.path config.yml
    2. [root@trade1 bin]# curl 10.100.20.143:9256/metrics |grep JSL
    3. namedprocess_namegroup_context_switches_total{ ctxswitchtype="nonvoluntary",groupname="JSL"} 0
    4. namedprocess_namegroup_context_switches_total{ ctxswitchtype="voluntary",groupname="JSL"} 627
    5. namedprocess_namegroup_cpu_system_seconds_total{ groupname="JSL"} 0.020000000000000018
    6. namedprocess_namegroup_cpu_user_seconds_total{ groupname="JSL"} 0.040000000000000036
    7. namedprocess_namegroup_major_page_faults_total{ groupname="JSL"} 0
    8. namedprocess_namegroup_memory_bytes{ groupname="JSL",memtype="resident"} 3.444736e+06
    9. namedprocess_namegroup_memory_bytes{ groupname="JSL",memtype="swapped"} 0
    10. namedprocess_namegroup_memory_bytes{ groupname="JSL",memtype="virtual"} 3.487744e+07
    11. namedprocess_namegroup_minor_page_faults_total{ groupname="JSL"} 0
    12. namedprocess_namegroup_num_procs{ groupname="JSL"} 1
    13. namedprocess_namegroup_num_threads{ groupname="JSL"} 1
    14. namedprocess_namegroup_oldest_start_time_seconds{ groupname="JSL"} 1.54755489e+09
    15. namedprocess_namegroup_open_filedesc{ groupname="JSL"} 7
    16. namedprocess_namegroup_read_bytes_total{ groupname="JSL"} 0
    17. namedprocess_namegroup_states{ groupname="JSL",state="Other"} 0
    18. namedprocess_namegroup_states{ groupname="JSL",state="Running"} 0
    19. namedprocess_namegroup_states{ groupname="JSL",state="Sleeping"} 1
    20. namedprocess_namegroup_states{ groupname="JSL",state="Waiting"} 0
    21. namedprocess_namegroup_states{ groupname="JSL",state="Zombie"} 0
    22. namedprocess_namegroup_threads_wchan{ groupname="JSL",wchan="do_msgrcv"} 1
    23. namedprocess_namegroup_worst_fd_ratio{ groupname="JSL"} 6.8359375e-06
    24. namedprocess_namegroup_write_bytes_total{ groupname="JSL"} 0

    可以看到我的进程已经在监控状态了。

    Grafana 画图

    https://grafana.com/dashboards/249

  • 相关阅读:
    linux下RTP编程(使用JRTPLIB)(转)
    omap 移植qt4.7.0
    mknod指令详解
    mplayer 在线播放错误
    移植Mplayer到OK6410开发板
    海量数据处理算法—Bit-Map
    海量数据面试题----分而治之/hash映射 + hash统计 + 堆/快速/归并排序
    并行、并发、同步和互斥
    阿里巴巴集团2014年校园招聘北京笔试题
    动态规划之矩阵连乘
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/16527619.html
Copyright © 2020-2023  润新知