Posted on June 5, 2020 7:51 pm
 |  Asked by Bora Atiti
 |  79 views
Tags:
RESOLVED
0
0
Print Friendly, PDF & Email

I’m trying to automate some performance monitoring tasks on my Arista switch. Is there is a supported command in the EAPI that can provide CPU utilization in a json format?

I know that there are alternatives like using the HOST-RESOURCES MIB or getting the data in plaintext format but all of my existing management scripts are setup to handle json responses so I’d like to avoid having to implement a one-off solution if possible.

1
Posted by Tamas Plugor
Answered on June 5, 2020 7:56 pm

you can use 'show processes top once as it's jsonified so you'll see the output in key value pairs

e.g.

switch...19:50:41#show processes top once | json
{
"cpuInfo": {
"%Cpu(s)": {
"idle": 84.1,
"stolen": 0.0,
"user": 11.9,
"swIrq": 0.1,
"ioWait": 0.0,
"system": 3.7,
"hwIrq": 0.2,
"nice": 0.0
}
},
...ommitted...

 

Simple eAPI test:

>>> from jsonrpclib import Server
>>> sw = Server("unix:/var/run/command-api.sock")

>>> response = sw.runCmds(1,['show processes top once'])
>>> response[0]['cpuInfo']
{'%Cpu(s)': {'idle': 84.1, 'stolen': 0.0, 'swIrq': 0.1, 'ioWait': 0.0, 'user': 11.9, 'system': 3.7, 'hwIrq': 0.2, 'nice': 0.0}}

Generally you'll find any eAPI info on any switch by accessing it's IP in a browser, you'll have all supported commands there and examples too.

HTH,

Tamas

0
Posted by Bora Atiti
Answered on June 5, 2020 8:45 pm

Hi Tamas, thanks for your help.

I ran the “show processes top once” in my switch’s explorer and it came back with the unconverted command error. Sounds like I may need to upgrade my EOS version. Are changes in the EAPI documented anywhere to show what versions are adding support for new commands?

Yes they are! With each release we release the CommandApiGuide PDF which you can find on the software-download page under each versions folder in the Docs folder. We introduced the show processes output in 4.21.0F
(Tamas Plugor at June 5, 2020 9:31 pm)
Perfect, thanks so much!
(Bora Atiti at June 5, 2020 10:29 pm)

Post your Answer

You must be logged in to post an answer.