Last active
July 26, 2017 04:54
-
-
Save webtech-yone/35ee5158eace146e1adf3326c99b26c5 to your computer and use it in GitHub Desktop.
RPM spec file: Amazon CloudWatch Monitoring Scripts for Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Summary: Amazon CloudWatch Monitoring Scripts for Linux | |
Name: aws-scripts-mon | |
Version: 1.2.1 | |
Release: 1w1%{dist} | |
License: ASL 2.0 | |
Group: Applications/System | |
URL: http://aws.amazon.com/code/8720044071969977 | |
Source: http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-%{version}.zip | |
Patch: mon-put-instance-data.inode.patch | |
BuildRoot: %{_tmppath}/%{name}-%{version}-root | |
Requires: perl(LWP::Protocol::https) | |
BuildRequires: unzip | |
BuildArch: noarch | |
%description | |
The Amazon CloudWatch Monitoring Scripts for Linux are sample scripts | |
for monitoring memory and disk space utilization on your Amazon EC2 | |
instances running Linux. | |
%prep | |
%setup -q -n aws-scripts-mon | |
%patch -p0 | |
%install | |
%__rm -rf %{buildroot} | |
%__mkdir_p %{buildroot}/opt/aws/aws-scripts-mon | |
%__install -m 755 *.pl %{buildroot}/opt/aws/aws-scripts-mon/ | |
%__install -m 644 *.pm %{buildroot}/opt/aws/aws-scripts-mon/ | |
%clean | |
%__rm -rf %{buildroot} | |
%files | |
%defattr(-,root,root) | |
%doc awscreds.template LICENSE.txt NOTICE.txt | |
/opt/aws/aws-scripts-mon | |
%changelog | |
* Fri May 19 2017 Yonekawa Susumu <yone@webtech.co.jp> | |
- 1.2.1-1w1 | |
* Tue Apr 26 2016 Yonekawa Susumu <yone@webtech.co.jp> | |
- 1.1.0-1w1 | |
- add --disk-inode-* options | |
* Mon Feb 22 2016 Yonekawa Susumu <yone@webtech.co.jp> | |
- 1.1.0-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- mon-put-instance-data.pl.orig 2015-03-07 07:57:07.000000000 +0900 | |
+++ mon-put-instance-data.pl 2017-05-19 15:48:15.927990051 +0900 | |
@@ -31,6 +31,9 @@ | |
--disk-space-util Reports disk space utilization in percentages. | |
--disk-space-used Reports allocated disk space in gigabytes. | |
--disk-space-avail Reports available disk space in gigabytes. | |
+ --disk-inode-util Reports disk inode utilization in percentages. | |
+ --disk-inode-used Reports allocated disk inodes. | |
+ --disk-inode-avail Reports available disk inodes. | |
--aggregated[=only] Adds aggregated metrics for instance type, AMI id, and region. | |
If =only is specified, does not report individual instance metrics | |
@@ -115,6 +118,9 @@ | |
my $report_disk_util; | |
my $report_disk_used; | |
my $report_disk_avail; | |
+my $report_inode_util; | |
+my $report_inode_used; | |
+my $report_inode_avail; | |
my $mem_used_incl_cache_buff; | |
my @mount_path; | |
my $mem_units; | |
@@ -153,6 +159,9 @@ | |
'disk-space-util' => \$report_disk_util, | |
'disk-space-used' => \$report_disk_used, | |
'disk-space-avail' => \$report_disk_avail, | |
+ 'disk-inode-util' => \$report_inode_util, | |
+ 'disk-inode-used' => \$report_inode_used, | |
+ 'disk-inode-avail' => \$report_inode_avail, | |
'auto-scaling:s' => \$auto_scaling, | |
'aggregated:s' => \$aggregated, | |
'memory-units:s' => \$mem_units, | |
@@ -320,11 +329,11 @@ | |
} | |
} | |
-if ($report_disk_space && !$report_disk_util && !$report_disk_used && !$report_disk_avail) { | |
- exit_with_error("Disk path is provided but metrics to report disk space are not specified."); | |
+if ($report_disk_space && !$report_disk_util && !$report_disk_used && !$report_disk_avail && !$report_inode_util && !$report_inode_used && !$report_inode_avail) { | |
+ exit_with_error("Disk path is provided but metrics to report disk space or inode are not specified."); | |
} | |
-if (!$report_disk_space && ($report_disk_util || $report_disk_used || $report_disk_avail)) { | |
- exit_with_error("Metrics to report disk space are provided but disk path is not specified."); | |
+if (!$report_disk_space && ($report_disk_util || $report_disk_used || $report_disk_avail || $report_inode_util || $report_inode_used || $report_inode_avail)) { | |
+ exit_with_error("Metrics to report disk space or inode are provided but disk path is not specified."); | |
} | |
# check that there is a need to monitor at least something | |
@@ -571,6 +580,31 @@ | |
add_metric('DiskSpaceAvailable', $disk_units, $disk_avail / $disk_unit_div, $fsystem, $mount); | |
} | |
} | |
+ | |
+ my @dfi = `/bin/df -i -l -P $df_path`; | |
+ shift @dfi; | |
+ | |
+ foreach my $line (@dfi) | |
+ { | |
+ my @fields = split('\s+', $line); | |
+ my $inode_total = $fields[1]; | |
+ my $inode_used = $fields[2]; | |
+ my $inode_avail = $fields[3]; | |
+ my $fsystem = $fields[0]; | |
+ my $mount = $fields[5]; | |
+ | |
+ if ($report_inode_util) { | |
+ my $inode_util = 0; | |
+ $inode_util = 100 * $inode_used / $inode_total if ($inode_total > 0); | |
+ add_metric('DiskInodeUtilization', 'Percent', $inode_util, $fsystem, $mount); | |
+ } | |
+ if ($report_inode_used) { | |
+ add_metric('DiskInodeUsed', 'Count', $inode_used, $fsystem, $mount); | |
+ } | |
+ if ($report_inode_avail) { | |
+ add_metric('DiskInodeAvailable', 'Count', $inode_avail, $fsystem, $mount); | |
+ } | |
+ } | |
} | |
# send metrics over to CloudWatch if any |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment