From 632921995c58c6dadced140ca4f2aed2932e3b74 Mon Sep 17 00:00:00 2001 From: gnhb Date: Sat, 10 Apr 2010 22:07:48 +0700 Subject: 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_.query files to /var/etc. Now, a simple calculation of the age of the /tmp/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 up and _router files. There is still the rm -r nameserver_ 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 : call. I think it's probably not necessary any more. --- etc/inc/interfaces.inc | 19 ------------- etc/inc/pfsense-utils.inc | 61 +++++++++++++++------------------------- usr/local/sbin/ppp-linkdown | 11 ++++---- usr/local/sbin/ppp-log-uptime.sh | 5 ++++ usr/local/sbin/ppp-uptime.sh | 3 ++ 5 files changed, 36 insertions(+), 63 deletions(-) create mode 100644 usr/local/sbin/ppp-log-uptime.sh create mode 100644 usr/local/sbin/ppp-uptime.sh diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 9dc9f9b..8bf674f 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -1033,25 +1033,6 @@ EOD; fwrite($fd, $mpdconf); fclose($fd); - $fdlnkq = fopen("{$g['varetc_path']}/mpd_{$interface}.query", "w"); - if (!$fdlnkq) { - /* NOTE: It is not fatal if we cannot write the query.") */ - log_error("Error: cannot open mpd_{$interface}.query in interface_ppp_configure().\n"); - } else { - $linkquery = <<> /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 -- cgit v1.1