source: trunk/debathena/debathena/counterlog/debian/athena-counterlog @ 25227

Revision 25227, 1.0 KB checked in by jdreed, 13 years ago (diff)
In counterlog: * Switch to socat instead of netcat (Trac: #929)
Line 
1#!/bin/sh
2
3PATH=/sbin:/bin:/usr/sbin:/usr/bin
4
5# We want a unique ID for each machine, ideally surviving a reinstall.
6# Produce the ID using the hardware addresses of the ethernet devices,
7# and save it to a file so that it at least survives the duration of
8# this install.
9idfile=/var/lib/debathena-counterlog/id
10if [ -r $idfile ]; then
11  id=$(cat $idfile)
12else
13  id=$(ifconfig -a | sed -nre 's/.*HWaddr ([^ ]+).*/\1/p' | sort -u \
14       | md5sum | awk '{print $1}')
15  echo "$id" > $idfile
16fi
17
18version=$(machtype -L)
19loghost=wslogger.mit.edu
20host=$(hostname --fqdn)
21mtype=$(lsb_release -sc | sed -e 's/\s/_/g')
22ctype=$(machtype -c)
23
24# Traditionally, we do counter logging via syslog.  (We could do it
25# via HTTP post or something else instead, if we wanted.)  We can't
26# rely on central syslogging being configured because that's a
27# cluster-only package.  Fortunately, the syslog protocol is dead
28# simple, so just fake a packet to the log host.
29msg="<13>root: counterlog: $host $mtype $ctype $version $id cron"
30printf "%s" "$msg" | socat STDIN UDP:${loghost}:syslog
Note: See TracBrowser for help on using the repository browser.