store mirror user's home directory
This commit is contained in:
parent
df3502e7e5
commit
decba6d28a
|
@ -1,3 +0,0 @@
|
||||||
<!--#include virtual="/include/ubar.txt" -->
|
|
||||||
<!-- The bandwidth bar program is available at:
|
|
||||||
http://www.kernel.org/pub/software/web/bwbar/ -->
|
|
|
@ -1,5 +0,0 @@
|
||||||
<div class="csclogo">
|
|
||||||
<a href="http://mirror.csclub.uwaterloo.ca">
|
|
||||||
<img src="/include/header.png" alt="Computer Science Club Mirror - The University of Waterloo - Funded by MEF" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
|
@ -1,7 +0,0 @@
|
||||||
img {
|
|
||||||
border-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.biglogo {
|
|
||||||
height: 100px;
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
|
@ -1,11 +0,0 @@
|
||||||
*
|
|
||||||
* Welcome to the University of Waterloo Computer Science Club Mirror
|
|
||||||
*
|
|
||||||
* http://csclub.uwaterloo.ca/
|
|
||||||
*
|
|
||||||
* Hardware funded by MEF (http://www.mef.uwaterloo.ca/)
|
|
||||||
*
|
|
||||||
* Admin Contact: systems-committee@csclub.uwaterloo.ca
|
|
||||||
* Hostname: mirror.csclub.uwaterloo.ca
|
|
||||||
* IP Address: 129.97.134.71
|
|
||||||
*
|
|
|
@ -1,2 +0,0 @@
|
||||||
User-agent: *
|
|
||||||
Disallow: /
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 3b8607ff1a97e77c0dc60c8c9b85d1f593527a53
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Non-directories in root
|
||||||
|
export FILES='index.html index.css stats.png'
|
||||||
|
|
||||||
|
# Include trailing slash on all paths
|
||||||
|
HOME=/srv/mirror/
|
||||||
|
export SOURCE='/mirror/root/'
|
||||||
|
export DESTINATION="/mirror/newroot/.cscmirror1/"
|
||||||
|
export LOGS="/var/log/mirror-newroot/"
|
||||||
|
export LOCKS="/tmp/mirror-locks/"
|
||||||
|
|
||||||
|
export RSYNC_FLAGS='-aHAv --quiet --stats --delay-updates --delete-after --partial --delete --numeric-ids --timeout=3600 --exclude .~tmp~/'
|
||||||
|
|
||||||
|
sync_project() {
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo 'Usage:' $0 'project|file' >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# only 1 active sync for this project
|
||||||
|
exec 9>"${LOCKS}$1.lck"
|
||||||
|
flock -n 9 || return 0
|
||||||
|
|
||||||
|
# delay a random time (<= 5 mins)
|
||||||
|
# that way all projects don't sync at once
|
||||||
|
#sleep $((RANDOM%300))
|
||||||
|
|
||||||
|
if [[ $FILES == *"$1"* ]]; then
|
||||||
|
nice rsync $RSYNC_FLAGS --log-file="${LOGS}$1.log" "${SOURCE}$1" "${DESTINATION}" >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
nice rsync $RSYNC_FLAGS --log-file="${LOGS}$1.log" "${SOURCE}$1/" "${DESTINATION}$1/" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
export -f sync_project
|
||||||
|
|
||||||
|
if [ ! -d "${LOGS}" ]; then
|
||||||
|
mkdir -p "${LOGS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "${LOCKS}" ]; then
|
||||||
|
mkdir -p "${LOCKS}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rsync --list-only "${SOURCE}" | grep -v '^[\*\.]' | awk '{print $5}' | grep '^[a-zA-Z0-9]' | parallel --no-notice --jobs 8 sync_project
|
|
@ -1,119 +0,0 @@
|
||||||
#!/usr/bin/python2.5
|
|
||||||
import sys, os, re, gzip, bz2, hashlib
|
|
||||||
|
|
||||||
package_file_map = {
|
|
||||||
'Packages' : file,
|
|
||||||
'Packages.gz' : gzip.GzipFile,
|
|
||||||
'Packages.bz2' : bz2.BZ2File,
|
|
||||||
'Sources' : file,
|
|
||||||
'Sources.gz' : gzip.GzipFile,
|
|
||||||
'Sources.bz2' : bz2.BZ2File,
|
|
||||||
}
|
|
||||||
|
|
||||||
def parse_packages_file(path):
|
|
||||||
try:
|
|
||||||
open_func = package_file_map[os.path.basename(path)]
|
|
||||||
file = open_func(path)
|
|
||||||
except IOError, e:
|
|
||||||
print "WARNING: failed to open %s: %s" % (path, e)
|
|
||||||
return {}
|
|
||||||
cur_dict = {}
|
|
||||||
key, value = None, ''
|
|
||||||
ret_list = []
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
line = file.readline()
|
|
||||||
except IOError, e:
|
|
||||||
print "WARNING: failed to read %s: %s" % (path, e)
|
|
||||||
print "WARNING: %s" % e
|
|
||||||
return {}
|
|
||||||
|
|
||||||
# check if we are done with current value
|
|
||||||
if (line == '' or line[0] == '\n' or line[0] != ' ') and key != None:
|
|
||||||
cur_dict[key] = value
|
|
||||||
|
|
||||||
if line == '' or line == '\n': # done current block
|
|
||||||
if cur_dict != {}:
|
|
||||||
ret_list.append(cur_dict)
|
|
||||||
cur_dict = {}
|
|
||||||
key = None
|
|
||||||
if line == '': break
|
|
||||||
elif line[0] == ' ': # multi-line value
|
|
||||||
value += '\n' + line[1:-1]
|
|
||||||
else:
|
|
||||||
if line[-1] == '\n': line = line[:-1]
|
|
||||||
pos = line.find(':')
|
|
||||||
key = line[:pos]
|
|
||||||
if key == '': key = None
|
|
||||||
value = line[pos+2:]
|
|
||||||
return ret_list
|
|
||||||
|
|
||||||
def find_packages_files(path):
|
|
||||||
files = []
|
|
||||||
for file in os.listdir(path):
|
|
||||||
file_path = "%s/%s" % (path, file)
|
|
||||||
if os.path.islink(file_path):
|
|
||||||
continue
|
|
||||||
elif os.path.isdir(file_path):
|
|
||||||
files += find_packages_files(file_path)
|
|
||||||
elif file in package_file_map:
|
|
||||||
files.append(file_path)
|
|
||||||
return files
|
|
||||||
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
print "Usage: debian-check-md5sum.py base-dir"
|
|
||||||
sys.exit(1)
|
|
||||||
base_dir = sys.argv[1]
|
|
||||||
|
|
||||||
all = {}
|
|
||||||
files_regex = re.compile('(\S+)\s+(\S+)\s+(\S+)')
|
|
||||||
for file in find_packages_files(base_dir):
|
|
||||||
file_type = os.path.basename(file).split('.')[0]
|
|
||||||
a = parse_packages_file(file)
|
|
||||||
for package in parse_packages_file(file):
|
|
||||||
if file_type == 'Packages':
|
|
||||||
if 'Filename' in package:
|
|
||||||
all[package['Filename']] = package
|
|
||||||
elif file_type == 'Sources':
|
|
||||||
files = package['Files'].split('\n')
|
|
||||||
for file in files:
|
|
||||||
if file == '': continue
|
|
||||||
match = files_regex.match(file)
|
|
||||||
file_path = '%s/%s' % (package['Directory'], match.group(3))
|
|
||||||
all[file_path] = { 'MD5sum' : match.group(1) }
|
|
||||||
print "NOTICE: need to check %d files" % len(all)
|
|
||||||
|
|
||||||
ret_val = 0
|
|
||||||
block_size = 65536
|
|
||||||
for (file, package) in all.iteritems():
|
|
||||||
path = '%s/%s' % (base_dir, file)
|
|
||||||
try:
|
|
||||||
file = open(path, 'rb')
|
|
||||||
except IOError:
|
|
||||||
print "WARNING: missing %s" % path
|
|
||||||
continue
|
|
||||||
if 'SHA256' in package:
|
|
||||||
md = hashlib.sha256()
|
|
||||||
hash = package['SHA256']
|
|
||||||
elif 'SHA1' in package:
|
|
||||||
md = hashlib.sha1()
|
|
||||||
hash = package['SHA1']
|
|
||||||
elif 'MD5sum' in package:
|
|
||||||
md = hashlib.md5()
|
|
||||||
hash = package['MD5sum']
|
|
||||||
else:
|
|
||||||
print "WARNING: no hash found for %s" % path
|
|
||||||
print package
|
|
||||||
exit(1)
|
|
||||||
while True:
|
|
||||||
data = file.read(block_size)
|
|
||||||
if data == '': break
|
|
||||||
md.update(data)
|
|
||||||
hash_calc = md.hexdigest()
|
|
||||||
if hash == hash_calc:
|
|
||||||
print "NOTICE: hash ok for %s [hash = %s]" % (path, hash)
|
|
||||||
else:
|
|
||||||
print "ERROR: hash mismatch for %s [hash = %s, hash_calc = %s]" % \
|
|
||||||
(path, hash, hash_calc)
|
|
||||||
ret_val = 1
|
|
||||||
exit(ret_val)
|
|
|
@ -1,22 +0,0 @@
|
||||||
# /etc/cron.d/csc-mirror: mirror cron jobs
|
|
||||||
|
|
||||||
# m h dom mon dow user command
|
|
||||||
|
|
||||||
# update orion routes
|
|
||||||
30 5 * * * root /usr/local/sbin/update-orion-routes
|
|
||||||
|
|
||||||
# make torrents
|
|
||||||
*/10 * * * * mirror /home/mirror/bin/make-torrents > /dev/null 2> /dev/null
|
|
||||||
|
|
||||||
# The rsync cron jobs are now run by a small script a2brenna wrote
|
|
||||||
# that works a bit more intelligently than cron. For one thing, it
|
|
||||||
# won't kick off a sync when one's already running. Please see
|
|
||||||
# ~mirror/merlin.
|
|
||||||
# -- mspang
|
|
||||||
|
|
||||||
# regenerate mirror index at 5:40 am on 14th & 28th of every month
|
|
||||||
# feel free to run this manually if you've added or removed an
|
|
||||||
# archive or some such thing
|
|
||||||
#
|
|
||||||
# Documented here: http://wiki.csclub.uwaterloo.ca/Mirror#Index
|
|
||||||
40 5 */14 * * mirror cd /home/mirror/mirror-index && /home/mirror/mirror-index/make-index.py
|
|
|
@ -1,48 +0,0 @@
|
||||||
# This file describes the network interfaces available on your system
|
|
||||||
# and how to activate them. For more information, see interfaces(5).
|
|
||||||
|
|
||||||
# The loopback network interface
|
|
||||||
auto lo
|
|
||||||
iface lo inet loopback
|
|
||||||
|
|
||||||
# The routes added here will not be visible to the 'route' command; you
|
|
||||||
# should use 'ip route show table foo' instead.
|
|
||||||
|
|
||||||
auto eth0
|
|
||||||
iface eth0 inet static
|
|
||||||
address 129.97.134.42
|
|
||||||
netmask 255.255.255.0
|
|
||||||
gateway 129.97.134.1
|
|
||||||
|
|
||||||
# campus routes are checked first and are maintained here
|
|
||||||
up ip rule add from all lookup campus prio 1
|
|
||||||
down ip rule del from all lookup campus prio 1
|
|
||||||
up ip route add 129.97.0.0/16 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
down ip route del 129.97.0.0/16 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
up ip route add 10.0.0.0/8 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
down ip route del 10.0.0.0/8 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
up ip route add 172.16.0.0/20 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
down ip route del 172.16.0.0/20 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
up ip route add 192.168.0.0/16 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
down ip route del 192.168.0.0/16 via 129.97.134.1 dev eth0 table campus realm campus
|
|
||||||
|
|
||||||
# orion routes are checked second and are maintained by a cronjob
|
|
||||||
up ip rule add from all lookup orion prio 2
|
|
||||||
down ip rule del from all lookup orion prio 2
|
|
||||||
|
|
||||||
# Traffic shaping - 100M cogent, 200M orion, 700M campus.
|
|
||||||
# Note that the border router is configured with a similar policy, but will
|
|
||||||
# drop rather than queue excess packets. These rules keep them from dropping.
|
|
||||||
up tc qdisc add dev eth0 parent root handle 1: htb default 2 r2q 10000
|
|
||||||
up tc class add dev eth0 parent 1: classid 1:1 htb rate 1000Mbit
|
|
||||||
up tc class add dev eth0 parent 1:1 classid 1:2 htb rate 100Mbit
|
|
||||||
up tc class add dev eth0 parent 1:1 classid 1:3 htb rate 200Mbit
|
|
||||||
up tc class add dev eth0 parent 1:1 classid 1:4 htb rate 700Mbit ceil 1000Mbit
|
|
||||||
up tc filter add dev eth0 parent 1: protocol ip pref 2 route to orion flowid 1:3
|
|
||||||
up tc filter add dev eth0 parent 1: protocol ip pref 1 route to campus flowid 1:4
|
|
||||||
down tc qdisc del dev eth0 parent root
|
|
||||||
|
|
||||||
auto eth0:mirror
|
|
||||||
iface eth0:mirror inet static
|
|
||||||
address 129.97.134.71
|
|
||||||
netmask 255.255.255.0
|
|
|
@ -1,186 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
# This file updates the orion routing table.
|
|
||||||
# Put it at /usr/local/sbin/orionroutes.py
|
|
||||||
|
|
||||||
# Configuration
|
|
||||||
ORION_TABLE = 1 # from /etc/iproute2/rt_tables
|
|
||||||
ORION_REALMS = 1 # from /etc/iproute2/rt_realms
|
|
||||||
ORION_VIAS = [ "66.97.23.33", "66.97.28.65", "129.97.1.46" ]
|
|
||||||
ORION_GW = "129.97.134.1"
|
|
||||||
ORION_SRC = "129.97.134.42"
|
|
||||||
ORION_IFACE = "eth0"
|
|
||||||
|
|
||||||
# Don't touch anything beyond here
|
|
||||||
|
|
||||||
import sys, iplib, SubnetTree
|
|
||||||
from ctypes import *
|
|
||||||
|
|
||||||
NETLINK_ROUTE = 0
|
|
||||||
AF_UNSPEC = 0
|
|
||||||
RT_SCOPE_UNIVERSE = 0
|
|
||||||
RTPROT_STATIC = 4
|
|
||||||
NLM_F_REPLACE = 0x100
|
|
||||||
|
|
||||||
def die(msg):
|
|
||||||
sys.stderr.write("orionroutes.py: %s\n" % msg)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
try:
|
|
||||||
libnl = cdll.LoadLibrary("libnl.so.1")
|
|
||||||
nl_geterror = CFUNCTYPE(c_char_p) (("nl_geterror", libnl), None)
|
|
||||||
nl_handle_alloc = CFUNCTYPE(c_void_p) (("nl_handle_alloc", libnl), None)
|
|
||||||
nl_connect = CFUNCTYPE(c_int, c_void_p, c_int) \
|
|
||||||
(("nl_connect", libnl), ((1, "handle", None), (1, "type", NETLINK_ROUTE)))
|
|
||||||
rtnl_route_alloc = CFUNCTYPE(c_void_p) (("rtnl_route_alloc", libnl), None)
|
|
||||||
rtnl_link_alloc_cache = CFUNCTYPE(c_void_p, c_void_p) \
|
|
||||||
(("rtnl_link_alloc_cache", libnl), ((1, "handle", None), ))
|
|
||||||
rtnl_link_name2i = CFUNCTYPE(c_int, c_void_p, c_char_p) \
|
|
||||||
(("rtnl_link_name2i", libnl), ((1, "cache", None), (1, "iface", -1)))
|
|
||||||
rtnl_route_set_oif = CFUNCTYPE(c_void_p, c_void_p, c_int) \
|
|
||||||
(("rtnl_route_set_oif", libnl), ((1, "route", None), (1, "iface", -1)))
|
|
||||||
nl_cache_free = CFUNCTYPE(None, c_void_p) \
|
|
||||||
(("nl_cache_free", libnl), ((1, "cache", None), ))
|
|
||||||
nl_addr_parse = CFUNCTYPE(c_void_p, c_char_p, c_int) \
|
|
||||||
(("nl_addr_parse", libnl), ((1, "dst", None), (1, "family", AF_UNSPEC)))
|
|
||||||
rtnl_route_set_dst = CFUNCTYPE(c_int, c_void_p, c_void_p) \
|
|
||||||
(("rtnl_route_set_dst", libnl), ((1, "route", None), (1, "dst", None)))
|
|
||||||
rtnl_route_set_pref_src = CFUNCTYPE(c_int, c_void_p, c_void_p) \
|
|
||||||
(("rtnl_route_set_pref_src", libnl), ((1, "route", None), (1, "src", None)))
|
|
||||||
nl_addr_put = CFUNCTYPE(None, c_void_p) \
|
|
||||||
(("nl_addr_put", libnl), ((1, "addr", None), ))
|
|
||||||
rtnl_route_set_gateway = CFUNCTYPE(c_int, c_void_p, c_void_p) \
|
|
||||||
(("rtnl_route_set_gateway", libnl), ((1, "route", None), (1, "gw", None)))
|
|
||||||
rtnl_route_set_table = CFUNCTYPE(None, c_void_p, c_int) \
|
|
||||||
(("rtnl_route_set_table", libnl), ((1, "route", None), (1, "table", -1)))
|
|
||||||
rtnl_route_set_scope = CFUNCTYPE(None, c_void_p, c_int) \
|
|
||||||
(("rtnl_route_set_scope", libnl), ((1, "route", None), (1, "scope", -1)))
|
|
||||||
rtnl_route_set_protocol = CFUNCTYPE(None, c_void_p, c_int) \
|
|
||||||
(("rtnl_route_set_protocol", libnl), ((1, "route", None), (1, "proto", -1)))
|
|
||||||
rtnl_route_set_realms = CFUNCTYPE(None, c_void_p, c_int) \
|
|
||||||
(("rtnl_route_set_realms", libnl), ((1, "route", None), (1, "realms", -1)))
|
|
||||||
rtnl_route_add = CFUNCTYPE(c_int, c_void_p, c_void_p, c_int) \
|
|
||||||
(("rtnl_route_add", libnl), ((1, "handle", None), (1, "route", None), (1, "flags", 0)))
|
|
||||||
rtnl_route_put = CFUNCTYPE(None, c_void_p) \
|
|
||||||
(("rtnl_route_put", libnl), ((1, "route", None), ))
|
|
||||||
nl_handle_destroy = CFUNCTYPE(None, c_void_p) \
|
|
||||||
(("nl_handle_destroy", libnl), ((1, "handle", None), ))
|
|
||||||
rtnl_route_alloc_cache = CFUNCTYPE(c_void_p, c_void_p) \
|
|
||||||
(("rtnl_route_alloc_cache", libnl), ((1, "handle", None), ))
|
|
||||||
nl_cache_get_first = CFUNCTYPE(c_void_p, c_void_p) \
|
|
||||||
(("nl_cache_get_first", libnl), ((1, "cache", None), ))
|
|
||||||
rtnl_route_get_table = CFUNCTYPE(c_int, c_void_p) \
|
|
||||||
(("rtnl_route_get_table", libnl), ((1, "route", None), ))
|
|
||||||
rtnl_route_get_dst = CFUNCTYPE(c_void_p, c_void_p) \
|
|
||||||
(("rtnl_route_get_dst", libnl), ((1, "route", None), ))
|
|
||||||
nl_addr2str = CFUNCTYPE(c_char_p, c_void_p, c_char_p, c_int) \
|
|
||||||
(("nl_addr2str", libnl), ((1, "addr", None), (1, "buffer", None), (1, "size", 0)))
|
|
||||||
rtnl_route_del = CFUNCTYPE(c_int, c_void_p, c_void_p, c_int) \
|
|
||||||
(("rtnl_route_del", libnl), ((1, "handle", None), (1, "route", None), (1, "flags", 0)))
|
|
||||||
nl_cache_get_next = CFUNCTYPE(c_void_p, c_void_p) \
|
|
||||||
(("nl_cache_get_next", libnl), ((1, "object", None), ))
|
|
||||||
except Exception,e:
|
|
||||||
die("Failed to load libnl: %s" % e)
|
|
||||||
|
|
||||||
def nl_die(func):
|
|
||||||
die("%s: %s" % (func, nl_geterror()))
|
|
||||||
|
|
||||||
ips = [[] for i in range(33)]
|
|
||||||
for line in sys.stdin:
|
|
||||||
try:
|
|
||||||
ip, mask, via = line.strip().split(',')[0:3]
|
|
||||||
except KeyError, ValueError:
|
|
||||||
die("Malformed line: %s" % line.strip())
|
|
||||||
|
|
||||||
if via not in ORION_VIAS:
|
|
||||||
continue
|
|
||||||
bits = int(iplib.IPv4NetMask(mask).get_bits())
|
|
||||||
ips[bits].append(int(iplib.IPv4Address(ip)))
|
|
||||||
|
|
||||||
count = sum([len(ip_list) for ip_list in ips])
|
|
||||||
if count < 10:
|
|
||||||
die("Not enough routes (got %d)" % count)
|
|
||||||
|
|
||||||
cidrs = []
|
|
||||||
for bits in range(32, 1, -1):
|
|
||||||
ips[bits].sort()
|
|
||||||
last_ip = 0
|
|
||||||
for ip in ips[bits]:
|
|
||||||
if ip != last_ip and (ip ^ last_ip) == (1 << (32 - bits)):
|
|
||||||
ips[bits - 1].append(ip & (((1 << (bits - 1)) - 1) << (32 - (bits - 1))))
|
|
||||||
last_ip = 0
|
|
||||||
elif last_ip != 0:
|
|
||||||
cidrs.append((iplib.IPv4Address(last_ip), bits))
|
|
||||||
last_ip = ip
|
|
||||||
if last_ip != 0:
|
|
||||||
cidrs.append((iplib.IPv4Address(last_ip), bits))
|
|
||||||
|
|
||||||
nlh = nl_handle_alloc()
|
|
||||||
if nlh == None: nl_die("nl_handle_alloc")
|
|
||||||
if nl_connect(nlh, NETLINK_ROUTE) < 0: nl_die("nl_connect")
|
|
||||||
|
|
||||||
link_cache = rtnl_link_alloc_cache(nlh)
|
|
||||||
if link_cache == None: nl_die("rtnl_link_alloc")
|
|
||||||
iface = rtnl_link_name2i(link_cache, ORION_IFACE)
|
|
||||||
if iface < 0: nl_die("rtnl_link_name2i")
|
|
||||||
nl_cache_free(link_cache)
|
|
||||||
|
|
||||||
cidrs.sort(lambda (ip1, bits1), (ip2, bits2): cmp(ip1, ip2) if bits1 == bits2 else (bits1 - bits2))
|
|
||||||
tree = SubnetTree.SubnetTree()
|
|
||||||
for (ip, bits) in cidrs:
|
|
||||||
if str(ip) not in tree:
|
|
||||||
cidr = "%s/%s" % (ip, bits)
|
|
||||||
tree[cidr] = None
|
|
||||||
|
|
||||||
route = rtnl_route_alloc()
|
|
||||||
if route == None: nl_die("rtnl_route_alloc")
|
|
||||||
|
|
||||||
dstaddr = nl_addr_parse(cidr, AF_UNSPEC)
|
|
||||||
if dstaddr == None: nl_die("nl_addr_parse(%s)" % cidr)
|
|
||||||
if rtnl_route_set_dst(route, dstaddr) < 0: nl_die("rtnl_route_set_dst")
|
|
||||||
nl_addr_put(dstaddr)
|
|
||||||
|
|
||||||
srcaddr = nl_addr_parse(ORION_SRC, AF_UNSPEC)
|
|
||||||
if srcaddr == None: nl_die("nl_addr_parse(%s)" % ORION_SRC)
|
|
||||||
if rtnl_route_set_pref_src(route, srcaddr) < 0: nl_die("nl_route_set_pref_src")
|
|
||||||
nl_addr_put(srcaddr)
|
|
||||||
|
|
||||||
gwaddr = nl_addr_parse(ORION_GW, AF_UNSPEC)
|
|
||||||
if gwaddr == None: nl_die("nl_addr_parse(%s)" % ORION_GW)
|
|
||||||
if rtnl_route_set_gateway(route, gwaddr) < 0: nl_die("nl_route_set_gateway")
|
|
||||||
nl_addr_put(gwaddr)
|
|
||||||
|
|
||||||
rtnl_route_set_oif(route, iface)
|
|
||||||
rtnl_route_set_table(route, ORION_TABLE)
|
|
||||||
rtnl_route_set_scope(route, RT_SCOPE_UNIVERSE)
|
|
||||||
rtnl_route_set_protocol(route, RTPROT_STATIC)
|
|
||||||
rtnl_route_set_realms(route, ORION_REALMS)
|
|
||||||
|
|
||||||
if rtnl_route_add(nlh, route, NLM_F_REPLACE) < 0: nl_die("rtnl_route_add(dst=%s)" % cidr)
|
|
||||||
rtnl_route_put(route)
|
|
||||||
|
|
||||||
route_cache = rtnl_route_alloc_cache(nlh)
|
|
||||||
if route_cache == None: nl_die("rtnl_route_alloc_cache")
|
|
||||||
dstaddr_s = create_string_buffer(100)
|
|
||||||
|
|
||||||
route = nl_cache_get_first(route_cache)
|
|
||||||
while route != None:
|
|
||||||
table = rtnl_route_get_table(route)
|
|
||||||
if table != ORION_TABLE:
|
|
||||||
route = nl_cache_get_next(route)
|
|
||||||
continue
|
|
||||||
|
|
||||||
dstaddr = rtnl_route_get_dst(route)
|
|
||||||
if dstaddr == None:
|
|
||||||
continue
|
|
||||||
if nl_addr2str(dstaddr, dstaddr_s, sizeof(dstaddr_s)) == None: nl_die("nl_addr2str")
|
|
||||||
dstaddr = str(repr(dstaddr_s.value)).strip('\'').split('/')[0]
|
|
||||||
|
|
||||||
if dstaddr not in tree:
|
|
||||||
rtnl_route_del(nlh, route, 0)
|
|
||||||
|
|
||||||
route = nl_cache_get_next(route)
|
|
||||||
|
|
||||||
nl_cache_free(route_cache)
|
|
||||||
|
|
||||||
nl_handle_destroy(nlh)
|
|
|
@ -1,11 +0,0 @@
|
||||||
# This file lives at /etc/iproute2/rt_realms
|
|
||||||
|
|
||||||
#
|
|
||||||
# reserved values
|
|
||||||
#
|
|
||||||
0 cosmos
|
|
||||||
#
|
|
||||||
# local
|
|
||||||
#
|
|
||||||
1 orion
|
|
||||||
2 campus
|
|
|
@ -1,14 +0,0 @@
|
||||||
# This file lives at /etc/iproute2/rt_tables
|
|
||||||
|
|
||||||
#
|
|
||||||
# reserved values
|
|
||||||
#
|
|
||||||
255 local
|
|
||||||
254 main
|
|
||||||
253 default
|
|
||||||
0 unspec
|
|
||||||
#
|
|
||||||
# local
|
|
||||||
#
|
|
||||||
1 orion
|
|
||||||
2 campus
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This file updates the orion routing table.
|
|
||||||
# Put it at /usr/local/sbin/update-orion-routes.
|
|
||||||
|
|
||||||
wget --quiet -O - https://istns.uwaterloo.ca/borderroutes/borderroutes.txt | /usr/local/sbin/orionroutes.py
|
|
|
@ -1,102 +0,0 @@
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <netlink/route/class.h>
|
|
||||||
#include <netlink/route/link.h>
|
|
||||||
#include <netlink/cache-api.h>
|
|
||||||
#include <netlink/object.h>
|
|
||||||
#include "mirror-nl-glue.h"
|
|
||||||
|
|
||||||
static struct nl_cache *link_cache, *class_cache;
|
|
||||||
static struct rtnl_link *eth;
|
|
||||||
static int ifindex;
|
|
||||||
|
|
||||||
struct class_info cogent_class = { "cogent", "01:02", };
|
|
||||||
struct class_info orion_class = { "orion", "01:03", };
|
|
||||||
struct class_info campus_class = { "campus", "01:04", };
|
|
||||||
|
|
||||||
static struct nl_handle *nl_handle;
|
|
||||||
|
|
||||||
void die(const char *message) {
|
|
||||||
fprintf(stderr, "fatal: %s\n", message);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void match_obj(struct nl_object *obj, void *arg) {
|
|
||||||
struct nl_object *needle = *(struct nl_object **)arg;
|
|
||||||
struct nl_object **ret = (struct nl_object **)arg + 1;
|
|
||||||
|
|
||||||
if (!*ret && nl_object_identical(obj, needle)) {
|
|
||||||
nl_object_get(obj);
|
|
||||||
*ret = obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct rtnl_class *get_class_by_id(char *id, int ifindex) {
|
|
||||||
uint32_t handle;
|
|
||||||
struct rtnl_class *needle;
|
|
||||||
struct nl_object *magic[2];
|
|
||||||
|
|
||||||
if (rtnl_tc_str2handle(id, &handle))
|
|
||||||
die("invalid id");
|
|
||||||
|
|
||||||
needle = rtnl_class_alloc();
|
|
||||||
rtnl_class_set_ifindex(needle, ifindex);
|
|
||||||
rtnl_class_set_handle(needle, handle);
|
|
||||||
|
|
||||||
magic[0] = (struct nl_object *)needle;
|
|
||||||
magic[1] = (struct nl_object *)NULL;
|
|
||||||
|
|
||||||
nl_cache_foreach(class_cache, match_obj, magic);
|
|
||||||
|
|
||||||
rtnl_class_put(needle);
|
|
||||||
return (struct rtnl_class *)magic[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t get_class_byte_count(struct class_info *info) {
|
|
||||||
struct rtnl_class *class = get_class_by_id(info->id, ifindex);
|
|
||||||
uint64_t bytes;
|
|
||||||
if (!class)
|
|
||||||
die("class not found");
|
|
||||||
bytes = rtnl_class_get_stat(class, RTNL_TC_BYTES);
|
|
||||||
rtnl_class_put(class);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mirror_stats_refresh(void) {
|
|
||||||
nl_cache_refill(nl_handle, class_cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mirror_stats_initialize(void) {
|
|
||||||
nl_handle = nl_handle_alloc();
|
|
||||||
if (!nl_handle)
|
|
||||||
die("unable to allocate handle");
|
|
||||||
|
|
||||||
if (nl_connect(nl_handle, NETLINK_ROUTE) < 0)
|
|
||||||
die("unable to connect to netlink");
|
|
||||||
|
|
||||||
link_cache = rtnl_link_alloc_cache(nl_handle);
|
|
||||||
if (!link_cache)
|
|
||||||
die("unable to allocate link cache");
|
|
||||||
|
|
||||||
eth = rtnl_link_get_by_name(link_cache, "eth0");
|
|
||||||
if (!eth)
|
|
||||||
die("unable to acquire eth0");
|
|
||||||
ifindex = rtnl_link_get_ifindex(eth);
|
|
||||||
|
|
||||||
class_cache = rtnl_class_alloc_cache(nl_handle, ifindex);
|
|
||||||
if (!class_cache)
|
|
||||||
die("unable to allocate class cache");
|
|
||||||
}
|
|
||||||
|
|
||||||
void mirror_stats_cleanup(void) {
|
|
||||||
rtnl_link_put(eth);
|
|
||||||
nl_cache_free(class_cache);
|
|
||||||
nl_cache_free(link_cache);
|
|
||||||
nl_close(nl_handle);
|
|
||||||
nl_handle_destroy(nl_handle);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <netlink/route/class.h>
|
|
||||||
#include <netlink/route/link.h>
|
|
||||||
#include <netlink/cache-api.h>
|
|
||||||
#include <netlink/object.h>
|
|
||||||
|
|
||||||
struct class_info {
|
|
||||||
char *name;
|
|
||||||
char *id;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct class_info cogent_class;
|
|
||||||
extern struct class_info orion_class;
|
|
||||||
extern struct class_info campus_class;
|
|
||||||
|
|
||||||
void mirror_stats_refresh(void);
|
|
||||||
void mirror_stats_initialize(void);
|
|
||||||
void mirror_stats_cleanup(void);
|
|
||||||
void die(const char *);
|
|
||||||
uint64_t get_class_byte_count(struct class_info *);
|
|
|
@ -1,40 +0,0 @@
|
||||||
#include "mirror-nl-glue.h"
|
|
||||||
#include <rrd.h>
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
char *argv[3];
|
|
||||||
unsigned long packet_count;
|
|
||||||
|
|
||||||
switch(fork()) {
|
|
||||||
case -1:
|
|
||||||
return -1;
|
|
||||||
case 0:
|
|
||||||
close(0);
|
|
||||||
close(1);
|
|
||||||
setsid();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
mirror_stats_initialize();
|
|
||||||
argv[0] = malloc(1024);
|
|
||||||
for (;;) {
|
|
||||||
packet_count = get_class_byte_count(&cogent_class);
|
|
||||||
snprintf(argv[0], 1024, "N:%lu", packet_count);
|
|
||||||
rrd_update_r("/var/rrdtool/cogent.rrd", NULL, 1, argv);
|
|
||||||
packet_count = get_class_byte_count(&orion_class);
|
|
||||||
snprintf(argv[0], 1024, "N:%lu", packet_count);
|
|
||||||
rrd_update_r("/var/rrdtool/orion.rrd", NULL, 1, argv);
|
|
||||||
packet_count = get_class_byte_count(&campus_class);
|
|
||||||
snprintf(argv[0], 1024, "N:%lu", packet_count);
|
|
||||||
rrd_update_r("/var/rrdtool/campus.rrd", NULL, 1, argv);
|
|
||||||
if (rrd_test_error()) {
|
|
||||||
fprintf(stderr, "ERROR: %s\n", rrd_get_error());
|
|
||||||
rrd_clear_error();
|
|
||||||
}
|
|
||||||
sleep(5);
|
|
||||||
mirror_stats_refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
/usr/bin/rrdtool graph /mirror/root/stats_monthly.png \
|
|
||||||
-s -1m \
|
|
||||||
--imgformat=PNG \
|
|
||||||
--title='Mirror Traffic' \
|
|
||||||
--base=1000 \
|
|
||||||
--height=120 \
|
|
||||||
--width=600 \
|
|
||||||
--alt-autoscale-max \
|
|
||||||
--lower-limit=0 \
|
|
||||||
--vertical-label='bits per second' \
|
|
||||||
--slope-mode \
|
|
||||||
--font TITLE:10: \
|
|
||||||
--font AXIS:8: \
|
|
||||||
--font LEGEND:8: \
|
|
||||||
--font UNIT:8: \
|
|
||||||
DEF:a="/var/rrdtool/cogent.rrd":snmp_oid:AVERAGE \
|
|
||||||
DEF:b="/var/rrdtool/orion.rrd":snmp_oid:AVERAGE \
|
|
||||||
DEF:c="/var/rrdtool/campus.rrd":snmp_oid:AVERAGE \
|
|
||||||
CDEF:cdefa=a,8,* \
|
|
||||||
CDEF:cdefe=b,8,* \
|
|
||||||
CDEF:cdefi=c,8,* \
|
|
||||||
CDEF:cdefbc=TIME,1318318854,GT,a,a,UN,0,a,IF,IF,TIME,1318318854,GT,b,b,UN,0,b,IF,IF,TIME,1318318854,GT,c,c,UN,0,c,IF,IF,+,+,8,* \
|
|
||||||
AREA:cdefa#157419FF:"Cogent" \
|
|
||||||
GPRINT:cdefa:LAST:"Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefa:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
AREA:cdefe#00CF00FF:"Orion":STACK \
|
|
||||||
GPRINT:cdefe:LAST:" Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefe:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefe:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
AREA:cdefi#EE5019FF:"Campus":STACK \
|
|
||||||
GPRINT:cdefi:LAST:"Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefi:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefi:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
LINE1:cdefbc#000000FF:"Total" \
|
|
||||||
GPRINT:cdefbc:LAST:" Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefbc:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefbc:MAX:"Maximum\:%8.2lf%s\n" >/dev/null 2>/dev/null
|
|
|
@ -1,39 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
/usr/bin/rrdtool graph /mirror/root/stats_yearly.png \
|
|
||||||
-s -1y \
|
|
||||||
--imgformat=PNG \
|
|
||||||
--title='Mirror Traffic' \
|
|
||||||
--base=1000 \
|
|
||||||
--height=120 \
|
|
||||||
--width=600 \
|
|
||||||
--alt-autoscale-max \
|
|
||||||
--lower-limit=0 \
|
|
||||||
--vertical-label='bits per second' \
|
|
||||||
--slope-mode \
|
|
||||||
--font TITLE:10: \
|
|
||||||
--font AXIS:8: \
|
|
||||||
--font LEGEND:8: \
|
|
||||||
--font UNIT:8: \
|
|
||||||
DEF:a="/var/rrdtool/cogent.rrd":snmp_oid:AVERAGE \
|
|
||||||
DEF:b="/var/rrdtool/orion.rrd":snmp_oid:AVERAGE \
|
|
||||||
DEF:c="/var/rrdtool/campus.rrd":snmp_oid:AVERAGE \
|
|
||||||
CDEF:cdefa=a,8,* \
|
|
||||||
CDEF:cdefe=b,8,* \
|
|
||||||
CDEF:cdefi=c,8,* \
|
|
||||||
CDEF:cdefbc=TIME,1318318854,GT,a,a,UN,0,a,IF,IF,TIME,1318318854,GT,b,b,UN,0,b,IF,IF,TIME,1318318854,GT,c,c,UN,0,c,IF,IF,+,+,8,* \
|
|
||||||
AREA:cdefa#157419FF:"Cogent" \
|
|
||||||
GPRINT:cdefa:LAST:"Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefa:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
AREA:cdefe#00CF00FF:"Orion":STACK \
|
|
||||||
GPRINT:cdefe:LAST:" Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefe:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefe:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
AREA:cdefi#EE5019FF:"Campus":STACK \
|
|
||||||
GPRINT:cdefi:LAST:"Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefi:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefi:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
LINE1:cdefbc#000000FF:"Total" \
|
|
||||||
GPRINT:cdefbc:LAST:" Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefbc:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefbc:MAX:"Maximum\:%8.2lf%s\n" >/dev/null 2>/dev/null
|
|
|
@ -1,38 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
/usr/bin/rrdtool graph /mirror/root/stats.png \
|
|
||||||
--imgformat=PNG \
|
|
||||||
--title='Mirror Traffic' \
|
|
||||||
--base=1000 \
|
|
||||||
--height=120 \
|
|
||||||
--width=600 \
|
|
||||||
--alt-autoscale-max \
|
|
||||||
--lower-limit=0 \
|
|
||||||
--vertical-label='bits per second' \
|
|
||||||
--slope-mode \
|
|
||||||
--font TITLE:10: \
|
|
||||||
--font AXIS:8: \
|
|
||||||
--font LEGEND:8: \
|
|
||||||
--font UNIT:8: \
|
|
||||||
DEF:a="/var/rrdtool/cogent.rrd":snmp_oid:AVERAGE \
|
|
||||||
DEF:b="/var/rrdtool/orion.rrd":snmp_oid:AVERAGE \
|
|
||||||
DEF:c="/var/rrdtool/campus.rrd":snmp_oid:AVERAGE \
|
|
||||||
CDEF:cdefa=a,8,* \
|
|
||||||
CDEF:cdefe=b,8,* \
|
|
||||||
CDEF:cdefi=c,8,* \
|
|
||||||
CDEF:cdefbc=TIME,1318318854,GT,a,a,UN,0,a,IF,IF,TIME,1318318854,GT,b,b,UN,0,b,IF,IF,TIME,1318318854,GT,c,c,UN,0,c,IF,IF,+,+,8,* \
|
|
||||||
AREA:cdefa#157419FF:"Cogent" \
|
|
||||||
GPRINT:cdefa:LAST:"Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefa:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
AREA:cdefe#00CF00FF:"Orion":STACK \
|
|
||||||
GPRINT:cdefe:LAST:" Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefe:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefe:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
AREA:cdefi#EE5019FF:"Campus":STACK \
|
|
||||||
GPRINT:cdefi:LAST:"Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefi:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefi:MAX:"Maximum\:%8.2lf%s\n" \
|
|
||||||
LINE1:cdefbc#000000FF:"Total" \
|
|
||||||
GPRINT:cdefbc:LAST:" Current\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefbc:AVERAGE:"Average\:%8.2lf%s" \
|
|
||||||
GPRINT:cdefbc:MAX:"Maximum\:%8.2lf%s\n" >/dev/null 2>/dev/null
|
|
|
@ -1,3 +0,0 @@
|
||||||
/csc-snmp-subagent
|
|
||||||
/mirror-stats
|
|
||||||
*.o
|
|
|
@ -1,49 +0,0 @@
|
||||||
# this file goes at /etc/csc/mibs/CSC-MIB.txt
|
|
||||||
# and make sure to copy snmp.conf
|
|
||||||
|
|
||||||
CSC-MIB DEFINITIONS ::= BEGIN
|
|
||||||
|
|
||||||
IMPORTS
|
|
||||||
MODULE-IDENTITY, OBJECT-TYPE, Counter32, Gauge32, Counter64,
|
|
||||||
Integer32, TimeTicks, mib-2, enterprises,
|
|
||||||
NOTIFICATION-TYPE FROM SNMPv2-SMI
|
|
||||||
TEXTUAL-CONVENTION, DisplayString,
|
|
||||||
PhysAddress, TruthValue, RowStatus,
|
|
||||||
TimeStamp, AutonomousType, TestAndIncr FROM SNMPv2-TC
|
|
||||||
MODULE-COMPLIANCE, OBJECT-GROUP,
|
|
||||||
NOTIFICATION-GROUP FROM SNMPv2-CONF
|
|
||||||
snmpTraps FROM SNMPv2-MIB
|
|
||||||
IANAifType FROM IANAifType-MIB;
|
|
||||||
|
|
||||||
csclub OBJECT IDENTIFIER ::= { enterprises 27934 }
|
|
||||||
|
|
||||||
cscMIB MODULE-IDENTITY
|
|
||||||
LAST-UPDATED "200905080000Z"
|
|
||||||
ORGANIZATION "University of Waterloo Computer Science Club"
|
|
||||||
CONTACT-INFO "systems-committee@csclub.uwaterloo.ca"
|
|
||||||
DESCRIPTION "Computer Science Club Local MIBs"
|
|
||||||
REVISION "200905080000Z"
|
|
||||||
DESCRIPTION "Initial revision"
|
|
||||||
::= { csclub 2 }
|
|
||||||
|
|
||||||
mirror OBJECT IDENTIFIER ::= { cscMIB 2 }
|
|
||||||
|
|
||||||
cogentBytes OBJECT-TYPE
|
|
||||||
SYNTAX Counter64
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
::= { mirror 1 }
|
|
||||||
|
|
||||||
orionBytes OBJECT-TYPE
|
|
||||||
SYNTAX Counter64
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
::= { mirror 2 }
|
|
||||||
|
|
||||||
campusBytes OBJECT-TYPE
|
|
||||||
SYNTAX Counter64
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
::= { mirror 3 }
|
|
||||||
|
|
||||||
END
|
|
|
@ -1,11 +0,0 @@
|
||||||
LDFLAGS := -lnl $(shell net-snmp-config --base-agent-libs)
|
|
||||||
CFLAGS := -g3 -O2 -Wall
|
|
||||||
|
|
||||||
all: mirror-stats csc-snmp-subagent
|
|
||||||
|
|
||||||
mirror-stats: mirror-stats.o mirror-nl-glue.o
|
|
||||||
|
|
||||||
csc-snmp-subagent: csc-snmp-subagent.o mirror-mib.o mirror-nl-glue.o
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o mirror-stats csc-snmp-subagent
|
|
|
@ -1,221 +0,0 @@
|
||||||
/* generated from net-snmp-config */
|
|
||||||
#include <net-snmp/net-snmp-config.h>
|
|
||||||
#ifdef HAVE_SIGNAL
|
|
||||||
#include <signal.h>
|
|
||||||
#endif /* HAVE_SIGNAL */
|
|
||||||
#include <net-snmp/net-snmp-includes.h>
|
|
||||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
||||||
#include "mirror-mib.h"
|
|
||||||
const char *app_name = "cscMIB";
|
|
||||||
|
|
||||||
extern int netsnmp_running;
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define UNUSED __attribute__((unused))
|
|
||||||
#else
|
|
||||||
#define UNUSED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
RETSIGTYPE
|
|
||||||
stop_server(UNUSED int a) {
|
|
||||||
netsnmp_running = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
usage(const char *prog)
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"USAGE: %s [OPTIONS]\n"
|
|
||||||
"\n"
|
|
||||||
"OPTIONS:\n", prog);
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
" -d\t\t\tdump all traffic\n"
|
|
||||||
" -D TOKEN[,...]\tturn on debugging output for the specified "
|
|
||||||
"TOKENs\n"
|
|
||||||
"\t\t\t (ALL gives extremely verbose debugging output)\n"
|
|
||||||
" -f\t\t\tDo not fork() from the calling shell.\n"
|
|
||||||
" -h\t\t\tdisplay this help message\n"
|
|
||||||
" -H\t\t\tdisplay a list of configuration file directives\n"
|
|
||||||
" -L LOGOPTS\t\tToggle various defaults controlling logging:\n");
|
|
||||||
snmp_log_options_usage("\t\t\t ", stderr);
|
|
||||||
#ifndef DISABLE_MIB_LOADING
|
|
||||||
fprintf(stderr,
|
|
||||||
" -m MIB[:...]\t\tload given list of MIBs (ALL loads "
|
|
||||||
"everything)\n"
|
|
||||||
" -M DIR[:...]\t\tlook in given list of directories for MIBs\n");
|
|
||||||
#endif /* DISABLE_MIB_LOADING */
|
|
||||||
#ifndef DISABLE_MIB_LOADING
|
|
||||||
fprintf(stderr,
|
|
||||||
" -P MIBOPTS\t\tToggle various defaults controlling mib "
|
|
||||||
"parsing:\n");
|
|
||||||
snmp_mib_toggle_options_usage("\t\t\t ", stderr);
|
|
||||||
#endif /* DISABLE_MIB_LOADING */
|
|
||||||
fprintf(stderr,
|
|
||||||
" -v\t\t\tdisplay package version number\n"
|
|
||||||
" -x TRANSPORT\tconnect to master agent using TRANSPORT\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
version(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "NET-SNMP version: %s\n", netsnmp_get_version());
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int arg;
|
|
||||||
char* cp = NULL;
|
|
||||||
int dont_fork = 0, do_help = 0;
|
|
||||||
|
|
||||||
while ((arg = getopt(argc, argv, "dD:fhHL:"
|
|
||||||
#ifndef DISABLE_MIB_LOADING
|
|
||||||
"m:M:"
|
|
||||||
#endif /* DISABLE_MIB_LOADING */
|
|
||||||
"n:"
|
|
||||||
#ifndef DISABLE_MIB_LOADING
|
|
||||||
"P:"
|
|
||||||
#endif /* DISABLE_MIB_LOADING */
|
|
||||||
"vx:")) != EOF) {
|
|
||||||
switch (arg) {
|
|
||||||
case 'd':
|
|
||||||
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
|
|
||||||
NETSNMP_DS_LIB_DUMP_PACKET, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'D':
|
|
||||||
debug_register_tokens(optarg);
|
|
||||||
snmp_set_do_debugging(1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
dont_fork = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'h':
|
|
||||||
usage(argv[0]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'H':
|
|
||||||
do_help = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'L':
|
|
||||||
if (snmp_log_options(optarg, argc, argv) < 0) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifndef DISABLE_MIB_LOADING
|
|
||||||
case 'm':
|
|
||||||
if (optarg != NULL) {
|
|
||||||
setenv("MIBS", optarg, 1);
|
|
||||||
} else {
|
|
||||||
usage(argv[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'M':
|
|
||||||
if (optarg != NULL) {
|
|
||||||
setenv("MIBDIRS", optarg, 1);
|
|
||||||
} else {
|
|
||||||
usage(argv[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif /* DISABLE_MIB_LOADING */
|
|
||||||
|
|
||||||
case 'n':
|
|
||||||
if (optarg != NULL) {
|
|
||||||
app_name = optarg;
|
|
||||||
netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
|
|
||||||
NETSNMP_DS_LIB_APPTYPE, app_name);
|
|
||||||
} else {
|
|
||||||
usage(argv[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifndef DISABLE_MIB_LOADING
|
|
||||||
case 'P':
|
|
||||||
cp = snmp_mib_toggle_options(optarg);
|
|
||||||
if (cp != NULL) {
|
|
||||||
fprintf(stderr, "Unknown parser option to -P: %c.\n", *cp);
|
|
||||||
usage(argv[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif /* DISABLE_MIB_LOADING */
|
|
||||||
|
|
||||||
case 'v':
|
|
||||||
version();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'x':
|
|
||||||
if (optarg != NULL) {
|
|
||||||
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
|
|
||||||
NETSNMP_DS_AGENT_X_SOCKET, optarg);
|
|
||||||
} else {
|
|
||||||
usage(argv[0]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fprintf(stderr, "invalid option: -%c\n", arg);
|
|
||||||
usage(argv[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (do_help) {
|
|
||||||
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
|
|
||||||
NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
|
|
||||||
} else {
|
|
||||||
/* we are a subagent */
|
|
||||||
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
|
|
||||||
NETSNMP_DS_AGENT_ROLE, 1);
|
|
||||||
|
|
||||||
if (!dont_fork) {
|
|
||||||
if (netsnmp_daemonize(1, snmp_stderrlog_status()) != 0)
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize tcpip, if necessary */
|
|
||||||
SOCK_STARTUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize the agent library */
|
|
||||||
init_agent(app_name);
|
|
||||||
|
|
||||||
/* initialize your mib code here */
|
|
||||||
init_mirror_mib();
|
|
||||||
|
|
||||||
/* cscMIB will be used to read cscMIB.conf files. */
|
|
||||||
init_snmp("cscMIB");
|
|
||||||
|
|
||||||
if (do_help) {
|
|
||||||
fprintf(stderr, "Configuration directives understood:\n");
|
|
||||||
read_config_print_usage(" ");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In case we received a request to stop (kill -TERM or kill -INT) */
|
|
||||||
netsnmp_running = 1;
|
|
||||||
#ifdef SIGTERM
|
|
||||||
signal(SIGTERM, stop_server);
|
|
||||||
#endif
|
|
||||||
#ifdef SIGINT
|
|
||||||
signal(SIGINT, stop_server);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* main loop here... */
|
|
||||||
while(netsnmp_running) {
|
|
||||||
agent_check_and_process(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* at shutdown time */
|
|
||||||
snmp_shutdown(app_name);
|
|
||||||
SOCK_CLEANUP;
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,109 +0,0 @@
|
||||||
/*
|
|
||||||
* Note: this file originally auto-generated by mib2c using
|
|
||||||
* : mib2c.scalar.conf 11805 2005-01-07 09:37:18Z dts12 $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <net-snmp/net-snmp-config.h>
|
|
||||||
#include <net-snmp/net-snmp-includes.h>
|
|
||||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
||||||
#include "mirror-mib.h"
|
|
||||||
#include "mirror-nl-glue.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
init_mirror_mib(void)
|
|
||||||
{
|
|
||||||
static oid cogentBytes_oid[] =
|
|
||||||
{ 1, 3, 6, 1, 4, 1, 27934, 2, 2, 1 };
|
|
||||||
static oid orionBytes_oid[] =
|
|
||||||
{ 1, 3, 6, 1, 4, 1, 27934, 2, 2, 2 };
|
|
||||||
static oid campusBytes_oid[] =
|
|
||||||
{ 1, 3, 6, 1, 4, 1, 27934, 2, 2, 3 };
|
|
||||||
|
|
||||||
DEBUGMSGTL(("mirror_mib", "Initializing\n"));
|
|
||||||
|
|
||||||
mirror_stats_initialize();
|
|
||||||
|
|
||||||
netsnmp_register_scalar(netsnmp_create_handler_registration
|
|
||||||
("cogentBytes", handle_cogentBytes,
|
|
||||||
cogentBytes_oid, OID_LENGTH(cogentBytes_oid),
|
|
||||||
HANDLER_CAN_RONLY));
|
|
||||||
netsnmp_register_scalar(netsnmp_create_handler_registration
|
|
||||||
("orionBytes", handle_orionBytes,
|
|
||||||
orionBytes_oid, OID_LENGTH(orionBytes_oid),
|
|
||||||
HANDLER_CAN_RONLY));
|
|
||||||
netsnmp_register_scalar(netsnmp_create_handler_registration
|
|
||||||
("campusBytes", handle_campusBytes,
|
|
||||||
campusBytes_oid, OID_LENGTH(campusBytes_oid),
|
|
||||||
HANDLER_CAN_RONLY));
|
|
||||||
}
|
|
||||||
|
|
||||||
void explode_counter64(uint64_t num, struct counter64 *counter) {
|
|
||||||
counter->low = num & 0xFFFFFFFF;
|
|
||||||
counter->high = (num >> 32) & 0xFFFFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
handle_cogentBytes(netsnmp_mib_handler *handler,
|
|
||||||
netsnmp_handler_registration *reginfo,
|
|
||||||
netsnmp_agent_request_info *reqinfo,
|
|
||||||
netsnmp_request_info *requests)
|
|
||||||
{
|
|
||||||
struct counter64 counter;
|
|
||||||
mirror_stats_refresh();
|
|
||||||
explode_counter64(get_class_byte_count(&cogent_class), &counter);
|
|
||||||
|
|
||||||
switch (reqinfo->mode) {
|
|
||||||
case MODE_GET:
|
|
||||||
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
|
|
||||||
(u_char *)&counter, sizeof(counter));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
die("unknown mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SNMP_ERR_NOERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
handle_orionBytes(netsnmp_mib_handler *handler,
|
|
||||||
netsnmp_handler_registration *reginfo,
|
|
||||||
netsnmp_agent_request_info *reqinfo,
|
|
||||||
netsnmp_request_info *requests)
|
|
||||||
{
|
|
||||||
struct counter64 counter;
|
|
||||||
mirror_stats_refresh();
|
|
||||||
explode_counter64(get_class_byte_count(&orion_class), &counter);
|
|
||||||
|
|
||||||
switch (reqinfo->mode) {
|
|
||||||
case MODE_GET:
|
|
||||||
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
|
|
||||||
(u_char *)&counter, sizeof(counter));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
die("unknown mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SNMP_ERR_NOERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
handle_campusBytes(netsnmp_mib_handler *handler,
|
|
||||||
netsnmp_handler_registration *reginfo,
|
|
||||||
netsnmp_agent_request_info *reqinfo,
|
|
||||||
netsnmp_request_info *requests)
|
|
||||||
{
|
|
||||||
struct counter64 counter;
|
|
||||||
mirror_stats_refresh();
|
|
||||||
explode_counter64(get_class_byte_count(&campus_class), &counter);
|
|
||||||
|
|
||||||
switch (reqinfo->mode) {
|
|
||||||
case MODE_GET:
|
|
||||||
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER64,
|
|
||||||
(u_char *)&counter, sizeof(counter));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
die("unknown mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SNMP_ERR_NOERROR;
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
#ifndef MIRRORMIB_H
|
|
||||||
#define MIRRORMIB_H
|
|
||||||
|
|
||||||
void init_mirror_mib(void);
|
|
||||||
Netsnmp_Node_Handler handle_cogentBytes;
|
|
||||||
Netsnmp_Node_Handler handle_orionBytes;
|
|
||||||
Netsnmp_Node_Handler handle_campusBytes;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,102 +0,0 @@
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <netlink/route/class.h>
|
|
||||||
#include <netlink/route/link.h>
|
|
||||||
#include <netlink/cache-api.h>
|
|
||||||
#include <netlink/object.h>
|
|
||||||
#include "mirror-nl-glue.h"
|
|
||||||
|
|
||||||
static struct nl_cache *link_cache, *class_cache;
|
|
||||||
static struct rtnl_link *eth;
|
|
||||||
static int ifindex;
|
|
||||||
|
|
||||||
struct class_info cogent_class = { "cogent", "01:02", };
|
|
||||||
struct class_info orion_class = { "orion", "01:03", };
|
|
||||||
struct class_info campus_class = { "campus", "01:04", };
|
|
||||||
|
|
||||||
static struct nl_handle *nl_handle;
|
|
||||||
|
|
||||||
void die(const char *message) {
|
|
||||||
fprintf(stderr, "fatal: %s\n", message);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void match_obj(struct nl_object *obj, void *arg) {
|
|
||||||
struct nl_object *needle = *(struct nl_object **)arg;
|
|
||||||
struct nl_object **ret = (struct nl_object **)arg + 1;
|
|
||||||
|
|
||||||
if (!*ret && nl_object_identical(obj, needle)) {
|
|
||||||
nl_object_get(obj);
|
|
||||||
*ret = obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct rtnl_class *get_class_by_id(char *id, int ifindex) {
|
|
||||||
uint32_t handle;
|
|
||||||
struct rtnl_class *needle;
|
|
||||||
struct nl_object *magic[2];
|
|
||||||
|
|
||||||
if (rtnl_tc_str2handle(id, &handle))
|
|
||||||
die("invalid id");
|
|
||||||
|
|
||||||
needle = rtnl_class_alloc();
|
|
||||||
rtnl_class_set_ifindex(needle, ifindex);
|
|
||||||
rtnl_class_set_handle(needle, handle);
|
|
||||||
|
|
||||||
magic[0] = (struct nl_object *)needle;
|
|
||||||
magic[1] = (struct nl_object *)NULL;
|
|
||||||
|
|
||||||
nl_cache_foreach(class_cache, match_obj, magic);
|
|
||||||
|
|
||||||
rtnl_class_put(needle);
|
|
||||||
return (struct rtnl_class *)magic[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t get_class_byte_count(struct class_info *info) {
|
|
||||||
struct rtnl_class *class = get_class_by_id(info->id, ifindex);
|
|
||||||
uint64_t bytes;
|
|
||||||
if (!class)
|
|
||||||
die("class not found");
|
|
||||||
bytes = rtnl_class_get_stat(class, RTNL_TC_BYTES);
|
|
||||||
rtnl_class_put(class);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mirror_stats_refresh(void) {
|
|
||||||
nl_cache_refill(nl_handle, class_cache);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mirror_stats_initialize(void) {
|
|
||||||
nl_handle = nl_handle_alloc();
|
|
||||||
if (!nl_handle)
|
|
||||||
die("unable to allocate handle");
|
|
||||||
|
|
||||||
if (nl_connect(nl_handle, NETLINK_ROUTE) < 0)
|
|
||||||
die("unable to connect to netlink");
|
|
||||||
|
|
||||||
link_cache = rtnl_link_alloc_cache(nl_handle);
|
|
||||||
if (!link_cache)
|
|
||||||
die("unable to allocate link cache");
|
|
||||||
|
|
||||||
eth = rtnl_link_get_by_name(link_cache, "eth0");
|
|
||||||
if (!eth)
|
|
||||||
die("unable to acquire eth0");
|
|
||||||
ifindex = rtnl_link_get_ifindex(eth);
|
|
||||||
|
|
||||||
class_cache = rtnl_class_alloc_cache(nl_handle, ifindex);
|
|
||||||
if (!class_cache)
|
|
||||||
die("unable to allocate class cache");
|
|
||||||
}
|
|
||||||
|
|
||||||
void mirror_stats_cleanup(void) {
|
|
||||||
rtnl_link_put(eth);
|
|
||||||
nl_cache_free(class_cache);
|
|
||||||
nl_cache_free(link_cache);
|
|
||||||
nl_close(nl_handle);
|
|
||||||
nl_handle_destroy(nl_handle);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <libgen.h>
|
|
||||||
#include <netlink/route/class.h>
|
|
||||||
#include <netlink/route/link.h>
|
|
||||||
#include <netlink/cache-api.h>
|
|
||||||
#include <netlink/object.h>
|
|
||||||
|
|
||||||
struct class_info {
|
|
||||||
char *name;
|
|
||||||
char *id;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct class_info cogent_class;
|
|
||||||
extern struct class_info orion_class;
|
|
||||||
extern struct class_info campus_class;
|
|
||||||
|
|
||||||
void mirror_stats_refresh(void);
|
|
||||||
void mirror_stats_initialize(void);
|
|
||||||
void mirror_stats_cleanup(void);
|
|
||||||
void die(const char *);
|
|
||||||
uint64_t get_class_byte_count(struct class_info *);
|
|
|
@ -1,12 +0,0 @@
|
||||||
#include "mirror-nl-glue.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
mirror_stats_initialize();
|
|
||||||
for (;;) {
|
|
||||||
printf("%s %"PRIu64"\n", cogent_class.id, get_class_byte_count(&cogent_class));
|
|
||||||
printf("%s %"PRIu64"\n", orion_class.id, get_class_byte_count(&orion_class));
|
|
||||||
printf("%s %"PRIu64"\n", campus_class.id, get_class_byte_count(&campus_class));
|
|
||||||
sleep(1);
|
|
||||||
mirror_stats_refresh();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
snmpwalk -v2c -cpublic mirror 1.3.6.1.4.1.27934.2.2
|
|
|
@ -1,2 +0,0 @@
|
||||||
mibdirs /etc/csc/mibs:/usr/share/snmp/mibs
|
|
||||||
mibs ALL
|
|
|
@ -1,56 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
|
||||||
|
|
||||||
PATH=$PATH:/bin:/usr/bin:/sbin:/usr/sbin
|
|
||||||
NAME=rtorrent
|
|
||||||
PIDFILE=/var/run/$NAME.screen
|
|
||||||
CHUSER=$NAME
|
|
||||||
DAEMON=/usr/bin/rtorrent
|
|
||||||
DAEMON_ARGS="-n -o try_import=/etc/rtorrent.rc"
|
|
||||||
|
|
||||||
do_start()
|
|
||||||
{
|
|
||||||
if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
log_daemon_msg "Starting" $NAME
|
|
||||||
start-stop-daemon --start --quiet --background --pidfile $PIDFILE \
|
|
||||||
--make-pidfile --exec /bin/su -- \
|
|
||||||
$CHUSER -c "/usr/bin/screen -D -m -- $DAEMON $DAEMON_ARGS"
|
|
||||||
log_end_msg 0
|
|
||||||
}
|
|
||||||
|
|
||||||
do_stop()
|
|
||||||
{
|
|
||||||
log_daemon_msg "Stopping" $NAME
|
|
||||||
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo
|
|
||||||
log_end_msg 0
|
|
||||||
}
|
|
||||||
|
|
||||||
do_status()
|
|
||||||
{
|
|
||||||
if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) >/dev/null 2>&1; then
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
exit 4
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
do_start
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
do_stop
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
do_stop
|
|
||||||
sleep 4
|
|
||||||
do_start
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
do_status
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -1,100 +0,0 @@
|
||||||
# This is an example resource file for rTorrent. Copy to
|
|
||||||
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
|
|
||||||
# uncomment the options you wish to enable.
|
|
||||||
|
|
||||||
# Maximum and minimum number of peers to connect to per torrent.
|
|
||||||
#min_peers = 40
|
|
||||||
#max_peers = 100
|
|
||||||
|
|
||||||
# Same as above but for seeding completed torrents (-1 = same as downloading)
|
|
||||||
#min_peers_seed = 10
|
|
||||||
#max_peers_seed = 50
|
|
||||||
|
|
||||||
# Maximum number of simultanious uploads per torrent.
|
|
||||||
#max_uploads = 15
|
|
||||||
|
|
||||||
# Global upload and download rate in KiB. "0" for unlimited.
|
|
||||||
#download_rate = 0
|
|
||||||
#upload_rate = 0
|
|
||||||
|
|
||||||
# Default directory to save the downloaded torrents.
|
|
||||||
directory = /mirror/root/csclub
|
|
||||||
|
|
||||||
# Default session directory. Make sure you don't run multiple instance
|
|
||||||
# of rtorrent using the same session directory. Perhaps using a
|
|
||||||
# relative path?
|
|
||||||
session = /var/lib/rtorrent/session
|
|
||||||
|
|
||||||
# Watch a directory for new torrents, and stop those that have been
|
|
||||||
# deleted.
|
|
||||||
schedule = watch_www_directory,1,5,load_start=/mirror/root/csclub/*.torrent
|
|
||||||
schedule = untied_directory,5,5,remove_untied=
|
|
||||||
|
|
||||||
# Close torrents when diskspace is low.
|
|
||||||
#schedule = low_diskspace,5,60,close_low_diskspace=100M
|
|
||||||
|
|
||||||
# Stop torrents when reaching upload ratio in percent,
|
|
||||||
# when also reaching total upload in bytes, or when
|
|
||||||
# reaching final upload ratio in percent.
|
|
||||||
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
|
|
||||||
#schedule = ratio,60,60,stop_on_ratio=200,200M,2000
|
|
||||||
|
|
||||||
# The ip address reported to the tracker.
|
|
||||||
#ip = 127.0.0.1
|
|
||||||
#ip = rakshasa.no
|
|
||||||
|
|
||||||
# The ip address the listening socket and outgoing connections is
|
|
||||||
# bound to.
|
|
||||||
bind = mirror
|
|
||||||
|
|
||||||
# Port range to use for listening.
|
|
||||||
port_range = 6900-6999
|
|
||||||
|
|
||||||
# Start opening ports at a random position within the port range.
|
|
||||||
#port_random = no
|
|
||||||
|
|
||||||
# Check hash for finished torrents. Might be usefull until the bug is
|
|
||||||
# fixed that causes lack of diskspace not to be properly reported.
|
|
||||||
#check_hash = no
|
|
||||||
|
|
||||||
# Set whetever the client should try to connect to UDP trackers.
|
|
||||||
#use_udp_trackers = yes
|
|
||||||
|
|
||||||
# Alternative calls to bind and ip that should handle dynamic ip's.
|
|
||||||
#schedule = ip_tick,0,1800,ip=rakshasa
|
|
||||||
#schedule = bind_tick,0,1800,bind=rakshasa
|
|
||||||
|
|
||||||
encryption = allow_incoming,prefer_plaintext
|
|
||||||
|
|
||||||
#
|
|
||||||
# Do not modify the following parameters unless you know what you're doing.
|
|
||||||
#
|
|
||||||
|
|
||||||
# Hash read-ahead controls how many MB to request the kernel to read
|
|
||||||
# ahead. If the value is too low the disk may not be fully utilized,
|
|
||||||
# while if too high the kernel might not be able to keep the read
|
|
||||||
# pages in memory thus end up trashing.
|
|
||||||
#hash_read_ahead = 10
|
|
||||||
|
|
||||||
# Interval between attempts to check the hash, in milliseconds.
|
|
||||||
#hash_interval = 100
|
|
||||||
|
|
||||||
# Number of attempts to check the hash while using the mincore status,
|
|
||||||
# before forcing. Overworked systems might need lower values to get a
|
|
||||||
# decent hash checking rate.
|
|
||||||
#hash_max_tries = 10
|
|
||||||
|
|
||||||
# Max number of files to keep open simultaniously.
|
|
||||||
#max_open_files = 128
|
|
||||||
|
|
||||||
# Number of sockets to simultaneously keep open.
|
|
||||||
#max_open_sockets = <no default>
|
|
||||||
|
|
||||||
|
|
||||||
# Example of scheduling commands: Switch between two ip's every 5
|
|
||||||
# seconds.
|
|
||||||
#schedule = "ip_tick1,5,10,ip=torretta"
|
|
||||||
#schedule = "ip_tick2,10,10,ip=lampedusa"
|
|
||||||
|
|
||||||
# Remove a scheduled event.
|
|
||||||
#schedule_remove = "ip_tick1"
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd ~mirror
|
||||||
|
PROG=`/opt/MegaCli/MegaCli64 -ldrecon -showprog -l1 -a0 | grep Completed |sed 's/.*Completed \([0-9]*\)%.*/\1/'`
|
||||||
|
sed -i "s/<div id=\"raid-progress\">.*<\/div>/<div id=\"raid-progress\">Reconstruction of the RAID has completed $PROG%<\/div>/" index.html
|
Loading…
Reference in New Issue