Re: /etc/periodic is hopefully perl-free [was: Perl script rewrites]

2002-05-28 Thread Mark Murray

> On 2002-05-19 12:20, Mark Murray wrote:
> > What I've done so far (and only slightly tested) is available at
> > http://www.FreeBSD.org/~keramida/diff/periodic.diff
> 
> Untested, but seemingly complete, the patch is available for review at
> the address mentioned above.  I am thinking a nice way to test this
> would be:

This looks excellent!

For my miniscule data set and manual test, things seem OK.

M
-- 
o   Mark Murray
\_
O.\_Warning: this .sig is umop ap!sdn

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



/etc/periodic is hopefully perl-free [was: Perl script rewrites]

2002-05-28 Thread Giorgos Keramidas

On 2002-05-19 12:20, Mark Murray wrote:
> What I've done so far (and only slightly tested) is available at
> http://www.FreeBSD.org/~keramida/diff/periodic.diff

Untested, but seemingly complete, the patch is available for review at
the address mentioned above.  I am thinking a nice way to test this
would be:

# cd /usr/src/etc/periodic
# cvs -q up -APCd

Clean repository versions of the files are in ${.CURDIR}

# make cleandir install

Here run periodic daily, and wait until it completes.

# cd /usr/src/etc/periodic
# patch -p1 < patch-file
# make cleandir install

Now run daily again and test to see that both versions of the daily
output messages have identical output.  The attached patch seems to
work for me.  Since my logfiles do not have data for all the possible
cases, I would be grateful if anyone of you has comments on the
changes.  If you can see any very obvious mistakes, bugs, or other
things you want changed, please do tell.

The patch follows between lines that match '^%%%$'.

- Giorgos

%%%
Index: etc/periodic/daily/440.status-mailq
===
RCS file: /home/ncvs/src/etc/periodic/daily/440.status-mailq,v
retrieving revision 1.8
diff -u -r1.8 440.status-mailq
--- etc/periodic/daily/440.status-mailq 7 May 2002 13:11:05 -   1.8
+++ etc/periodic/daily/440.status-mailq 28 May 2002 20:47:54 -
@@ -25,7 +25,7 @@
rc=$(case "$daily_status_mailq_shorten" in
[Yy][Ee][Ss])
mailq |
-   perl -ne  'print if /^\s+\S+@/' |
+   egrep -e '^[[:space:]]+[^[:space:]]+@' |
sort |
uniq -c |
sort -nr |
@@ -45,7 +45,7 @@
rc=$(case "$daily_status_mailq_shorten" in
[Yy][Ee][Ss])
mailq -Ac |
-   perl -ne  'print if /^\s+\S+@/' |
+   egrep -e '^[[:space:]]+[^[:space:]]+@' |
sort |
uniq -c |
sort -nr |
Index: etc/periodic/daily/460.status-mail-rejects
===
RCS file: /home/ncvs/src/etc/periodic/daily/460.status-mail-rejects,v
retrieving revision 1.14
diff -u -r1.14 460.status-mail-rejects
--- etc/periodic/daily/460.status-mail-rejects  30 Apr 2002 17:07:32 -  1.14
+++ etc/periodic/daily/460.status-mail-rejects  28 May 2002 20:47:54 -
@@ -51,8 +51,9 @@
done
cat /var/log/maillog
} |
-   perl -ne "print \"\$2\n\"
-   if (/reject=/ and 
/^$start.*ruleset=check_\S+,\s+arg1=(<[^@]+@)?([^>,]+).*reject=/o);" |
+   fgrep 'reject=' |
+   egrep -e 
+"^$start.*ruleset=check_[^[:space:]]+,[[:space:]]+arg1=(<[^@]+@)?([^>,]+).*reject=.*" 
+|
+   sed -e 's/.*arg1=//' -e 's/.*@//' -e 's/[>[:space:]].*$//' |
sort -f | uniq -ic | sort -fnr | tee /dev/stderr | wc -l)
[ $rc -gt 0 ] && rc=1
fi;;
Index: etc/periodic/daily/470.status-named
===
RCS file: /home/ncvs/src/etc/periodic/daily/470.status-named,v
retrieving revision 1.2
diff -u -r1.2 470.status-named
--- etc/periodic/daily/470.status-named 26 Jul 2001 02:37:12 -  1.2
+++ etc/periodic/daily/470.status-named 28 May 2002 20:47:54 -
@@ -25,30 +25,30 @@
 
start=`date -v-1d '+%b %d' | sed 's/0\(.\)$/ \1/'`
rc=$(catmsgs |
-   perl -ne 'print "$2 from $1\n"
-   if (/^'"$start"'.*named\[\d+\]: denied [AI]XFR from \[(.*)\]\.\d+ for 
"(.*)"/);' |
-   sort -f | uniq -ic | 
-   perl -e '
-   use Socket;
+   fgrep '^'"$start"'.*named\[[[:digit:]]\+\]: denied [AI]XFR from 
+\[.*\]\.[[:digit:]]\+ for' | \
+   sed -e 's/.*: denied [AI]XFR from \[\(.*\)\]\.[[:digit:]]* for 
+"\(.*\)".*$/\2 from \1/'
+   sort -f | uniq -ic | (
+   usedns=0
+   if [ X"${daily_status_named_usedns}" != X"" ]; then
+   case $daily_status_named_usedns in
+   [yY][eE][sS])   usedns=1 ;;
+   esac
+   fi
 
-   while () {
-   if (/^.*from (.*)$/) {
-   $ip_addr = $1;
-   chomp;
-   if ($ARGV[0] =~ /^yes$/i) {
-   ($host) = gethostbyaddr(inet_aton($ip_addr), 
AF_INET);
-   } else {
-   $host = "";
-   }
-
-   if ($host) {
-   print "$_ ($host)\n";
-