添加监控参数

编写指标数据获取接口

下面以io_read为例,在task目录的metric_task.py中编写如下io_read指标获取函数:

  1. def io_read():
  2. child1 = subprocess.Popen(['pidstat', '-d'], stdout=subprocess.PIPE, shell=False)
  3. child2 = subprocess.Popen(['grep', 'gaussd[b]'], stdin=child1.stdout, stdout=subprocess.PIPE, shell=False)
  4. result = child2.communicate()
  5. if not result[0]:
  6. return 0.0
  7. else:
  8. return result[0].split()[3].decode('utf-8')

添加指标监控参数

在task目录下的metric_task.conf中添加io_read的section:

  1. [io_read]
  2. minimum = 30
  3. maximum = 100
  4. data_period = 1H
  5. forecast_interval = 2H
  6. forecast_period = 30M

重启服务

命令参考获取帮助

  1. 重启agent
  2. 本地服务器:
  3. python main.py start --role agent
  4. python main.py stop --role agent
  5. 远程服务器:
  6. python main.py start --user USER --host HOST --project-path PROJECT_PATH --role agent
  7. python main.py stop --user USER --host HOST --project-path PROJECT_PATH --role agent
  8. 重启server
  9. 本地服务器:
  10. python main.py start --role server
  11. python main.py stop --role server
  12. 远程服务器:
  13. python main.py start --user USER --host HOST --project-path PROJECT_PATH --role server
  14. python main.py stop --user USER --host HOST --project-path PROJECT_PATH --role server
  15. 重启monitor
  16. 本地服务器:
  17. python main.py start --role monitor
  18. python main.py stop --role monitor
  19. 远程服务器:
  20. python main.py start --user USER --host HOST --project-path PROJECT_PATH --role monitor
  21. python main.py stop --user USER --host HOST --project-path PROJECT_PATH --role monitor