Oxidized kasutamine: erinevus redaktsioonide vahel

Allikas: Imre kasutab arvutit
Mine navigeerimisribaleMine otsikasti
Resümee puudub
1. rida: 1. rida:
===Sissejuhatus===
===Sissejuhatus===
TODO
===Tööpõhimõte===


TODO
TODO
18. rida: 22. rida:
#!/bin/bash
#!/bin/bash


# 1. Capture the input arguments
# 1. Print a fake Cisco login welcome and prompt instantly on connection
CMD="$@"
echo "Cisco IOS Software, Simulation Engine Version 1.0(MOCK)"
echo ""
echo -n "mock-edge-sw01#"


# 2. If the command starts with "-c ", strip it out completely
# 2. Enter an infinite loop to read incoming commands interactively
if [[ "$CMD" == -c\ * ]]; then
while true; do
     CMD="${CMD#-c }"
     # Read the next command passed over the terminal stream
fi
    read -r CMD


# 3. Clean up any accidental wrapping quotes or double quotes
    # Clean up trailing carriage returns (\r) sent by network tools
CMD=$(echo "$CMD" | tr -d '"' | tr -d "'")
    CMD=$(echo "$CMD" | tr -d '\r' | tr -d '"' | tr -d "'")


# 4. Run the evaluation match on the cleaned command string
    case "$CMD" in
case "$CMD" in
        "show run"|"show running-config"|"show startup-config")
    "show run"|"show running-config"|"show startup-config")
            cat /home/cisco/mock_cisco.cfg
        cat /home/cisco/mock_cisco.cfg
            ;;
        exit 0
        "show version")
        ;;
            echo "Cisco IOS Software, Simulation Engine Version 1.0(MOCK)"
    "show version")
            ;;
        echo "Cisco IOS Software, Simulation Engine Version 1.0(MOCK)"
        "terminal length 0"|"terminal width 0"|"enable"|"")
        exit 0
            # Return success silently for environment setup instructions
        ;;
            ;;
    "terminal length 0"|"terminal width 0"|"")
        "exit"|"quit")
        # Handle Oxidized setup initializations cleanly
            echo "Closing connection."
        exit 0
            exit 0
        ;;
            ;;
    *)
         *)
        echo "Error: Command '$CMD' not implemented on this mock switch."
            # If Oxidized sends an unhandled cleanup command, absorb it silently
        exit 1
            ;;
         ;;
    esac
esac
 
    # CRITICAL: Print the Cisco prompt back to the stream so Oxidized
    # knows the command finished and it is safe to send the next line!
    echo -n "mock-edge-sw01#"
done
</pre>
</pre>


68. rida: 78. rida:
end
end
imreoolberg@Imres-MacBook-Air ~ %
imreoolberg@Imres-MacBook-Air ~ %
</pre>
===Paigaldamine - Docker===
Docker compose faili näidis
<pre>
# cat docker-compose-oxidized.yml
services:
  oxidized:
    image: oxidized/oxidized:latest
    container_name: oxidized
    restart: unless-stopped
    ports:
      - "8888:8888"    # Web UI and REST API
    volumes:
      - '/srv/oxidized/volume/home/oxidized/.config/oxidized:/home/oxidized/.config/oxidized'
    environment:
      - CONFIG_RELOAD_INTERVAL=600
    networks:
      - oxidized-net
volumes:
  oxidized-output:
networks:
  oxidized-net:
    driver: bridge
</pre>
</pre>



Redaktsioon: 3. juuni 2026, kell 11:25

Sissejuhatus

TODO

Tööpõhimõte

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:~# grep cisco /etc/passwd
cisco:x:1001:1001::/home/cisco:/home/cisco/router_cli.sh

ja

root@zabbix-pub-01:~# cat /home/cisco/router_cli.sh
#!/bin/bash

# 1. Print a fake Cisco login welcome and prompt instantly on connection
echo "Cisco IOS Software, Simulation Engine Version 1.0(MOCK)"
echo ""
echo -n "mock-edge-sw01#"

# 2. Enter an infinite loop to read incoming commands interactively
while true; do
    # Read the next command passed over the terminal stream
    read -r CMD

    # Clean up trailing carriage returns (\r) sent by network tools
    CMD=$(echo "$CMD" | tr -d '\r' | tr -d '"' | tr -d "'")

    case "$CMD" in
        "show run"|"show running-config"|"show startup-config")
            cat /home/cisco/mock_cisco.cfg
            ;;
        "show version")
            echo "Cisco IOS Software, Simulation Engine Version 1.0(MOCK)"
            ;;
        "terminal length 0"|"terminal width 0"|"enable"|"")
            # Return success silently for environment setup instructions
            ;;
        "exit"|"quit")
            echo "Closing connection."
            exit 0
            ;;
        *)
            # If Oxidized sends an unhandled cleanup command, absorb it silently
            ;;
    esac

    # CRITICAL: Print the Cisco prompt back to the stream so Oxidized
    # knows the command finished and it is safe to send the next line!
    echo -n "mock-edge-sw01#"
done

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 ~ %

Paigaldamine - Docker

Docker compose faili näidis

# cat docker-compose-oxidized.yml
services:
  oxidized:
    image: oxidized/oxidized:latest
    container_name: oxidized
    restart: unless-stopped
    ports:
      - "8888:8888"    # Web UI and REST API
    volumes:
      - '/srv/oxidized/volume/home/oxidized/.config/oxidized:/home/oxidized/.config/oxidized'
    environment:
      - CONFIG_RELOAD_INTERVAL=600
    networks:
      - oxidized-net

volumes:
  oxidized-output:

networks:
  oxidized-net:
    driver: bridge

Kasulikud lisamaterjalid

  • TODO