Oxidized kasutamine: erinevus redaktsioonide vahel
Allikas: Imre kasutab arvutit
Mine navigeerimisribaleMine otsikasti
Uus lehekülg: '===Sissejuhatus=== TODO ===Kasulikud lisamaterjalid=== * TODO' |
Resümee puudub |
||
| 2. rida: | 2. rida: | ||
TODO | TODO | ||
===Mock switch - Linux kasutaja shell script=== | |||
Mock switch seisneb Linux operatsioonisüsteemi tavalise kasutaja tekitamises, mille shell on asendatud nt sellise skriptiga | |||
<pre> | |||
root@zabbix-pub-01:~# cat /home/cisco/router_cli.sh | |||
#!/bin/bash | |||
# 1. Capture the input arguments | |||
CMD="$@" | |||
# 2. If the command starts with "-c ", strip it out completely | |||
if [[ "$CMD" == -c\ * ]]; then | |||
CMD="${CMD#-c }" | |||
fi | |||
# 3. Clean up any accidental wrapping quotes or double quotes | |||
CMD=$(echo "$CMD" | tr -d '"' | tr -d "'") | |||
# 4. Run the evaluation match on the cleaned command string | |||
case "$CMD" in | |||
"show run"|"show running-config"|"show startup-config") | |||
cat /home/cisco/mock_cisco.cfg | |||
exit 0 | |||
;; | |||
"show version") | |||
echo "Cisco IOS Software, Simulation Engine Version 1.0(MOCK)" | |||
exit 0 | |||
;; | |||
"terminal length 0"|"terminal width 0"|"") | |||
# Handle Oxidized setup initializations cleanly | |||
exit 0 | |||
;; | |||
*) | |||
echo "Error: Command '$CMD' not implemented on this mock switch." | |||
exit 1 | |||
;; | |||
esac | |||
</pre> | |||
Kasutamiseks | |||
<pre> | |||
imreoolberg@Imres-MacBook-Air ~ % ssh cisco@192.168.10.193 "show run" | |||
cisco@192.168.10.193's password: | |||
! | |||
hostname mock-edge-sw01 | |||
! | |||
interface GigabitEthernet1/1 | |||
description Uplink to Core | |||
switchport mode trunk | |||
! | |||
interface GigabitEthernet1/2 | |||
description Connected to Zabbix Proxy | |||
switchport access vlan 10 | |||
! | |||
end | |||
imreoolberg@Imres-MacBook-Air ~ % | |||
</pre> | |||
===Kasulikud lisamaterjalid=== | ===Kasulikud lisamaterjalid=== | ||
* TODO | * TODO | ||
Redaktsioon: 3. juuni 2026, kell 10:27
Sissejuhatus
TODO
Mock switch - Linux kasutaja shell script
Mock switch seisneb Linux operatsioonisüsteemi tavalise kasutaja tekitamises, mille shell on asendatud nt sellise skriptiga
root@zabbix-pub-01:~# cat /home/cisco/router_cli.sh
#!/bin/bash
# 1. Capture the input arguments
CMD="$@"
# 2. If the command starts with "-c ", strip it out completely
if [[ "$CMD" == -c\ * ]]; then
CMD="${CMD#-c }"
fi
# 3. Clean up any accidental wrapping quotes or double quotes
CMD=$(echo "$CMD" | tr -d '"' | tr -d "'")
# 4. Run the evaluation match on the cleaned command string
case "$CMD" in
"show run"|"show running-config"|"show startup-config")
cat /home/cisco/mock_cisco.cfg
exit 0
;;
"show version")
echo "Cisco IOS Software, Simulation Engine Version 1.0(MOCK)"
exit 0
;;
"terminal length 0"|"terminal width 0"|"")
# Handle Oxidized setup initializations cleanly
exit 0
;;
*)
echo "Error: Command '$CMD' not implemented on this mock switch."
exit 1
;;
esac
Kasutamiseks
imreoolberg@Imres-MacBook-Air ~ % ssh cisco@192.168.10.193 "show run" cisco@192.168.10.193's password: ! hostname mock-edge-sw01 ! interface GigabitEthernet1/1 description Uplink to Core switchport mode trunk ! interface GigabitEthernet1/2 description Connected to Zabbix Proxy switchport access vlan 10 ! end imreoolberg@Imres-MacBook-Air ~ %
Kasulikud lisamaterjalid
- TODO