Skip to content

Commit cda3c61

Browse files
committed
Updated Git structure
Updated the structure of this git repo.
1 parent f4bbbf0 commit cda3c61

File tree

90 files changed

+39677
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+39677
-0
lines changed

bin/external_lookup.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python
2+
3+
import csv
4+
import sys
5+
import socket
6+
7+
""" An adapter that takes CSV as input, performs a lookup to the operating
8+
system hostname resolution facilities, then returns the CSV results
9+
10+
This is intended as an example of creating external lookups in general.
11+
12+
Note that the script offers mapping both ways, from host to IP and from IP
13+
to host.
14+
15+
Bidrectional mapping is always required when using an external lookup as an
16+
'automatic' lookup: one configured to be used without explicit reference in
17+
a search.
18+
19+
In the other use mode, eg in a search string as "|lookup lookupname", it is
20+
sufficient to provide only the mappings that will be used.
21+
22+
WARNING: DNS is not unambiguously reversible, so this script will produce
23+
unusual results when used for values that do not reverse-resolve to
24+
their original values in your environment.
25+
26+
For example, if your events have host=foo, and you search for
27+
ip=1.2.3.4, the generated search expression may be
28+
host=foo.yourcompany.com, which will not match.
29+
"""
30+
31+
32+
# Given a host, find the ip
33+
def lookup(host):
34+
try:
35+
hostname, aliaslist, ipaddrlist = socket.gethostbyname_ex(host)
36+
return ipaddrlist
37+
except:
38+
return []
39+
40+
# Given an ip, return the host
41+
def rlookup(ip):
42+
try:
43+
hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ip)
44+
return hostname
45+
except:
46+
return ''
47+
48+
def main():
49+
if len(sys.argv) != 3:
50+
print "Usage: python external_lookup.py [host field] [ip field]"
51+
sys.exit(1)
52+
53+
hostfield = sys.argv[1]
54+
ipfield = sys.argv[2]
55+
56+
infile = sys.stdin
57+
outfile = sys.stdout
58+
59+
r = csv.DictReader(infile)
60+
header = r.fieldnames
61+
62+
w = csv.DictWriter(outfile, fieldnames=r.fieldnames)
63+
w.writeheader()
64+
65+
for result in r:
66+
# Perform the lookup or reverse lookup if necessary
67+
if result[hostfield] and result[ipfield]:
68+
# both fields were provided, just pass it along
69+
w.writerow(result)
70+
71+
elif result[hostfield]:
72+
# only host was provided, add ip
73+
ips = lookup(result[hostfield])
74+
for ip in ips:
75+
result[ipfield] = ip
76+
w.writerow(result)
77+
78+
elif result[ipfield]:
79+
# only ip was provided, add host
80+
result[hostfield] = rlookup(result[ipfield])
81+
if result[hostfield]:
82+
w.writerow(result)
83+
84+
main()

bin/isp-tester.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
#
3+
# Script to test the speed of our ISP.
4+
#
5+
# Conversion to Mbps taken from:
6+
# http://www.fir3net.com/General-UNIX/test-bandwith-on-linux.html
7+
#
8+
9+
UBUNTUVER="13.10"
10+
PARAMETER="--progress-bar"
11+
12+
if [ "$1" == "silent" ]; then
13+
PARAMETER="--silent"
14+
else
15+
echo 'To run silently, use parameter "silent".'
16+
fi
17+
18+
echo "Speed downloading Ubuntu ISO from PREGINET"
19+
echo "scale=2; `curl $PARAMETER -w "%{speed_download}" -o /dev/null -r 0-10485760 http://mirror.pregi.net/pub/Linux/ubuntu-iso/$UBUNTUVER/ubuntu-$UBUNTUVER-desktop-amd64.iso` / 131072" | bc | xargs -I {} echo {}Mb\/s
20+
echo ""
21+
echo "--------------------------------------------------"
22+
echo ""
23+
echo "Speed downloading random2500x2500.jpg from Eastern Telecom"
24+
echo "scale=2; `curl $PARAMETER -w "%{speed_download}" -o /dev/null http://speedtest.eastern-tele.com/mini/speedtest/random2500x2500.jpg` / 131072" | bc | xargs -I {} echo {}Mb\/s
25+
echo ""
26+
echo "--------------------------------------------------"
27+
echo ""
28+
echo "Speed downloading random2500x2500.jpg from PLDT"
29+
echo "scale=2; `curl $PARAMETER -w "%{speed_download}" -o /dev/null http://210.213.242.46/speedtest/speedtest/random2500x2500.jpg` / 131072" | bc | xargs -I {} echo {}Mb\/s
30+
echo ""
31+
echo "--------------------------------------------------"
32+
echo ""
33+
echo "Speed downloading random2500x2500.jpg from Globe Telecom"
34+
echo "scale=2; `curl $PARAMETER -w "%{speed_download}" -o /dev/null http://speedtest.globe.com.ph/speedtest/random2500x2500.jpg` / 131072" | bc | xargs -I {} echo {}Mb\/s
35+
echo ""
36+
echo "fin."

bin/namelookup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#from socket import gethostbyaddr
2+
import socket
3+
4+
def nslooky(ip):
5+
try:
6+
output = gethostbyaddr(ip)
7+
return output[0]
8+
except:
9+
output = "not found"
10+
return ".join(output[2])"
11+
12+
your_ip = request.META.get('REMOTE_ADDR')
13+
# above is Django module object
14+
your_name = nslooky(your_ip)

bin/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is where you put any scripts you want to add to this app.

bin/test2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import socket
2+
3+
ip_list = []
4+
ais = socket.getaddrinfo("guard.gridgig.com",0,0,0,0)
5+
for result in ais:
6+
ip_list.append(result[-1][0])
7+
ip_list = list(set(ip_list))

bin/test3.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import dns.resolver
2+
3+
answers = dns.resolver.query('guard.gridgig.com', 'A')
4+
for rdata in answers:
5+
print 'Host', rdata.exchange, 'has preference', rdata.preference

bin/test4.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os, re, subprocess
2+
3+
nslkp_domain = 'guard.gridgig.com'
4+
nslkp_type = 'NS'
5+
nslkp = 'nslookup'
6+
out = subprocess.Popen([nslkp ,'-type='+nslkp_type ,nslkp_domain],stdout=subprocess.PIPE).communicate()[0]
7+
8+
result = out.split("\n")
9+
nslkp_result=[]
10+
for data in result:
11+
if re.search('nameserver', data):
12+
data = data.split(" ")
13+
nslkp_result.append(data[2])
14+
15+
print('Nameservers for domain :', nslkp_domain)
16+
for ns in nslkp_result:
17+
print(ns)

bin/test5.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sys, socket
2+
3+
def getipaddrs(hostname):
4+
result = socket.getaddrinfo(hostname, None, 0, socket.SOCK_STREAM)
5+
return [x[4][0] for x in result]
6+
7+
# the name of the local machine
8+
hostname = socket.gethostname()
9+
10+
try:
11+
print "IP addresses:", ", ".join(getipaddrs(hostname))
12+
except socket.gaierror, e:
13+
print "Couldn't not get IP addresses:", e

bin/test6.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import socket
2+
import sys,splunk.Intersplunk
3+
results = []
4+
5+
try:
6+
host=socket.getfqdn(ip)
7+
print host
8+
except socket.gaierror,err:
9+
print "cannot resolve hostname: ",ip,err

default/app.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[ui]
2+
is_visible = 1
3+
label = home | monitor > 4.2.0
4+
5+
[launcher]
6+
author = Kamilo Amir
7+
description = Home Monitor offers a simple view into your home network traffic based on the syslog data being gathered from your home router.
8+
version = 4.2.0
9+
10+
[install]
11+
is_configured = 0
12+
install_source_checksum = 1e57f4e2d8a646872fd6b00173e79ec501593309
13+
14+
[package]
15+
id = homemonitor
16+
check_for_updates = 1

0 commit comments

Comments
 (0)