Answers: <p>AWS have published a plugin for <code>collectd</code> which allows to send metrics collected using <code>collectd</code> to CloudWatch.</p>
  
  <p><a href="https://github.com/awslabs/collectd-cloudwatch" rel="nofollow noreferrer">https://github.com/awslabs/collectd-cloudwatch</a></p>
  
  <p>The <code>collectd</code> monitoring tool runs on the server and can be configured to collect various metrics, among them metrics on disks and filesystems using their <code>DF</code> plugin. <a href="https://collectd.org/wiki/index.php/Plugin:DF" rel="nofollow noreferrer">https://collectd.org/wiki/index.php/Plugin:DF</a></p>
  
  <p>You can turn the <code>ReportInodes</code> option of the CollectD DF plugin and then have these metrics reported to CloudWatch as custom metrics using the AWS CollectD CloudWatch plugin.</p>
  
Answers: CC BY-SA 3.0
Answers: 2018-01-30T11:46:36.817Z
Answers: 2018-01-30T11:46:36.817Z
Answers: Evgeny Zislis
Answers: <p>AWS have a CloudWatch agent which will submit a number of useful (configurable) metrics, including <code>inodes_free</code>, <code>inodes_used</code>, and <code>inodes_total</code>. They'll appear, by default, under the <code>CWAgent</code> namespace in CloudWatch metrics from where you can view them, add them to dashboards, create alarms etc.</p>
  
  <p>For the full details, these links will be useful:</p>
  
  <ul>
  <li><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-first-instance.html" rel="nofollow noreferrer">installing the agent</a></li>
  <li><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html" rel="nofollow noreferrer">configuring the agent</a></li>
  <li><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/troubleshooting-CloudWatch-Agent.html" rel="nofollow noreferrer">troubleshooting the agent</a></li>
  </ul>
  
  <p>Alternatively, the quickest way to get started is to:</p>
  
  <ol>
  <li>Download the agent from <a href="https://s3.amazonaws.com/amazoncloudwatch-agent/linux/amd64/latest/AmazonCloudWatchAgent.zip" rel="nofollow noreferrer">https://s3.amazonaws.com/amazoncloudwatch-agent/linux/amd64/latest/AmazonCloudWatchAgent.zip</a></li>
  <li>Unzip and run <code>install.sh</code></li>
  <li>Start the agent by running <code>/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a start</code> (this will create a default config file)</li>
  <li>Edit the default config file at <code>/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json</code> and modify the <code>metrics_collected</code> to include the inode metrics under the <code>disk</code> category (see below for sample).</li>
  <li>Stop (above command but with <code>-a stop</code> instead) and start the agent for the new config to take effect.</li>
  </ol>
  
  <p>You should then see the new metrics appear in CloudWatch within a minute or so. The agent should also automatically start at boot.</p>
  
  <p>Here's a sample of defining the inode metrics (for full details see the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html" rel="nofollow noreferrer">configuration docs</a>):</p>
  
  <pre><code>{
    "metrics": {
      "append_dimensions": {
        "InstanceId": "${aws:InstanceId}"
      },
      "metrics_collected": {
        "disk": {
          "measurement": [
            "inodes_free",
            "inodes_used",
            "inodes_total"
          ],
          "metrics_collection_interval": 60,
          "resources": [
            "*"
          ]
        }
      }
    }
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-06-17T01:11:19.470Z
Answers: 2018-06-17T01:11:19.470Z
Answers: Tim Malone
Answers: <p>SSH into the instance and add the script that will collect the inode usage and send metrics to the alarm</p>
  <pre><code>!/bin/bash
  USAGE=80
  INODE_USED=$(df -ih | sed -n '4p'| awk '{print $5}'| grep -v U | cut -d% -f1)
  aws cloudwatch put-metric-data --metric-name inode-usage --dimensions Instance=&lt;Instance id&gt;  --namespace &quot;Custom&quot; --value $INODE_USED
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-04-22T10:13:39.497Z
Answers: 2021-04-22T10:13:39.497Z
Answers: Javeed Shakeel
Body: <p>I have created custom CloudWatch alarm for Disk Utilization for root and mount volume to monitor the disk space for my Ubuntu (16.04) instances, but quite often it happens that disk is only 60% full (df -h) and still it's unable to create any more file as the i-node (df -i) already reached its limit. To keep an eye on this, I want to introduce a custom metric for i-node utilization and then want to configure an alarm on it.</p>
  
  <p>Please provide a solution, considering I am relatively new in AWS.</p>
  
Tags: <amazon-web-services><amazon-cloudwatch>
Title: How to create custom AWS CloudWatch metric for i-node
UserDisplayName: thecloudguy
ThreadText: # How to create custom AWS CloudWatch metric for i-node
  
  (Asked by: username_0 on 2018-01-30)
  
  I have created custom CloudWatch alarm for Disk Utilization for root and mount volume to monitor the disk space for my Ubuntu (16.04) instances, but quite often it happens that disk is only 60% full (df -h) and still it's unable to create any more file as the i-node (df -i) already reached its limit. To keep an eye on this, I want to introduce a custom metric for i-node utilization and then want to configure an alarm on it.
  
  Please provide a solution, considering I am relatively new in AWS.
  
  **Tags:** amazon-web-services, amazon-cloudwatch
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2018-01-30. Score: 1
  
  AWS have published a plugin for `collectd` which allows to send metrics collected using `collectd` to CloudWatch.
  
  <https://github.com/awslabs/collectd-cloudwatch>
  
  The `collectd` monitoring tool runs on the server and can be configured to collect various metrics, among them metrics on disks and filesystems using their `DF` plugin. <https://collectd.org/wiki/index.php/Plugin:DF>
  
  You can turn the `ReportInodes` option of the CollectD DF plugin and then have these metrics reported to CloudWatch as custom metrics using the AWS CollectD CloudWatch plugin.
  
  
  ---
  
  ### Answer by username_2 on 2018-06-17. Score: 1
  
  AWS have a CloudWatch agent which will submit a number of useful (configurable) metrics, including `inodes_free`, `inodes_used`, and `inodes_total`. They'll appear, by default, under the `CWAgent` namespace in CloudWatch metrics from where you can view them, add them to dashboards, create alarms etc.
  
  For the full details, these links will be useful:
  
  * [installing the agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-first-instance.html)
  * [configuring the agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html)
  * [troubleshooting the agent](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/troubleshooting-CloudWatch-Agent.html)
  
  Alternatively, the quickest way to get started is to:
  
  1. Download the agent from <https://s3.amazonaws.com/amazoncloudwatch-agent/linux/amd64/latest/AmazonCloudWatchAgent.zip>
  2. Unzip and run `install.sh`
  3. Start the agent by running `/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a start` (this will create a default config file)
  4. Edit the default config file at `/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json` and modify the `metrics_collected` to include the inode metrics under the `disk` category (see below for sample).
  5. Stop (above command but with `-a stop` instead) and start the agent for the new config to take effect.
  
  You should then see the new metrics appear in CloudWatch within a minute or so. The agent should also automatically start at boot.
  
  Here's a sample of defining the inode metrics (for full details see the [configuration docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html)):
  
  ```
  {
    "metrics": {
      "append_dimensions": {
        "InstanceId": "${aws:InstanceId}"
      },
      "metrics_collected": {
        "disk": {
          "measurement": [
            "inodes_free",
            "inodes_used",
            "inodes_total"
          ],
          "metrics_collection_interval": 60,
          "resources": [
            "*"
          ]
        }
      }
    }
  }
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2021-04-22. Score: 0
  
  SSH into the instance and add the script that will collect the inode usage and send metrics to the alarm
  
  ```
  !/bin/bash
  USAGE=80
  INODE_USED=$(df -ih | sed -n '4p'| awk '{print $5}'| grep -v U | cut -d% -f1)
  aws cloudwatch put-metric-data --metric-name inode-usage --dimensions Instance=<Instance id>  --namespace "Custom" --value $INODE_USED
  
  ```
  
  
  ---
  
  