Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added autoconf capabilities for nginx_memory #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions nginx_memory
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,19 @@ MIT

=cut

## Munin config method.
if (exists $ARGV[0] and $ARGV[0] eq "config") {
## Plugin
if (exists $ARGV[0] and $ARGV[0] eq "autoconf") {
## Return yes as long as nginx is installed

my $nginx = `which nginx >/dev/null 2>/dev/null`;
if ( $? != 0 ) {
print "no\n";
} else {
print "yes\n";
}
} elsif (exists $ARGV[0] and $ARGV[0] eq "config") {
## Configure the plugin

print "graph_title nginx RAM usage\n";
print "graph_vlabel RAM\n";
print "graph_category nginx\n";
Expand All @@ -81,15 +92,7 @@ if (exists $ARGV[0] and $ARGV[0] eq "config") {

exit 0;
} else {

## Get the current OS name.
my $osname = $^O;

if ($osname eq 'freebsd') { # FreeBSD
my $pid_nginx = "pgrep -d ' ' nginx";
} else { # Linux
my $pid_nginx = "pidof nginx";
}
## Normal operation

my $m = `ps u -p \$(pgrep -d ' ' nginx) | awk 'NR > 1 {nm += \$5} END {print nm*1024}'`;

Expand Down