Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I attempted to use the plugin but was not successful.
Can anyone point out where I am going wrong?

xxx@xxx-Aspire-5738:/usr/lib/nagios/plugins$ python -u ( -w 2.25 -c 2.5  
[1] 11103  
[2] 11104  
[3] 11105  
[4] 11106  
Status Unknown: Graphite returned an empty list of values  
-w: command not found  
[1]   Exit 3 ....                 python -u (   
[2]   Done       .....             height=308  
[3]-  Done            .....        _salt=1349434980.323  
[4]+  Done                 .....  from=-10minutes 

and thus it ends. Any ideas?

from NagAconda import Plugin
import urllib2

def f_avg(values):
  return sum(values)/len(values);

def f_last(values):
  return values[-1]

def f_min(values):
  return min(values)

def f_max(values):
  return max(values)

functionmap = {
  "avg":{  "label": "average", "function": f_avg },
  "last":{ "label": "last",    "function": f_last },
  "min":{  "label": "minimum", "function": f_min },
  "max":{  "label": "maximum", "function": f_max },

graphite = Plugin("Plugin to retrieve data from graphite", "1.0")
graphite.add_option("u", "url", "URL to query for data", required=True)
graphite.add_option("U", "username", "User for authentication")
graphite.add_option("P", "password", "Password for authentication")
graphite.add_option("H", "hostname", "Host name to use in the URL")
graphite.add_option("n", "none", "Ignore None values: 'yes' or 'no' (default no)")
graphite.add_option("f", "function", "Function to run on retrieved values: avg/min/max/last (default 'avg')",


if graphite.options.username and graphite.options.password:
    password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
    auth_handler =urllib2.HTTPBasicAuthHandler(password_mgr)
    opener = urllib2.build_opener(auth_handler)

if graphite.options.hostname:
  graphite.options.url = graphite.options.url.replace('@HOSTNAME@', 

usock = urllib2.urlopen(graphite.options.url)
data =

if graphite.options.function not in functionmap:
  graphite.unknown_error("Bad function name given to -f/--function option: '%s'" % graphite.options.function)

pieces = data.split("|")
counter = pieces[0].split(",")[0]
values = pieces[1].split(",")[:-1]

if graphite.options.none == 'yes':
  values = map(lambda x: float(x), filter(lambda x: x != 'None', values))
  values = map(lambda x: 0.0 if x == 'None' else float(x), values)
if len(values) == 0:
  graphite.unknown_error("Graphite returned an empty list of values")
  value = functionmap[graphite.options.function]["function"](values)

graphite.set_value(counter, value)
graphite.set_status_message("%s value of %s: %f" % (functionmap[graphite.options.function]["label"], counter, value))

share|improve this question
Exo, the script you pasted above appears to be the check plugin available at: but you have removed the copyright notice at the top, which is REQUIRED under the terms of the license. Please edit and comply with the law. – Jason Antman Oct 22 '12 at 20:42
Just as a test, you may want to download the latest version of the script and try that... – Jason Antman Oct 22 '12 at 20:42

Instead of enclosing your render URL with parentheses, try the following instead.

python -u "" -w 2.25 -c 2.5
share|improve this answer
I have placed the parenthesis in this post only, i executed the command in terminal without them...sorry forgot to mention that before :( – exo Oct 9 '12 at 6:21
You need to add the " or escape some of the characters. – pkhamre Oct 9 '12 at 6:27
I got the following error: Traceback (most recent call last): File "", line 63, in <module> values = map(lambda x: 0.0 if x == 'None' else float(x), values) File "", line 63, in <lambda> values = map(lambda x: 0.0 if x == 'None' else float(x), values) ValueError: could not convert string to float: ��P�:� – exo Oct 10 '12 at 10:46
I have edited the question & pasted the script i'm using. – exo Oct 11 '12 at 6:11
I will take a look. Edited your question to improve the formatting btw. – pkhamre Oct 11 '12 at 6:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.