Skip to content

Commit

Permalink
Merge c798403 into d06ed98
Browse files Browse the repository at this point in the history
  • Loading branch information
tcaiazza committed Sep 18, 2019
2 parents d06ed98 + c798403 commit 9c03bcf
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 7 deletions.
24 changes: 17 additions & 7 deletions napalm/ios/ios.py
Expand Up @@ -2095,13 +2095,23 @@ def get_environment(self):
break

output = self._send_command(mem_cmd)
for line in output.splitlines():
if "Processor" in line:
_, _, proc_total_mem, proc_used_mem, _ = line.split()[:5]
elif "I/O" in line or "io" in line:
_, _, io_total_mem, io_used_mem, _ = line.split()[:5]
total_mem = int(proc_total_mem) + int(io_total_mem)
used_mem = int(proc_used_mem) + int(io_used_mem)
if "Invalid input detected at" not in output:
for line in output.splitlines():
if "Processor" in line:
_, _, proc_total_mem, proc_used_mem, _ = line.split()[:5]
elif "I/O" in line or "io" in line:
_, _, io_total_mem, io_used_mem, _ = line.split()[:5]
total_mem = int(proc_total_mem) + int(io_total_mem)
used_mem = int(proc_used_mem) + int(io_used_mem)
else:
# Parse the memory for IOS-XR devices correctly
output = self._send_command("show memory")
for line in output.splitlines():
if "System memory" in line:
total_mem, _, used_mem = line.split()[3:6]
total_mem = int(total_mem.replace('K', ''))
used_mem = int(used_mem.replace('K', ''))

environment.setdefault("memory", {})
environment["memory"]["used_ram"] = used_mem
environment["memory"]["available_ram"] = total_mem
Expand Down
@@ -0,0 +1,35 @@
{
"cpu": {
"0": {
"%usage": 16
}
},
"fans": {
"invalid": {
"status": true
}
},
"memory": {
"available_ram": 3931592,
"used_ram": 1506752
},
"power": {
"invalid": {
"capacity": -1,
"output": -1,
"status": true
}
},
"temperature": {
"hotspot": {
"is_alert": false,
"is_critical": false,
"temperature": 43
},
"inlet": {
"is_alert": false,
"is_critical": false,
"temperature": 26
}
}
}
@@ -0,0 +1,9 @@
Inlet Temperature Value: 26 Degree Celsius
Temperature State: GREEN
Yellow Threshold : 46 Degree Celsius
Red Threshold : 60 Degree Celsius

Hotspot Temperature Value: 43 Degree Celsius
Temperature State: GREEN
Yellow Threshold : 105 Degree Celsius
Red Threshold : 125 Degree Celsius
@@ -0,0 +1,6 @@
System memory : 3931592K total, 1506752K used, 2424840K free, 221424K kernel reserved
Lowest(b) : 1854732696

Total(K) Used(K) Free(K)
Process 3931592 1506752 2424840
Config 0 0 0
@@ -0,0 +1,2 @@
^
% Invalid input detected at '^' marker.
208 changes: 208 additions & 0 deletions test/ios/mocked_data/test_get_environment/ios_xe/show_proc_cpu.txt
@@ -0,0 +1,208 @@
Core 0: CPU utilization for five seconds: 18%; one minute: 16%; five minutes: 15%
Core 1: CPU utilization for five seconds: 8%; one minute: 8%; five minutes: 7%
Core 2: CPU utilization for five seconds: 6%; one minute: 5%; five minutes: 4%
Core 3: CPU utilization for five seconds: 2%; one minute: 2%; five minutes: 3%
PID Runtime(ms) Invoked uSecs 5Sec 1Min 5Min TTY Process
1 1870 1438 1300 0.00 0.00 0.00 0 init
2 0 181 0 0.00 0.00 0.00 0 kthreadd
3 6220 922484 6 0.00 0.00 0.00 0 migration/0
4 0 3 0 0.00 0.00 0.00 0 sirq-high/0
5 1837302 107437039 1 0.00 0.00 0.00 0 sirq-timer/0
6 570 15422 36 0.00 0.00 0.00 0 sirq-net-tx/0
7 4121122 248137282 33 0.00 0.00 0.00 0 sirq-net-rx/0
8 13120 3480660 3 0.00 0.00 0.00 0 sirq-block/0
9 0 8 0 0.00 0.00 0.00 0 sirq-block-iopo
10 17210 3339586 5 0.00 0.00 0.00 0 sirq-tasklet/0
11 2912140 245813579 1 0.00 0.00 0.00 0 sirq-sched/0
12 95770 14342592 6 0.00 0.00 0.00 0 sirq-hrtimer/0
13 215032 884228442 0 0.00 0.00 0.00 0 sirq-rcu/0
14 15550 2492090 6 0.00 0.00 0.00 0 desched/0
15 5330 601168 8 0.00 0.00 0.00 0 migration/1
16 0 15 0 0.00 0.00 0.00 0 sirq-high/1
17 2943280 303456311 0 0.00 0.00 0.00 0 sirq-timer/1
18 110 4375 25 0.00 0.00 0.00 0 sirq-net-tx/1
19 1686916 894062383 30 0.00 0.05 0.05 0 sirq-net-rx/1
20 430 201874 2 0.00 0.00 0.00 0 sirq-block/1
21 0 20 0 0.00 0.00 0.00 0 sirq-block-iopo
22 0 21 0 0.00 0.00 0.00 0 sirq-tasklet/1
23 716480 216536714 0 0.00 0.00 0.00 0 sirq-sched/1
24 0 1453213 0 0.00 0.00 0.00 0 sirq-hrtimer/1
25 4172370 292908875 1 0.00 0.00 0.00 0 sirq-rcu/1
26 17800 1622116 10 0.00 0.00 0.00 0 desched/1
27 10390 1399850 7 0.00 0.00 0.00 0 migration/2
28 0 27 0 0.00 0.00 0.00 0 sirq-high/2
29 375010 262741636 0 0.00 0.00 0.02 0 sirq-timer/2
30 90 4049 22 0.00 0.00 0.00 0 sirq-net-tx/2
31 515974 133352067 29 0.00 0.00 0.04 0 sirq-net-rx/2
32 280 80498 3 0.00 0.00 0.00 0 sirq-block/2
33 0 32 0 0.00 0.00 0.00 0 sirq-block-iopo
34 0 33 0 0.00 0.00 0.00 0 sirq-tasklet/2
35 81030 198983980 0 0.00 0.00 0.00 0 sirq-sched/2
36 0 1131340 0 0.00 0.00 0.00 0 sirq-hrtimer/2
37 470480 257655108 0 0.00 0.00 0.00 0 sirq-rcu/2
38 11340 1735365 6 0.00 0.00 0.00 0 desched/2
39 11440 1463938 7 0.00 0.00 0.00 0 migration/3
40 0 39 0 0.00 0.00 0.00 0 sirq-high/3
41 1750 204773518 0 0.00 0.00 0.00 0 sirq-timer/3
42 20 2610 7 0.00 0.00 0.00 0 sirq-net-tx/3
43 3937534 148230290 28 0.00 0.01 0.03 0 sirq-net-rx/3
44 180 44738 4 0.00 0.00 0.00 0 sirq-block/3
45 0 44 0 0.00 0.00 0.00 0 sirq-block-iopo
46 0 45 0 0.00 0.00 0.00 0 sirq-tasklet/3
47 200 158098038 0 0.00 0.00 0.00 0 sirq-sched/3
48 0 875207 0 0.00 0.00 0.00 0 sirq-hrtimer/3
49 130 201695884 0 0.00 0.00 0.00 0 sirq-rcu/3
50 14870 2174693 6 0.00 0.00 0.00 0 desched/3
51 233080 194376708 1 0.00 0.00 0.00 0 events/0
52 38260 72906002 0 0.00 0.00 0.02 0 events/1
53 17610 67441906 0 0.00 0.00 0.00 0 events/2
54 2520 70242380 0 0.00 0.00 0.01 0 events/3
55 0 54 0 0.00 0.00 0.00 0 cpuset
56 10 3890 2 0.00 0.00 0.00 0 khelper
59 0 56 0 0.00 0.00 0.00 0 netns
60 0 61 0 0.00 0.00 0.00 0 async/mgr
165 11580 11058522 1 0.00 0.00 0.00 0 sync_supers
167 350 221341 1 0.00 0.00 0.00 0 bdi-default
169 3530 2750096 1 0.00 0.00 0.00 0 kblockd/0
170 310 159227 1 0.00 0.00 0.00 0 kblockd/1
171 200 62426 3 0.00 0.00 0.00 0 kblockd/2
172 20 34599 0 0.00 0.00 0.00 0 kblockd/3
178 0 67 0 0.00 0.00 0.00 0 ata/0
179 0 67 0 0.00 0.00 0.00 0 ata/1
180 0 66 0 0.00 0.00 0.00 0 ata/2
181 0 67 0 0.00 0.00 0.00 0 ata/3
182 0 68 0 0.00 0.00 0.00 0 ata_aux
191 0 71 0 0.00 0.00 0.00 0 khubd
222 0 284 0 0.00 0.00 0.00 0 rpciod/0
223 10 183 54 0.00 0.00 0.00 0 rpciod/1
224 10 206 48 0.00 0.00 0.00 0 rpciod/2
225 10 176 56 0.00 0.00 0.00 0 rpciod/3
259 0 78 0 0.00 0.00 0.00 0 kswapd0
260 0 79 0 0.00 0.00 0.00 0 aio/0
261 0 80 0 0.00 0.00 0.00 0 aio/1
262 0 81 0 0.00 0.00 0.00 0 aio/2
263 0 82 0 0.00 0.00 0.00 0 aio/3
264 0 83 0 0.00 0.00 0.00 0 nfsiod
266 0 84 0 0.00 0.00 0.00 0 crypto/0
267 0 85 0 0.00 0.00 0.00 0 crypto/1
268 0 86 0 0.00 0.00 0.00 0 crypto/2
269 0 87 0 0.00 0.00 0.00 0 crypto/3
927 0 99 0 0.00 0.00 0.00 0 scsi_eh_0
936 298930 38520 7760 0.00 0.00 0.00 0 mtdblockd
1011 0 96 0 0.00 0.00 0.00 0 kstriped
1013 0 97 0 0.00 0.00 0.00 0 ksnapd
1016 48520 131995570 0 0.00 0.00 0.00 0 edac-poller
1051 107610 87643891 1 0.00 0.00 0.00 0 octeon-ethernet
1116 460 1728 266 0.00 0.00 0.00 0 udevd
1793 260 4402 59 0.00 0.00 0.00 0 loop1
1798 9180 12505482 0 0.00 0.00 0.00 0 flush-8:0
1812 70 4601 15 0.00 0.00 0.00 0 loop2
1830 40 2766 14 0.00 0.00 0.00 0 loop3
1848 110 4098 26 0.00 0.00 0.00 0 loop4
1866 30 908 33 0.00 0.00 0.00 0 loop5
1951 0 401 0 0.00 0.00 0.00 0 loop6
2687 40 1428 28 0.00 0.00 0.00 0 udevd
2768 20 1289 15 0.00 0.00 0.00 0 udevd
3684 170 1282 132 0.00 0.00 0.00 0 dbus-daemon
4064 130 1735 74 0.00 0.00 0.00 0 klogd
4076 30 1555 19 0.00 0.00 0.00 0 portmap
4144 0 1128 0 0.00 0.00 0.00 0 sshd
4156 20 1430 13 0.00 0.00 0.00 0 xinetd
4160 70 1526 45 0.00 0.00 0.00 0 xinetd
4194 0 113 0 0.00 0.00 0.00 0 lockd
4195 0 18545 0 0.00 0.00 0.00 0 nfsd
4196 20 18546 1 0.00 0.00 0.00 0 nfsd
4197 10 18547 0 0.00 0.00 0.00 0 nfsd
4198 10 18626 0 0.00 0.00 0.00 0 nfsd
4199 10 18704 0 0.00 0.00 0.00 0 nfsd
4200 50 19038 2 0.00 0.00 0.00 0 nfsd
4201 30 19041 1 0.00 0.00 0.00 0 nfsd
4202 0 18551 0 0.00 0.00 0.00 0 nfsd
4208 330 1676 196 0.00 0.00 0.00 0 rpc.mountd
4608 10 1283 7 0.00 0.00 0.00 0 sh
4611 0 1283 0 0.00 0.00 0.00 0 inotifywait
5165 10 1338 7 0.00 0.00 0.00 0 sh
5168 130 1351 96 0.00 0.00 0.00 0 epc_sm_liaison
5361 120 1532 78 0.00 0.00 0.00 34824 in.telnetd
5362 110 1531 71 0.00 0.00 0.00 34820 bexec.sh
5365 10 1531 6 0.00 0.00 0.00 34820 mcp_chvrf.sh
5366 120 1541 77 0.00 0.00 0.00 34820 vty_attach.sh
5816 811820 132667737 135 0.00 0.01 0.01 0 system_mgr
6039 2082800 126045626 16 0.00 0.00 0.00 1088 slproc
6081 1091531 215778492 83 3.08 2.97 2.91 0 fed
6082 1795814 152524660 15 0.19 0.11 0.10 0 platform_mgr
6083 4183596 103486965 86 0.82 0.85 0.86 0 stack-mgr
6558 2206105 132523451 81 0.00 0.01 0.00 0 idope.py
6612 925670 72974019 12 0.00 0.00 0.00 0 ns_oir_proxy
6613 926720 72978940 12 0.00 0.00 0.00 0 profiled
6614 615572 6610689 742 0.00 0.01 0.04 0 oom_poll.sh
6615 1359332 440928938 12 0.05 0.02 0.01 0 obfld
6616 924160 72978829 12 0.00 0.00 0.00 0 consoled
6617 2552755 139687532 79 0.00 0.02 0.01 0 console_relay
6618 941010 72978902 12 0.00 0.00 0.02 0 csprovider
6619 920580 72978978 12 0.00 0.00 0.00 0 system_mgr_cli
6620 2216808 340559492 44 0.00 0.01 0.03 0 plogd
6621 927830 72979067 12 0.00 0.00 0.00 0 psdprov
6622 1754219 392827239 36 0.10 0.11 0.10 0 pdsd
6623 2820430 82701668 34 0.00 0.00 0.04 0 gold_slave
6624 940210 72998620 12 0.00 0.03 0.04 0 osinfo-provider
6625 923560 72978895 12 0.00 0.00 0.00 0 oscore_p
6626 2221210 80916299 27 0.00 0.00 0.00 0 netd
6627 840706 132601005 200 0.05 0.03 0.02 0 mem_mgmt
6628 2522110 139311434 18 0.00 0.00 0.01 0 mgmte_tap
6629 928460 73054547 12 0.00 0.03 0.04 0 installer
6630 915122 157337753 33 0.00 0.00 0.00 0 ffm
6631 3616770 73679085 49 0.00 0.06 0.08 0 eicored
6632 943880 75193759 12 0.00 0.00 0.00 0 dtmgr
6633 3857772 139209642 737 0.05 0.04 0.05 0 cpumemd
6640 2522970 142766423 17 0.00 0.00 0.02 0 liin_tap
6646 999020 73157102 13 0.05 0.20 0.30 0 cli_agent
6650 971910 610222561 1 0.00 0.03 0.04 0 snmp_subagent
6652 2018970 139316547 14 0.00 0.00 0.02 0 erm_p
6657 1700330 139317006 12 0.00 0.00 0.00 34821 ngdumper_provid
6658 1720060 139316991 12 0.00 0.00 0.00 34818 sysinfo_p
6667 919200 72971967 12 0.00 0.00 0.00 34820 fs_cmd
8467 410 1574 260 0.00 0.00 0.00 34818 rollback_timer.
8536 0 6610690 0 0.00 0.00 0.00 34820 sleep
8554 0 1564 0 0.00 0.00 0.00 34818 rollback_timer.
8555 180 1564 115 0.00 0.00 0.00 34820 xlogger
8560 0 1568 0 0.00 0.00 0.00 34818 inotifywait
8924 130 1358 95 0.00 0.00 0.00 34823 nova_sntp.sh
9264 0 1355 0 0.00 0.00 0.00 34819 nova_sntp.sh
9265 160 1355 118 0.00 0.00 0.00 34819 xlogger
9268 143390 1283521 111 0.00 0.00 0.00 34819 sntp
22145 2915500 173856815 1 0.00 0.01 0.04 34823 table_mgr
22146 170 2025 83 0.00 0.00 0.00 0 wnweb.sh
22147 928450 72987714 12 0.00 0.03 0.04 34816 iifd
22148 2610794 139394176 266 4.72 4.00 3.82 34819 iosd
22149 47082 100382805 43 0.05 0.01 0.04 34820 ha_mgr
24317 110 1513 72 0.00 0.00 0.00 34816 in.telnetd
24319 120 1512 79 0.00 0.00 0.00 34816 bexec.sh
24324 10 1512 6 0.00 0.00 0.00 34816 mcp_chvrf.sh
24325 110 1521 72 0.00 0.00 0.00 34816 vty_attach.sh
24348 110 1519 72 0.00 0.00 0.00 34816 in.telnetd
24352 120 1518 79 0.00 0.00 0.00 34818 bexec.sh
24355 10 1518 6 0.00 0.00 0.00 34818 mcp_chvrf.sh
24356 120 1525 78 0.00 0.00 0.00 34818 vty_attach.sh
24360 110 1522 72 0.00 0.00 0.00 34818 in.telnetd
24362 130 1521 85 0.00 0.00 0.00 34819 bexec.sh
24365 0 1521 0 0.00 0.00 0.00 34819 mcp_chvrf.sh
24366 110 1528 71 0.00 0.00 0.00 34819 vty_attach.sh
24380 110 1525 72 0.00 0.00 0.00 34819 in.telnetd
24381 100 1527 65 0.00 0.00 0.00 34819 in.telnetd
24383 120 1524 78 0.00 0.00 0.00 34817 bexec.sh
24384 110 1525 72 0.00 0.00 0.00 34821 bexec.sh
24388 10 1524 6 0.00 0.00 0.00 34817 mcp_chvrf.sh
24389 110 1534 71 0.00 0.00 0.00 34817 vty_attach.sh
24392 10 1525 6 0.00 0.00 0.00 34821 mcp_chvrf.sh
24393 100 1532 65 0.00 0.00 0.00 34821 vty_attach.sh
24436 110 1528 71 0.00 0.00 0.00 34821 in.telnetd
24441 110 1527 72 0.00 0.00 0.00 34823 bexec.sh
24444 10 1527 6 0.00 0.00 0.00 34823 mcp_chvrf.sh
24445 100 1538 65 0.00 0.00 0.00 34823 vty_attach.sh
24462 3954865 132704949 94 0.00 0.00 0.03 34823 wnweb_paster.py
24463 430 2025 212 0.00 0.00 0.00 0 xlogger
24589 110 1530 71 0.00 0.00 0.00 0 in.telnetd
24590 110 1529 71 0.00 0.00 0.00 34824 bexec.sh
24593 10 1529 6 0.00 0.00 0.00 34824 mcp_chvrf.sh
24594 100 1539 64 0.00 0.00 0.00 34824 vty_attach.sh

0 comments on commit 9c03bcf

Please sign in to comment.