From 92102800574e9a8db0302201697dfa137e88cf84 Mon Sep 17 00:00:00 2001 From: Hellmuth Michaelis Date: Fri, 25 May 2001 13:25:59 +0000 Subject: [PATCH] Add the contributed directory from the i4b tarball and the files from it which would be nice to have. Move isdnd_acct and isdnctl to the contrib directory where they belong to. --- share/examples/isdn/contrib/README | 42 +++ share/examples/isdn/contrib/anleitung.ppp | 142 ++++++++++ share/examples/isdn/contrib/answer.c | 178 ++++++++++++ share/examples/isdn/contrib/answer.sh | 111 ++++++++ share/examples/isdn/contrib/convert.sh | 86 ++++++ share/examples/isdn/contrib/hplay.c | 241 ++++++++++++++++ .../examples/isdn/contrib/i4b-ppp-newbie.txt | 237 ++++++++++++++++ share/examples/isdn/{ => contrib}/isdnctl | 0 share/examples/isdn/{ => contrib}/isdnd_acct | 6 +- share/examples/isdn/contrib/isdnd_acct.pl | 258 ++++++++++++++++++ share/examples/isdn/contrib/isdntelmux.c | 197 +++++++++++++ share/examples/isdn/contrib/mrtg-isp0.sh | 53 ++++ 12 files changed, 1547 insertions(+), 4 deletions(-) create mode 100644 share/examples/isdn/contrib/README create mode 100644 share/examples/isdn/contrib/anleitung.ppp create mode 100644 share/examples/isdn/contrib/answer.c create mode 100644 share/examples/isdn/contrib/answer.sh create mode 100644 share/examples/isdn/contrib/convert.sh create mode 100644 share/examples/isdn/contrib/hplay.c create mode 100644 share/examples/isdn/contrib/i4b-ppp-newbie.txt rename share/examples/isdn/{ => contrib}/isdnctl (100%) rename share/examples/isdn/{ => contrib}/isdnd_acct (98%) create mode 100644 share/examples/isdn/contrib/isdnd_acct.pl create mode 100644 share/examples/isdn/contrib/isdntelmux.c create mode 100644 share/examples/isdn/contrib/mrtg-isp0.sh diff --git a/share/examples/isdn/contrib/README b/share/examples/isdn/contrib/README new file mode 100644 index 000000000000..ae5969f09e84 --- /dev/null +++ b/share/examples/isdn/contrib/README @@ -0,0 +1,42 @@ +$FreeBSD$ + +This directory contains various unsupported contributions to isdn4bsd +--------------------------------------------------------------------- + +anleitung.ppp Anleitung für syncPPP Internet-Zugang und + Anrufbeantworter / FreeBSD 2.2.x / Teles.S0/16.3-Karte + (stefan@asterix.webaffairs.net) + +answer.c answering machine in C by David Wetzel + (dave@turbocat.de) + +answer.sh a much better replacement for answer, tell and record + from Stefan Esser (se@freebsd.org) + +convert.sh convert recorded message to WAV format, optionally + send it via mail. from Stefan Herrmann + (stefan@asterix.webaffairs.net) + +hplay.c isdn4bsd telephony output driver for the "rsynth" + package to play synthetic speech to a telephone + connection + +i4b-ppp-newbie.txt setup PPP for isdn4bsd for newbies text from + Dominik Brettnacher (german) + +isdnctl This script can control the state of your ISDN line. + It counts how many scripts/users currently use the + ISDN line and uses "ifconfig down" if noone uses it + any more. Alexander Langer + +isdnd_acct the barebones isdnd accounting script + +isdnd_acct.pl enhanced accounting from Joachim Kuebart + (joki@kuebart.stuttgart.netsurf.de) + +isdntelmux.c a "record while play" program contributed by + Michael Reifenberger (Michael@Reifenberger.com) + +mrtg-isp0.sh shell script and mrtg config entry to display + callout and callback statistics with mrtg + (www.mrtg.org) using the budget file statistics diff --git a/share/examples/isdn/contrib/anleitung.ppp b/share/examples/isdn/contrib/anleitung.ppp new file mode 100644 index 000000000000..01466e2f4880 --- /dev/null +++ b/share/examples/isdn/contrib/anleitung.ppp @@ -0,0 +1,142 @@ +$FreeBSD$ + +i4b Anleitung für syncPPP Internet-Zugang und Anrufbeantworter +unter FreeBSD 2.2.x mit Teles.S0/16.3-Karte +=============================================================== + +by Stefan Herrmann + + +Installation +------------ +1) Neues Verzeichnis "/usr/src/i4b" anlegen. + +2) Ins Verzeichnis "/usr/src/i4b" wechseln und Sourcen entpacken. + +3) Ins Verzeichnis "FreeBSD" wechseln und den Befehl "sh install.sh ausführen: + z.B. "root@asterix[0]/usr/src/i4b/FreeBSD # sh install.sh" + + Wenn auf eine neuere Version von i4b gewechselt wird, zuerst + "sh uninstall.sh" ausführen, dann erst "sh install.sh" + +4) Dann ins Verzeichnis "/usr/src/i4b" (zurück-)wechseln und die Befehle + "make depend", "make" und "make install" ausführen. + +5) Nun muß der kernel mit neuen Optionen versehen werden. Dazu wird an die + Kernel-Konfigurationsdatei im Verzeichnis "/sys/i386/conf" folgendes ans + Ende hinzugefügt: + +# i4b passive ISDN cards support (isic - I4b Siemens Isdn Chipset driver) +# note that the ``options'' and ``device'' lines must BOTH be defined ! + +# Teles S0/16.3 +options "TEL_S0_16_3" +device isic0 at isa? port 0xd80 net irq 5 flags 0x04 vector isicintr + +# i4b passive cards D channel handling +# Q.921 +pseudo-device "i4bq921" +# Q.931 +pseudo-device "i4bq931" + +# common passive and active layer 4 +# layer 4 +pseudo-device "i4b" + +# userland driver to do ISDN tracing (for passive cards oly) +pseudo-device "i4btrc" 4 +# userland driver to control the whole thing +pseudo-device "i4bctl" +# userland driver for access to raw B channel +pseudo-device "i4brbch" 4 +# userland driver for telephony +pseudo-device "i4btel" 2 +# network driver for IP over raw HDLC ISDN +pseudo-device "i4bipr" 4 +# enable VJ header compression detection for ipr i/f +options IPR_VJ +# network driver for sync PPP over ISDN +pseudo-device "i4bisppp" 4 +pseudo-device sppp 4 + +6) Danach wird der kernel durch Eingabe der Befehle "make depend", "make" und + "make install" im Verzeichniss "/usr/src/sys/compile/" neu + übersetzt und installiert. + +7) Nach dem Booten kann man dann mit dem Befehl "dmesg" überprüfen, ob die + Karte korrekt erkannt wurde und alle erforderlichen Treiber installiert + sind. + + +Konfiguration +------------- +8) Die Konfiguration von i4b wird hauptsächlich im Verzeichnis "/etc/isdn" + druchgeführt, dort sucht der isdnd beim Start auch seine Konfigurations- + datei "isdnd.rc". Da vorgenanntes Verzeichnis nach der Installation aber + noch leer ist, kopiert man zuerst die Beispieldateien aus dem Verzeichnis + "/etc/isdn/samples" nach "/etc/isdn". + +9) Die Datei "isdnd.rc" enthält schon recht aussagekräftige Kommentare zu den + einzelnen Optionen, weitere Informationen erhält man mit "man isdnd.rc" und + "man isdnd". + +10) Für syncPPP und Anrufbeantworter sind nur die Sektionen "SYSTEM", + "telephone answering" und "example for sPPP" notwendig, die Sektion + "IP over ISDN example" kann dafür also entfernt werden. + +11) Für den automatisierten Start des isp0 Interfaces und des isdnd erstellt + man nun ein Start-Skript. Dazu kopiert man die Datei + "/usr/src/i4b/etc/rc.isdn-PPP" nach "/etc/rc.isdn" und paßt sie + entsprechend an. Man beachte hierbei auch die FAQ "/usr/src/i4b/FAQ", die + Tips für die richtige Eintragung der IP-Adressen bereithält. + +12) Der Anrufbeantworter wird dadurch aktiviert, daß das entsprechende + Programm, das in "/etc/isdn/isdnd.rc" hinter dem Eintrag "answerprog = " + steht, aufgerufen wird. Wird dort kein Pfad angegeben, wird das Programm + im Verzeichniss "/etc/isdn" erwartet. Beispiele solcher Programme findet + man wiederum im Verzeichnis "/etc/isdn/samples". Sie nennen sich + + "answer" Nur Ansagetext abspielen, keine Aufzeichnungsmöglichkeit. + "record" Ansage wird abgespielt, nach Piep-Ton kann gesprochen + werden. + "tell" Als Ansagetext wird die anrufende Nummer gesprochen, keine + Aufzeichnung. + "tell-record" Anrufende Nummer als Ansagetext, nach Piep-Ton kann ge- + sprochen werden. + "isdntel.sh" Ansagetext und Aufzeichnung; mittels dem Programm "isdntel" + hat man die Kontrolle übe die Aufzeichnungen im Ver- + zeichniss "/var/isdn". Siehe auch "man isdntel" und + "man isdntelctl". + + Diese Programme müssen an die eigenen Wünsche angepaßt werden. Leider gibt es + kein mitgeliefertes Programm, mit dem man so auch den Ansagetext aufsprechen + kann. Das ist aber nicht allzuschlimm, da man nur das Programm "record" dafür + etwas anpassen muß (Ansagetexte beep und msg auskommentieren). Damit die Anrufe + aufgezeichnet werden können, muß zuerst noch das Verzeichnis "/var/isdn" + angelegt werden. Dort werden dann alle Aufzeichnungen obiger Programme gespeichert. + +13) Man sollte sich auch noch die man-Pages der Programme "isdnd", "isdnctl", + "isdnd_acct", "isdndebug" und "isdntrace" zu Gemüte führen. + + +Betrieb +------- +14) Der syncPPP Zugang zum Provider wird einfach mit dem Aufruf von + "/etc/rc.isdn" initialisiert. Jegliche Aktivitäten ins Internet (also z.B. + ein "ping 141.1.1.1") starten die Verbindung. Wenn in "/etc/isdn/isdnd.rc" + beim Eintrag "unitlengthsrc = " "rate" angegeben wurde, wird die Verbindung + kurz bevor die nächste Einheit begonnen wird, beendet. Informationen über + die Einheiten werden aus der Datei "/etc/isdn/isdnd.rates" ausgelesen + (Beispiele sind in "/etc/isdn/samples"). + + Mit "/etc/rc.isdn [restart|stop]" kann i4b entweder neu gestartet (z.B. zum + Einlesen der geänderten Konfiguration aus "isdnd.rc") oder beendet werden. + +15) Für den Anrufbeantworter muß nur der "isdnd" gestartet sein. Ein + ankommender Anruf wird dann automatisch angenommen (je nach den Einträgen + in "/etc/isdn/isdnd.rc"). + +16) Informationen über die Verbindung erhält man sowohl in "/var/log/messages", + also auch in "/var/log/isdnd.log" (so der isdnd mit der Option "-l" + gestartet wird) bzw. auf dem aktuellen tty (wenn der isdnd mit der Option + "-f" gestartet wird). diff --git a/share/examples/isdn/contrib/answer.c b/share/examples/isdn/contrib/answer.c new file mode 100644 index 000000000000..da19aa946fd7 --- /dev/null +++ b/share/examples/isdn/contrib/answer.c @@ -0,0 +1,178 @@ +// $FreeBSD$ +// changed ".g711a" to ".al" (-hm) +// Tue Mar 3 02:42:14 MET 1998 dave@turbocat.de +// started + +#define BLK_SIZE 2048 +#define SOX "/usr/local/bin/sox" +#define ALAWULAW "/usr/local/bin/alaw2ulaw" + +#include +#include + + FILE *device; + FILE *logfile; + char srcNum[30]; + char destNum[30]; + char argbuf[255]; + char tmpBuf[1024] = ""; + + +void writeToPhone (char *path) +{ + char buf[BLK_SIZE]; + FILE *srcfile; + int i = 0; + int readcount = 0; + + srcfile = fopen(path,"r"); + if (srcfile) { + for (i=0;i 2) { + argbuf[strlen(argbuf)-1] = '\0'; + } + + + device = fopen(argWithName("-D"),"r+"); + strcpy(destNum, argWithName("-d")); + strcpy(srcNum, argWithName("-s")); + + fprintf(logfile,"device '%s'\n", argWithName("-D")); + fprintf(logfile,"srcNum '%s'\n", srcNum); + fprintf(logfile,"destNum '%s'\n", destNum); + + + if (device) { + + strftime(timeStr,40,I4B_TIME_FORMAT,localtime(&now)); + + sprintf(outfileName,"/var/isdn/%s_%s_%s", timeStr, srcNum, destNum); + + writeToPhone ("/usr/local/lib/isdn/msg.al"); + readFromPhone (outfileName); + + sprintf(cmdStr,"/bin/cat %s | %s | %s -t raw -U -b -r 8000 - -t .au %s.snd", outfileName, ALAWULAW, SOX, outfileName); + fprintf(logfile,"%s\n",cmdStr); + system(cmdStr); + unlink(outfileName); + + fclose(device); + } else { + fprintf(logfile,"Can't open file '%s'\n",argWithName("-D")); + } + + now=time(NULL); + + strftime(timeStr,40,I4B_TIME_FORMAT,localtime(&now)); + + fprintf(logfile,"%s Done\n",timeStr); + fclose(logfile); + exit(0); // insure the process exit status is 0 + return 0; // ...and make main fit the ANSI spec. +} diff --git a/share/examples/isdn/contrib/answer.sh b/share/examples/isdn/contrib/answer.sh new file mode 100644 index 000000000000..34073d359923 --- /dev/null +++ b/share/examples/isdn/contrib/answer.sh @@ -0,0 +1,111 @@ +#!/bin/sh +#--------------------------------------------------------------------------- +# +# answer script for i4b isdnd +# --------------------------- +# +# last edit-date: [Fri May 25 15:21:05 2001] +# +# $FreeBSD$ +# +#--------------------------------------------------------------------------- +VARDIR=/var/isdn +LIBDIR=/usr/local/lib/isdn +LOGFILE=/tmp/answer.log + +NCALLFILE=$VARDIR/ncall +DATE=`date +%d%H` + +progname=${0##*/} +set -- $@ # have to split argument string !!! + +# ---------------------------------------------------------------------- + +usage () +{ + echo "usage: $progname -D device -d dest -s src" + exit 1 +} + +ncall () +{ + nfile=$1 + [ -f $nfile ] && read n < $nfile || n=0 + echo $(($n + 1)) > $nfile + printf "%.4d" $n +} + +# ---------------------------------------------------------------------- + +while getopts "D:d:s:" opt +do + case $opt + in +D) DEVICE=$OPTARG ;; +d) DEST=$OPTARG ;; +s) SRC=$OPTARG ;; + esac +done + +[ -c "$DEVICE" -a -n "$DEST" -a -n "$SRC" ] || usage; + +shift $(($OPTIND - 1)) + +# ---------------------------------------------------------------------- + +NCALL=`ncall $NCALLFILE` + +echo "$progname: device $DEVICE destination $DEST source $SRC " >>$LOGFILE + +{ + echo "Date: "`date` + echo "From: \"$SRC\"" + echo "To: \"$DEST\"" + echo +} >> $VARDIR/I.$NCALL.$DATE + +# ---------------------------------------------------------------------- + +tellnumber () +{ + number=$1 + digits=`echo $number | sed -e 's/\(.\)/\1 /g'` + + files="" + for digit in $digits + do + files="$files $LIBDIR/$digit.al" + done + cat $files +} + +# ---------------------------------------------------------------------- + +do_answer () +{ + [ -f $LIBDIR/beep.al ] && cat $LIBDIR/beep.al + [ -f $LIBDIR/msg.al ] && cat $LIBDIR/msg.al + [ -f $LIBDIR/beep.al ] && cat $LIBDIR/beep.al +} > $DEVICE + +do_record () +{ + cat $DEVICE > $VARDIR/R.$NCALL.$DATE +} + +do_tell () +{ + [ -f $LIBDIR/beep.al ] && cat $LIBDIR/beep.al + [ -f $LIBDIR/msg.al ] && cat $LIBDIR/msg.al + tellnumber $SRC + [ -f $LIBDIR/beep.al ] && cat $LIBDIR/beep.al +} > $DEVICE + +# ---------------------------------------------------------------------- + +case $progname +in +answer) do_answer ;; +record) do_answer; do_record ;; +tell) do_tell ;; +esac diff --git a/share/examples/isdn/contrib/convert.sh b/share/examples/isdn/contrib/convert.sh new file mode 100644 index 000000000000..b4a6e7d8d852 --- /dev/null +++ b/share/examples/isdn/contrib/convert.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# +# convert recorded message to WAV format, optionally send it via mail +# +# by: Stefan Herrmann +# Date: Fr 22 Mai 1998 14:18:40 CEST +# +# $FreeBSD$ + +CAT=/bin/cat +RM=/bin/rm +SOX=/usr/local/bin/sox +ALAW2ULAW=/usr/local/bin/alaw2ulaw +MAIL=/usr/bin/mail +GZIP=/usr/bin/gzip +ZIP=/usr/local/bin/zip +UUENCODE=/usr/bin/uuencode + +inputfile="" +outfilename="" +mailto="" +iF=0 +oF=0 +mF=0 + +set -- `getopt i:o:m: $*` + +if test $? != 0 +then + echo 'Usage: r2w -i -o .wav -m ' + exit 1 +fi + +for i +do + case "$i" + in + -i) + inputfile=$2 + iF=1 + shift + shift + ;; + -o) + outfilename=$2 + oF=1 + shift + shift + ;; + -m) + mailto=$2 + mF=1 + shift + shift + ;; + --) + shift + break + ;; + esac +done + +if [ $iF -eq 0 -o $oF -eq 0 ] +then + echo 'Usage: r2w -i -o .wav -m ' + exit 1 +fi + +if [ $iF -eq 1 -a $oF -eq 1 ] +then + echo + echo "converting $inputfile to $outfilename.wav ..." + + $CAT $inputfile | $ALAW2ULAW | $SOX -t raw -U -b -r 8000 - -t .wav $outfilename.wav +fi + +if [ $iF -eq 1 -a $oF -eq 1 -a $mF -eq 1 ] +then + echo "... and sending it via email to $mailto ..." + $UUENCODE $outfilename.wav message.wav | $MAIL -s"new message $outfilename" $mailto && $RM $outfilename.wav + # only usefull when sending over the internet + #$GZIP -c $outfilename.wav | $UUENCODE message.zip | $MAIL -s"Nachricht vom ISDN Anrufbeantworter" $mailto && $RM $outfilename.wav +fi + +echo "done." +echo diff --git a/share/examples/isdn/contrib/hplay.c b/share/examples/isdn/contrib/hplay.c new file mode 100644 index 000000000000..10660ac7b7b1 --- /dev/null +++ b/share/examples/isdn/contrib/hplay.c @@ -0,0 +1,241 @@ +/*---------------------------------------------------------------------------* + * + * rsynth driver to output to + * - an open isdn4bsd telephone connection or + * - an output file or + * - the /dev/audio device + * ---------------------------------------------------------------- + * + * tested with rsynth-2.0 + * + * written by Hellmuth Michaelis (hm@kts.org) + * + * last edit-date: [Fri May 25 15:21:33 2001] + * + * $FreeBSD$ + * + *---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "proto.h" +#include "getargs.h" +#include "hplay.h" +#include "l2u.h" + +#define SAMP_RATE 8000 +long samp_rate = SAMP_RATE; + +char *prog = "hplay"; + +static int use_audio = 1; +static int use_isdn = 0; +static int unit_no = 0; + +static int audio_fd = -1; +static int isdn_fd = -1; +static int file_fd = -1; + +char *audio_dev = "/dev/dsp"; +char *isdn_dev = "/dev/i4btel"; +static char *ulaw_file = NULL; + +int +audio_init(int argc, char *argv[]) +{ + char dev[64]; + int format = CVT_ALAW2ULAW; + + prog = argv[0]; + + argc = getargs("FreeBSD audio/i4b/file output driver",argc, argv, + "a", NULL, &use_audio, "use /dev/audio (default)", + "i", NULL, &use_isdn, "use /dev/i4btel", + "u", "%d", &unit_no, "/dev/i4btel unit number (def = 0)", + "f", "", &ulaw_file, "u-law output to file", + NULL); + + if(help_only) + return argc; + + if(ulaw_file) + { + if(strcmp(ulaw_file, "-") == 0) + { + file_fd = 1; /* stdout */ + } + else + { + file_fd = open(ulaw_file, O_WRONLY | O_CREAT | O_TRUNC, 0666); + if(file_fd < 0) + fprintf(stderr, "ERROR: cannot open %s, error = %s\n", ulaw_file, strerror(errno)); + } + } + + if(use_isdn) + { + sprintf(dev, "%s%d", isdn_dev, unit_no); + + if((isdn_fd = open(dev, O_WRONLY)) < 0) + { + fprintf(stderr, "ERROR: cannot open %s, error = %s\n", dev, strerror(errno)); + } + + if((ioctl(isdn_fd, I4B_TEL_SETAUDIOFMT, &format)) < 0) + { + fprintf(stderr, "ioctl I4B_TEL_SETAUDIOFMT failed: %s", strerror(errno)); + } + } + + if(use_audio) + { + audio_fd = open(audio_dev, O_WRONLY | O_NDELAY); + if(audio_fd < 0) + { + fprintf(stderr, "ERROR: cannot open %s, error = %s\n", audio_dev, strerror(errno)); + } + } + + return argc; +} + +void +audio_term() +{ + int format = CVT_NONE; + + if(isdn_fd >= 0) + { + if((ioctl(isdn_fd, I4B_TEL_SETAUDIOFMT, &format)) < 0) + { + fprintf(stderr, "ioctl I4B_TEL_SETAUDIOFMT failed: %s", strerror(errno)); + } + close(isdn_fd); + isdn_fd = -1; + } + + if(audio_fd >= 0) + { +#if 0 + ioctl(audio_fd, SNDCTL_DSP_SYNC, &dummy); +#endif + close(audio_fd); + audio_fd = -1; + } + + if(file_fd >= 0) + { + close(file_fd); + file_fd = -1; + } +} + +void +audio_play(int n, short *data) +{ + int ret; + unsigned char *p; + + if (n > 0) + { + unsigned char *converted = (unsigned char *) malloc(n); + int i; + + if(converted == NULL) + { + fprintf(stderr, "Could not allocate memory for conversion\n"); + exit(3); + } + + for (i = 0; i < n; i++) + { + converted[i] = short2ulaw(data[i]); + } + + if (isdn_fd >= 0) + { + p = converted; + errno = 0; + + while((ret = write(isdn_fd, p, n)) != n) + { + if(!errno) + { + p += ret; + if(p > (converted + n)) + break; + } + else + { + fprintf(stderr, "write /dev/i4btel ERROR: ret (%d) != n (%d), error = %s\n", ret, n, strerror(errno)); + break; + } + } + } + + for (i = 0; i < n; i++) + converted[i] = (data[i] - 32768) / 256; + + if(audio_fd >= 0) + { + p = converted; + + errno = 0; + + while((ret = write(audio_fd, p, n)) != n) + { + if(!errno) + { + p += ret; + if(p > (converted + n)) + break; + } + else + { + fprintf(stderr, "write /dev/dsp ERROR: ret (%d) != n (%d), error = %s\n", ret, n, strerror(errno)); + break; + } + } + } + + if(file_fd >= 0) + { + int ret; + p = converted; + + errno = 0; + + while((ret = write(file_fd, p, n)) != n) + { + if(!errno) + { + p += ret; + if(p > (converted + n)) + break; + } + else + { + fprintf(stderr, "write file ERROR: ret (%d) != n (%d), error = %s\n", ret, n, strerror(errno)); + break; + } + } + } + + free(converted); + } +} + +/* EOF */ diff --git a/share/examples/isdn/contrib/i4b-ppp-newbie.txt b/share/examples/isdn/contrib/i4b-ppp-newbie.txt new file mode 100644 index 000000000000..7d6c4b0870ae --- /dev/null +++ b/share/examples/isdn/contrib/i4b-ppp-newbie.txt @@ -0,0 +1,237 @@ +$FreeBSD$ + + PPP mit isdn4bsd + _________________________________________________________________ + + Version 1.01 + Datum: 22.02.1999 + Autor: [1]Dominik Brettnacher + + - Anmerkungen und Verbesserungsvorschläge sind willkommen - + + 1. vorab + Dieser Text soll Neulingen helfen, sich mittels isdn4bsd und BSD + per PPP z.B. bei ihrem Provider einwählen zu können. + isdn4bsd bringt einiges an Dokumentation und + Konfigurationsbeispielen mit, jedoch ist es nicht immer leicht, + die entsprechenden Hinweise gut miteinander zu kombinieren, so daß + am Schluß das dabei herauskommt, was man haben möchte. + 2. Wo bekomme ich isdn4bsd? + hier solle es keine allzu großen Probleme geben: isdn4bsd ist auf + dem FTP-Server [2]ftp.consol.de erhältlich. Man beachte dabei, daß + man sich nicht, wie üblich, als anonymous, sondern als isdn4bsd + einloggen muß. Benutzer von Browsern geben als Adresse + [3]ftp://isdn4bsd@ftp.consol.de und als Passwort ihre + eMail-Adresse an. + Wertvolle Informationen findet man in der Datei README. + 3. Welche ISDN-Karten werden unterstützt? + Informationen darüber findet man in der README-Datei. + 4. Ich benutze einen externen ISDN-Adapter - was nun? + Externe Adapter benötigen keine direkte Unterstützung, weil sie + über die serielle Schnittstelle angesteuert werden. Man kann also + das normale PPP benutzen. man ppp hilft hier sicher weiter. + 5. isdn4bsd installieren + Wie man isdn4bsd installiert, steht in der Datei + FreeBSD/INSTALLATION (für NetBSD und OpenBSD analog). Eine + Beispielkonfiguration des Kernel sieht so aus: +[...] +# +# i4b passive ISDN cards support (isic - I4b Siemens Isdn Chipset driver) +# note that the ``options'' and ``device'' lines must BOTH be defined ! +# +# Non-PnP Cards: +# -------------- +# +# AVM A1 or AVM Fritz!Card +options "AVM_A1" +device isic0 at isa? port 0x300 net irq 15 flags 4 vector isicintr +# +# ISDN Protocol Stack +# ------------------- +# +# Q.921 / layer 2 - i4b passive cards D channel handling +pseudo-device "i4bq921" +# +# Q.931 / layer 3 - i4b passive cards D channel handling +pseudo-device "i4bq931" +# +# layer 4 - i4b common passive and active card handling +pseudo-device "i4b" +# +# ISDN devices +# ------------ +# +# userland driver to do ISDN tracing (for passive cards only) +pseudo-device "i4btrc" 4 +# +# userland driver to control the whole thing +pseudo-device "i4bctl" +# +# userland driver for access to raw B channel +#pseudo-device "i4brbch" 4 +# +# userland driver for telephony +#pseudo-device "i4btel" 2 +# +# network driver for IP over raw HDLC ISDN +#pseudo-device "i4bipr" 4 +# enable VJ header compression detection for ipr i/f +#options IPR_VJ +# +# network driver for sync PPP over ISDN +pseudo-device "i4bisppp" 1 +pseudo-device sppp 1 +# +#--------------------------------------------------------------------------- +[...] + Nachdem ein neuer Kernel kompiliert und das System neugestartet + wurde, kann es weiter gehen. + 6. Konfiguration isdnd.rc + Die für ISDN wichtigste Konfigurationsdatei ist + /etc/isdn/isdnd.rc. Mit man isdnd.rc erhält man Informationen über + die Einstellungen, die man dort vornehmen kann. Im Folgenden ein + Beispiel: + + +#============================================================================== +# SYSTEM section: isdnd global configuration parameters +#============================================================================== +system + +# accounting +# ---------- + +acctall = on # generate info for everything +acctfile = /var/log/isdnd.acct # name & location of accounting file +useacctfile = yes # generate accouting info to file + +# monitor +# ------- + +monitor-allowed = no # global switch: monitor on/off +monitor-port = 451 # default monitor TCP port + +# Monitor rights are granted due to the most specific host/net spec, i.e. in +# the example below host 192.168.1.2 will have the rights specified on that +# line, even so it belongs to net 192.168.1.0/24 as well. +# +# A monitor specification may either be: +# +# - the name of a local (UNIX-domain) socket; this MUST start with a "/" +monitor = "/var/run/isdn-monitor" +monitor-access = fullcmd +monitor-access = channelstate, logevents +monitor-access = callin, callout + +# ratesfile +# --------- + +ratesfile = /etc/isdn/isdnd.rates # name & location of rates file + +# regular expression pattern matching +# ----------------------------------- + +#regexpr = "connected.*KTS" # look for matches in log messages +#regprog = connectKTS # execute program when match is found + +# realtime priority section +# ------------------------- + +rtprio = 25 # modify isdnd's process priority + +############################################################################### +entry +name = lf +usrdevicename = isp +usrdeviceunit = 0 +isdncontroller = 0 +isdnchannel = -1 +local-phone-incoming = 012345678 +remote-phone-incoming = 876543210 +local-phone-dialout = 012345678 +remote-phone-dialout = 876543210 +remdial-handling = first +dialin-reaction = accept +dialout-type = normal +b1protocol = hdlc +idletime-incoming = 240 +idletime-outgoing = 30 +earlyhangup = 5 +ratetype = 0 +unitlength = 90 +unitlengthsrc = rate +dialretries = 3 +dialrandincr = on +recoverytime = 25 + +connectprog = is-up +disconnectprog = is-down + + Wichtig sind hier für den Neuling die vier *-phone-* Einträge, die + jeweils die lokale Rufnummer und die der Gegenstelle für ein- und + ausgehende Verbindungen angeben. + + 7. ISDN-Verbindungen aufbauen + um ISDN-Verbindungen aufzubauen, bedarf es einiger Befehle, die + beim Systemstart aufgerufen werden. Man kann sie zum Beispiel am + Ende von /etc/rc.local unterbringen. Hier gibt es aber durchaus + noch andere Lösungen: + [...] + # start ISDN + echo -n 'ppp / ISDN...' + echo -n 'isdnd...' + /usr/local/bin/isdnd + echo -n 'ifconfig...' + ifconfig isp0 link1 0.0.0.0 1.1.1.1 netmask 0xffffff00 + ifconfig isp0 down + echo -n 'sppp...' + spppcontrol isp0 myauthproto=pap myauthname="xxx" + myauthsecret="xxx" hisauthproto=none + echo -n 'ifconfig...' + ifconfig isp0 up + echo -n 'setting routes...' + route add default -interface isp0 + echo '.' + Ändern muß man hier eventuell die Zieladresse des Providers (im + Beispiel 1.1.1.1). Man bekommt diese entweder vom Provider, oder + aber man muß einen Versuch daransetzen, sie selbst herauszufinden. + Wie das funktioniert, steht in der Datei FAQ des isdn4bsd-Paketes. + Auch am Aufruf von spppcontrol (Vorsicht: spppcontrol bis + hisauthproto=none ist eine Zeile!) muß noch etwas umgestellt + werden: + + myauthproto steht für das Authentifizierungsprotokoll. + Möglich sind pap oder chap. + + myauthname ist der PPP-Benutzername. + + myauthsecret ist das PPP-Kennwort. + Wenn man nun die Befehle in /etc/rc.local ausführt, kann man mit + einem ping auf eine beliebige Adresse außerhalb des lokalen Netzes + eine Verbindung öffnen. Sie wird automatisch nach einiger + Inaktivität (siehe isdnd.rc) wieder geschlossen. + + 8. Es funktioniert nicht - was kann ich tun? + Es gibt einige Möglichkeiten zur Fehlerdiagnose: + + dmesg gibt Aufschluß darüber, ob die Karte richtig erkannt + wurde. + + ifconfig (siehe rc.local) kann mit dem Parameter debug + aufgerufen werden und gibt dann einiges an Informationen aus. + + die Nachrichten in /var/log/messages können außerdem + hilfreich sein + + 9. wer kann mir helfen? + + die erste Adresse für ISDN-Probleme ist die Mailingliste + [4]freebsd-isdn@freebsd.org - man bestellt sie, indem man + eine Mail mit dem Text subscribe freebsd-isdn an + [5]majordomo@freebsd.org schickt. + + auch die deutschsprachige Mailingliste kann hilfreich sein. + Mit einer Mail an [6]majordomo@de.freebsd.org, die im Text + subscribe de-bsd-questions enthält bestellt man sie. + _________________________________________________________________ + +References + + 1. mailto:domi@saargate.de + 2. ftp://isdn4bsd@ftp.consol.de/ + 3. ftp://isdn4bsd@ftp.consol.de/ + 4. mailto:freebsd-isdn@freebsd.org + 5. mailto:majordomo@freebsd.org + 6. mailto:majordomo@de.freebsd.org diff --git a/share/examples/isdn/isdnctl b/share/examples/isdn/contrib/isdnctl similarity index 100% rename from share/examples/isdn/isdnctl rename to share/examples/isdn/contrib/isdnctl diff --git a/share/examples/isdn/isdnd_acct b/share/examples/isdn/contrib/isdnd_acct similarity index 98% rename from share/examples/isdn/isdnd_acct rename to share/examples/isdn/contrib/isdnd_acct index be97a4ae458f..21223b7cd0f4 100644 --- a/share/examples/isdn/isdnd_acct +++ b/share/examples/isdn/contrib/isdnd_acct @@ -29,12 +29,10 @@ # accounting report script for the isdnd daemon accounting info # ------------------------------------------------------------- # +# last edit-date: [Fri May 25 15:28:20 2001] +# # $FreeBSD$ # -# last edit-date: [Wed May 5 16:24:16 1999] -# -# -hm updated for isdnd support -# #--------------------------------------------------------------------------- # where the isdnd accounting file resides diff --git a/share/examples/isdn/contrib/isdnd_acct.pl b/share/examples/isdn/contrib/isdnd_acct.pl new file mode 100644 index 000000000000..03062160104d --- /dev/null +++ b/share/examples/isdn/contrib/isdnd_acct.pl @@ -0,0 +1,258 @@ +#!/usr/bin/perl +# +#ich habe zwei vielleicht n?tzliche Erweiterungen an isdn_pacct +#gemacht: +# +# 1) Man kann den Namen der Accounting-Datei angeben. Ich +# habe Accounting-Files nach Telekom-Rechnung aufgeteilt +# und kann diese so sehr sch?n nachvollziehen. +# +# 2) Die Abrechnung wird nach Einheitenl?ngen aufgelistet. +# Leider wird zur Zeit immer Nahzone verwendet (isdnd.rates +# wird ausgelesen), und Feiertage stehen als erstes auf +# der TODO-Liste. Wenn man dieses Feature durch einen +# Switch anschaltet, kann man es sogar unauff?llig in die +# Distribution aufnehmen. +# +# Mir hilft diese Abrechnung, an mir zu arbeite und mehr +# Tests und Zug?nge nachts durchzuf?hren... Aber die meisten +# Einheiten werden immer noch im 90s-Takt verbraucht :-( +# +# $FreeBSD$ +# +#--------------------------------------------------------------------------- +# +# Copyright (c) 1994, 1996 Hellmuth Michaelis. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by Hellmuth Michaelis +# 4. Neither the name of the author nor the names of any co-contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +#--------------------------------------------------------------------------- +# +# accounting script for the isdn daemon accounting info +# ----------------------------------------------------- +# +# last edit-date: [Fri May 25 15:22:26 2001] +# +# -hm my first perl program :-) +# -hm sorting the output +# -hm adding grand total +# +#--------------------------------------------------------------------------- + +sub wday { + local ($y, $m, $d) = @_; + local ($nday, @mon); + + @mon = (0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337); +# M A M J J A S O N D J F + + if ($m > 2) { + $m -= 3; + } else { + $m += 9; + $y--; + } + if ($y < 1600) { + return -1; + } + $y -= 1600; + $nday = $y * 365 + $mon[$m] + $d + + int($y / 4) - int($y / 100) + int($y / 400); + ($nday + 2) % 7; +} + +# where the isdnd accounting file resides +if ($#ARGV == 0) { + $ACCT_FILE = $ARGV[0]; +} else { + $ACCT_FILE = "/var/log/isdnd.acct"; +} + +# $PERIOD_FILE = "/usr/local/etc/isdnd.periods"; +# # read periods that need to be separately listed +# if (open(IN, $PERIOD_FILE)) { +# while () { +# chop; +# ($start, $end) = split(/ /); +# push(@p_start, $start); +# push(@p_end, $end); +# } +# close(IN); +# } + +$RATES_FILE = "/etc/isdn/isdnd.rates"; +if (open(IN, $RATES_FILE)) { + while() { + chop; + if (! /^ra0/) { + next; + } + ($ra0, $day, $rest) = split(/[ \t]+/, $_, 3); + @periods = split(/[ \t]+/, $rest); + foreach $period (@periods) { + ($h_start, $m_start, $h_end, $m_end, $secs) = + $period =~ /(.+)\.(.+)-(.+)\.(.+):(.+)/; + for ($h = int($h_start); $h < $h_end; $h++) { + $secs{$day, $h} = $secs; + } + } + } + close(IN); +} + +# the charge for a unit, currently 0,12 DM +$UNIT_PRICE = 0.12; + +# open accounting file +open(IN, $ACCT_FILE) || + die "ERROR, cannot open $ACCT_FILE !\n"; + +# set first thru flag +$first = 1; + +# process file line by line +while () +{ + # remove ( and ) from length and bytecounts + tr/()//d; + + # split line into pieces + ($from_d, $from_h, $dash, $to_d, $to_h, $name, $units, $secs, $byte) + = split(/ /, $_); + + # get starting date + if($first) + { + $from = "$from_d $from_h"; + $first = 0; + } + + # split bytecount + ($inb, $outb) = split(/\//, $byte); + + # if user wants to account time periods, put this to the right + # slot(s) + ($hour, $minute, $second) = split(/:/, $from_h); + ($day, $mon, $year) = split(/\./, $from_d); + $day = &wday('19' . $year, $mon, $day); + if ($secs{$day, int($hour)}) { + $secs = $secs{$day, int($hour)}; + # process fields + $p_secs{$name, $secs} += $secs; + $p_calls{$name, $secs}++; + $p_units{$name, $secs} += $units; + $p_charge{$name, $secs} += $units * $UNIT_PRICE; + $p_inbytes{$name, $secs} += $inb; + $p_outbytes{$name, $secs} += $outb; + $p_bytes{$name, $secs} = $p_bytes{$name, $secs} + $inb + $outb; + } + + # process fields + $a_secs{$name} += $secs; + $a_calls{$name}++; + $a_units{$name} += $units; + $a_charge{$name} += $units * $UNIT_PRICE; + $a_inbytes{$name} += $inb; + $a_outbytes{$name} += $outb; + $a_bytes{$name} = $a_bytes{$name} + $inb + $outb; +} + +# close accouting file +close(IN); + +# write header +print "\n"; +print " ISDN Accounting Report ($from -> $to_d $to_h)\n"; +print " =================================================================\n"; + +#write the sum for each interface/name +foreach $n (sort(keys %a_secs)) +{ + $o_secs = $a_secs{$n}; + $gt_secs += $o_secs; + $o_calls = $a_calls{$n}; + $gt_calls += $o_calls; + $o_units = $a_units{$n}; + $gt_units += $o_units; + $o_charge = $a_charge{$n}; + $gt_charge += $o_charge; + $o_inbytes = $a_inbytes{$n}; + $gt_inbytes += $o_inbytes; + $o_outbytes = $a_outbytes{$n}; + $gt_outbytes += $o_outbytes; + $o_bytes = $a_bytes{$n}; + $gt_bytes = $o_bytes; + $name = $n; + write; + + foreach $i (keys %p_secs) { + ($nam, $secs) = split(/$;/, $i); + if ($nam ne $n) { + next; + } + $o_secs = $p_secs{$i}; + $o_calls = $p_calls{$i}; + $o_units = $p_units{$i}; + $o_charge = $p_charge{$i}; + $o_inbytes = $p_inbytes{$i}; + $o_outbytes = $p_outbytes{$i}; + $o_bytes = $p_bytes{$i}; + $name = sprintf(' %5.1fs', $secs / 10); + write; + } +} + +$o_secs = $gt_secs; +$o_calls = $gt_calls; +$o_units = $gt_units; +$o_charge = $gt_charge; +$o_inbytes = $gt_inbytes; +$o_outbytes = $gt_outbytes; +$o_bytes = $gt_bytes; +$name = "Total"; + +print "======= ====== ===== ===== ======== ============ ============ ============\n"; +write; + +print "\n\n"; +exit; + +# top of page header +format top = + +Name charge units calls secs inbytes outbytes bytes +------- ------ ----- ----- -------- ------------ ------------ ------------ +. + +# record template +format STDOUT = +@<<<<<< @##.## @#### @#### @####### @########### @########### @########### +$name, $o_charge, $o_units, $o_calls, $o_secs, $o_inbytes, $o_outbytes, $o_bytes +. + +# EOF diff --git a/share/examples/isdn/contrib/isdntelmux.c b/share/examples/isdn/contrib/isdntelmux.c new file mode 100644 index 000000000000..318ebfcb937e --- /dev/null +++ b/share/examples/isdn/contrib/isdntelmux.c @@ -0,0 +1,197 @@ +/* + * Copyright (c) 1999 Michael Reifenberger (Michael@Reifenberger.com). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + *--------------------------------------------------------------------------- + * + * i4btemux - record while playing + * =============================== + * + * $FreeBSD$ + * + *----------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// DECL DEFS +#define BUFLEN 2048 +#define MAXBLOCKS_DEFAULT 23 + +// DECL VARS +int ibytes = 0; +int obytes = 0; +int maxbytes = (BUFLEN * MAXBLOCKS_DEFAULT); + +int xfd = -1, xact = 0; +int ifd = -1, iact = 0; +int ofd = -1; +FILE *dfp = NULL; +int opt_dbg = 0; +int maxfd = 0; +fd_set set; +struct timeval timeout; +char nambuf[PATH_MAX]; +int ch; + +// DECL FUNC +void ifd_hdlr( void); +void xfd_hdlr( void); +void usage( void); +void dbg( char *fmt, ... ); + +// DEF FUNC +int main (int argc, char **argv) { + int dummy; + int x = -1; + + dfp = stderr; + while( ( ch = getopt( argc, argv, "x:i:o:b:D:")) != -1 ){ + switch(ch){ + case 'b': + x = atoi(optarg); + maxbytes = x * BUFLEN; + break; + case 'i': + ifd = open( optarg, O_RDONLY ); + iact = 1; + break; + case 'o': + ofd = open( optarg, O_WRONLY|O_TRUNC|O_CREAT ); + break; + case 'x': + xfd = open( optarg, O_RDWR ); + xact = 1; + break; + case 'D': + opt_dbg = 1; + if( (dfp = fopen( optarg, "w" )) < 0) { + dfp = stderr; + dbg("Err for opening %s\n", optarg); + exit(1); + } + break; + case '?': + default: + usage(); + break; + } + } + if( ( xfd < 0 ) || ( ifd < 0 ) || ( ofd < 0 ) ) { + dbg("Err opening one ore more Files.\n"); + dbg("xfd: %d, ifd: %d, ofd: %d\n", xfd, ifd, ofd ); + usage(); + } + + if((x = ioctl(xfd, I4B_TEL_EMPTYINPUTQUEUE, &dummy)) < 0){ + dbg("Err I4B_TEL_EMPTYINPUTQUEUE\n"); + } + + while( (iact == 1) || ( (obytes < maxbytes) && (xact == 1) ) ){ + FD_ZERO( &set); + if( iact == 1){ + FD_SET( ifd, &set); + if( ifd > maxfd) + maxfd = ifd; + dbg("FSET ifd\n"); + } + if( xact == 1){ + FD_SET( xfd, &set); + if( xfd > maxfd) + maxfd = xfd; + dbg("FSET xfd\n"); + } + x=select( maxfd+1, &set, NULL, NULL, NULL); + if( x > 0){ + if( (iact == 1) && FD_ISSET( ifd, &set) ){ + ifd_hdlr(); + } + if( (xact == 1) && FD_ISSET( xfd, &set) ){ + xfd_hdlr(); + } + } + } + dbg("exit0\n"); + return(0); +} + +void ifd_hdlr( void) { + int x; + unsigned char buf[BUFLEN]; + + x = read( ifd, buf, BUFLEN); + dbg("ifd read %d bytes\n", x); + if( x > 0 ){ + write( xfd, buf, x); + ibytes += x; + dbg("xfd %d bytes written to %d\n", x, ibytes); + } else { + iact = 0; + } +} + +void xfd_hdlr( void) { + int x; + unsigned char buf[BUFLEN]; + + x = read( xfd, buf, BUFLEN); + dbg("xfd read %d bytes\n", x); + if( x > 0){ + write( ofd, buf, x); + obytes += x; + dbg("ofd %d bytes written to %d\n", x, obytes); + } else { + xact = 0; + } +} + +void usage( void) { + fprintf(dfp, "isdntelmux V.1\n"); + fprintf(dfp, "usage: isdntelmux -x device -i ifile -o ofile [-b blocks]\n"); + exit(1); +} + +void dbg( char *fmt, ... ) { + va_list ap; + + if( opt_dbg == 0 ) + return; + va_start( ap, fmt ); + vfprintf( dfp, fmt, ap); + va_end(ap); +} diff --git a/share/examples/isdn/contrib/mrtg-isp0.sh b/share/examples/isdn/contrib/mrtg-isp0.sh new file mode 100644 index 000000000000..bdc9671883ac --- /dev/null +++ b/share/examples/isdn/contrib/mrtg-isp0.sh @@ -0,0 +1,53 @@ +#!/bin/sh +#--------------------------------------------------------------------------- +# +# collect callout and callback statistics for the isp0 i/f +# +# enable budget callout and callback restrictions and file +# rotation in the isdnd.rc file. +# +# last edit-date: [Fri May 25 15:22:45 2001] +# +# $FreeBSD$ +# +#--------------------------------------------------------------------------- +# +#--------------------------------------------------------------------------- +# this is the entry for mrtg in mrtg.cfg +#--------------------------------------------------------------------------- +# Target[ernie.cstat.isp0]: `/usr/local/etc/mrtg/util/mrtg-isp0.sh` +# MaxBytes[ernie.cstat.isp0]: 10 +# AbsMax[ernie.cstat.isp0]: 200 +# Title[ernie.cstat.isp0]: isp0: callouts / callbacks +# PageTop[ernie.cstat.isp0]:

isp0: callouts /callbacks

+# Options[ernie.cstat.isp0]: gauge, nopercent, integer +# YLegend[ernie.cstat.isp0]: co / cb +# ShortLegend[ernie.cstat.isp0]: n +# Legend1[ernie.cstat.isp0]: callouts +# Legend2[ernie.cstat.isp0]: callbacks +# LegendI[ernie.cstat.isp0]: callouts: +# LegendO[ernie.cstat.isp0]: callbacks: +# WithPeak[ernie.cstat.isp0]: ymwd +# +#--------------------------------------------------------------------------- +# this is the shell script run by mrtg +#--------------------------------------------------------------------------- +if [ -r /var/log/isdn/callouts.isp0 ] +then + cat /var/log/isdn/callouts.isp0 | awk '{print $3}' +else + echo 0 +fi + +if [ -r /var/log/isdn/callbacks.isp0 ] +then + cat /var/log/isdn/callbacks.isp0 | awk '{print $3}' +else + echo 0 +fi + +uptime | cut -c 12-18 +uname -nsr + +exit 0 +