Forum Discussion
- Kerry_DeVilbissEmployee
Hey @Roland Banks,
That should be possible - the commands listed there are mostly Groovy methods that have been added on by LogicMonitor, which doesn't necessarily mean we're locking down Groovy capabilities in other ways. If you happen to own the LM Config add-on, there's an example of a Groovy script logging in via FTP and pulling the contents of a file:
import org.apache.commons.net.ftp.FTPClient import org.apache.commons.net.ftp.FTPReply def host = hostProps.get("system.hostname"); def port = hostProps.get("ftp.port") ?: '21'; def user = hostProps.get("ftp.user"); def pass = hostProps.get("ftp.pass"); def client = new FTPClient() client.connect(host, port.toInteger()) // After connection attempt, you should check the reply code to verify // success. def reply = client.getReplyCode(); // Did we get a positive completion reply? if (!FTPReply.isPositiveCompletion(reply)) { // no, disconnect client.disconnect(); println "FTP server refused connection."; return 1; } // Connection looks good, login client.login(user, pass) // Create a BAOS to store the file contents ByteArrayOutputStream baos = new ByteArrayOutputStream() // Retreive the file client.retrieveFile("##WILDVALUE##", baos) // Log out and disconnection from the server client.logout() client.disconnect() // Print the contents of the file from the BAOS. println baos return 0;
Hope that helps!
Cheers,
Kerry
Related Content
- 9 years ago