Junos PyEZ Table View for “show system process extensive”

root> show system processes extensivelast pid: 26688; load averages: 0.81, 0.95, 0.87 up 1+09:50:29 07:16:56448 threads: 10 running, 397 sleeping, 41 waitingCPU: 5.9% user, 0.0% nice, 11.8% system, 9.6% interrupt, 72.7% idleMem: 201M Active, 2796M Inact, 1348M Wired, 494M Buf, 11G FreeSwap: 3072M Total, 3072M FreePID USERNAME PRI NICE SIZE RES STATE C TIME WCPU COMMAND11828 root 4 0 924M 125M select 1 341:28 16.36% chassisd{chassisd}13733 root 22 0 775M 54M CPU1 1 115:33 5.37% jinsightd{jinsightd}13741 root 22 0 50M 27M RUN 1 88:10 4.05% na-grpcd{na-grpcd}26686 root 23 0 86M 69M select 0 0:00 1.76% cli13769 root 20 0 739M 28M select 0 9:58 0.10% agentd{agentd}11734 root 20 0 734M 23M select 1 7:27 0.10% eventd
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/22.3I0/junos"><output>
last pid: 26688; load averages: 0.81, 0.95, 0.87 up 1+09:50:29 07:16:56
448 threads: 10 running, 397 sleeping, 41 waitingCPU: 5.9% user, 0.0% nice, 11.8% system, 9.6% interrupt, 72.7% idleMem: 201M Active, 2796M Inact, 1348M Wired, 494M Buf, 11G FreeSwap: 3072M Total, 3072M FreePID USERNAME PRI NICE SIZE RES STATE C TIME WCPU COMMAND11828 root 4 0 924M 125M select 1 341:28 16.36% chassisd{chassisd}13733 root 22 0 775M 54M CPU1 1 115:33 5.37% jinsightd{jinsightd}13741 root 22 0 50M 27M RUN 1 88:10 4.05% na-grpcd{na-grpcd}26686 root 23 0 86M 69M select 0 0:00 1.76% cli13769 root 20 0 739M 28M select 0 9:58 0.10% agentd{agentd}11734 root 20 0 734M 23M select 1 7:27 0.10% eventd
</output>
</rpc-reply>
from jnpr.junos.factory.factory_loader import FactoryLoader
import yaml
import json
from pprint import pprint

yaml_data = """
---
SystemProcExtTable:
command: show system processes extensive
key:
- pid
- cmd
title: ' PID '
view: SystemProcExtView

SystemProcExtView:
regex:
pid: '(\d+)'
size: '.* \S +(\d+(K|M|G))\s+'
res: '(\d+(K|M|G))'
wcpu: '.* (\d+\.\d+)%'
cmd: '[\w\-\{\}]+'

"""

with Device(host=’X.X.X.X’, user='XXX', password='XXX', port=22) as dev:
globals().update(FactoryLoader().load(yaml.load(yaml_data, Loader=yaml.FullLoader)))
proc = SystemProcExtTable(dev)
proc.get()
pprint(json.loads(proc.to_json()))
{"(1, 'init')": {'cmd': 'init',
'pid': 1,
'res': '636K',
'size': '9560K',
'wcpu': '0.00'},
"(10825, 'eventd')": {'cmd': 'eventd',
'pid': 10825,
'res': '15M',
'size': '734M',
'wcpu': '0.00'},
"(10831, 'jlaunchd')": {'cmd': 'jlaunchd',
'pid': 10831,
'res': '7112K',
'size': '750M',
'wcpu': '0.00'}
}

--

--

--

Network Automation Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

New Enterprise DApp Running on CPUcoin

Day 4: Errors can be fun, too

Concurrent vs Parallel Execution

Discovery Phase For Software Development Companies

Open video links like Telegram do with oEmbed and Kotlin

For Developers, Ego Is the Enemy

Engineering hyperlocal deliveries in India

Getting the Stack Trace of a Running Python Program

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dineshbaburam

Dineshbaburam

Network Automation Engineer

More from Medium

Your First Steps Toward Data-Driven Decision Making

Data-Driven Decision Making

Improving Powkiddy V90’s Portable Experience

FHIR and Its Benefits for the Healthcare System

A Quick Look into Spring 2022 with Codebase