# def runcontrolcommand require 'socket' # Change this line... ip = '127.0.0.1' # And this one... port = $rwdcontrolport1 if @a_remoteportinput port = @a_remoteportinput.to_i end # Done! commandtext = @a_remotecommandinput.to_s remotehostnotfound = true client = UDPSocket::new() client.send(commandtext, 0, ip, port) if (commandtext == "stop") begin @socket = UDPSocket::new() @socket.bind(ip, port) # Rescue the "Address in use" error rescue Errno::EADDRINUSE databack, info = client.recv(128) @remotecommandresult = databack @lastremotecommand = "rwdtinker remote:: Port #{port} on host #{ip} ." remotehostnotfound = false # Rescue the "Address not available" error rescue Errno::EADDRNOTAVAIL puts "Network plugin: Address #{host} is not available to bind." # Rescue "permission denied errors rescue Errno::EACCES puts "Network plugin: Access denied when binding interface addresses. Did you try to bind a port under 1024 as a regular user?" # Rescue all other errors rescue puts "Network plugin: An error occured." # Rescue all other errors end if remotehostnotfound @remotecommandresult = "Remote Host not running" end @socket.close end remotehostnotfound = true if (commandtext == "query") begin @socket = UDPSocket::new() @socket.bind(ip, port) # Rescue the "Address in use" error rescue Errno::EADDRINUSE databack, info = client.recv(128) @remotecommandresult = databack @lastremotecommand = "rwdtinker remote: Port #{port} on host #{ip} " remotehostnotfound = false # Rescue the "Address not available' error rescue Errno::EADDRNOTAVAIL puts "Network plugin: Address #{host} is not available to bind." # Rescue "permission denied errors rescue Errno::EACCES puts "Network plugin: Access denied when binding interface addresses. Did you try to bind a port under 1024 as a regular user?" # Rescue all other errors rescue puts "Network plugin: An error occured." # Rescue all other errors end @socket.close end if remotehostnotfound @remotecommandresult = "Remote Host not running" end # Close the socket after use client.close() end def showremoteportoptions @remoteportoptions = $rwdcontrolports.rwd_options @remotecommandoptions = ["query","stop"].rwd_options end