简体   繁体   English

使用aws mon脚本监控EC2磁盘指标

[英]Monitoring EC2 disk metrics using aws mon scripts

I am using aws mon scripts for monitoring EC2 instances using following script : 我使用aws mon脚本使用以下脚本监视EC2实例:

#!/bin/bash
a="$(df | grep /dev/ | awk {'print $1'})"
IFS=' ' read -r -a array <<< $a
#echo "${array[0]}"
for element in "${array[@]}"
do
/opt/aws-scripts-mon/mon-put-instance-data.pl --mem-util --disk-space-util  --swap-util --disk-path="$element" --aws-credential-file=/opt/aws-scripts-mon/awscreds.template
done

Issue is it shows udev in cloudwatch for few machines instead of disk xvda1. 问题是它在cloudwatch中显示了几台机器而不是磁盘xvda1的udev。 Also,when I run this shell script in debug mode, it is compiled as xvda1 but passed to cloudwatch as udev. 此外,当我在调试模式下运行此shell脚本时,它被编译为xvda1,但作为udev传递给cloudwatch。

If you read the docs it states that you need to give the mount point. 如果您阅读文档,则表明您需要提供挂载点。

--disk-path=PATH Selects the disk on which to report. --disk-path = PATH选择要报告的磁盘。

PATH can specify a mount point or any file located on a mount point for the filesystem that needs to be reported PATH可以指定挂载点或位于需要报告的文件系统的挂载点上的任何文件

Your script is giving the file-system point where as if you see the df output we need to give mount point. 你的脚本给出了文件系统点,就像你看到我们需要给出挂载点的df输出一样。

a="$(df | grep /dev/ | awk {'print $6'})" 

This should solve your problem. 这应该可以解决您的问题。 So for xvda1 it will like this --disk-path=/ 所以对于xvda1,它会像这样--disk-path=/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM