Skip to content

Instantly share code, notes, and snippets.

View michaelrice's full-sized avatar

Michael Rice michaelrice

View GitHub Profile
@michaelrice
michaelrice / gist:4116788
Created November 20, 2012 08:44
vsphere check
#!/usr/bin/env perl
#
# Simple script to run from icinga/nagios to monitor the API
# of a vshpere host.
#
use warnings;
use strict;
BEGIN { $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 }
@michaelrice
michaelrice / jersey-request-builder-example.groovy
Created October 9, 2013 06:24
jersey-request-builder syntax
def payload = new RequestBuilder().get {
ignoreInvalidSSL = true
accept = "application/json"
useBasicAuth = true
basicAuthUserName = grailsApplication.config.niftyApi.user
basicAuthPassword = grailsApplication.config.niftyApi.password
uri = "${grailsApplication.config.niftyApi.url}/action"
}
# first get the disks...
disks = [d for d in vm.config.hardware.device
if isinstance(d, pyVmomi.vim.vm.device.VirtualDisk) and
isinstance(d.backing, pyVmomi.vim.vm.device.VirtualDisk.RawDiskMappingVer1BackingInfo)]
print d.deviceInfo.deviceName
# then later
ss = vm.runtime.host.configManager.storageSystem
@michaelrice
michaelrice / gist:632f92a43828f77514d2
Created May 9, 2014 05:52
fabric success on esxi
errr@ubuntu-12-04-python$ /usr/bin/fab -H 10.12.254.10 hello
[10.12.254.10] Executing task 'hello'
[10.12.254.10] run: vmkping -c 1 -X 10.12.254.1
[10.12.254.10] out: <?xml version="1.0"?><esxcli:output xmlns:esxcli="http://www.vmware.com/Products/ESX/5.0/esxcli/">
[10.12.254.10] out: <esxcli:list type="struct">
[10.12.254.10] out: <esxcli:struct type="VMKPing">
[10.12.254.10] out: <esxcli:field name="Trace">
[10.12.254.10] out: <esxcli:list type="struct">
[10.12.254.10] out: <esxcli:struct type="VMKPingTrace">
[10.12.254.10] out: <esxcli:field name="Recieved Bytes"><esxcli:int>64</esxcli:int></esxcli:field>
@michaelrice
michaelrice / RemoteSCP.groovy
Created May 11, 2014 07:27
example of SCPClient
String runCommandWithOutput(Connection connection) {
log.trace("SCP command to place ${file} on ${host} at ${remotedir}")
output = new StringBuilder()
try {
SCPClient scp = connection.createSCPClient()
scp.put(file, 0, remotedir, "0600")
connection.close()
output.append("File $file should now be copied to $host:$remotedir\n")
}
catch (Exception e) {
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/**
* This program will demonstrate how to use "aes128-cbc".
*
*/
import com.jcraft.jsch.*;
import java.awt.*;
import javax.swing.*;
public class AES{
2014-05-11 23:39:11,599 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - starting ssh process.
2014-05-11 23:39:11,601 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - opened session to host
2014-05-11 23:39:11,607 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - created user info
2014-05-11 23:39:11,608 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - set user info
2014-05-11 23:39:11,689 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - showMessage:
2014-05-11 23:39:11,700 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - prompt: Password:
2014-05-11 23:39:11,700 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - The server is asking us for a password.
2014-05-11 23:39:11,777 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient$MyUserInfo - echo: false
2014-05-11 23:39:11,796 [http-bio-8080-exec-7] TRACE jschssh.SecureJschClient - connected to server.
2014-05-11 23:39:11,797 [http-bio-8080-exec-7] TRACE jschssh.SecureJs
```xml
<?xml version="1.0"?><esxcli:output xmlns:esxcli="http://www.vmware.com/Products/ESX/5.0/esxcli/">
<esxcli:list type="struct">
<esxcli:struct type="VMKPing">
<esxcli:field name="Trace">
<esxcli:list type="struct">
<esxcli:struct type="VMKPingTrace">
<esxcli:field name="Recieved Bytes"><esxcli:int>64</esxcli:int></esxcli:field>
<esxcli:field name="Host"><esxcli:string>10.12.254.1</esxcli:string></esxcli:field>
<esxcli:field name="ICMP Seq"><esxcli:int>0</esxcli:int></esxcli:field>
configure:10660: $PKG_CONFIG --exists --print-errors " xrandr >= 1.4.0 "
Requested 'xrandr >= 1.4.0' but version of Xrandr is 1.3.2
configure:10663: $? = 1
configure:10677: $PKG_CONFIG --exists --print-errors " xrandr >= 1.4.0 "
Requested 'xrandr >= 1.4.0' but version of Xrandr is 1.3.2
configure:10680: $? = 1
configure:10694: result: no
Requested 'xrandr >= 1.4.0' but version of Xrandr is 1.3.2