From a88873b812872b72f153359f0323cb7677ef7670 Mon Sep 17 00:00:00 2001 From: Stanislaw Gackowski Date: Fri, 26 Jan 2018 12:23:13 +0100 Subject: [PATCH 1/2] Added autoconf capabilities for nginx_memory --- nginx_memory | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/nginx_memory b/nginx_memory index 0e99df9..3039b6f 100755 --- a/nginx_memory +++ b/nginx_memory @@ -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 ( $nginx eq "" ) { + 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"; @@ -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}'`; From 798029bb87476d70c930f4de86b11a6121a23b48 Mon Sep 17 00:00:00 2001 From: Stanislaw Gackowski Date: Fri, 26 Jan 2018 13:59:40 +0100 Subject: [PATCH 2/2] Obviously meant this --- nginx_memory | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx_memory b/nginx_memory index 3039b6f..14b82e0 100755 --- a/nginx_memory +++ b/nginx_memory @@ -76,7 +76,7 @@ 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 ( $nginx eq "" ) { + if ( $? != 0 ) { print "no\n"; } else { print "yes\n";