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

Add autoconf capabilities to the munin plugins #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
48 changes: 36 additions & 12 deletions munin_plugins/zorp_mem_
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
##
############################################################################
#
# Usage:
# Make symbolic links like:
# ln -s zorp_mem_ zorp_mem_rss
# ln -s zorp_mem_ zorp_mem_vsz
# And run the script through links.
#
#%# family=auto
#%# capabilities=autoconf suggest

try:
from zorpctl import Instances
have_zorpctl = True
except ImportError:
have_zorpctl = False

from zorpctl import Instances
import subprocess
import sys

rss_not_vsz = True

Expand Down Expand Up @@ -58,16 +61,37 @@ def print_values():
print format_label(str(process_status.name)) + ".value " +\
str(usage)

def detect_zorp():
if not have_zorpctl:
return "No zorpctl library found"
try:
zorpctl_status = subprocess.call("zorpctl --status")
if zorpctl_status != 0:
return "zorpctl return with an error"
except OSError:
return "No zorpctl found"
return ""

if __name__ == '__main__':
import sys

# check if the launched script's name ends in VSZ
if __file__ is not None and \
__file__.upper()[-3:] == 'VSZ':
rss_not_vsz = False

if len(sys.argv) > 1 and sys.argv[1] == 'config':
print_config()
if len(sys.argv) > 1 and sys.argv[1] == 'autoconf':
excuse = detect_zorp()
if excuse == "":
print("yes")
else:
print("no ({})".format(excuse))
elif len(sys.argv) > 1 and sys.argv[1] == 'suggest':
print("rss")
print("vsz")
elif have_zorpctl:
if len(sys.argv) > 1 and sys.argv[1] == 'config':
print_config()
else:
print_values()
else:
print_values()
print("No zoprctl found, the plugin cannot be run")
sys.exit(1)
39 changes: 34 additions & 5 deletions munin_plugins/zorp_thread
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,18 @@
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
##
############################################################################
#
#%# family=auto
#%# capabilities=autoconf

from zorpctl import Instances
try:
from zorpctl import Instances
have_zorpctl = True
except ImportError:
have_zorpctl = False

import subprocess
import sys

def print_config():
print 'graph_title Zorp threads'
Expand All @@ -40,10 +49,30 @@ def print_values():
if process_status.threads > 0:
print process_status.name + ".value " + str(process_status.threads)

def detect_zorp():
if not have_zorpctl:
return "No zorpctl library found"
try:
zorpctl_status = subprocess.call("zorpctl --status")
if zorpctl_status != 0:
return "zorpctl return with an error"
except OSError:
return "No zorpctl found"
return ""


if __name__ == '__main__':
import sys
if len(sys.argv) > 1 and sys.argv[1] == 'config':
print_config()
if len(sys.argv) > 1 and sys.argv[1] == 'autoconf':
excuse = detect_zorp()
if excuse == "":
print("yes")
else:
print("no ({})".format(excuse))
elif have_zorpctl:
if len(sys.argv) > 1 and sys.argv[1] == 'config':
print_config()
else:
print_values()
else:
print_values()
print("No zoprctl found, the plugin cannot be run")
sys.exit(1)