Revision 25227,
1.0 KB
checked in by jdreed, 13 years ago
(diff) |
In counterlog:
* Switch to socat instead of netcat (Trac: #929)
|
Rev | Line | |
---|
[23163] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | PATH=/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. |
---|
| 9 | idfile=/var/lib/debathena-counterlog/id |
---|
| 10 | if [ -r $idfile ]; then |
---|
| 11 | id=$(cat $idfile) |
---|
| 12 | else |
---|
| 13 | id=$(ifconfig -a | sed -nre 's/.*HWaddr ([^ ]+).*/\1/p' | sort -u \ |
---|
| 14 | | md5sum | awk '{print $1}') |
---|
| 15 | echo "$id" > $idfile |
---|
| 16 | fi |
---|
| 17 | |
---|
[23519] | 18 | version=$(machtype -L) |
---|
[23518] | 19 | loghost=wslogger.mit.edu |
---|
[23163] | 20 | host=$(hostname --fqdn) |
---|
[24336] | 21 | mtype=$(lsb_release -sc | sed -e 's/\s/_/g') |
---|
[23163] | 22 | ctype=$(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. |
---|
| 29 | msg="<13>root: counterlog: $host $mtype $ctype $version $id cron" |
---|
[25227] | 30 | printf "%s" "$msg" | socat STDIN UDP:${loghost}:syslog |
---|
Note: See
TracBrowser
for help on using the repository browser.