We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hi,
I'm trying to use the LIBRARY to issue commands on a series of switches, but I don't know Ruby.
I tried several writes like the following one. The script found 27 switches but the command is only executed on the first switch !
#!/usr/bin/env ruby
require 'oxidized/script'
Oxidized::Config.load Oxidized.setup_logger
Oxidized::Script.new(:ostype=>'cisco', :verbose=>true) do |oxs| puts oxs.cmd 'show running-config view full | inc hostname' end
oxidized@ct-oxid:~$ ./ruby1.cmd I, [2024-02-08T18:30:25.407738 #3685] INFO -- : lib/oxidized/nodes.rb: Loading nodes I, [2024-02-08T18:30:25.506940 #3685] INFO -- : lib/oxidized/nodes.rb: Loaded 27 nodes HOST - OXS - show running-config view full | inc hostname hostname BRIO-DCC761
I dont understand which option i can use. In the script.rb, the constructor is defined like that :
# @param [Hash] opts options for Oxidized::Script # @option opts [String] :host @hostname or ip address for Oxidized::Node # @option opts [String] :model node model (ios, junos etc) if defined, nodes are not loaded from source # @option opts [String] :ostype OS Type (ios, junos, etc) # @option opts [Fixnum] :timeout oxidized timeout # @option opts [String] :username username for login # @option opts [String] :passsword password for login # @option opts [String] :enable enable password to use # @option opts [String] :community community to use for discovery # @option opts [String] :protocols protocols to use to connect, default "ssh ,telnet" # @option opts [boolean] :verbose extra output, e.g. show command given in output # @yieldreturn [self] if called in block, returns self and disconnnects session after exiting block # @return [void] def initialize opts, &block @host = opts.delete :host model = opts.delete :model ostype = opts.delete :ostype timeout = opts.delete :timeout username = opts.delete :username password = opts.delete :password enable = opts.delete :enable community = opts.delete :community group = opts.delete :group @verbose = opts.delete :verbose
Any help would be welcome :-)
GE
The text was updated successfully, but these errors were encountered:
Here a workaround script for dummie in ruby like me. It's slow but it works.
source = ".config/oxidized/router.db"
file = File.open(source) file_data = file.readlines.map(&:chomp)
for line in file_data switch = line.split(":") name = switch[0] ip = switch[1] print "Name = #{name}, IP = #{ip}\n"
Oxidized::Script.new(:host=>ip, :verbose=>false) do |oxs| puts oxs.cmd 'show clock' end print"\n\n"
end
file.close
bye
Sorry, something went wrong.
No branches or pull requests
hi,
I'm trying to use the LIBRARY to issue commands on a series of switches, but I don't know Ruby.
I tried several writes like the following one. The script found 27 switches but the command is only executed on the first switch !
#!/usr/bin/env ruby
require 'oxidized/script'
Oxidized::Config.load
Oxidized.setup_logger
Oxidized::Script.new(:ostype=>'cisco', :verbose=>true) do |oxs|
puts oxs.cmd 'show running-config view full | inc hostname'
end
oxidized@ct-oxid:~$ ./ruby1.cmd
I, [2024-02-08T18:30:25.407738 #3685] INFO -- : lib/oxidized/nodes.rb: Loading nodes
I, [2024-02-08T18:30:25.506940 #3685] INFO -- : lib/oxidized/nodes.rb: Loaded 27 nodes
HOST -
OXS - show running-config view full | inc hostname
hostname BRIO-DCC761
I dont understand which option i can use. In the script.rb, the constructor is defined like that :
Any help would be welcome :-)
GE
The text was updated successfully, but these errors were encountered: