diff options
author | gnhb <gnoahb@gmail.com> | 2010-04-10 22:07:48 +0700 |
---|---|---|
committer | gnhb <gnoahb@gmail.com> | 2010-04-10 22:07:48 +0700 |
commit | 632921995c58c6dadced140ca4f2aed2932e3b74 (patch) | |
tree | 5636313589460fcc625b7fa9ecb86ab51737fb0b /usr/local/sbin | |
parent | 73ee49f20460fe724258153aabcd61be8bc4f52f (diff) | |
download | pfsense-632921995c58c6dadced140ca4f2aed2932e3b74.zip pfsense-632921995c58c6dadced140ca4f2aed2932e3b74.tar.gz |
Implement reporting and logging of historical PPP uptime with data persistent through reboot.
Also, change the way uptime is captured. The mpd console is no longer used to
get PPP uptime data, which will prevent spamming of PPP logs with console access messages.
This means we no longer have to write out mpd_<interface>.query files to /var/etc.
Now, a simple calculation of the age of the /tmp/<interface>up file is used. This
gives the same data within the second as the console data so it seems acceptable.
I removed some "rm -f" calls from ppp-linkdown as there was already code in interfaces.inc
interface_bring_down function that unlinks the <interface>up and <interface>_router files.
There is still the rm -r nameserver_<interface> call in the linkdown script. Maybe this should
be moved to the interfac_bring_down function for consistency? Also, I commented out the
ngctl shutdown <interface>: call. I think it's probably not necessary any more.
Diffstat (limited to 'usr/local/sbin')
-rwxr-xr-x | usr/local/sbin/ppp-linkdown | 11 | ||||
-rw-r--r-- | usr/local/sbin/ppp-log-uptime.sh | 5 | ||||
-rw-r--r-- | usr/local/sbin/ppp-uptime.sh | 3 |
3 files changed, 14 insertions, 5 deletions
diff --git a/usr/local/sbin/ppp-linkdown b/usr/local/sbin/ppp-linkdown index 83d1790..420216f 100755 --- a/usr/local/sbin/ppp-linkdown +++ b/usr/local/sbin/ppp-linkdown @@ -1,7 +1,8 @@ #!/bin/sh - +if [ -f /tmp/$1up ] && [ -f /conf/$1.log ]; then + seconds=$((`date -j +%s` - `/usr/bin/stat -f %m /tmp/$1up`)) + /usr/local/sbin/ppp-log-uptime.sh $seconds $1 & +fi # delete the node just in case mpd cannot do that -/usr/sbin/ngctl shutdown $1: -/bin/rm -f /var/etc/nameserver_$1 -/bin/rm -f /tmp/$1_router -/bin/rm -f /tmp/$1up +#/usr/sbin/ngctl shutdown $1: +/bin/rm -f /var/etc/nameserver_$1
\ No newline at end of file diff --git a/usr/local/sbin/ppp-log-uptime.sh b/usr/local/sbin/ppp-log-uptime.sh new file mode 100644 index 0000000..6fd8def --- /dev/null +++ b/usr/local/sbin/ppp-log-uptime.sh @@ -0,0 +1,5 @@ +#!/bin/sh +#write the uptime in seconds to the persistent log in /conf/ +/etc/rc.conf_mount_rw +/bin/echo `date -j +%Y.%m.%d-%H:%M:%S` $1 >> /conf/$2.log +/etc/rc.conf_mount_ro diff --git a/usr/local/sbin/ppp-uptime.sh b/usr/local/sbin/ppp-uptime.sh new file mode 100644 index 0000000..d7a8441 --- /dev/null +++ b/usr/local/sbin/ppp-uptime.sh @@ -0,0 +1,3 @@ +#!/bin/sh +#get ppp uptime from age of /tmp/{interface}up file +[ -f /tmp/$1up ] && /bin/echo $((`date -j +%s` - `/usr/bin/stat -f %m /tmp/$1up`))
\ No newline at end of file |