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

Revision 24336, 1.0 KB checked in by jdreed, 14 years ago (diff)
Replace "machtype" with lsb_release -sc as per Trac #491, and add dependency on lsb-release package
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" | nc -q0 -u $loghost syslog
Note: See TracBrowser for help on using the repository browser.