TECHZEN Zenoss User Community ARCHIVE  

COMMAND data source testing failing

Subject: COMMAND data source testing failing
Author: Bharat Kumar Kobagana
Posted: 2018-09-11 02:47

Hi,

We have created a sample COMMAND data source with below attributes:

Name: test
Enabled: True
Event Class: /Cmd/Fail
Parser: Auto
Component:
Severity: Warning
Cycle Time (seconds): 300
Use SSH: False (Unchecked)
Event Key:
Command Template: /usr/bin/env echo TEST

When I am testing this command data source by Clicking on Test button, it is failing with below error.

Preparing Command...
Executing command
/usr/bin/env [args omitted]
against lxvcw1oc201
Exception while performing command: <br />
<pre>Traceback (most recent call last):
File "/opt/zenoss/Products/ZenUI3/browser/command.py", line 149, in stream
self.reportError)
File "/opt/zenoss/Products/ZenModel/BasicDataSource.py", line 242, in testDataSourceAgainstDevice
remoteCollector = device.getPerformanceServer().id != 'localhost'
AttributeError: 'NoneType' object has no attribute 'id'
</pre>
Please help me in solving the issue. Thanks in advance.

------------------------------
Bharat Kumar K
India
------------------------------

Attachments:

Bug_1.png

Bug_2.png



Subject: RE: COMMAND data source testing failing
Author: Jane Curry
Posted: 2018-09-11 04:43

I have set up the same template and it works for me - no errors.  I am on Zenoss 4.2.5 SUP 743. 

Bear in mind that a template expects to provide performance data - ie numbers - and your test script doesn't.  Different versions of Zenoss may respond differently to this scenario.  For example, if there is a datapoint in your performance  template then it probably will fail.

Try running zencommand standalone in debug against your test device, for example:

zencommand run -v 10 -d zen42.class.example.org > /tmp/fred 2>&1

and then inspect /tmp/fred, looking for the name of your template.

If you want a little test script that runs a COMMAND and generates numbers, I use the following:

[zenoss@zen42 local]$ cat test.sh
#!/bin/sh

# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
#
exitstatus=$STATE_OK

# Nagios format echos information and status followed by pipe |
# followed by <var name>=<value> tuples
# Note that Zenoss datapoints must match these var names exactly
#
echo "This is a test - status OK | timevar=74s sizevar=9B percentvar=10% countervar=123c"
exit $exitstatus

Make sure that your template has datapoints for timevar, sizevar percentvar and countervar.

Cheers,
Jane

------------------------------
Jane Curry
Skills 1st United Kingdom
jane.curry@skills-1st.co.uk
------------------------------


< Previous
fully setting event fields and dealing with multi-line data
  Next
Zenpack component graph has no data
>