Hi,
I'm using VirtualBox on Windows 10 and am running the following image: Juniper JunOS Olive12.1R1.9 Virtualbox image.ova. I'm also using Python 3.6.3 with PyEz installed through pip. I have two scripts one for getting box health (CPU, memory, temprature etc.) and the other for getting network interface based I/O bytes and other traffic attributes. The problem is both the scripts exit with "Process finished with exit code 0" with returning any thing. Well the network script only prints the MTU size even though there are other values I'm trying to print. I'm copy/pasting my code and the outputs here. Any and all help would be appreciated. If this is not the right place for asking this question I apologize and will rectify the problem if asked.
BTW if I try to execute the RPCs from the tables in JunOS directly I get error: Unrecognized command (chassis-control)
#netstats.py
from jnpr.junos import Device
from jnpr.junos.factory.factory_loader import FactoryLoader
import yaml
yaml_data = """
---
EthPortTable:
rpc: get-interface-information
args:
media: True
interface_name: '[afgxe]m*'
args_key: interface_name
item: physical-interface
view: EthPortView
EthPortView:
groups:
mac_stats: ethernet-mac-statistics
flags: if-device-flags
fields:
oper: oper-status
admin: admin-status
description: description
mtu: { mtu : int }
link_mode: link-mode
macaddr: current-physical-address
fields_mac_stats:
rx_bytes: input-bytes
rx_packets: input-packets
tx_bytes: output-bytes
tx_packets: output-packets
fields_flags:
running: { ifdf-running: flag }
present: { ifdf-present: flag }
"""
dev = Device(host='192.168.56.20', user='root', password='njamal99', gather_facts=False)
dev.open()
globals().update(FactoryLoader().load(yaml.load(yaml_data)))
hostmetrics = EthPortTable(dev)
hostmetrics.get()
for hostmetric in hostmetrics:
print('status: ', hostmetric.oper)
print('admin: ', hostmetric.admin)
print('rx_bytes:', hostmetric.rx_bytes)
print('rx_packets:', hostmetric.rx_packets)
print('tx_packets:', hostmetric.tx_packets)
print('mtu:', hostmetric.mtu)
dev.close()
Output from netstats.py:
status: up
admin: up
rx_bytes: None
rx_packets: None
tx_packets: None
mtu: 1514
Process finished with exit code 0
#hoststats.py
from jnpr.junos import Device
from jnpr.junos.factory.factory_loader import FactoryLoader
import yaml
yaml_data="""
---
REStats:
rpc: get-route-engine-information
key: mastership-state
item: route-engine
view: REStatsView
REStatsView:
fields:
status: status
used: cpu-idle
cpu-user : cpu-user
cpu-background: cpu-background
cpu-interrupt: cpu-interrupt
cpu-system: cpu-system
cpu-load_average: load-average-five
temperature : temperature/@celsius
memory: memory-buffer-utilization
"""
dev = Device(host='192.168.56.20', user='root', password='njamal99', gather_facts=False)
dev.open()
globals().update(FactoryLoader().load(yaml.load(yaml_data)))
hostmetrics = REStats(dev)
hostmetrics.get()
for hostmetric in hostmetrics:
print('status: ', hostmetric.status)
print('cpu_used: ', hostmetric.used)
print('cpu-user:', hostmetric.cpu-user)
print('cpu-background:', hostmetric.cpu-background)
print('cpu-system:', hostmetric.cpu-system)
print(hostmetrics)
dev.close()
Output from hoststats.py:
Process finished with exit code 0
Many thanks,
Tahir-PyEz
#PyEzVirtualBoxJunOSTableViews