isdnlog enhancments

taken from Debian sid isdnlog-diffs.patch without
the directory change for the logfile

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
This commit is contained in:
Karsten Keil 2012-02-25 15:20:55 +01:00
parent 1260aa752f
commit dce2c7ee85
8 changed files with 84 additions and 34 deletions

View File

@ -0,0 +1,18 @@
V:-0.1 default [2001/10/10]
W:1 Monday
W:2 Tuesday
W:3 Wednesday
W:4 Thursday
W:5 Friday
W:6 Saturday
W:7 Sunday
W:W weekday
W:E weekend
W:H holiday
W:* everyday
D:1.1 New Year's Day
D:easter Easter
D:1.5 May Day
D:25.12 Christmas

12
isdnlog/rate-default.dat Normal file
View File

@ -0,0 +1,12 @@
V:0.01-default [2001/10/10]
U:%.3f UNITS
P:10 .
B:1234
D:x
# 1 currency unit per minute
Z:1 .
A:*
T:*/*=1.00/60

View File

@ -0,0 +1 @@
P:10

View File

@ -1,37 +1,53 @@
#!/bin/sh
# very simple reload-example for the new chargemax feature of isdnlog
# this is called by isdnlog every time we get a AOCD and chargesum of
# active device is greater then CHARGEMAX.
# there are three parameter available:
# Very simple reload default for the chargemax feature of isdnlog.
# This is called by isdnlog every time we get a AOCD and chargesum of
# active device is greater than CHARGEMAX.
# there are three parameters available:
#
# first ($1) is chargesum-CHARGEMAX
# second ($2) is ALIAS as defined in ISDNLOG.CONF
# third ($3) is total chargesum for active device
msg=`tempfile -p isdn`
myecho() {
echo "$@" >> $msg
}
case "$1" in
5\.*)
echo "WARNING, charge-limit set by CHARGEMAX is reached!" >> /dev/console
echo "$2 is talking to much!" >> /dev/console
# /bin/aplay /usr/sounds/attention.au
myecho "WARNING, charge-limit set by CHARGEMAX is reached!"
myecho "$2 is talking too much!"
# /bin/play /usr/sounds/attention.au
;;
10\.* | 11\.* )
echo "WARNING, $2 got charge-overflow == $1, total chargesum == $3" >> /dev/console
echo "next chargeint will cause i4l to stop" >> /dev/console
# /bin/aplay /usr/sounds/earthdestruction.au
myecho "WARNING, $2 got charge-overflow == $1, total chargesum == $3"
myecho "next chargeint will cause i4l to stop"
# /bin/play /usr/sounds/earthdestruction.au
;;
20\.* | 21\.* )
echo "reload got charge-overflow == $1, now i4l will be stopped!" >> /dev/console
/sbin/init.d/i4l stop
myecho "reload got charge-overflow == $1, now ipppd will be stopped!"
/sbin/init.d/isdnutils stop ipppd
;;
25\.* | 26\.* )
echo "aeh, still alive?! so we'll do a reboot!!" >> /dev/console
# /bin/aplay /usr/sounds/crash.au
/sbin/reboot
# echo "aeh, still alive?! so we'll do a reboot!!" >> /dev/console
# /bin/play /usr/sounds/crash.au
# /sbin/reboot
myecho "still alive?! Stopping ISDN subsystem!"
/usr/sbin/isdnctrl system off
;;
esac
echo "got charge_ov=$1 dev=$2 scharge=$3 " >> /dev/console
myecho "got charge_ov=$1 dev=$2 scharge=$3 "
if [ -s "$msg" ]; then
logger -f $msg -p daemon.notice -t isdnlog
cat $msg >> /dev/console
fi
rm -f $msg
exit 0

View File

@ -43,15 +43,15 @@ distclean: clean
-rm config.{status,log,h,cache} Makefile .depend
install-dirs:
install -d -m0755 $(MAN1DIR) $(MAN3DIR) $(LIBDIR) $(BINDIR) \
$(INCDIR)
install -d -m0755 $(MAN1DIR) $(MAN3DIR) $(LIBDIR) $(BINDIR) $(INCDIR)
install:
install -m0755 $(BINS) $(BINDIR)
install -m0644 $(MAN1) $(MAN1DIR)
install -m0644 $(MAN3) $(MAN3DIR)
install -m0644 $(LIBS) $(LIBDIR)
install -m0644 freecdb.h freecdbmake.h $(INCDIR)
true
# install -m0755 $(BINS) $(BINDIR)
# install -m0644 $(MAN1) $(MAN1DIR)
# install -m0644 $(MAN3) $(MAN3DIR)
# install -m0644 $(LIBS) $(LIBDIR)
# install -m0644 freecdb.h freecdbmake.h $(INCDIR)
cdbdump: cdbdump.o cdb_unpack.o

View File

@ -145,8 +145,9 @@ Connect to a running isdnrate daemon. This avoids long startup times.
.P
.B \-D
Start as a daemon, waiting for connections from a client. The socket
.I /tmp/isdnrate
is created, which clients can connect to.
.I /var/run/isdnrate/socket
is created, which clients can connect to
(the socket can be changed by using the -O option).
.P
.B \-D2
Start as a daemon and go background.
@ -171,8 +172,8 @@ Show info about following numbers. If no provider is given, the preselected
provider is used.
.P
.BI \-O socketfile
Write socket to given filename on start of daemon. Default is
.IR tmp/isdnrate .
Use given filename as the socket on start of daemon. Default is
.IR /var/run/isdnrate/socket .
.P
.BI \-P piddir
Write own PID to

View File

@ -622,6 +622,13 @@
#define _GNU_SOURCE 1
#include <sys/types.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
@ -630,12 +637,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>

View File

@ -523,7 +523,8 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
from=sto;
sto=temp;
}
strncpy(newfrom, from, LENGTH-1);
if (newfrom != from)
memmove(newfrom, from, LENGTH-1);
while (strlen(newfrom)) {
UL lifrom = (UL) atol(newfrom); /* keys could be long */
US ifrom = (US) lifrom;