Skip to content

Instantly share code, notes, and snippets.

@jsidhu
jsidhu / gist:a102bf49d256b43d73b4
Created February 15, 2016 06:29
NMAP: find free ips
nmap -v -sn -n 192.168.1.0/24 -oG - | awk '/Status: Down/{print $2}'
When you use the -v option, Nmap will print the addresses it finds as "down" in addition to the ones that are "up".
Instead of -sP, I've substituted the newer spelling -sn, which still accomplishes the same scan, but means "skip the port scan" instead of the misleading "Ping scan" (since the host discovery phase does not necessarily mean an ICMP Echo scan or Ping).
The -n option skips reverse DNS lookups, which buys you a bit of time, since you aren't interested in names but just IP addresses.
The -oG option tells Nmap to output grepable format, which is easier for awk to process. The argument "-" tells it to send this output to stdout.
@jsidhu
jsidhu / gist:4f8b94df1560c4ed0f23
Last active September 16, 2016 00:27
bash tcp port check
timeout 1 bash -c 'cat < /dev/null > /dev/tcp/lmm-kafka-2.ash2.symcpe.net/9092'; echo "Port Check result: $?"
for x in $(cat x); do timeout 2 bash -c 'cat < /dev/null > /dev/tcp/'$x'/22' || echo "No SSH to $x"; done
Access http://hypervisor-ip:8085/Snh_SandeshTraceRequest?x=XmppMessageTrace to see if vrouter-agent sent the VM details to the contrail-dns service, for example:
2016-02-25 17:14:57.079 XmppTxStream: Sent xmpp message to: <CONTROLLER-IP> Port 8093 Size: 452 Packet: <?xml version="1.0"?> <iq type="set" from="<HYPERVISOR>/dns" to="[email protected]/dns-peer" id="10020"> <dns transid="10020"> <update> <virtual-dns>default-domain:project-name-virtual-DNS</virtual-dns> <zone>project-name.local</zone> <entry> <class>1</class> <type>1</type> <name>vm-hostname</name> <data>10.20.22.5</data> <ttl>86400</ttl> <priority>0</priority> </entry> </update> </dns> </iq> $ controller/src/xmpp/xmpp_connection.cc 211
<?xml version="1.0"?>
<iq type="set" from="<HYPERVISOR>/dns" to="[email protected]/dns-peer" id="10020">
<dns transid="10020">
<update>
<virtual-dns>default-domain:project-name-virtual-DNS</virtual-dns>
@jsidhu
jsidhu / gist:78a54197589518fe3b49
Last active March 22, 2016 20:44
OpenContrail - get list of 169 mdata ip addresses and vm names from vrouer introspect
curl -sq http://localhost:8085/Snh_ItfReq? | xmllint --format - |grep "mdata_ip_addr\|vm_name\|<name" |grep -C1 <vmname>
@jsidhu
jsidhu / hubot.ini
Last active March 16, 2016 16:06
Supervisord config to use proxychains with hubot
# can we wired in to deploy/update/restart hubot via RESTFUL interface of supervisord
#
[program:deploy]
stdout_logfile=/var/log/supervisor/deploy-hubot-stdout.log
stderr_logfile=/var/log/supervisor/deploy-hubot-stderr.log
command=/opt/hubot/git_deploy.sh
autostart=false
[program:hubot]
stdout_logfile=/var/log/supervisor/hubot-hubot-stdout.log
@jsidhu
jsidhu / gist:dec92987a10591ec1d01197c1c24930f
Created April 19, 2016 00:53
nova boot vm on a specific compute
nova boot --image <image id> --flavor <flavor id> --availability-zone <az>:<compute> --nic net-id=<network id> <vm name>
@jsidhu
jsidhu / statsd.sh
Created May 19, 2016 17:19
send metric to statsd via netcat
echo "deploys.test.myservice:1|c" | nc -w 1 -u graphite.example.com 8125
@jsidhu
jsidhu / gist:43455f55ee2a651d2540a6b923b342b2
Created June 6, 2016 21:44
linux: run tail for a limited interval
(tail -F named.log & P=$! ; sleep 5; kill -9 $P) | wc -l
@jsidhu
jsidhu / vnc_api_list_vms_example.py
Created June 29, 2016 17:03
vnc api example - list virtual machines
from vnc_api import vnc_api
myVnc = vnc_api.VncApi(api_server_host='127.0.0.1')
vms = myVnc.virtual_machines_list(detail=True, fields=['virtual_machine_interface_back_refs', 'virtual_router_back_ref'])
# See whats in the first object in the list
vms[0].__dict__
@jsidhu
jsidhu / gist:766e4e85193f89c94640495959eb5620
Created July 6, 2016 19:01
Curl post to zabbix api (api_jsonrpc.php)
curl -i -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0","method":"user.login","params":{ "user":"myUserName","password":"myPassword"},"auth":null,"id":0}' https://zabbix-web.symcpe.net/api_jsonrpc.php