OK. If you are trying to get numeric data for a datasource, then there are a few things to think about.
First is whether you want data from the device itself ie. a single piece of data for the box, or whether you are trying to get data for each component of your Noviflow switch. For example, if there was a command to get the temperature of the box, that would fit the first scenario; if you wanted to get bytes transmitted by each port of the switch, that would be the second (component) scenario. The first should be fairly easy and shouldn't require you writing code (other than the command to retrieve the data); the second, component scenario, you would need to write a ZenPack that models the components and then provide datasources to collect the component data.
. Chapter 12 takes you through the process of gathering data using a COMMAND template, both for a device and for device components.
You will need to establish how you are going to run these commands on your Noviflow boxes - I am guessing using ssh? So you will need to setup various zCommand zProperties to permit such communication - see chapter 12.2 for this.
Subject: |
RE: How to execute command on Noviflow Switch |
Author: |
Bharat Kumar Kobagana |
Posted: |
2018-10-04 07:53 |
Hi Jane,
Thanks a lot for your inputs.
Yes, I need to execute commands over SSH. And my case fits into the first scenario. (Execute a command on switch and parse the output).
I am mainly looking for how to execute COMMANDS on Noviflow switch device through ZenOSS, like:
- Configuration changes on Switch side
- Setting proper Configuration properties like zCommandUsername and zCommandPassword, etc.
I am very much familiar with executing commands on Linux device. But I stuck when executing commands on Noviflow Switch. I have configured zCommandUsername and zCommandPassword for Noviflow device, but I am getting below alarms:
- Datasource test/test command timed out
- Logged in as superuser (Super permissions). Press CTRL-D or type command "exit" to logout
And when I configure COMMAND TEMPLATE as "show status switch" I am getting below error:
Preparing Command...
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 206, in testDataSourceAgainstDevice command = self.compile(self, device) File "/opt/zenoss/Products/ZenModel/Commandable.py", line 205, in compile res = compiled(getEngine().getContext(environ)) File "/opt/zenoss/lib/python2.7/site-packages/Products/PageTemplates/Expressions.py", line 383, in __call__ v = evaluate(var) File "/opt/zenoss/lib/python2.7/site-packages/zope/tales/tales.py", line 696, in evaluate return expression(self) File "/opt/zenoss/lib/python2.7/site-packages/zope/tales/expressions.py", line 217, in __call__ return self._eval(econtext) File "/opt/zenoss/lib/python2.7/site-packages/Products/PageTemplates/Expressions.py", line 147, in _eval ob = self._subexprs[-1](econtext) File "/opt/zenoss/lib/python2.7/site-packages/zope/tales/expressions.py", line 118, in _eval ob = vars[base]
KeyError: 'ZENHOME'
</pre>
------------------------------
Bharat Kumar K
------------------------------
Subject: |
RE: How to execute command on Noviflow Switch |
Author: |
Jane Curry |
Posted: |
2018-10-05 05:17 |
Hmm - that error highlighting ZENHOME could be several things.
You say you are very familiar with executing ssh against Linux systems - is that through Zenoss?? If not, I might suggest that you set up a little test against a Linux system first, with a very simple command - just so that you are sure you understand the various zCommand parameters.. Have a good look at the ZenPack Developers' Guide chapter 12.2, pages 224 - 227. You will see from those pages that there is a discussion about using $ZENHOME in the zCommandPath property (and also note that there have been slight quirks with the use of the zCommandPath property with different releases of Zenoss and SUPs - what exactly do you have?). Also have a look at pages 205 - 207, chapter 11.5.2, that has a further discussion about zCommand properties.
Do your Noviflow switches allow you to setup public-key access for ssh? I find this ismuch easier to drive COMMAND templates from Zenoss, once you have the key mechanism setup.
Make sure you can test against your Noviflow switch using ssh from the Zenoss machine's unix command line - that way you know that the basic ssh mechanism is working.
Cheers,
Jane
------------------------------
Jane Curry
Skills 1st United Kingdom
jane.curry@skills-1st.co.uk
------------------------------
Subject: |
RE: How to execute command on Noviflow Switch |
Author: |
Bharat Kumar Kobagana |
Posted: |
2018-10-07 08:20 |
Hi Jane,
I have gone through the documentation that you have provided,
able to resolve ZENHOME issue.
I have configured zCommandUsername and zCommandPassword for my Noviflow device, but I am unable to get output from COMMAND data source. Below are my observations:
Running a command on Linux device through SSH:
[root@core-master ~]# ssh -l centos 180.148.27.103 uname -a
centos@180.148.27.103's password:
Linux ansible-tower.novalocal 3.10.0-862.3.3.el7.x86_64 #1 SMP Fri Jun 15 04:15:27 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Running a command on Noviflow Switch device through SSH:
[root@core-master ~]# ssh -l superuser 192.168.125.91 show status switch
superuser@192.168.125.91's password:
Logged in as superuser (Super permissions). Press CTRL-D or type command "exit" to logout
novi2#
On Noviflow device I am not able to get output while executing a command with
ssh -l command, instead it is giving Switch command prompt. That is why ZenOSS COMMAND data source is not working on Noviflow device.
How can I solve this issue?
------------------------------
Bharat Kumar Kobagana
------------------------------
Subject: |
RE: How to execute command on Noviflow Switch |
Author: |
Jane Curry |
Posted: |
2018-10-11 05:43 |
Sorry Baharat - that's a Noviflow issue, not a Zenoss one At least we have now diagnosed that fact. Once you have this resolved, it should also work with Zenoss.
Do report back here if you fix it so others can learn from this experience.
Cheers,
Jane
------------------------------
Jane Curry
Skills 1st United Kingdom
jane.curry@skills-1st.co.uk
------------------------------