[Orca-checkins] rev 207 - in branches/orca/import_orca_services_2.0: lib lib/Orca_services data_gatherers/orca_services
sean at seanoneill.info
sean at seanoneill.info
Sat Mar 8 10:26:23 PST 2003
Author: sean at seanoneill.info
Date: 2003-03-08 10:25:54 -0800 (Sat, 08 Mar 2003)
New Revision: 207
Added:
branches/orca/import_orca_services_2.0/lib/Orca_services/
branches/orca/import_orca_services_2.0/lib/Orca_services/Dns.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Http.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Mailq.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/MeritRad.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Nntp.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Output.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Pop.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Radius.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Sendmail.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Slapd.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Utils.pm
branches/orca/import_orca_services_2.0/lib/Orca_services/Vars.pm
Modified:
branches/orca/import_orca_services_2.0/data_gatherers/orca_services/S99orca_services.sh.in
branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.cfg.in
branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.pl.in
branches/orca/import_orca_services_2.0/data_gatherers/orca_services/start_orca_services.sh.in
branches/orca/import_orca_services_2.0/data_gatherers/orca_services/stop_orca_services.sh.in
branches/orca/import_orca_services_2.0/lib/Makefile.in
Log:
Modifications being made for new orca_services 2.0 release. orca_service 2.0
is a complete rewrite of orca_services.
In branches/orca/import_orca_services_2.0:
Modified:
data_gatherers/orca_services/S99orca_services.sh.in
data_gatherers/orca_services/orca_services.cfg.in
data_gatherers/orca_services/orca_services.pl.in
data_gatherers/orca_services/start_orca_services.sh.in
data_gatherers/orca_services/stop_orca_services.sh.in
lib/Makefile.in
Added:
lib/Orca_services/
lib/Orca_services/Dns.pm
lib/Orca_services/Http.pm
lib/Orca_services/Mailq.pm
lib/Orca_services/MeritRad.pm
lib/Orca_services/Nntp.pm
lib/Orca_services/Output.pm
lib/Orca_services/Pop.pm
lib/Orca_services/Radius.pm
lib/Orca_services/Sendmail.pm
lib/Orca_services/Slapd.pm
lib/Orca_services/Utils.pm
lib/Orca_services/Vars.pm
Log:
* data_gatherers/orca_services/S99orca_services.sh.in,
data_gatherers/orca_services/orca_services.cfg.in,
data_gatherers/orca_services/orca_services.pl.in,
data_gatherers/orca_services/start_orca_services.sh.in,
data_gatherers/orca_services/stop_orca_services.sh.in:
Updated for orca_services 2.0.
* lib/Makefile.in:
Updated for orca_services 2.0. New section of code added to create new
lib/Orca_services directory and copy contents during installation.
* lib/Orca_services/,
lib/Orca_services/Dns.pm,
lib/Orca_services/Http.pm,
lib/Orca_services/Mailq.pm,
lib/Orca_services/MeritRad.pm,
lib/Orca_services/Nntp.pm,
lib/Orca_services/Output.pm,
lib/Orca_services/Pop.pm,
lib/Orca_services/Radius.pm,
lib/Orca_services/Sendmail.pm,
lib/Orca_services/Slapd.pm,
lib/Orca_services/Utils.pm,
lib/Orca_services/Vars.pm:
New directory lib/Orca_services and files listed added for orca_services 2.0.
Modified: branches/orca/import_orca_services_2.0/lib/Makefile.in
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Makefile.in (original)
+++ branches/orca/import_orca_services_2.0/lib/Makefile.in 2003-03-08 10:26:12.000000000 -0800
@@ -30,6 +30,7 @@
$(MKDIR) $(libdir)/Orca
$(MKDIR) $(libdir)/SE/3.2.1
$(MKDIR) $(libdir)/SE/3.3
+ $(MKDIR) $(libdir)/Orca_services
@for f in Orca/*.pm; do \
echo $(INSTALL) -m 0644 $$f $(libdir)/Orca; \
$(INSTALL) -m 0644 $$f $(libdir)/Orca; \
@@ -49,6 +50,10 @@
echo $(INSTALL) -m 0644 $$f $(libdir)/SE/3.3; \
$(INSTALL) -m 0644 $$f $(libdir)/SE/3.3; \
done
+ @for f in Orca_services/*; do \
+ echo $(INSTALL) -m 0644 $$f $(libdir)/Orca_services; \
+ $(INSTALL) -m 0644 $$f $(libdir)/Orca_services; \
+ done
clean:
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Dns.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Dns.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Dns.pm 2003-03-08 10:26:12.000000000 -0800
@@ -0,0 +1,525 @@
+#
+# Dns.pm : Orca_Services package for dns monitoring
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Dns;
+
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Dns}{File} = "/var/log/named";
+ $Services{Dns}{FileD} = "";
+ $Services{Dns}{Ok} = -1;
+ $Services{Dns}{External} = 0;
+ $Services{Dns}{Init} = "init_dns";
+ $Services{Dns}{Init_Vars} = "init_dns_vars";
+ $Services{Dns}{Measure} = "measure_dns";
+ $Services{Dns}{Put} = "put_dns";
+
+ $PrgOptions{"dns_logfile=s"} = \$Services{Dns}{File};
+
+ $HelpText{$Services{Dns}{File}} = "--dns_logfile=FILE syslog from named (default:";
+}
+
+
+use Orca_Services::Utils;
+use Orca_Services::Output;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_dns
+ init_dns_vars
+ measure_dns
+ put_dns
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($dns_cpu_u, $dns_cpu_s, $dns_ccpu_u, $dns_ccpu_s, $dns_a);
+my ($dns_ptr, $dns_mx, $dns_any, $dns_ns, $dns_soa, $dns_axfr);
+my ($dns_aaaa, $dns_other, $dns_rr, $dns_rq, $dns_rother, $dns_sans);
+my ($dns_snaans, $dns_snxd, $dns_sother);
+my ($dns_usage_started, $dns_nstats_started, $dns_xstats_started);
+my ($odns_rr, $odns_rq, $odns_rother, $odns_sans, $odns_snaans, $odns_snxd, $odns_sother);
+my ($odns_cpu_u, $odns_cpu_s, $odns_ccpu_u, $odns_ccpu_s, $odns_a);
+my ($odns_ptr, $odns_mx, $odns_any, $odns_ns, $odns_soa, $odns_axfr);
+my ($odns_aaaa, $odns_other);
+my ($dns_ino, $dns_size);
+
+
+#
+# usage: &init_dns($dns_logfile);
+#
+sub init_dns {
+ my ($filename) = @_;
+ my ($retval);
+
+ if ($filename) {
+ $retval = OpenFile($filename, "Dns", \$dns_ino, \$dns_size);
+ }
+
+ if($retval == 0) {
+ &init_dns_vars ();
+ }
+ return $retval;
+}
+
+#
+# Get values for dns columns
+#
+# usage: &measure_dns( );
+#
+sub measure_dns () {
+ my ($buf);
+
+ $buf = $Services{Dns}{FileD}->getline;
+ while ($buf) {
+ ## process line read and check for eof
+ if ($buf) {
+ &process_dns_line ($buf);
+ }
+ if ($Services{Dns}{FileD}->eof) {
+ printf "DNS: eof on $Services{Dns}{File}\n" if $Options{debug};
+ last; # get out of while($buf)
+ }
+ $buf = $Services{Dns}{FileD}->getline;
+ } ## while ($buf)
+
+ my $retval = CheckFileChange ("Dns", \$dns_ino, \$dns_size);
+
+ return $retval;
+}
+
+
+#
+# init dns vars
+#
+# usage: &init_dns_vars();
+#
+sub init_dns_vars() {
+ $dns_usage_started = 0;
+ $dns_nstats_started = 0;
+ $dns_xstats_started = 0;
+
+ &init_dns_usage_vars();
+ &init_dns_nstats_vars();
+ &init_dns_xstats_vars();
+
+ &init_odns_vars();
+}
+
+sub init_dns_usage_vars () {
+ $dns_cpu_u = 0;
+ $dns_cpu_s = 0;
+ $dns_ccpu_u = 0;
+ $dns_ccpu_s = 0;
+}
+sub init_dns_nstats_vars () {
+ $dns_a = 0;
+ $dns_ptr = 0;
+ $dns_mx = 0;
+ $dns_any = 0;
+
+ $dns_ns = 0;
+ $dns_soa = 0;
+ $dns_axfr = 0;
+ $dns_aaaa = 0;
+ $dns_other = 0;
+}
+
+sub init_dns_xstats_vars () {
+ $dns_rr = 0;
+ $dns_rq = 0;
+ $dns_rother = 0;
+
+ $dns_sans = 0;
+ $dns_snaans = 0;
+ $dns_snxd = 0;
+ $dns_sother = 0;
+}
+
+
+#
+# init odns vars (save old values)
+#
+# usage: &init_odns_vars();
+#
+
+sub init_odns_vars() {
+ &init_odns_usage_vars();
+ &init_odns_nstats_vars();
+ &init_odns_xstats_vars();
+}
+
+sub init_odns_usage_vars() {
+ $odns_cpu_u = $dns_cpu_u ;
+ $odns_cpu_s = $dns_cpu_s ;
+ $odns_ccpu_u = $dns_ccpu_u ;
+ $odns_ccpu_s = $dns_ccpu_s ;
+
+ &init_dns_usage_vars();
+}
+
+sub init_odns_nstats_vars() {
+ $odns_a = $dns_a ;
+ $odns_ptr = $dns_ptr ;
+ $odns_mx = $dns_mx ;
+ $odns_any = $dns_any ;
+
+ $odns_ns = $dns_ns ;
+ $odns_soa = $dns_soa ;
+ $odns_axfr = $dns_axfr ;
+ $odns_aaaa = $dns_aaaa ;
+ $odns_other = $dns_other ;
+
+ &init_dns_nstats_vars();
+}
+
+sub init_odns_xstats_vars() {
+ $odns_rr = $dns_rr ;
+ $odns_rq = $dns_rq ;
+ $odns_rother = $dns_rother ;
+
+ $odns_sans = $dns_sans ;
+ $odns_snaans = $dns_snaans ;
+ $odns_snxd = $dns_snxd ;
+ $odns_sother = $dns_sother ;
+
+ &init_dns_xstats_vars();
+}
+
+
+#
+# calc dns delta
+#
+# usage: &calc_dns_delta();
+#
+sub calc_dns_delta() {
+ &calc_dns_usage_delta();
+ &calc_dns_nstats_delta();
+ &calc_dns_xstats_delta();
+}
+
+sub calc_dns_usage_delta() {
+ my $temp = 0;
+
+ if ($dns_cpu_u < $odns_cpu_u) {
+ $odns_cpu_u = $dns_cpu_u;
+ } else {
+ $temp = $dns_cpu_u; $dns_cpu_u = $dns_cpu_u - $odns_cpu_u; $odns_cpu_u = $temp;
+ }
+
+ if ($dns_cpu_s < $odns_cpu_s) {
+ $odns_cpu_s = $dns_cpu_s;
+ } else {
+ $temp = $dns_cpu_s; $dns_cpu_s = $dns_cpu_s - $odns_cpu_s; $odns_cpu_s = $temp;
+
+ }
+ if ($dns_ccpu_u < $odns_ccpu_u) {
+ $odns_ccpu_u = $dns_ccpu_u;
+ } else {
+ $temp = $dns_ccpu_u; $dns_ccpu_u = $dns_ccpu_u - $odns_ccpu_u; $odns_ccpu_u = $temp;
+
+ }
+ if ($dns_ccpu_s < $odns_ccpu_s) {
+ $odns_ccpu_s = $dns_ccpu_s;
+ } else {
+ $temp = $dns_ccpu_s; $dns_ccpu_s = $dns_ccpu_s - $odns_ccpu_s; $odns_ccpu_s = $temp;
+ }
+
+}
+sub calc_dns_nstats_delta() {
+ my $temp = 0;
+
+ if ($dns_a < $odns_a) {
+ $odns_a = $dns_a;
+ } else {
+ $temp = $dns_a; $dns_a = $dns_a - $odns_a; $odns_a = $temp;
+ }
+
+ if ($dns_ptr < $odns_ptr) {
+ $odns_ptr = $dns_ptr;
+ } else {
+ $temp = $dns_ptr; $dns_ptr = $dns_ptr - $odns_ptr; $odns_ptr = $temp;
+ }
+
+ if ($dns_mx < $odns_mx) {
+ $odns_mx = $dns_mx;
+ } else {
+ $temp = $dns_mx; $dns_mx = $dns_mx - $odns_mx; $odns_mx = $temp;
+ }
+
+ if ($dns_any < $odns_any) {
+ $odns_any = $dns_any;
+ } else {
+ $temp = $dns_any; $dns_any = $dns_any - $odns_any; $odns_any = $temp;
+ }
+
+ if ($dns_ns < $odns_ns) {
+ $odns_ns = $dns_ns;
+ } else {
+ $temp = $dns_ns; $dns_ns = $dns_ns - $odns_ns; $odns_ns = $temp;
+ }
+
+ if ($dns_soa < $odns_soa) {
+ $odns_soa = $dns_soa;
+ } else {
+ $temp = $dns_soa; $dns_soa = $dns_soa - $odns_soa; $odns_soa = $temp;
+ }
+ if ($dns_axfr < $odns_axfr) {
+ $odns_axfr = $dns_axfr;
+ } else {
+ $temp = $dns_axfr; $dns_axfr = $dns_axfr - $odns_axfr; $odns_axfr = $temp;
+ }
+
+ if ($dns_aaaa < $odns_aaaa) {
+ $odns_aaaa = $dns_aaaa;
+ } else {
+ $temp = $dns_aaaa; $dns_aaaa = $dns_aaaa - $odns_aaaa; $odns_aaaa = $temp;
+ }
+
+ if ($dns_other < $odns_other) {
+ $odns_other = $dns_other;
+ } else {
+ $temp = $dns_other; $dns_other = $dns_other - $odns_other; $odns_other = $temp;
+ }
+}
+
+sub calc_dns_xstats_delta() {
+ my $temp = 0;
+
+ if ($dns_rr < $odns_rr) {
+ $odns_rr = $dns_rr;
+ } else {
+ $temp = $dns_rr; $dns_rr = $dns_rr - $odns_rr; $odns_rr = $temp;
+ }
+
+ if ($dns_rq < $odns_rq) {
+ $odns_rq = $dns_rq;
+ } else {
+ $temp = $dns_rq; $dns_rq = $dns_rq - $odns_rq; $odns_rq = $temp;
+ }
+
+ if ($dns_rother < $odns_rother) {
+ $odns_rother = $dns_rother;
+ } else {
+ $temp = $dns_rother; $dns_rother = $dns_rother - $odns_rother; $odns_rother = $temp;
+ }
+
+ if ($dns_sans < $odns_sans) {
+ $odns_sans = $dns_sans;
+ } else {
+ $temp = $dns_sans; $dns_sans = $dns_sans - $odns_sans; $odns_sans = $temp;
+ }
+
+ if ($dns_snaans < $odns_snaans) {
+ $odns_snaans = $dns_snaans;
+ } else {
+ $temp = $dns_snaans; $dns_snaans = $dns_snaans - $odns_snaans; $odns_snaans = $temp;
+ }
+
+ if ($dns_snxd < $odns_snxd) {
+ $odns_snxd = $dns_snxd;
+ } else {
+ $temp = $dns_snxd; $dns_snxd = $dns_snxd - $odns_snxd; $odns_snxd = $temp;
+ }
+
+ if ($dns_sother < $odns_sother) {
+ $odns_sother = $dns_sother;
+ } else {
+ $temp = $dns_sother; $dns_sother = $dns_sother - $odns_sother; $odns_sother = $temp;
+ }
+}
+
+
+# -------------------------------------------------------------------
+#
+# Parse dns log line
+#
+# usage: &process_dns_line ($buf);
+#
+
+sub process_dns_line () {
+ my ($line) = @_;
+ my ($t, $v, @types);
+
+ #
+ # Oct 24 14:27:49 r1 named[17279]: USAGE 972394069 970586866 CPU=188.82u/82.79s CHILDCPU=0u/0s
+ # Oct 24 14:27:49 r1 named[17279]: NSTATS 972394069 970586866 0=6 A=322014 NS=25 SOA=415 PTR=35772 MX=111 SRV=110 ANY=238
+ # Oct 24 14:27:49 r1 named[17279]: XSTATS 972394069 970586866 RR=293985 RNXD=22941 RFwdR=205718 RDupR=3603 RFail=508 RFErr=0 RErr=141 RAXFR=0 RLame=2636 ROpts=0 SSysQ=58851 SAns=205888 SFwdQ=169140 SDupQ=23529 SErr=0 RQ=358773 RIQ=0 RFwdQ=0 RDupQ=8397 RTCP=206 SFwdR=205718 SFail=3 SFErr=0 SNaAns=204478 SNXD=45736
+ #
+ if ($line !~ / named\[\d+\]: (USAGE|NSTATS|XSTATS) /) {
+ return 0;
+ }
+
+
+ # Oct 24 14:27:49 r1 named[17279]: USAGE 972394069 970586866 CPU=188.82u/82.79s CHILDCPU=0u/0s
+ if ($line =~ /: USAGE \d+ \d+ CPU=([\d\.]+)u\/([\d\.]+)s CHILDCPU=([\d\.]+)u\/([\d\.]+)s/) {
+ $dns_cpu_u = $1;
+ $dns_cpu_s = $2;
+ $dns_ccpu_u = $3;
+ $dns_ccpu_s = $4;
+
+ printf "DNS_USAGE: %s", $line if $Options{debug};
+ printf "dns_cpu_u=%s, dns_cpu_s=%s, dns_ccpu_u=%s, dns_ccpu_s=%s\n", $dns_cpu_u, $dns_cpu_s, $dns_ccpu_u, $dns_ccpu_s if $Options{debug};
+
+ if ($dns_usage_started) {
+ &calc_dns_usage_delta(); # puts delta into vars to print -&- saves into old
+ } else {
+ $dns_usage_started = 1;
+ &init_odns_usage_vars(); # saves old and cleans current values
+ }
+
+ # Oct 24 14:27:49 r1 named[17279]: NSTATS 972394069 970586866 0=6 A=322014 NS=25 SOA=415 PTR=35772 MX=111 SRV=110 ANY=238
+ } elsif ($line =~ /: NSTATS \d+ \d+ /) {
+ my $l;
+
+ ($l = $line) =~ s/^.*: NSTATS \d+ \d+ //; # trim beginning
+ chop $l;
+
+ @types = split(' ',$l);
+
+ $dns_other = 0;
+ while (@types) {
+ ($t,$v) = split ('=', pop @types);
+ if ($t eq 'A') {
+ $dns_a = $v;
+ } elsif ($t eq 'PTR') {
+ $dns_ptr = $v;
+ } elsif ($t eq 'MX') {
+ $dns_mx = $v;
+ } elsif ($t eq 'ANY') {
+ $dns_any = $v;
+ } elsif ($t eq 'NS') {
+ $dns_ns = $v;
+ } elsif ($t eq 'SOA') {
+ $dns_soa = $v;
+ } elsif ($t eq 'AXFR') {
+ $dns_axfr = $v;
+ } elsif ($t eq 'AAAA') {
+ $dns_aaaa = $v;
+ } else {
+ $dns_other += $v;
+ }
+ }
+
+ printf "DNS_NSTATS: %s", $line if $Options{debug};
+ printf "dns_a=%s, dns_ptr=%s, dns_mx=%s, dns_any=%s, dns_ns=%s, dns_soa=%s, dns_axfr=%s, dns_aaaa=%s, dns_other=%s\n", $dns_a, $dns_ptr, $dns_mx, $dns_any, $dns_ns, $dns_soa, $dns_axfr, $dns_aaaa, $dns_other if $Options{debug};
+
+ if ($dns_nstats_started) {
+ &calc_dns_nstats_delta(); # puts delta into vars to print -&- saves into old
+ } else {
+ $dns_nstats_started = 1;
+ &init_odns_nstats_vars(); # saves old and cleans current values
+ }
+
+ # Oct 24 14:27:49 r1 named[17279]: XSTATS 972394069 970586866 RR=293985 RNXD=22941 RFwdR=205718 RDupR=3603 RFail=508 RFErr=0 RErr=141 RAXFR=0 RLame=2636 ROpts=0 SSysQ=58851 SAns=205888 SFwdQ=169140 SDupQ=23529 SErr=0 RQ=358773 RIQ=0 RFwdQ=0 RDupQ=8397 RTCP=206 SFwdR=205718 SFail=3 SFErr=0 SNaAns=204478 SNXD=45736
+ } elsif ($line =~ /: XSTATS \d+ \d+ /) {
+ my $l;
+
+ ($l = $line) =~ s/^.*: XSTATS \d+ \d+ //; # trim beginning
+ chop $l;
+
+ @types = split(' ',$l);
+
+ $dns_rother = $dns_sother = 0;
+ while (@types) {
+ ($t,$v) = split ('=', pop @types);
+ if ($t eq 'RR') {
+ $dns_rr = $v;
+ } elsif ($t eq 'RQ') {
+ $dns_rq = $v;
+ } elsif ($t =~ /^R/) {
+ $dns_rother += $v;
+ } elsif ($t eq 'SAns') {
+ $dns_sans = $v;
+ } elsif ($t eq 'SNaAns') {
+ $dns_snaans = $v;
+ } elsif ($t eq 'SNXD') {
+ $dns_snxd = $v;
+ } elsif ($t =~ /^S/) {
+ $dns_sother += $v;
+ }
+ }
+
+ printf "DNS_XSTATS: %s", $line if $Options{debug};
+ printf "dns_rr=%s, dns_rq=%s, dns_rother=%s, dns_sans=%s, dns_snaans=%s, dns_snxd=%s, dns_sother=%s\n", $dns_rr, $dns_rq, $dns_rother, $dns_sans, $dns_snaans, $dns_snxd, $dns_sother if $Options{debug};
+
+ if ($dns_xstats_started) {
+ &calc_dns_xstats_delta(); # puts delta into vars to print -&- saves into old
+ } else {
+ $dns_xstats_started = 1;
+ &init_odns_xstats_vars(); # saves old and cleans current values
+ }
+ }
+ return 0;
+}
+
+
+#
+# Put the dns values for output
+#
+# usage: &put_dns();
+#
+sub put_dns() {
+ &put_output("dns_cpu_u", sprintf("%8.2f", $dns_cpu_u));
+ &put_output("dns_cpu_s", sprintf("%8.2f", $dns_cpu_s));
+ &put_output("dns_ccpu_u", sprintf("%8.2f", $dns_ccpu_u));
+ &put_output("dns_ccpu_s", sprintf("%8.2f", $dns_ccpu_s));
+
+ &put_output("dns_a", sprintf("%8.2f", $dns_a));
+ &put_output("dns_ptr", sprintf("%8.2f", $dns_ptr));
+ &put_output("dns_mx", sprintf("%8.2f", $dns_mx));
+ &put_output("dns_any", sprintf("%8.2f", $dns_any));
+
+ &put_output("dns_ns", sprintf("%8.2f", $dns_ns));
+ &put_output("dns_soa", sprintf("%8.2f", $dns_soa));
+ &put_output("dns_axfr", sprintf("%8.2f", $dns_axfr));
+ &put_output("dns_aaaa", sprintf("%8.2f", $dns_aaaa));
+ &put_output("dns_other", sprintf("%8.2f", $dns_other));
+
+ &put_output("dns_rr", sprintf("%8.2f", $dns_rr));
+ &put_output("dns_rq", sprintf("%8.2f", $dns_rq));
+ &put_output("dns_rother", sprintf("%8.2f", $dns_rother));
+
+ &put_output("dns_sans", sprintf("%8.2f", $dns_sans));
+ &put_output("dns_snaans", sprintf("%8.2f", $dns_snaans));
+ &put_output("dns_snxd", sprintf("%8.2f", $dns_snxd));
+ &put_output("dns_sother", sprintf("%8.2f", $dns_sother));
+
+ return 0;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Radius.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Radius.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Radius.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,224 @@
+#
+# Radius.pm : Orca_Services package for monitoring Radius
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Radius;
+
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Radius}{File} = "/usr/local/lib/orca_services.DB.$nodename";
+ $Services{Radius}{FileD} = "";
+ $Services{Radius}{Ok} = -1;
+ $Services{Radius}{External} = 1;
+ $Services{Radius}{Init} = "init_radius";
+ $Services{Radius}{Init_Vars} = "";
+ $Services{Radius}{Measure} = "measure_radius";
+ $Services{Radius}{Put} = "put_radius";
+
+ $PrgOptions{"radius_db=s"} = \$Services{Radius}{File};
+
+ $HelpText{$Services{Radius}{File}} = "--radius_db=FILE file for user/passwd for DB access (default:";
+}
+
+#use DBI;
+use Orca_Services::Utils;
+use Orca_Services::Output;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_radius
+ measure_radius
+ put_radius
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($radius_inc_time ,$radius_inc_sessions);
+my ($radius_base_ts, $rad_sessions, $rad_time, $ACCUM_radius_DB);
+
+sub init_radius {
+ my ($filename) = @_;
+ my ($radius_ok);
+
+ #check if database user/passwd is given!
+ if( ! -f $filename){
+ print "Database init error: No such file: $filename\n";
+ print "Not using Radius module\n";
+ return -1;
+ }
+
+ my($proto,$drv,$database,$user,$pass)= split(/:/,`$CAT $filename`);
+
+ if(!$proto || !$drv || !$database || !$user || !$pass){
+ print "Database init error: unable to parse $filename\n";
+ print "Syntax must be: protocol:driver:database:user:passwd ex: DBI:oracle:ORCA:user:pass\n";
+ print "Not using Radius module\n";
+ return -1;
+ }
+ chomp($pass);
+
+ if ( ($radius_ok = &init_radius_vars("$proto:$drv:$database",$user,$pass)) ) {
+ print "ERROR: Radius init failed! Aborting $radius_ok\n";
+ return -1;
+ }
+}
+
+#
+# init_radius - set RADIATOR_RADIUS vars, connect to DB, calculate correct time stamp
+#
+# usage: &init_radius($db,$user,$pass);
+#
+
+sub init_radius_vars {
+ my ($db,$user,$pass) = @_;
+ my ($BASE_ACCUM_radius_DB);
+
+
+ $Services{Radius}{FileD} = DBI->connect($db,$user,$pass);
+ if(!$Services{Radius}{FileD}) {
+ print "Connect error $DBI::errstr\n";
+ return 1;
+ }
+
+ #get the lower time limit that our queries will start from
+ #get a "history" of 5minutes
+
+ $radius_base_ts= time - 5*60;
+
+ #get accumulated values for what we want to measure:
+
+ #jcp correct this please!
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, undef) = localtime($radius_base_ts);
+ $year += 1900;
+ $mon++;
+
+
+ $BASE_ACCUM_radius_DB="/var/orca/orca_services/$nodename";
+ if ($mon<10) {
+ $ACCUM_radius_DB= "$BASE_ACCUM_radius_DB/radiatorRadiusAccum.$year"."0"."$mon.txt";
+ } else {
+ $ACCUM_radius_DB= "$BASE_ACCUM_radius_DB/radiatorRadiusAccum.$year$mon.txt";
+ }
+ `$TOUCH $ACCUM_radius_DB`;
+
+ ($radius_inc_time,$radius_inc_sessions) = split(/:/,`$CAT $ACCUM_radius_DB`);
+ chomp $radius_inc_sessions if $radius_inc_sessions;
+
+ $radius_inc_time ||= 0;
+ $radius_inc_sessions ||= 0;
+
+ #END jcp correct this please!
+
+ return 0;
+}
+
+
+#
+# Get values for radiator radius columns
+#
+# usage: &measure_radius( );
+#
+
+sub measure_radius () {
+ my ($query);
+
+ my $upper_ts= time;
+
+ #Begin GET Accounting
+
+ $query = "SELECT ACCT_SESSION_TIME,ACCT_STATUS_TYPE FROM ACCOUNTING ";
+ $query .= " WHERE ACCT_STATUS_TYPE = 'Stop'";
+ $query .= " AND TIMESTAMP > $radius_base_ts";
+ $query .= " AND TIMESTAMP < $upper_ts";
+
+ ($rad_time,$rad_sessions) = calculateRadVals($query);
+
+ ## incremental/accumulated values
+ $radius_inc_time += $rad_time;
+ $radius_inc_sessions += $rad_sessions;
+
+ #END GET Accounting
+
+ `$ECHO "$radius_inc_time:$radius_inc_sessions" > $ACCUM_radius_DB`;
+ $radius_base_ts += ($upper_ts - $radius_base_ts);
+ return 0;
+}
+
+##
+# IN: query
+# RET: time, sessions
+##
+sub calculateRadVals{
+ my $query = shift(@_);
+ my ($sth, @row);
+
+ #print "radius query: $query\n";
+
+ my ($rad_t,$rad_s)= (0,0);
+ $sth = $Services{Radius}{FileD}->prepare($query);
+ $sth ->execute();
+
+ $"=" \t ";
+ while ( @row = $sth -> fetchrow_array()){
+ #print "$row[0].$row[1]: $eca\n";
+ $rad_t += $row[0];
+ $rad_s++;
+ }
+
+ #print "Time: $rad_t seconds\t Sess: $rad_s sessions\n";
+return ($rad_t,$rad_s);
+}
+
+
+#
+# Put the radiator radius values for output
+#
+# usage: &put_radius();
+#
+
+sub put_radius() {
+ &put_output("rad_time", sprintf("%8.2f", $rad_time));
+ &put_output("rad_sessions", sprintf("%8.2f", $rad_sessions));
+
+ #incremental graph
+ &put_output("radius_inc_time", sprintf("%8.2f", $radius_inc_time));
+ &put_output("radius_inc_sessions", sprintf("%8.2f", $radius_inc_sessions));
+
+ return 0;
+}
+
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/MeritRad.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/MeritRad.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/MeritRad.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,274 @@
+#
+# MeritRad.pm : Orca_Services package for monitoring Merit Radius
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::MeritRad;
+
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Merit}{File} = "/usr/local/etc/raddb/logfile";
+ $Services{Merit}{FileD} = "";
+ $Services{Merit}{Ok} = -1;
+ $Services{Merit}{External} = 0;
+ $Services{Merit}{Init} = "init_merit_radius";
+ $Services{Merit}{Init_Vars} = "init_merit_radius_vars";
+ $Services{Merit}{Measure} = "measure_merit_radius";
+ $Services{Merit}{Put} = "put_merit_radius";
+
+ $PrgOptions{"merit_radius_logfile=s"} = \$Services{Merit}{File};
+
+ $HelpText{$Services{Merit}{File}} = "--merit_radius_logile=FILE syslog from merit radius (default:";
+}
+
+use Orca_Services::Output;
+use Orca_Services::Utils;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_merit_radius
+ init_merit_radius_vars
+ measure_merit_radius
+ put_merit_radius
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($merit_radius_auth, $merit_radius_auth_ok, $merit_radius_auth_nok);
+my ($merit_radius_acct_start, $merit_radius_acct_stop);
+my ($merit_radius_rem_auth, $merit_radius_rem_auth_ok);
+my ($merit_radius_rem_auth_nok, $merit_radius_undefs);
+my ($merit_radius_ino, $merit_radius_size);
+
+#
+# init_merit_radius - set Merit_RADIUS vars, open the logfile and seek into the end.
+#
+# usage: &init_merit_radius($radius_logfile);
+#
+
+sub init_merit_radius {
+ my ($filename) = @_;
+ my ($retval);
+
+ if ($filename) {
+ $retval = OpenFile($filename, "Merit", \$merit_radius_ino, \$merit_radius_size);
+ }
+
+ if($retval == 0) {
+ &init_merit_radius_vars ();
+ }
+ return $retval;
+}
+
+
+#
+# init merit_radius vars
+#
+# usage: &init_merit_radius_vars();
+#
+
+sub init_merit_radius_vars() {
+ $merit_radius_auth = 0;
+ $merit_radius_auth_ok = 0;
+ $merit_radius_auth_nok = 0;
+
+ $merit_radius_acct_start = 0;
+ $merit_radius_acct_stop = 0;
+
+ $merit_radius_rem_auth = 0;
+ $merit_radius_rem_auth_ok = 0;
+ $merit_radius_rem_auth_nok = 0;
+
+ $merit_radius_undefs = 0;
+}
+
+
+#
+# Get values for merit_radius columns
+#
+# usage: &measure_merit_radius( );
+#
+
+sub measure_merit_radius () {
+ my ($buf);
+
+ $buf = $Services{Merit}{FileD}->getline;
+ while ($buf) {
+ ## process line read and check for eof
+ if ($buf) {
+ &process_merit_radius_line ($buf);
+ }
+ if ($Services{Merit}{FileD}->eof) {
+ printf "Merit_RADIUS: eof on $Services{Merit}{File}\n" if $Options{debug};
+ last; # get out of while($buf)
+ }
+ $buf = $Services{Merit}{FileD}->getline;
+ } ## while ($buf)
+
+ my $retval = CheckFileChange ("Merit", \$merit_radius_ino, \$merit_radius_size);
+
+ return $retval;
+}
+
+
+#
+# Parse merit_radius log line
+#
+# usage: &process_merit_radius_line ($buf);
+#
+
+sub process_merit_radius_line () {
+ my ($line) = @_;
+
+ ### AUTH RECEIVED
+ # Mon Jul 24 00:02:16 2000: Received-Authentication: 214/28832 'luser' from 13.12.15.17 port 25 PPP
+
+ if ($line =~ /: Received-Authentication: .* from /i) {
+ $merit_radius_auth ++;
+ printf "Merit_RADIUS_AUTH: %s", $line if $Options{debug};
+ printf "merit_radius_auth=%s\n", $merit_radius_auth if $Options{debug};
+ return 0;
+ }
+
+ ### AUTH OK
+ # Mon Jul 24 00:02:16 2000: Authentication: 214/28832 'luser2' from 13.12.25.17 port 35 PPP - OK -- total 0, holding 0
+
+ if ($line =~ /: Authentication: .* from .* OK /i) {
+ $merit_radius_auth_ok ++;
+ printf "Merit_RADIUS_AUTH_OK: %s", $line if $Options{debug};
+ printf "merit_radius_auth_ok=%s\n", $merit_radius_auth_ok if $Options{debug};
+ return 0;
+ }
+
+ ### AUTH FAILED
+ # Mon Jul 24 01:49:20 2000: Authentication: 201/29347 'luser3' from 13.16.19.20 port 2 PPP - FAILED Authentication failure -- total 0, holding 0
+
+ if ($line =~ /: Authentication: .* from .* FAILED Authentication /i) {
+ $merit_radius_auth_nok ++;
+ printf "Merit_RADIUS_AUTH_NOK: %s", $line if $Options{debug};
+ printf "merit_radius_auth_nok=%s\n", $merit_radius_auth_nok if $Options{debug};
+ return 0;
+ }
+
+ ### ACCT START RECEIVED
+ # Mon Jul 24 00:02:16 2000: Received-Accounting: 215/8376 'luser4' from 13.16.15.17 port 35 $"5200DB70" PPP/13.16.19.25 Start
+ ### ACCT STOP RECEIVED
+ # Mon Jul 24 00:02:19 2000: Received-Accounting: 176/8377 'luser5' from 13.16.11.18 port 1 $"040065AE" PPP/13.16.24.22 Stop/User-Request
+ # Wed Aug 9 16:55:15 2000: getpwnam: good line for luser6 on file
+ if ( ($line =~ /: Received-Accounting: .* from /i) ||
+ ($line =~ /: getpwnam: good line for /i) ){
+ printf "Merit_RADIUS_IGNORE: %s", $line if $Options{debug};
+ return 0;
+ }
+
+ ### ACCT START OK
+ # Mon Jul 24 00:02:16 2000: Accounting: 215/8376 'luser6' from 13.16.15.17 port 35 $"5200DB70" PPP/13.16.19.24 Start - OK -- total 0, holding 0
+
+ if ($line =~ /: Accounting: .* from .* Start - OK /i) {
+ $merit_radius_acct_start ++;
+ printf "Merit_RADIUS_ACCT_START: %s", $line if $Options{debug};
+ printf "merit_radius_acct_start=%s\n", $merit_radius_acct_start if $Options{debug};
+ return 0;
+ }
+
+ ### ACCT STOP OK
+ # Mon Jul 24 00:02:19 2000: Accounting: 176/8377 'luser7' from 13.16.11.18 port 1 $"040065AE" PPP/13.16.24.22 Stop/User-Request - OK -- total 0, holding 0
+
+ if ($line =~ /: Accounting: .* from .* Stop.* OK /i) {
+ $merit_radius_acct_stop ++;
+ printf "Merit_RADIUS_ACCT_STOP: %s", $line if $Options{debug};
+ printf "merit_radius_acct_stop=%s\n", $merit_radius_acct_stop if $Options{debug};
+ return 0;
+ }
+
+ ### REMOTE AUTH RECEIVED
+ # Mon Jul 24 20:53:38 2000: Received-AUTHENTICATE: 167/44566 'luser9 at realm.com' via some.host.com from some.nas.com port 6 PPP
+
+ if ($line =~ /: Received-AUTHENTICATE: .* via .* from /i) {
+ $merit_radius_rem_auth ++;
+ printf "Merit_RADIUS_REM_AUTH: %s", $line if $Options{debug};
+ printf "merit_radius_rem_auth=%s\n", $merit_radius_rem_auth if $Options{debug};
+ return 0;
+ }
+
+ ### REMOTE AUTH OK
+ # Mon Jul 24 20:53:38 2000: AUTHENTICATE: 167/44566 'luser9 at realm.com' via some.host.com from some.nas.com port 6 PPP - OK -- total 0, holding 0
+
+ if ($line =~ /: AUTHENTICATE: .* via .* from .* OK /i) {
+ $merit_radius_rem_auth_ok ++;
+ printf "Merit_RADIUS_REM_AUTH_OK: %s", $line if $Options{debug};
+ printf "merit_radius_rem_auth_ok=%s\n", $merit_radius_rem_auth_ok if $Options{debug};
+ return 0;
+ }
+
+ ### REMOTE AUTH FAILED
+ # Mon Jul 24 14:05:56 2000: AUTHENTICATE: 230/37578 'luser9 at realm.com' via some.host.com from i-Pass VNAS\0\0\0\0 port 1 - FAILED Authentication failure -- total 0, holding 0
+
+ if ($line =~ /: AUTHENTICATE: .* via .* from .* FAILED Authentication /i) {
+ $merit_radius_rem_auth_nok ++;
+ printf "Merit_RADIUS_REM_AUTH_NOK: %s", $line if $Options{debug};
+ printf "merit_radius_rem_auth_nok=%s\n", $merit_radius_rem_auth_nok if $Options{debug};
+ return 0;
+ }
+
+ $merit_radius_undefs ++;
+ printf "Merit_RADIUS_UNDEF: %s", $line if $Options{debug};
+ printf "merit_radius_undefs=%s\n", $merit_radius_undefs if $Options{debug};
+ return 0;
+}
+
+
+#
+# Put the merit_radius values for output
+#
+# usage: &put_merit_radius();
+#
+
+sub put_merit_radius() {
+ &put_output("merit_radius_auth", sprintf("%8.2f", $merit_radius_auth));
+ &put_output("merit_radius_auth_ok", sprintf("%8.2f", $merit_radius_auth_ok));
+ &put_output("merit_radius_auth_nok", sprintf("%8.2f", $merit_radius_auth_nok));
+ &put_output("merit_radius_acct_start", sprintf("%8.2f", $merit_radius_acct_start));
+ &put_output("merit_radius_acct_stop", sprintf("%8.2f", $merit_radius_acct_stop));
+ &put_output("merit_radius_rem_auth", sprintf("%8.2f", $merit_radius_rem_auth));
+ &put_output("merit_radius_rem_auth_ok", sprintf("%8.2f", $merit_radius_rem_auth_ok));
+ &put_output("merit_radius_rem_auth_nok", sprintf("%8.2f", $merit_radius_rem_auth_nok));
+
+ &put_output("merit_radius_undefs", sprintf("%8.2f", $merit_radius_undefs));
+
+ return 0;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Vars.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Vars.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Vars.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,133 @@
+#
+# Var.pm : Orca_Services package for global vars
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Vars;
+
+use strict;
+use Exporter;
+use vars qw(@EXPORT @ISA $VERSION);
+ at ISA = qw(Exporter);
+
+#
+# program VERSION
+#
+push(@EXPORT, qw($VERSION));
+$VERSION = "2.0a1";
+
+
+#
+# progra name
+#
+use vars qw($progname);
+push(@EXPORT, qw($progname));
+$progname = "orca_services";
+
+#
+# vars for syslogging
+#
+use vars qw($log_facility $log_priority);
+push(@EXPORT, qw($log_facility $log_priority));
+$log_facility = "user";
+$log_priority = "info";
+
+#
+# some helper programs
+#
+use vars qw($CAT $ECHO $TOUCH);
+push(@EXPORT, qw($CAT $ECHO $TOUCH));
+$CAT="/usr/local/bin/cat";
+$ECHO="/usr/local/bin/echo";
+$TOUCH="/usr/local/bin/touch";
+
+#
+#
+#
+use vars qw($SaveDay $OutputFilename $print_header $current_column);
+push(@EXPORT, qw($SaveDay $Compress $OutputFilename $print_header $current_column));
+$SaveDay = 0;
+$OutputFilename = "";
+$print_header = 0;
+$current_column = 0;
+
+#
+# the mailq command
+#
+# mailq when postfix is installed
+# $MAILQCMD = "/usr/bin/mailq | egrep -v '^-' | egrep '^[A-Z0-9]' | egrep -v 'empty' | wc -l";
+#
+use vars qw($MAILQCMD);
+push(@EXPORT, qw($MAILQCMD));
+$MAILQCMD = "/usr/bin/mailq | egrep -v '^-' | egrep '^[A-Z0-9]' | egrep -v 'empty' | wc -l";
+
+#
+# Central Hash for Services parameter
+#
+use vars qw(%Services %Options %PrgOptions %HelpText);
+push(@EXPORT, qw(%Services %Options %PrgOptions %HelpText));
+%Services=();
+%Options=("interval" => 300,
+ "outputdir" => "/opt/SWorca/var/orca/orca_services",
+ "compress" => "/usr/bin/gzip -9",
+ "debug" => 0,
+ "help" => 0
+ );
+$Options{pidfile} = "$Options{outputdir}/${progname}.pid";
+
+%PrgOptions = ("pidfile=s" => \$Options{pidfile},
+ "debug:s" => \$Options{debug},
+ "interval=i" => \$Options{interval},
+ "outputdir=s" => \$Options{outputdir},
+ "compress=s" => \$Options{compress},
+ "help" => \$Options{help},
+ "version" => \$Options{help}
+ );
+
+%HelpText = ($Options{pidfile} => "--pidfile=FILE write my PID here (default:",
+ $Options{debug} => "--debug[=0|1] show copious debugging info (default:",
+ $Options{interval} => "--interval=i pooling interval in sec. (default:",
+ $Options{outputdir} => "--outputdir=DIR (default:",
+ $Options{compress} => "--compress=COMMAND use this to compress files (default:",
+ );
+
+#
+#
+#
+use vars qw($interval $nodename);
+push(@EXPORT, qw($interval $nodename));
+$interval=0;
+
+my $UNAME = "/usr/bin/uname";
+$nodename = `$UNAME -n`;
+chop($nodename);
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Sendmail.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Sendmail.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Sendmail.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,352 @@
+#
+# Sendmail.pm : Orca_Services package to process sendmail log
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+
+package Orca_Services::Sendmail;
+
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+
+ $Services{Sendmail}{File} = "/var/log/mail.log";
+ $Services{Sendmail}{FileD} = "";
+ $Services{Sendmail}{Ok} = -1;
+ $Services{Sendmail}{External} = 0;
+ $Services{Sendmail}{Init} = "init_smtp";
+ $Services{Sendmail}{Init_Vars} = "init_smtp_vars";
+ $Services{Sendmail}{Measure} = "measure_smtp";
+ $Services{Sendmail}{Put} = "put_smtp";
+
+ $PrgOptions{"smtp_logfile=s"} = \$Services{Sendmail}{File};
+
+ $HelpText{$Services{Sendmail}{File}} = "--smtp_logfile=FILE syslog from sendmail (default:";
+}
+
+use Orca_Services::Output;
+use Orca_Services::Utils;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_smtp
+ init_smtp_vars
+ measure_smtp
+ put_smtp
+ );
+
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($smtp_froms, $smtp_MaxSize, $smtp_sizes, $smtp_MaxSeconds, $smtp_seconds);
+my ($smtp_sent, $smtp_fail, $smtp_retries, $smtp_queued, $smtp_t_or_f);
+my ($smtp_check_mail, $smtp_check_rcpt, $smtp_notifies, $smtp_dsns);
+my ($smtp_spam, $smtp_virus, $smtp_overquota, $smtp_undefs);
+my ($smtp_ino, $smtp_size);
+
+# -------------------------------------------------------------------
+#
+# init_smtp - set SMTP vars, open the logfile and seek into the end.
+#
+# usage: &init_smtp($smtp_logfile);
+#
+
+sub init_smtp {
+ my ($filename) = @_;
+ my ($retval);
+
+ if ($filename) {
+ $retval = OpenFile($filename, "Sendmail", \$smtp_ino, \$smtp_size);
+ }
+
+ if($retval == 0) {
+ &init_smtp_vars ();
+ }
+ return $retval;
+}
+
+# -------------------------------------------------------------------
+#
+# Get values for smtp columns
+#
+# usage: &measure_smtp( );
+#
+
+sub measure_smtp () {
+ my ($buf);
+
+ $buf = $Services{Sendmail}{FileD}->getline;
+ while ($buf) {
+ ## process line read and check for eof
+ if ($buf) {
+ process_smtp_line ($buf);
+ }
+ if ($Services{Sendmail}{FileD}->eof) {
+ printf "SMTP: eof on $Services{Sendmail}{File}\n" if $Options{debug};
+ last; # get out of while($buf)
+ }
+ $buf = $Services{Sendmail}{FileD}->getline;
+ } ## while ($buf)
+
+ my $retval = CheckFileChange ("Sendmail", \$smtp_ino, \$smtp_size);
+
+ return $retval;
+}
+
+
+# -------------------------------------------------------------------
+#
+# init smtp vars
+#
+# usage: &init_smtp_vars();
+#
+
+sub init_smtp_vars() {
+ $smtp_froms = 0;
+ $smtp_MaxSize = 0;
+ $smtp_sizes = 0;
+
+ $smtp_MaxSeconds = 0;
+ $smtp_seconds = 0;
+ $smtp_sent = 0;
+
+ $smtp_fail = 0;
+ $smtp_retries = 0;
+ $smtp_queued = 0;
+ $smtp_t_or_f = 0;
+
+ $smtp_check_mail = 0;
+ $smtp_check_rcpt = 0;
+ $smtp_notifies = 0;
+ $smtp_dsns = 0;
+
+ $smtp_spam = 0;
+ $smtp_virus = 0;
+
+ $smtp_overquota = 0;
+
+ $smtp_undefs = 0;
+}
+
+
+# -------------------------------------------------------------------
+#
+# Parse smtp log line
+#
+# usage: &process_smtp_line ($buf);
+#
+
+sub process_smtp_line () {
+ my ($line) = @_;
+ my ($size, $seconds);
+
+ if (($line !~ /\ssendmail\[\d+\]:\s/) && ($line !~ /\smailscanner\[\d+\]:\s/) && ($line !~ /\sllmail\[\d+\]:\s/)) {
+ return 0;
+ }
+
+
+ # from
+ # Jul 16 03:22:12 server123 sendmail[4977]: e6G2M7O04977: from=<jsmith at server321.domain.com>, size=981, class=0, nrcpts=1, msgid=<200007152000.VAA24441 at server321.domain.com>, proto=ESMTP, daemon=MTA, relay=server321.domain.com [10.0.0.65]
+ # 0 Month, 1 Day, 2 hh:mm:ss, 3 nodename, 4 sendmail[NNNNN]:, 5 msg-id:, 6 from=FROM\,, 7 size=NNNNN\,, ...
+ if ($line =~ /: from=.*, size=(\d+)/i) {
+ $smtp_froms ++;
+ $size = $1;
+ $smtp_sizes += $size;
+ if ($size > $smtp_MaxSize) {
+ $smtp_MaxSize = $size;
+ }
+ printf "SMTP_FROM: %s", $line if $Options{debug};
+ # printf "smtp_froms=%s, size=%s, smtp_sizes=%s, smtp_MaxSize=%s\n", $smtp_froms, $size, $smtp_sizes, $smtp_MaxSize if $Options{debug};
+ return 0;
+ }
+
+ # to
+ #Jul 16 03:26:32 server123 sendmail[5060]: e6G2PqO05058: to=<info at domain1.pt>, delay=00:00:35, xdelay=00:00:35, mailer=esmtp, pri=120745, relay=server321.domain.com. [10.0.0.65], dsn=2.0.0, stat=Sent (DAA19487 Message accepted for delivery)
+ #Jul 16 03:15:16 server123 sendmail[4828]: e6EBXrO12616: to=<sales at mail.domain2.pt>, delay=1+14:41:13, xdelay=00:00:55, mailer=esmtp, pri=3001977, relay=mail.domain2.pt. [11.0.0.130], dsn=4.0.0, stat=Deferred: Connection refused by mail.domain2.pt.
+ #Jul 16 22:31:20 server123 sendmail[881]: e6GLUxP00881: to=<info at domain3.pt>, delay=00:00:11, xdelay=00:00:11, mailer=esmtp, pri=37973, relay=mail.domain4.pt. [12.0.0.15], dsn=5.0.0, stat=Service unavailable
+ #Jul 24 18:33:05 server999 sendmail[15932]: SAA15929: to=<jsmith at domain4.pt>, ctladdr=<jjjj at domain9.pt> (16306/1984), delay=00:00:10, xdelay=00:00:09, mailer=esmtp, relay=mail.domain4.pt. [13.0.0.3], stat=Sent (Ok)
+ if ($line =~ /: to=/) {
+ if ($line =~ /, delay=(\d+)*\+*(\d+):(\d+):(\d+), .*, stat=Sent/i) {
+ $seconds = 86400*$1 + 3600*$2 + 60*$3 + $4;
+
+ $smtp_seconds += $seconds;
+ if ($seconds > $smtp_MaxSeconds) {
+ $smtp_MaxSeconds = $seconds;
+ }
+ $smtp_sent ++;
+ printf "SMTP_SENT: %s", $line if $Options{debug};
+ # printf "seconds=%s, smtp_seconds=%s, smtp_MaxSeconds=%s, smtp_sent=%s\n", $seconds, $smtp_seconds, $smtp_MaxSeconds, $smtp_sent if $Options{debug};
+ return 0;
+ }
+ if ($line =~ /, dsn=5/i) {
+ $smtp_fail++;
+ printf "SMTP_FAIL: %s", $line if $Options{debug};
+ # printf "smtp_fail=%s\n", $smtp_fail if $Options{debug};
+ return 0;
+ }
+ if (($line =~ /, dsn=4/i) || ($line =~ /, stat=Deferred:/i)) {
+ $smtp_retries++;
+ printf "SMTP_RETRY: %s", $line if $Options{debug};
+ # printf "smtp_retries=%s\n", $smtp_retries if $Options{debug};
+ return 0;
+ }
+ if ($line =~ /, stat=queued/i) {
+ $smtp_queued++;
+ printf "SMTP_QUEUE: %s", $line if $Options{debug};
+ # printf "smtp_queued=%s\n", $smtp_queued if $Options{debug};
+ return 0;
+ }
+ $smtp_t_or_f++;
+ printf "SMTP_T_OR_F: %s", $line if $Options{debug};
+ # printf "smtp_t_or_f=%s\n", $smtp_t_or_f if $Options{debug};
+ return 0;
+ }
+
+ # ruleset=check_mail
+ #Jul 16 22:24:43 server123 sendmail[604]: e6GLNMO00604: ruleset=check_mail, arg1=<Mary.Wilson at domain10.pt>, relay=server321.domain.com [10.0.0.65], reject=451 4.1.8 <Mary.Wilson at domain10.pt>... Domain of sender address Mary.Wilson at domain10.pt does not resolve
+ if ($line =~ /: ruleset=check_mail, /i) {
+ $smtp_check_mail ++;
+ printf "SMTP_CHECK_MAIL: %s", $line if $Options{debug};
+ # printf "smtp_check_mail=%s\n", $smtp_check_mail if $Options{debug};
+ return 0;
+ }
+
+ # ruleset=check_rcpt
+ #Jul 19 16:54:55 server123 sendmail[11437]: e6JFsoO11437: ruleset=check_rcpt, arg1=<xyz at domain777.net>, relay=a.b.c.net [6.1.6.7], reject=550 5.7.1 <xyz at domain777.net>... Relaying denied
+ #Jul 19 17:34:54 server123 sendmail[12479]: e6JGYKO12479: ruleset=check_rcpt, arg1=<Edgar.Silva at mail.soso.domain8888.pt>, relay=individual [10.0.0.67], reject=450 4.7.1 <Edgar.Silva at mail.soso.domain8888.pt>... Can not check MX records for recipient host mail.soso.domain8888.pt
+ if ($line =~ /: ruleset=check_rcpt, /i) {
+ $smtp_check_rcpt ++;
+ printf "SMTP_CHECK_RCPT: %s", $line if $Options{debug};
+ # printf "smtp_check_rcpt=%s\n", $smtp_check_rcpt if $Options{debug};
+ return 0;
+ }
+
+ # postmaster notify:
+ #Jul 17 05:30:04 server123 sendmail[10016]: e6EKWRO24933: e6H401o10016: postmaster notify: Cannot send message within 2 days
+ if ($line =~ /: postmaster notify: /i) {
+ $smtp_notifies ++;
+ printf "SMTP_NOTIFIES: %s", $line if $Options{debug};
+ # printf "smtp_notifies=%s\n", $smtp_notifies if $Options{debug};
+ return 0;
+ }
+
+ # DSN
+ #Jul 18 22:28:58 server123 sendmail[7172]: e6ILQlO07170: e6ILSwO07172: DSN: Service unavailable
+ #Jul 19 14:38:00 server123 sendmail[1846]: e6HBWSO21997: e6JDU0t01846: DSN: Cannot send message within 2 days
+ #Jul 19 17:33:51 server123 sendmail[12272]: e6JGTlO12270: e6JGXpO12272: DSN: Return receipt
+ if ($line =~ /: DSN: /i) {
+ $smtp_dsns ++;
+ printf "SMTP_DSN: %s", $line if $Options{debug};
+ # printf "smtp_dsns=%s\n", $smtp_dsns if $Options{debug};
+ return 0;
+ }
+
+ # Jun 7 11:37:08 server24 mailscanner[494]: Message g57Aam400830 is spam according to SpamAssassin (score=10.5, required 5, FROM_MALFORMED, FROM_NO_USER, PLING, PLING_PLING, HTML_EMBEDS, RAZOR_CHECK, CTYPE_JUST_HTML)
+ if ($line =~ /: Message .* is spam according to/) {
+ $smtp_spam ++;
+ printf "SMTP_SPAM: %s", $line if $Options{debug};
+ # printf "smtp_spam=%s\n", $smtp_spam if $Options{debug};
+ return 0;
+ }
+
+
+ # Jun 7 10:31:33 ns2 mailscanner[23848]: Found 3 viruses in messages g579Uu428481,g579Uv428484
+ # Jun 7 10:34:20 ns2 mailscanner[23848]: Found 1 viruses in messages g579Xm428666
+ if ($line =~ /: Found (\d+) viruses in message/i) {
+ $smtp_virus += $1;
+ printf "SMTP_VIRUS: %s", $line if $Options{debug};
+ # printf "smtp_virus=%s\n", $smtp_virus if $Options{debug};
+ return 0;
+ }
+
+ # ignore the rest of mailscanner
+ # Jun 7 10:31:33 ns2 mailscanner[23848]:
+ if ($line =~ / mailscanner\[\d+\]: /) {
+ return 0;
+ }
+
+ # Nov 4 16:30:29 host2 llmail[9188]: OverQuota: user4 current: 15808428 bytes limit: 15728640 bytes
+ if ($line =~ / llmail\[\d+\]: OverQuota: /) {
+ $smtp_overquota ++;
+ printf "SMTP_OVERQUOTA: %s", $line if $Options{debug};
+ # printf "smtp_overquota: %s\n", $smtp_overquota if $Options{debug};
+ return 0;
+ }
+
+ $smtp_undefs ++;
+ printf "SMTP_UNDEF: %s", $line if $Options{debug};
+ # printf "smtp_undefs=%s\n", $smtp_undefs if $Options{debug};
+ return 0;
+}
+
+# -------------------------------------------------------------------
+#
+# Put the smtp values for output
+#
+# usage: &put_smtp();
+#
+
+sub put_smtp() {
+ &put_output("smtp_from", sprintf("%8.2f", $smtp_froms));
+ &put_output("smtp_tops", sprintf("%8.2f", $smtp_MaxSize));
+ if ($smtp_froms) {
+ &put_output("smtp_sizes", sprintf("%8.2f", $smtp_sizes/$smtp_froms));
+ } else {
+ &put_output("smtp_sizes", sprintf("%8.2f", 0));
+ }
+ &put_output("smtp_sent", sprintf("%8.2f", $smtp_sent));
+ &put_output("smtp_maxd", sprintf("%8.2f", $smtp_MaxSeconds));
+ if ($smtp_sent) {
+ &put_output("smtp_delay", sprintf("%8.2f", $smtp_seconds/$smtp_sent));
+ } else {
+ &put_output("smtp_delay", sprintf("%8.2f", 0));
+ }
+ &put_output("smtp_fail", sprintf("%8.2f", $smtp_fail));
+ &put_output("smtp_rtrs", sprintf("%8.2f", $smtp_retries));
+ &put_output("smtp_queued", sprintf("%8.2f", $smtp_queued));
+ &put_output("smtp_torf", sprintf("%8.2f", $smtp_t_or_f));
+ &put_output("smtp_c_ml", sprintf("%8.2f", $smtp_check_mail));
+ &put_output("smtp_c_rt", sprintf("%8.2f", $smtp_check_rcpt));
+ &put_output("smtp_ntfs", sprintf("%8.2f", $smtp_notifies));
+ &put_output("smtp_dsns", sprintf("%8.2f", $smtp_dsns));
+
+ &put_output("smtp_spam", sprintf("%8.2f", $smtp_spam));
+ &put_output("smtp_virus", sprintf("%8.2f", $smtp_virus));
+
+ &put_output("smtp_overquota", sprintf("%8.2f", $smtp_overquota));
+
+ &put_output("smtp_undf", sprintf("%8.2f", $smtp_undefs));
+
+ return 0;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Pop.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Pop.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Pop.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,294 @@
+#
+# Pop.pm : Orca_Services package for monitoring pop service
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Pop;
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Pop}{File} = "/var/log/ipop3d.log";
+ $Services{Pop}{FileD} = "";
+ $Services{Pop}{Ok} = -1;
+ $Services{Pop}{External} = 0;
+ $Services{Pop}{Init} = "init_pop";
+ $Services{Pop}{Init_Vars} = "init_pop_vars";
+ $Services{Pop}{Measure} = "measure_pop";
+ $Services{Pop}{Put} = "put_pop";
+
+ $PrgOptions{"pop_logfile=s"} = \$Services{Pop}{File};
+
+ $HelpText{$Services{Dns}{File}} = "--pop_logfile=FILE syslog from pop (default:";
+}
+
+use Orca_Services::Utils;
+use Orca_Services::Output;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_pop
+ init_pop_vars
+ measure_pop
+ put_pop
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($pop_connect, $pop_login , $pop_logout, $pop_failure, $pop_refused);
+my ($pop_net_error, $pop_local_error, $pop_undefs);
+my ($pop_ino, $pop_size);
+
+#
+# init_pop - set POP vars, open the logfile and seek into the end.
+#
+# usage: &init_pop($pop_logfile);
+#
+sub init_pop {
+ my ($filename) = @_;
+ my ($retval);
+
+ if ($filename) {
+ $retval = OpenFile($filename, "Pop", \$pop_ino, \$pop_size);
+ }
+
+ if($retval == 0) {
+ &init_pop_vars ();
+ }
+ return $retval;
+}
+
+
+#
+# init pop vars
+#
+# usage: &init_pop_vars();
+#
+sub init_pop_vars() {
+ $pop_connect = 0;
+ $pop_login = 0;
+ $pop_logout = 0;
+
+ $pop_failure = 0;
+ $pop_refused = 0;
+
+ $pop_net_error = 0;
+ $pop_local_error = 0;
+
+ $pop_undefs = 0;
+}
+
+
+#
+# Get values for pop columns
+#
+# usage: &measure_pop( );
+#
+
+sub measure_pop () {
+ my($buf);
+
+ $buf = $Services{Pop}{FileD}->getline;
+ while ($buf) {
+ ## process line read and check for eof
+ if ($buf) {
+ &process_pop_line ($buf);
+ }
+ if ($Services{Pop}{FileD}->eof) {
+ printf "POP: eof on $Services{Pop}{File}\n" if $Options{debug};
+ last; # get out of while($buf)
+ }
+ $buf = $Services{Pop}{FileD}->getline;
+ } ## while ($buf)
+
+ my $retval = CheckFileChange ("Pop", \$pop_ino, \$pop_size);
+
+ return $retval;
+
+}
+
+
+#
+# Parse pop log line
+#
+# usage: &process_pop_line ($buf);
+#
+sub process_pop_line () {
+ my ($line) = @_;
+
+
+ # Oct 27 04:03:00 host2 pop3d: Connection, ip=[::ffff:10.0.0.133]
+ # Oct 27 04:03:00 host2 pop3d: LOGIN, user=user7, ip=[::ffff:10.0.0.133]
+ # Oct 27 04:03:00 host2 pop3d: LOGOUT, user=user7, ip=[::ffff:10.0.0.133], top=0, retr=0
+
+ if (($line !~ / ipop3d\[\d+\]: /) &&
+ ($line !~ / perdition\[\d+\]: /) &&
+ ($line !~ / pop3d: /)) {
+ return 0;
+ }
+
+ ### connect
+ # Aug 11 07:01:50 host1 ipop3d[13929]: connect from 14.5.8.10
+ # Feb 28 22:13:34 host1 perdition[26127]: Connect: 10.0.0.1->12.1.1.1 user="id1" server="host1.KPNQwest.pt" port="110"
+ # Oct 27 04:03:00 host2 pop3d: Connection, ip=[::ffff:10.0.0.133]
+
+ if (($line =~ /: connect from /i) ||
+ ($line =~ /: Connect: /i) ||
+ ($line =~ /: Connection, /i)) {
+ $pop_connect ++;
+ printf "POP_CONNECT: %s", $line if $Options{debug};
+ printf "pop_connect=%s\n", $pop_connect if $Options{debug};
+ return 0;
+ }
+
+ ### login + auth
+ # Aug 11 07:01:57 host1 ipop3d[13928]: Login user=luser2 host=host.domain.pt [13.16.6.27] nmsgs=0/0
+ # Aug 11 07:02:06 host1 ipop3d[13936]: Auth user=luser3 host=2-4-4.domain.pt [13.16.2.18] nmsgs=0/0
+ # Feb 28 22:13:34 host1 perdition[26121]: Auth: 10.0.0.1->12.1.1.1 user="id1" server="host1.KPNQwest.pt" port="110"
+ # Oct 27 04:03:00 host2 pop3d: LOGIN, user=user7, ip=[::ffff:10.0.0.133]
+
+ if ( ($line =~ /: Login user=/i) ||
+ ($line =~ /: Auth user=/i) ||
+ ($line =~ /: Auth: /i) ||
+ ($line =~ /: LOGIN, /i)) {
+ $pop_login ++;
+ printf "POP_LOGIN: %s", $line if $Options{debug};
+ printf "pop_login=%s\n", $pop_login if $Options{debug};
+ return 0;
+ }
+
+ ### logout
+ # Aug 11 07:01:50 host1 ipop3d[13929]: Logout user=luser4 host=[14.6.8.10] nmsgs=0 ndele=0
+ # Aug 11 11:20:24 host1 ipop3d[1866]: Autologout user=luser5 host=3-0-0.domain.pt [13.16.1.18]
+ # Feb 28 22:13:35 host1 perdition[26127]: Closing: 10.0.0.1->12.1.1.1 user=id1 12 18
+ # Oct 27 04:03:48 host2 perdition[14872]: Close: 11.1.1.2->13.3.3.4 user="user2" received=6 sent=0
+ # Oct 27 04:03:00 host2 pop3d: LOGOUT, user=user7, ip=[::ffff:10.0.0.133], top=0, retr=0
+
+ if (($line =~ /: .*[lL]ogout user=/i) ||
+ ($line =~ /: Closing: /i) ||
+ ($line =~ /: Close: /i) ||
+ ($line =~ /: LOGOUT, /i)) {
+ $pop_logout ++;
+ printf "POP_LOGOUT: %s", $line if $Options{debug};
+ printf "pop_LOGOUT=%s\n", $pop_logout if $Options{debug};
+ return 0;
+ }
+
+ ### failure
+ # Aug 11 09:19:19 host1 ipop3d[22171]: Login failure user=luser44 host=4-0-0.domain.pt [13.16.12.1]
+ # Aug 11 09:19:22 host1 ipop3d[22171]: AUTHENTICATE LOGIN failure host=4-0-0.domain.pt [13.16.12.1]
+ # Aug 11 09:47:47 host1 ipop3d[25308]: AUTHENTICATE luser323 failure host=[13.12.24.24]
+ # Feb 28 21:42:54 host1 perdition[21930]: Fatal Error reading authentication information from client "10.0.0.1->12.1.1.1 ": Exiting child
+ # Feb 28 21:46:56 host1 perdition[22466]: Fail reauthentication for user id1
+
+ if (($line =~ / failure /i) ||
+ ($line =~ /: Fatal Error reading authentication information from client /i) ||
+ ($line =~ /: Fail reauthentication for user /i)) {
+ $pop_failure ++;
+ printf "POP_FAILURE: %s", $line if $Options{debug};
+ printf "pop_failure=%s\n", $pop_failure if $Options{debug};
+ return 0;
+ }
+
+ ### refused
+ # Aug 11 13:32:14 host1 ipop3d[28886]: refused connect from 13.17.8.28
+
+ if ($line =~ /: refused connect from /i) {
+ $pop_refused ++;
+ printf "POP_REFUSED: %s", $line if $Options{debug};
+ printf "pop_refused=%s\n", $pop_refused if $Options{debug};
+ return 0;
+ }
+
+ ### local_error
+ # Aug 11 11:50:36 host1 ipop3d[13132]: Error opening or locking INBOX user=luser10 host=3-4-3.domain.pt [13.16.4.7]
+ # Feb 28 21:41:53 host1 perdition[20588]: Fatal error piping data. Exiting child.
+
+ if (($line =~ /: Error opening or locking INBOX user=/i) ||
+ ($line =~ /: Fatal error piping data. Exiting child./i)) {
+ $pop_local_error ++;
+ printf "POP_LOCAL_ERROR: %s", $line if $Options{debug};
+ printf "pop_local_error=%s\n", $pop_local_error if $Options{debug};
+ return 0;
+ }
+
+ ### net_error
+ # Aug 11 07:36:14 host1 ipop3d[15759]: Command stream end of file while reading line user=luser234 host=9-9-9-domain.pt [13.16.4.5]
+ # Aug 11 09:50:09 host1 ipop3d[24960]: Connection reset by peer while reading line user=luser555 host=[12.5.19.16]
+ # Aug 11 12:15:01 host1 ipop3d[16601]: Connection timed out while reading line user=luser7985 host=4-5-6.domain.pt [13.16.1.15]
+ # Oct 27 04:17:16 host2 pop3d: Disconnected, ip=[::ffff:10.0.0.132]
+ # Oct 27 04:19:59 host2 pop3d: DISCONNECTED, user=user4, ip=[::ffff:10.0.0.133], top=0, retr=0
+ # Oct 27 10:46:50 host2 pop3d: TIMEOUT, user=user55, ip=[::ffff:10.0.0.133], top=0, retr=0
+
+ if ( ($line =~ /: Command stream end of file while reading line user=/i) ||
+ ($line =~ /: Connection reset by peer while reading line user=/i) ||
+ ($line =~ /: Connection timed out while reading line user=/i) ||
+ ($line =~ /: Disconnected,/i) ||
+ ($line =~ /: TIMEOUT,/i) ) {
+ $pop_net_error ++;
+ printf "POP_NET_ERROR: %s", $line if $Options{debug};
+ printf "pop_net_error=%s\n", $pop_net_error if $Options{debug};
+ return 0;
+ }
+
+
+ $pop_undefs ++;
+ printf "POP_UNDEF: %s", $line if $Options{debug};
+ printf "pop_undefs=%s\n", $pop_undefs if $Options{debug};
+ return 0;
+}
+
+
+#
+# Put the pop values for output
+#
+# usage: &put_pop();
+#
+
+sub put_pop() {
+ &put_output("pop_connect", sprintf("%8.2f", $pop_connect));
+ &put_output("pop_login", sprintf("%8.2f", $pop_login));
+ &put_output("pop_logout", sprintf("%8.2f", $pop_logout));
+
+ &put_output("pop_failure", sprintf("%8.2f", $pop_failure));
+ &put_output("pop_refused", sprintf("%8.2f", $pop_refused));
+
+ &put_output("pop_net_error", sprintf("%8.2f", $pop_net_error));
+ &put_output("pop_local_error", sprintf("%8.2f", $pop_local_error));
+
+ &put_output("pop_undefs", sprintf("%8.2f", $pop_undefs));
+
+ return 0;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Http.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Http.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Http.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,278 @@
+#
+# Http.pm : Orca_Services package for http monitoring
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Http;
+
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Http}{File} = "/export/home/squid/logs/access.log";
+ $Services{Http}{FileD} = "";
+ $Services{Http}{Ok} = -1;
+ $Services{Http}{External} = 0;
+ $Services{Http}{Init} = "init_http";
+ $Services{Http}{Init_Vars} = "init_http_vars";
+ $Services{Http}{Measure} = "measure_http";
+ $Services{Http}{Put} = "put_http";
+
+ #
+ # something you want to do in the external loop
+ $Services{Http}{Extra} = "count_http_procs";
+
+ $PrgOptions{"http_logfile=s"} = \$Services{Http}{File};
+
+ $HelpText{$Services{Http}{File}} = "--http_logfile=FILE log from http (default:";
+}
+
+use Proc::ProcessTable;
+use Orca_Services::Utils;
+use Orca_Services::Output;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_http
+ init_http_vars
+ measure_http
+ put_http
+ count_http_procs
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($http_procs, $http_condgets, $http_gets, $http_heads, $http_posts);
+my ($http_hits, $http_errors, $http_total_bytes, $http_1k, $http_10k);
+my ($http_100k, $http_1000k, $http_1M, $http_undefs);
+my ($http_ino, $http_size);
+
+#
+# init_http - set HTTP vars, open the logfile and seek into the end.
+#
+# usage: &init_http($http_logfile);
+#
+sub init_http {
+ my ($filename) = @_;
+ my ($retval);
+
+ if ($filename) {
+ $retval = OpenFile($filename, "Http", \$http_ino, \$http_size);
+ }
+
+ if($retval == 0) {
+ &init_http_vars ();
+ }
+ return $retval;
+}
+
+#
+# Get values for http columns
+#
+# usage: &measure_http( );
+#
+
+sub measure_http () {
+ my ($buf);
+
+ $buf = $Services{Http}{FileD}->getline;
+ while ($buf) {
+ ## process line read and check for eof
+ if ($buf) {
+ &process_http_line ($buf);
+ }
+ if ($Services{Http}{FileD}->eof) {
+ printf "HTTP: eof on $Services{Http}{File}\n" if $Options{debug};
+ last; # get out of while($buf)
+ }
+ $buf = $Services{Http}{FileD}->getline;
+ } ## while ($buf)
+
+ my $retval = CheckFileChange ("Http", \$http_ino, \$http_size);
+
+ return $retval;
+}
+
+
+#
+# init http vars
+#
+# usage: &init_http_vars();
+#
+
+sub init_http_vars() {
+ $http_procs = 0;
+
+ $http_condgets = 0;
+ $http_gets = 0;
+ $http_heads = 0;
+ $http_posts = 0;
+
+ $http_hits = 0;
+ $http_errors = 0;
+ $http_total_bytes = 0;
+ $http_1k = $http_10k = $http_100k = $http_1000k = $http_1M = 0;
+
+ $http_undefs = 0;
+}
+
+#
+# Parse http log line
+#
+# usage: &process_http_line ($buf);
+#
+
+sub process_http_line () {
+ my ($line) = @_;
+
+ printf "HTTP_LINE: %s", $line if $Options{debug};
+
+ ### mix-bayonne-102-1-111.abo.wanadoo.fr - - [28/Feb/2001:17:46:54 +0000] "GET /Lisboa/i/lisboa.html HTTP/1.1" 301 328 "http://www.quid.fr/generation/detail_selectweb.php?iso=pt" "Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; DigExt; KITV4.7 Wanadoo)"
+ if ($line =~ / \"GET\s.*\"\s(3\d+)\s(\d+)/) {
+ $http_condgets++;
+ &process_http_values( $1, $2 );
+ return 0
+ }
+ ### mail.abola.pt - - [28/Feb/2001:17:49:24 +0000] "GET /images/mc_kpnq.gif HTTP/1.1" 304 - "http://www.kpnqwest.pt/entrada.html" "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)"
+ if ($line =~ / \"GET\s.*\"\s(3\d+)\s\-/) {
+ $http_condgets++;
+ &process_http_values( $1, 0 );
+ return 0
+ }
+
+ ### p153a155.teleweb.pt - - [27/Feb/2001:02:02:28 +0000] "GET /images/menu_0.gif HTTP/1.1" 200 6356 "http://www.kpnqwest.pt/menu.html" "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90)"
+ if ($line =~ / \"GET\s.*\"\s(\d+)\s(\d+)/) {
+ $http_gets++;
+ &process_http_values( $1, $2 );
+ return 0
+ }
+
+
+ ### marvin.northernlight.com - - [27/Feb/2001:17:55:52 +0000] "HEAD /corporate/press_130100.html HTTP/1.1" 200 0 "-" "Gulliver/1.3"
+ if ($line =~ / \"HEAD\s.*\"\s(\d+)\s(\d+)/) {
+ $http_heads++;
+ &process_http_values( $1, $2 );
+ return 0
+ }
+
+ ### p87.b.shuttle.de - - [27/Feb/2001:10:55:58 +0000] "POST /cgi-bin/idx/eunet/search.dat HTTP/1.0" 200 5932 "http://www.kpnqwest.pt/entrada.html" "Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)"
+ if ($line =~ / \"HEAD\s.*\"\s(\d+)\s(\d+)/) {
+ $http_posts++;
+ &process_http_values( $1, $2 );
+ return 0
+ }
+
+ $http_undefs++;
+ printf "HTTP_UNDEF: %s", $line if $Options{debug};
+ return 0;
+}
+
+sub process_http_values () {
+ my ($code, $bytes) = @_;
+
+
+ $http_hits++;
+ $http_total_bytes += $bytes;
+
+ if ($code =~ /^[45]\d\d/) {
+ $http_errors++;
+ }
+
+ printf "HTTP_code_bytes: %s %s", $code, $bytes if $Options{debug};
+ if ($bytes < 1024) {
+ $http_1k ++;
+ } elsif ($bytes < 10240) {
+ $http_10k ++;
+ } elsif ($bytes < 102400) {
+ $http_100k ++;
+ } elsif ($bytes < 1024000) {
+ $http_1000k ++;
+ } else {
+ $http_1M ++;
+ }
+
+ return 0;
+}
+
+
+
+# -------------------------------------------------------------------
+#
+# Put the http values for output
+#
+# usage: &put_http();
+#
+
+sub put_http() {
+ &put_output("http_hits", sprintf("%8.2f", $http_hits));
+ &put_output("http_condgets", sprintf("%8.2f", $http_condgets));
+ &put_output("http_gets", sprintf("%8.2f", $http_gets));
+ &put_output("http_heads", sprintf("%8.2f", $http_heads));
+ &put_output("http_posts", sprintf("%8.2f", $http_posts));
+ &put_output("http_errors", sprintf("%8.2f", $http_errors));
+ &put_output("http_undefs", sprintf("%8.2f", $http_undefs));
+
+ if ($interval) {
+ &put_output("http_Bps", sprintf("%8.2f", $http_total_bytes/$interval));
+ } else {
+ &put_output("http_Bps", sprintf("%8.2f", 0));
+ }
+
+ if ($http_hits) {
+ &put_output("http_1k", sprintf("%8.2f", $http_1k/$http_hits));
+ &put_output("http_10k", sprintf("%8.2f", $http_10k/$http_hits));
+ &put_output("http_100k", sprintf("%8.2f", $http_100k/$http_hits));
+ &put_output("http_1000k", sprintf("%8.2f", $http_1000k/$http_hits));
+ &put_output("http_1M", sprintf("%8.2f", $http_1M/$http_hits));
+ } else {
+ &put_output("http_1k", sprintf("%8.2f", 0));
+ &put_output("http_10k", sprintf("%8.2f", 0));
+ &put_output("http_100k", sprintf("%8.2f", 0));
+ &put_output("http_1000k", sprintf("%8.2f", 0));
+ &put_output("http_1M", sprintf("%8.2f", 0));
+ }
+
+ &put_output("http_procs", sprintf("%8.2f", $http_procs));
+}
+
+sub count_http_procs {
+ my $t = new Proc::ProcessTable;
+ $http_procs = 0;
+ foreach $p ( @{$t->table} ){
+ if ($p->cmndline =~ /http/) {
+ $http_procs++;
+ }
+ }
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Nntp.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Nntp.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Nntp.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,191 @@
+#
+# Nntp.pm : Orca_Services package for monitoring nntp
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Nntp;
+
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Nntp}{File} = "/var/log/news/news.debug";
+ $Services{Nntp}{FileD} = "";
+ $Services{Nntp}{Ok} = -1;
+ $Services{Nntp}{External} = 0;
+ $Services{Nntp}{Init} = "init_nntpcache";
+ $Services{Nntp}{Init_Vars} = "init_nntpcache";
+ $Services{Nntp}{Measure} = "measure_nntpcache";
+ $Services{Nntp}{Put} = "put_nntpcache";
+
+ $PrgOptions{"nntpcache_logfile=s"} = \$Services{Nntp}{File};
+
+ $HelpText{$Services{Nntp}{File}} = "--nntpcache_logfile=FILE log from nntpcache (default:";
+}
+
+use Orca_Services::Utils;
+use Orca_Services::Output;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_nntpcache
+ init_nntpcache_vars
+ measure_nntpcache
+ put_nntpcache
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($nntpcache_connects,$nntpcache_groups,$nntpcache_articles);
+my ($nntpcache_ino, $nntpcache_size);
+
+#
+# init_nntpcache - set NNTPCACHE vars, open the logfile and seek into the end.
+#
+# usage: &init_nntpcache($nntpcache_logfile);
+#
+sub init_nntpcache {
+ my ($filename) = @_;
+ my ($retval);
+
+ if ($filename) {
+ $retval = OpenFile($filename, "Nntp", \$nntpcache_ino, \$nntpcache_size);
+ }
+
+ if($retval == 0) {
+ &init_nntpcache_vars ();
+ }
+ return $retval;
+}
+
+
+#
+# Get values for nntpcache columns
+#
+# usage: &measure_nntpcache( );
+#
+
+sub measure_nntpcache () {
+ my($buf);
+
+ $buf = $Services{Nntp}{FileD}->getline;
+ while ($buf) {
+ ## process line read and check for eof
+ if ($buf) {
+ &process_nntpcache_line ($buf);
+ }
+ if ($Services{Nntp}{FileD}->eof) {
+ printf "NNTPCACHE: eof on $Services{Nntp}{File}\n" if $Options{debug};
+ last; # get out of while($buf)
+ }
+ $buf = $Services{Nntp}{FileD}->getline;
+ } ## while ($buf)
+
+ my $retval = CheckFileChange ("Nntp", \$nntpcache_ino, \$nntpcache_size);
+
+ return $retval;
+}
+
+
+#
+# init nntpcache vars
+#
+# usage: &init_nntpcache_vars();
+#
+
+sub init_nntpcache_vars() {
+ $nntpcache_connects = 0;
+ $nntpcache_groups = 0;
+ $nntpcache_articles = 0;
+}
+
+
+#
+# Parse nntpcache log line
+#
+# usage: &process_nntpcache_line ($buf);
+#
+
+sub process_nntpcache_line () {
+ my ($line) = @_;
+
+ if ($line !~ /\snntpcache-client\[\d+\]:\s/) {
+ return 0;
+ }
+
+
+ # connect from
+ # Nov 5 16:27:01 news nntpcache-client[6789]: 10.1.2.2 connect from (10.1.2.2)
+
+ if ($line =~ /\sconnect\sfrom\s/) {
+ $nntpcache_connects ++;
+ printf "NNTPCACHE_CONNECTS: %s", $line if $Options{debug};
+ return 0;
+ }
+
+ # GROUP
+ # Nov 5 16:27:01 news nntpcache-client[6789]: sockets.c:455: <- GROUP microsoft.public.visual.sourcesafe
+
+ if ($line =~ /:\s<-\sGROUP\s/) {
+ $nntpcache_groups ++;
+ printf "NNTPCACHE_GROUPS: %s", $line if $Options{debug};
+ return 0;
+ }
+
+ # ARTICLE
+ # Nov 5 16:27:07 news nntpcache-client[6789]: sockets.c:455: <- ARTICLE 13460
+
+ if ($line =~ /:\s<-\sARTICLE\s/) {
+ $nntpcache_articles ++;
+ printf "NNTPCACHE_ARTICLES: %s", $line if $Options{debug};
+ return 0;
+ }
+
+ return 0;
+}
+
+
+#
+# Put the nntpcache values for output
+#
+# usage: &put_nntpcache();
+#
+sub put_nntpcache() {
+ &put_output("nntpcache_connects", sprintf("%8.2f", $nntpcache_connects));
+ &put_output("nntpcache_groups", sprintf("%8.2f", $nntpcache_groups));
+ &put_output("nntpcache_articles", sprintf("%8.2f", $nntpcache_articles));
+
+ return 0;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Utils.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Utils.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Utils.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,128 @@
+#
+# Utils.pm : Orca_Services package for some usefull functions
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Utils;
+
+use strict;
+use Carp;
+use Exporter;
+use IO::File;
+use Sys::Syslog;
+use Orca_Services::Vars;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(logit
+ OpenFile
+ CheckFileChange
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+#
+# logit -- send MSG(s) to the syslog.
+#
+# usage: &logit($msg_to_log);
+#
+
+sub logit {
+ my($Msg) = @_;
+
+ &Sys::Syslog::openlog("$progname", 'cons,pid', "$log_facility");
+ &Sys::Syslog::syslog("$log_priority", $Msg);
+ &Sys::Syslog::closelog();
+}
+
+sub OpenFile {
+ my ($filename, $ServName, $ref_ino, $ref_size) = @_;
+ my ($retval, $seek_ok);
+
+ $retval = 0;
+ $Services{$ServName}{FileD} = new IO::File "$filename", "r";
+ if (defined($Services{$ServName}{FileD})) {
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($Services{$ServName}{FileD});
+ if (!$dev) {
+ &logit ("can't stat $filename");
+ warn "$progname: can't stat $filename\n";
+ $retval = 1;
+ }
+ $$ref_ino = $ino;
+ $$ref_size = $size;
+ $seek_ok = seek($Services{$ServName}{FileD}, 0, SEEK_END);
+ if (!$seek_ok) {
+ &logit ("can't seek into EOF on $filename");
+ warn "$progname: can't seek into EOF on $filename\n";
+ $retval = 2;
+ }
+ } else {
+ &logit ("can't open $filename");
+ warn "$progname: can't open $filename\n";
+ $retval = 3;
+ }
+
+ return $retval;
+}
+
+sub CheckFileChange {
+ my ($ServName, $ref_ino, $ref_size) = @_;
+ my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev );
+ my ($size, $atime, $mtime, $ctime, $blksize, $blocks);
+
+ # test for file change via different inode or filesize decrease
+ $dev = $ino = $mode = $nlink = $uid = $gid = $rdev =
+ $size = $atime = $mtime = $ctime = $blksize = $blocks = '';
+ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks) = stat($Services{$ServName}{File});
+ if (!$dev) {
+ &logit ("can't stat $Services{$ServName}{File}");
+ warn "$progname: can't stat $Services{$ServName}{File}\n";
+ return 1;
+ }
+ printf "Filedesc %s old_ino=%s vs. ino=%s\told_size=%s vs. size=%s\n", $ServName, $$ref_ino, $ino, $$ref_size, $size if $Options{debug};
+ if (($$ref_ino != $ino) || ($$ref_size > $size)) {
+ undef $Services{$ServName}{FileD};
+ printf "Ffile change on $Services{$ServName}{File}\n" if $Options{debug};
+ $Services{$ServName}{FileD} = new IO::File "$Services{$ServName}{File}", "r";
+ if (!defined ($Services{$ServName}{FileD})) {
+ &logit ("can't re-open $Services{$ServName}{File}");
+ warn "$progname: can't re-open $Services{$ServName}{File}\n";
+ $$ref_ino = $$ref_size = 0;
+ return 2;
+ }
+ $$ref_ino = $ino;
+ $$ref_size = $size;
+ }
+ return 0;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Output.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Output.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Output.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,158 @@
+#
+# Output.pm : Orca_Services package for output funcions
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Output;
+
+use strict;
+use Carp;
+use Exporter;
+use POSIX;
+use IO::File;
+use Sys::Syslog;
+use Orca_Services::Utils;
+use Orca_Services::Vars;
+
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(put_output
+ flush_output
+ check_output
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my (@col_data, @col_comment);
+
+#
+# check_output - set outputfile vars, open the outputfile.
+#
+# usage: &check_output($outputdir);
+#
+
+sub check_output {
+ my ($outputdir) = @_;
+ my ($sec1,$min1,$hour1,$mday1,$mon1,$year1,$wday1,$yday1,$isdst1);
+ my ($now_string);
+
+ $sec1=$min1=$hour1=$mday1=$mon1=$year1=$wday1=$yday1=$isdst1 = 0;
+
+ ($sec1,$min1,$hour1,$mday1,$mon1,$year1,$wday1,$yday1,$isdst1) = localtime();
+
+ if ($mday1 != $SaveDay) {
+ # First time or day has changed, start new logfile.
+ if (OUTFD->opened) {
+ close(OUTFD); # ignore error
+ }
+ if (($Options{compress}) && ($SaveDay)) { # just on day change
+ if ($OutputFilename) {
+ &logit ("compressing $OutputFilename");
+ system ("$Options{compress} $OutputFilename"); # ignore error ??
+ }
+ }
+
+ $now_string = strftime "%Y-%m-%d", localtime;
+
+ my $subday = 0;
+ my $tempfilename = "$outputdir/orca_services-" . $now_string . "-" . sprintf("%03d", $subday);
+ while (-f $tempfilename) {
+ $subday ++;
+ $tempfilename = "$outputdir/orca_services-" . $now_string . "-" . sprintf("%03d", $subday);
+ }
+ $OutputFilename = $tempfilename;
+
+ if (!open (OUTFD, ">$OutputFilename")) {
+ &logit ("can't open outputfile $OutputFilename");
+ die "$progname: can't open outputfile $OutputFilename\n";
+ }
+
+ $SaveDay = $mday1;
+ $print_header = 1;
+ }
+
+ return 0;
+}
+
+
+#
+# flush_output - dumps line into outputfile
+#
+# usage: &flush_output();
+#
+
+sub flush_output() {
+ if ($print_header) {
+ &print_columns(\@col_comment);
+ $print_header = 0;
+ }
+ &print_columns(\@col_data);
+ $current_column = 0;
+}
+
+#
+# Send the stored columns of information to the output.
+#
+# usage: &print_columns( \@array );
+#
+
+sub print_columns() {
+ my ($ref) = @_;
+ my ($i, @col);
+
+ @col = @$ref;
+
+ for ($i=0; $i < $current_column; $i++) {
+ printf OUTFD "%s", $col[$i];
+ if ($i != $current_column - 1) {
+ printf OUTFD " ";
+ }
+ }
+ printf OUTFD "\n";
+ OUTFD->flush;
+}
+
+#
+# Add one column of comments and data to the buffers.
+#
+# usage: &put_output( $comment, $data );
+#
+
+sub put_output() {
+ my ($comment, $data) = @_;
+
+ printf "OUT: --%s-- %s\n", $comment, $data if $Options{debug};
+ $col_comment[$current_column] = $comment;
+ $col_data[$current_column] = $data;
+ $current_column++;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Mailq.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Mailq.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Mailq.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,134 @@
+#
+# Mailq.pm : Orca_Services package for mailq monitoring
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+
+package Orca_Services::Mailq;
+
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Mailq}{File} = "on";
+ $Services{Mailq}{FileD} = "";
+ $Services{Mailq}{Ok} = -1;
+ $Services{Mailq}{External} = 1;
+ $Services{Mailq}{Init} = "init_mailq";
+ $Services{Mailq}{Init_Vars} = "init_mailq_vars";
+ $Services{Mailq}{Measure} = "measure_mailq";
+ $Services{Mailq}{Put} = "put_mailq";
+
+ $PrgOptions{"mailq=s"} = \$Services{Mailq}{File};
+
+ $HelpText{$Services{Mailq}{File}} = "--mailq=[on|off] get mailq total requests (default:";
+}
+
+use Orca_Services::Output;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_mailq
+ init_mailq_vars
+ measure_mailq
+ put_mailq
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($mailq_total);
+
+#
+# Get values for mailq columns
+#
+# usage: &measure_mailq( );
+#
+
+sub measure_mailq () {
+ my ($mailq_t, $line);
+
+ open (MFD, "$MAILQCMD |");
+ $line = <MFD>;
+ close (MFD);
+
+ if ($line =~ /(\d+)/i) {
+ $mailq_t = $1;
+ } else {
+ $mailq_t = 0;
+ }
+
+ print "MAILQ : $mailq_t\n" if $Options{debug};
+ $mailq_total += $mailq_t;
+
+ return 0;
+}
+
+
+#
+# init mailq
+#
+# usage: &init_mailq();
+#
+
+sub init_mailq() {
+ if ($Services{Mailq}{File} eq "off" ){
+ return -1;
+ }
+ return 0;
+}
+
+
+#
+# init mailq vars
+#
+# usage: &init_mailq_vars();
+#
+
+sub init_mailq_vars() {
+ $mailq_total = 0;
+}
+
+
+#
+# Put the mailq values for output
+#
+# usage: &put_mailq();
+#
+
+sub put_mailq() {
+
+ &put_output("mailq_total", sprintf("%8.2f", $mailq_total));
+
+ return 0;
+}
+
+1;
Added: branches/orca/import_orca_services_2.0/lib/Orca_services/Slapd.pm
==============================================================================
--- branches/orca/import_orca_services_2.0/lib/Orca_services/Slapd.pm (original)
+++ branches/orca/import_orca_services_2.0/lib/Orca_services/Slapd.pm 2003-03-08 10:26:13.000000000 -0800
@@ -0,0 +1,183 @@
+#
+# Slapd.pm : Orca_Services package for monitoring slapd
+#
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
+#
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
+#
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
+#
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
+#
+#
+# BUGS:
+#
+#
+# TODO:
+#
+#
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
+#
+#
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
+#
+#
+#
+
+package Orca_Services::Slapd;
+BEGIN {
+ use strict;
+ use Carp;
+ use Exporter;
+ use IO::File;
+ use Sys::Syslog;
+ use Orca_Services::Vars;
+ $Services{Slapd}{File} = "/var/ds5/slapd-velsatis/logs/access";
+ $Services{Slapd}{FileD} = "";
+ $Services{Slapd}{Ok} = -1;
+ $Services{Slapd}{External} = 0;
+ $Services{Slapd}{Init} = "init_slapd";
+ $Services{Slapd}{Init_Vars} = "init_slapd_vars";
+ $Services{Slapd}{Measure} = "measure_slapd";
+ $Services{Slapd}{Put} = "put_slapd";
+
+ $PrgOptions{"slapd_logfile=s"} = \$Services{Slapd}{File};
+
+ $HelpText{$Services{Slapd}{File}} = "--slapd_logfile=FILE log from slapd (default:";
+}
+
+
+use Orca_Services::Output;
+use Orca_Services::Utils;
+use vars qw(@EXPORT @ISA $VERSION);
+
+ at EXPORT = qw(init_slapd
+ init_slapd_vars
+ measure_slapd
+ put_slapd
+ );
+ at ISA = qw(Exporter);
+$VERSION = substr q$Revision: 0.01 $, 10;
+
+my ($slapd_binds, $slapd_searchs);
+my ($slapd_ino, $slapd_size);
+
+#
+# When we do a Iplanet access file, all records are valid
+#
+my ($Iplanet) = 1;
+
+
+#
+# init_slapd - set SLAPD vars, open the logfile and seek into the end.
+#
+# usage: &init_slapd($slapd_logfile);
+#
+sub init_slapd {
+ my ($filename) = @_;
+ my ($retval);
+
+ if ($filename) {
+ $retval = OpenFile($filename, "Slapd", \$slapd_ino, \$slapd_size);
+ }
+
+ if($retval == 0) {
+ &init_slapd_vars ();
+ }
+ return $retval;
+}
+
+
+#
+# Get values for slapd columns
+#
+# usage: &measure_slapd( );
+#
+sub measure_slapd () {
+ my ($buf);
+
+ $buf = $Services{Slapd}{FileD}->getline;
+ while ($buf) {
+ ## process line read and check for eof
+ if ($buf) {
+ &process_slapd_line ($buf);
+ }
+ if ($Services{Slapd}{FileD}->eof) {
+ printf "SLAPD: eof on $Services{Slapd}{File}\n" if $Options{debug};
+ last; # get out of while($buf)
+ }
+ $buf = $Services{Slapd}{FileD}->getline;
+ } ## while ($buf)
+
+ my $retval = CheckFileChange ("Slapd", \$slapd_ino, \$slapd_size);
+
+ return $retval;
+}
+
+
+#
+# init slapd vars
+#
+# usage: &init_slapd_vars();
+#
+sub init_slapd_vars() {
+ $slapd_binds = 0;
+ $slapd_searchs = 0;
+}
+
+
+#
+# Parse slapd log line
+#
+# usage: &process_slapd_line ($buf);
+#
+
+sub process_slapd_line () {
+ my ($line) = @_;
+
+ if ($line !~ /\sslapd\[\d+\]:\s/ && $Iplanet == 0) {
+ return 0;
+ }
+
+ # BIND
+ # Nov 6 18:24:05 ldap1 slapd[259]: conn=808413 op=0 BIND dn="xxxxxxxxxxxx" method=128
+ if ($line =~ /\sBIND\s/) {
+ $slapd_binds ++;
+ printf "SLAPD_BINDS: %s", $line if $Options{debug};
+ return 0;
+ }
+
+ # SRCH
+ # Nov 6 18:24:05 ldap10 slapd[3456]: conn=32453 op=1 SRCH base="zzzzzzzzzzzzzz" scope=1 filter="yyyyyyyyyyyyyyyyyyy"
+ if ($line =~ /\sSRCH\s/) {
+ $slapd_searchs ++;
+ printf "SLAPD_SEARCHS: %s", $line if $Options{debug};
+ return 0;
+ }
+
+ return 0;
+}
+
+
+#
+# Put the slapd values for output
+#
+# usage: &put_slapd();
+#
+
+sub put_slapd() {
+ &put_output("slapd_binds", sprintf("%8.2f", $slapd_binds));
+ &put_output("slapd_searchs", sprintf("%8.2f", $slapd_searchs));
+
+ return 0;
+}
+
+1;
Modified: branches/orca/import_orca_services_2.0/data_gatherers/orca_services/start_orca_services.sh.in
==============================================================================
--- branches/orca/import_orca_services_2.0/data_gatherers/orca_services/start_orca_services.sh.in (original)
+++ branches/orca/import_orca_services_2.0/data_gatherers/orca_services/start_orca_services.sh.in 2003-03-08 10:26:13.000000000 -0800
@@ -1,32 +1,37 @@
#!/bin/sh
-# This script runs orca_services with the proper options for your
-# site.
+# This script runs orca_services with the proper options for your site.
# Define program locations that will be needed.
prefix=@prefix@
exec_prefix=@exec_prefix@
-libexecdir=@libexecdir@
-sysconfdir=@sysconfdir@
+libdir=@libexecdir@
AWK=@AWK@
CUT=@CUT@
UNAME=@UNAME@
-RAW_ORCA_SERVICES_DIR=@VAR_DIR@/orca_services
+ORCA_SERVICES_DIR=@VAR_DIR@/orca_services
# Get the hostname without the fully qualified part; that is, trim off
# anything past the first `.'.
uname=`$UNAME -n | $CUT -d. -f1`
-# The directory these files go into is $RAW_ORCA_SERVICES_DIR/HOSTNAME.
-OUTDIR=$RAW_ORCA_SERVICES_DIR/$uname
+OPERSYS=`$UNAME -s`
+if test "${OPERSYS}" = "Linux"; then
+ PSCMD="/bin/ps"
+else
+ PSCMD="/usr/ucb/ps" # Solaris
+fi
+
+# The directory these files go into is $ORCA_SERVICES_DIR/HOSTNAME
+OUTDIR=$ORCA_SERVICES_DIR/$uname
# Export the environmental variables.
export OUTDIR
# Check if orca_services is already running.
-pids=`/usr/ucb/ps auxww | $AWK '/orca_services/ && !/awk/ {print $2}'`
+pids=`$PSCMD auxww | $AWK '/orca_services/ && !/awk/ && !/start_orca_services/ && !/daemon/ && !/ \/etc\/init\.d/ && !/ \/etc\/rc/ {print $2}'`
if test "$pids" != ""; then
- echo "Orca_services already running. Exiting."
+ echo "Orca_Services already running. Exiting."
exit 1
fi
@@ -49,16 +54,15 @@
# Now start the logging.
echo "Starting logging"
HOSTNAME=`hostname`
-if test -f "$libexecdir/orca_services.$HOSTNAME"; then
- $libexecdir/orca_services `cat $sysconfdir/orca_services.$HOSTNAME`
+if test -f "$libdir/orca_services.$HOSTNAME"; then
+ $libdir/orca_services `cat $libdir/orca_services.$HOSTNAME`
else
- $libexecdir/orca_services
+ $libdir/orca_services
fi
-# Write the PID of orca_services to a file to make killing easier.
-pid=$!
-echo $pid > $OUTDIR/orca_services.pid
+### # Write the PID of orca_services to a file to make killing easier.
+### pid=$!
+### echo $pid > $OUTDIR/orca_services.pid
-# Sleep for a couple of seconds to allow any orca_services startup
-# warnings to appear on the terminal before exiting.
+# Sleep for a couple of seconds to allow any orca_services warnings to appear.
sleep 5
Modified: branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.pl.in
==============================================================================
--- branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.pl.in (original)
+++ branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.pl.in 2003-03-08 10:26:13.000000000 -0800
@@ -1,2022 +1,281 @@
-##
-##
-## Orca_services.pl, a log generating services usage monitor
-##
-##
-
-##
-## This program logs many different services usage to a log file
-## for later processing.
-##
-
-##
-## Author: Carlos Canau <Carlos.Canau at KPNQwest.com>
-## With: Jose Carlos Pereira <Jose.Pereira at KPNQwest.com>
-##
-
-##
-## Portions adapted from Orcallator.se written by Blair Zajac
-## Portions ported to perl from Orcallator.se written by Blair Zajac
-## other portions adapted from several other open source scripts
-##
-##
-
-##
-## Version 1.5.5.dist: 06 Nov 2000 First distribution version
-##
-## Version 1.5.5: 31 Oct 2000 Bug with increasing "others" in named
-##
-## Version 1.5.4: 31 Oct 2000 DB radiator more secure method of getting DB user/pass
-##
-## Version 1.5.3: 31 Oct 2000 DB radiator accounting
-##
-## Version 1.5.2: 30 Oct 2000 Bugs---, bugs---, ...
-##
-## Version 1.5.1: 27 Oct 2000 Bugs--, bugs--, ...
-##
-## Version 1.5.0: 27 Oct 2000 Radiator/SQL accounting
-##
-## Version 1.4.1: 26 Oct 2000 on/off on services
-##
-## Version 1.4.0.3: 25 Oct 2000 some bugs crashed
-##
-## Version 1.4.0: 24 Oct 2000 DNS / named added
-##
-## Version 1.3.10: 17 Oct 2000 1 query/5min mechanism
-##
-## Version 1.3.9: 12 Oct 2000 New value: mailq
-##
-## Version 1.2.0: 11 Aug 2000 CAC.Washington.EDU ipop3d logfile added
-##
-## Version 1.1.0: 09 Aug 2000 Merit Radius logfile added
-##
-## Version 1.0.3: 09 Aug 2000 Re-open bug fixed (?)
-##
-## Version 1.0.2: 27 Jul 2000 Changes in SMTP regex
-##
-## Version 1.0.1: 25 Jul 2000 Lots of bugs smashed.
-##
-## Version 1.0.0: 23 Jul 2000 First release. Just SMTP.
-##
-##
-
-##
-## BUGS:
-## several ?...
-##
-
-##
-## TODO:
-## more services and diferent logfile reading synchronization
-## code optimization and cleaning
-## debugging
-## can this code be GPLed ??
-##
-
-##
-## LICENSE:
-## GPL.
-## (c) 2000 Carlos Canau & Jose Carlos Pereira
-##
-
-##
-## DISCLAIMER:
-## you use this program at your own and complete risk
-## if you don't agree with that then delete it
-##
-
-$version = "1.5.5.dist";
-
-#
-# ATTENTION: you might need to edit this variables
-#
-$CAT="/usr/local/bin/cat";
-$ECHO="/usr/local/bin/echo";
-$TOUCH="/usr/local/bin/touch";
-
-$UNAME = "/usr/bin/uname";
-$nodename = `$UNAME -n`;
-chop($nodename);
-
-require 5.004_05;
-use Fcntl;
-use Getopt::Long; # option handler
-use POSIX; # useful functions
-use IO::Handle;
-use IO::File;
-use Sys::Syslog;
- at PERL_USE_TIME_HIRES@ # import time from Time::HiRes
- # for nanosecond precision
-
-$log_facility = "user";
-$log_priority = "info";
-
-($progname = $0) =~ s(.*/)();
-
-$SaveDay = 0;
-
-# put this in an option
-#
-# ATTENTION: you might need to edit this
-#
-$MAILQCMD = "/usr/bin/mailq | /usr/bin/tail -1";
-
-##
-## options
-##
-local %options;
-# my $def_poll = 5;
-# my $def_lines = 10;
-# my $def_count = (-1);
-my $def_interval = 300; # 5 minutes
-my $def_dns_logfile = "/var/log/named";
-my $def_smtp_logfile = "/var/log/syslog";
-my $def_merit_radius_logfile = "/usr/local/etc/raddb/logfile";
-my $def_pop_logfile = "/var/log/ipop3d.log";
-my $def_outputdir = "@VAR_DIR@/orca_services";
-my $def_pid = "$def_outputdir/${progname}.pid";
-my $def_compress = "@COMPRESSOR@";
-
-my $def_radius_auth = "/usr/local/lib/orca_services.DB.$nodename";
-
-my $def_mailq = "on";
-
-GetOptions("pidfile=s" => \$options{pidfile},
- "debug:s" => \$options{debug},
- "interval=i" => \$options{interval},
- "dns_logfile=s" => \$options{dns_logfile},
- "smtp_logfile=s" => \$options{smtp_logfile},
- "merit_radius_logfile=s" => \$options{merit_radius_logfile},
- "radius_db=s" => \$options{radius_db},
- "pop_logfile=s" => \$options{pop_logfile},
- "outputdir=s" => \$options{outputdir},
- "compress=s" => \$options{compress},
- "mailq=s" => \$options{mailq},
- "help" => \$options{help},
- "version" => \$options{help}
- ) || usage();
-usage() if $options{help};
-
-if ($options{debug}) {
- if ($options{debug} ne "on") {
- $debug = 0;
- exit if fork;
- } else {
- $debug = 1;
- }
-} else {
- $debug = 0;
- exit if fork;
-}
-
-if ($options{interval}) {
- $interval = $options{interval};
-} else {
- $interval = $def_interval;
-}
-
-if ($options{compress}) {
- $Compress = $options{compress};
-} else {
- $Compress = $def_compress;
-}
-
-if ($options{outputdir}) {
- $OutputDir = $options{outputdir};
-} else {
- $OutputDir = $def_outputdir;
-}
-system ("mkdir $OutputDir 2>/dev/null"); # ignore return value
-system ("chmod 0755 $OutputDir 2>/dev/null"); # if you can change these
- # two systems bye the perl
- # syscall ... :-)
-system ("mkdir $OutputDir/$nodename 2>/dev/null"); # ignore return value
-system ("chmod 0755 $OutputDir/$nodename 2>/dev/null");
-if ($options{pidfile}) {
- $PidFile = $options{pidfile};
-} else {
- $PidFile = "$OutputDir/$nodename/${progname}.pid";;
-}
-
-if ($options{dns_logfile}) {
- $DNSFile = $options{dns_logfile};
-} else {
- $DNSFile = $def_dns_logfile;
-}
-
-if ($options{smtp_logfile}) {
- $SMTPFile = $options{smtp_logfile};
-} else {
- $SMTPFile = $def_smtp_logfile;
-}
-
-if ($options{mailq}) {
- $MAILQ = $options{mailq};
-} else {
- $MAILQ = $def_mailq;
-}
-
-if ($options{merit_radius_logfile}) {
- $Merit_RADIUSFile = $options{merit_radius_logfile};
-} else {
- $Merit_RADIUSFile = $def_merit_radius_logfile;
-}
-
-if ($options{pop_logfile}) {
- $POPFile = $options{pop_logfile};
-} else {
- $POPFile = $def_pop_logfile;
-}
-
-if ($options{radius_db}) {
- $RADIUS_DB = $options{radius_db};
-### print "\n\nWARNING: radius_db option not being used via cmd line. Using default\n\n";
-### $RADIUS_DB = $def_radius_auth;
-} else {
- $RADIUS_DB = $def_radius_auth;
-}
-
-##
-## options
-##
-
-
-
-
-&logit ("ready (pid $$)");
-if (open(P, "> $PidFile")) {
- print P "$$\n";
- close P;
-} else {
- &logit("can't save pid (can't write to \`$PidFile')");
- warn "$progname: can't save pid (can't write to \`$PidFile')\n";
-}
-
-
-
-##
-## init logfiles
-##
-my ($dns_ino, $dns_size, $dns_ok) = (0,0,0);
-if ($DNSFile !~ /^off$/i) {
- $dns_ok = &init_dns ($DNSFile); # inits DNSFD
-}
-
-my ($smtp_ino, $smtp_size, $smtp_ok) = (0,0,0);
-if ($SMTPFile !~ /^off$/i) {
- $smtp_ok = &init_smtp ($SMTPFile); # inits SMTPFD
-}
-
-my ($merit_radius_ino, $merit_radius_size, $merit_radius_ok) = (0,0,0);
-if ($Merit_RADIUSFile !~ /^off$/i) {
- $merit_radius_ok = &init_merit_radius ($Merit_RADIUSFile); # inits RADIUSFD
-}
-
-my ($pop_ino, $pop_size, $pop_ok) = (0,0,0);
-if ($POPFile !~ /^off$/i) {
- $pop_ok = &init_pop ($POPFile); # inits POPFD
-}
-
-if ($RADIUS_DB !~ /^off$/i) {
-
- #check if database user/passwd is given!
- if( ! -f $RADIUS_DB){
- print "Database init error: No such file: $RADIUS_DB\n";
- print "Aborting\n";
- exit;
- }
-
- my($proto,$drv,$database,$user,$pass)= split(/:/,`$CAT $RADIUS_DB`);
-
- if(!$proto || !$drv || !$database || !$user || !$pass){
- print "Database init error: unable to parse $RADIUS_DB\n";
- print "Syntax must be: protocol:driver:database:user:passwd ex: DBI:oracle:ORCA:user:pass\n";
- print "Aborting\n";
- exit;
- }
- chomp($pass);
-
- if ( ($radius_ok = &init_radius("$proto:$drv:$database",$user,$pass)) ) { # inits $RADdbh
- print "ERROR: Radius init failed! Aborting $radius_ok\n";
- exit;
- }
-}
-
-$print_header = 0;
-$current_column = 0;
-
-##
-## init outpufile
-##
-my $OutputFilename = "";
-#$outputfile_ok = &check_output ("$OutputDir/$nodename"); # inits OUTFD
-# # & $OutputFilename
-
-
-# incremental
-if (defined($DNSFD)) {
- &init_dns_vars ();
-}
-
-while () {
- my $outputfile_ok = 0;
- my ($now, $sleep_till);
-
- $now = time;
- $sleep_till = ($now/$interval) * $interval;
- while ($sleep_till < $now + $interval*0.5) {
- $sleep_till += $interval;
- }
-
- &measure_head ($now);
-
- if (defined($SMTPFD)) {
- &init_smtp_vars ();
- }
- if ($MAILQ eq "on") {
- &init_mailq_vars ();
- }
- if (defined($Merit_RADIUSFD)) {
- &init_merit_radius_vars ();
- }
- if (defined($POPFD)) {
- &init_pop_vars ();
- }
-
- ### call the measure routines...
- &measure ($sleep_till);
-
- if (defined($RADdbh)) {
- &put_radius ();
- }
-
- if (defined($DNSFD)) {
- &put_dns ();
- }
- if (defined($SMTPFD)) {
- &put_smtp ();
- }
- if ($MAILQ eq "on") {
- &put_mailq ();
- }
- if (defined($Merit_RADIUSFD)) {
- &put_merit_radius ();
- }
- if (defined($POPFD)) {
- &put_pop ();
- }
-
- $outputfile_ok = &check_output ("$OutputDir/$nodename");
-
- &flush_output ();
-
-}
-
-exit 0;
-
-
-
-# ----------------------------------------------------------------------------
-
-sub usage {
- die "Usage: $progname [options]
- ($progname uses the GNU extended POSIX option format)
-
- --pidfile=FILE write my PID here (default: $def_pid)
- --debug[=on|off] show copious debugging info (default: off)
- --interval=i pooling interval in sec. (default: $def_interval)
- --dns_logfile=FILE syslog from named (default: $def_dns_logfile)
- --smtp_logfile=FILE syslog from sendmail (default: $def_smtp_logfile)
- --merit_radius_logfile=FILE syslog from merit_radius (default: $def_merit_radius_logfile)
- --radius_db=FILE file for user/passwd for DB access (default: $def_radius_auth)
- --pop_logfile=FILE syslog from pop (default: $def_pop_logfile)
- --outputdir=DIR write here output files (default: $def_outputdir)
- --compress=COMMAND use this to compress files (default: $def_compress)
- --mailq=[on|off] get mailq total requests (default: $def_mailq)
- --help, --version this option summary
-
- Note: use filename 'off' to turn off the specific service
-
- This is $progname version $version
-
-";
-}
-
-
-# -------------------------------------------------------------------
-#
-# logit -- send MSG(s) to the syslog.
-#
-# usage: &logit($msg_to_log);
-#
-
-sub logit {
- local($Msg) = @_;
-
- &Sys::Syslog::openlog("$progname", 'cons,pid', "$log_facility");
- &Sys::Syslog::syslog("$log_priority", $Msg);
- &Sys::Syslog::closelog();
-}
-
-
-# -------------------------------------------------------------------
-#
-# measure_head -- put first values
-#
-# usage: &measure_head($time)
-#
-
-sub measure_head() {
- my ($time) = @_;
-
- $now_string = strftime "%T", localtime;
- put_output(" timestamp", sprintf("%10d", $time));
- put_output("locltime", $now_string);
-}
-
-
-# ----------------------------------------------------------------------
-#
-# init_radius - set RADIATOR_RADIUS vars, connect to DB, calculate correct time stamp
-#
-# usage: &init_radius($db,$user,$pass);
-#
-
-sub init_radius {
- my ($db,$user,$pass) = @_;
-
- use DBI;
-
- $RADdbh = DBI->connect($db,$user,$pass);
- if(!$RADdbh) {
- print "Connect error $DBI::errstr\n";
- return 1;
- }
-
- #get the lower time limit that our queries will start from
- #get a "history" of 5minutes
-
- $radius_base_ts= time - 5*60;
-
- #get accumulated values for what we want to measure:
-
-#jcp correct this please!
-## my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, undef) = localtime($radius_base_ts);
-## $year += 1900;
-## $mon++;
-
-
-## $BASE_ACCUM_radius_DB="/var/orca/orca_services/$nodename";
-## $ACCUM_radius_DB= "$BASE_ACCUM_radius_DB/radiatorRadiusAccum.$year$mon.txt";
-## `$TOUCH $ACCUM_radius_DB`;
-
-## $radius_inc_time ||= 0;
-## $radius_inc_sessions ||= 0;
-
-#END jcp correct this please!
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# init_dns - set DNS vars, open the logfile and seek into the end.
-#
-# usage: &init_dns($dns_logfile);
-#
-
-sub init_dns {
- my ($filename) = @_;
-
- if ($filename) {
- $DNSFD = new IO::File "$filename", "r";
- if (defined($DNSFD)) {
- my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($DNSFD);
- if (!$dev) {
- &logit ("can't stat $filename");
- warn "$progname: can't stat $filename\n";
- return 1;
- }
- $dns_ino = $ino;
- $dns_size = $size;
- $seek_ok = seek($DNSFD, 0, SEEK_END);
- if (!$seek_ok) {
- &logit ("can't seek into EOF on $filename");
- warn "$progname: can't seek into EOF on $filename\n";
- return 2;
- }
- } else {
- &logit ("can't open $filename");
- warn "$progname: can't open $filename\n";
- return 3;
- }
- }
- &init_dns_vars ();
- return 0;
-}
-
-# -------------------------------------------------------------------
-#
-# init_smtp - set SMTP vars, open the logfile and seek into the end.
-#
-# usage: &init_smtp($smtp_logfile);
-#
-
-sub init_smtp {
- my ($filename) = @_;
-
- if ($filename) {
- $SMTPFD = new IO::File "$filename", "r";
- if (defined($SMTPFD)) {
- my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($SMTPFD);
- if (!$dev) {
- &logit ("can't stat $filename");
- warn "$progname: can't stat $filename\n";
- return 1;
- }
- $smtp_ino = $ino;
- $smtp_size = $size;
- $seek_ok = seek($SMTPFD, 0, SEEK_END);
- if (!$seek_ok) {
- &logit ("can't seek into EOF on $filename");
- warn "$progname: can't seek into EOF on $filename\n";
- return 2;
- }
- } else {
- &logit ("can't open $filename");
- warn "$progname: can't open $filename\n";
- return 3;
- }
- }
- &init_smtp_vars ();
- return 0;
-}
-
-
-# ----------------------------------------------------------------------
-#
-# init_merit_radius - set Merit_RADIUS vars, open the logfile and seek into the end.
+# orca_services.pl, a log generating services usage monitor
#
-# usage: &init_merit_radius($radius_logfile);
+# This program logs many different services usage to a log file
+# for later processing.
#
-
-sub init_merit_radius {
- my ($filename) = @_;
-
- if ($filename) {
- $Merit_RADIUSFD = new IO::File "$filename", "r";
- if (defined($Merit_RADIUSFD)) {
- my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($Merit_RADIUSFD);
- if (!$dev) {
- &logit ("can't stat $filename");
- warn "$progname: can't stat $filename\n";
- return 1;
- }
- $merit_radius_ino = $ino;
- $merit_radius_size = $size;
- $seek_ok = seek($Merit_RADIUSFD, 0, SEEK_END);
- if (!$seek_ok) {
- &logit ("can't seek into EOF on $filename");
- warn "$progname: can't seek into EOF on $filename\n";
- return 2;
- }
- } else {
- &logit ("can't open $filename");
- warn "$progname: can't open $filename\n";
- return 3;
- }
- }
- &init_merit_radius_vars ();
- return 0;
-}
-
-
-# ----------------------------------------------------------------------
+# Author: Sjaak Westdijk <westdijk at fastmail.fm>
#
-# init_pop - set POP vars, open the logfile and seek into the end.
+# thanks to :
+# Carlos Canau <Carlos.Canau at KPNQwest.pt>
+# Jose Carlos Pereira <Jose.Pereira at KPNQwest.pt>
#
-# usage: &init_pop($pop_logfile);
+# Most code is adapted from Orca_servcies 1.X written by Carlos Canau
#
-
-sub init_pop {
- my ($filename) = @_;
-
- if ($filename) {
- $POPFD = new IO::File "$filename", "r";
- if (defined($POPFD)) {
- my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($POPFD);
- if (!$dev) {
- &logit ("can't stat $filename");
- warn "$progname: can't stat $filename\n";
- return 1;
- }
- $pop_ino = $ino;
- $pop_size = $size;
- $seek_ok = seek($POPFD, 0, SEEK_END);
- if (!$seek_ok) {
- &logit ("can't seek into EOF on $filename");
- warn "$progname: can't seek into EOF on $filename\n";
- return 2;
- }
- } else {
- &logit ("can't open $filename");
- warn "$progname: can't open $filename\n";
- return 3;
- }
- }
- &init_pop_vars ();
- return 0;
-}
-
-
-# -------------------------------------------------------------------
+# Portions ported to perl from Orcallator.se written by Blair Zajac
+# other portions adapted from several other open source scripts
#
-# check_output - set outputfile vars, open the outputfile.
#
-# usage: &check_output($outputdir);
+# BUGS:
#
-
-sub check_output {
- my ($outputdir) = @_;
- $sec1=$min1=$hour1=$mday1=$mon1=$year1=$wday1=$yday1=$isdst1 = 0;
-
- ($sec1,$min1,$hour1,$mday1,$mon1,$year1,$wday1,$yday1,$isdst1) = localtime();
-
- if ($mday1 != $SaveDay) {
- # First time or day has changed, start new logfile.
- if (OUTFD->opened) {
- close(OUTFD); # ignore error
- }
- if (($Compress) && ($SaveDay)) { # just on day change
- if ($OutputFilename) {
- &logit ("compressing $OutputFilename");
- system ("$Compress $OutputFilename"); # ignore error ??
- }
- }
-
- $now_string = strftime "%Y-%m-%d", localtime;
-
- $OutputFilename = "$outputdir/percol-$now_string";
-
- if (!open (OUTFD, ">>$OutputFilename")) {
- &logit ("can't open outputfile $OutputFilename");
- die "$progname: can't open outputfile $OutputFilename\n";
- }
-
- $SaveDay = $mday1;
-
- $print_header = 1;
- }
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
#
-# flush_output - dumps line into outputfile
+# TODO:
#
-# usage: &flush_output();
#
-
-sub flush_output() {
-
- if ($print_header) {
- &print_columns(\@col_comment);
- $print_header = 0;
- }
- &print_columns(\@col_data);
- $current_column = 0;
-}
-
-# -------------------------------------------------------------------
+# LICENSE:
+# GPL.
+# (c) 2003 Sjaak Westdijk
+# (c) 2000-2002 Carlos Canau & Jose Carlos Pereira
#
-# Send the stored columns of information to the output.
#
-# usage: &print_columns( \@array );
+# DISCLAIMER:
+# you use this program at your own and complete risk
+# if you don't agree with that then delete it
#
-sub print_columns() {
- my ($ref) = @_;
-
- @col = @$ref;
-
- for ($i=0; $i < $current_column; $i++) {
- printf OUTFD "%s", $col[$i];
- if ($i != $current_column - 1) {
- printf OUTFD " ";
- }
- }
- printf OUTFD "\n";
-
- OUTFD->flush;
+# Set the location of the Orca_Services modules.
+BEGIN {
+ my $prefix = "@prefix@";
+ my $exec_prefix = "@exec_prefix@";
+ my $libdir = "@libdir@";
+ unshift(@INC, $libdir);
}
-# -------------------------------------------------------------------
-#
-# Add one column of comments and data to the buffers.
#
-# usage: &put_output( $comment, $data );
+# which standard modules to use
#
+require 5.004;
+use Fcntl;
+use Getopt::Long; # option handler
+use POSIX; # useful functions
+use IO::Handle;
+use IO::File;
-sub put_output() {
- my ($comment, $data) = @_;
-
- printf "OUT: --%s-- %s\n", $comment, $data if $debug;
- $col_comment[$current_column] = $comment;
- $col_data[$current_column] = $data;
- $current_column++;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Cycle several measurables
#
-# usage: &measure( $sleep_till );
+# which Orca_Services modules to use
#
+use Orca_Services::Vars;
+use Orca_Services::Utils;
+use Orca_Services::Output;
+use Orca_Services::Sendmail;
+#use Orca_Services::Dns;
+use Orca_Services::Mailq;
+use Orca_Services::Http;
+#use Orca_Services::Nntp;
+#use Orca_Services::Pop;
+use Orca_Services::Slapd;
+#use Orca_Services::MeritRad;
+#use Orca_Services::Radius;
-sub measure () {
- my ($sleep_till) = @_;
-
-
- $now = time;
- while ($now < $sleep_till) {
-
- printf "SMTP: sleeping for 5\n" if $debug;
- sleep(5);
- $now = time;
-
- # measure...
- if (defined($SMTPFD)) {
- &measure_smtp();
- }
- if (defined($Merit_RADIUSFD)) {
- &measure_merit_radius();
- }
- if (defined($POPFD)) {
- &measure_pop();
- }
- #
- # stats only once an hour... but better not have logfile reading picks
- #
- if (defined($DNSFD)) {
- &measure_dns();
- }
-
- # measure...
-
- $now = time;
-
- } ## while ($now < $sleep_till)
- # put in the end... calls external prog.
- if ($MAILQ eq "on") {
- &measure_mailq();
- }
-
- if (defined($RADdbh)) {
- &measure_radius();
- }
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Get values for smtp columns
#
-# usage: &measure_smtp( );
+# See if the modules load succesfully
#
-
-sub measure_smtp () {
-
-
- #################################### insert bail out for too much
- #################################### time spent ??
- $buf = <$SMTPFD>;
- while ($buf) {
- ## process line read and check for eof
- if ($buf) {
- &process_smtp_line ($buf);
- }
- if ($SMTPFD->eof) {
- printf "SMTP: eof on $SMTPFile\n" if $debug;
- last; # get out of while($buf)
- }
- $buf = <$SMTPFD>;
- } ## while ($buf)
-
-
- # test for file change via different inode or filesize decrease
- $dev = $ino = $mode = $nlink = $uid = $gid = $rdev =
- $size = $atime = $mtime = $ctime = $blksize = $blocks = '';
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($SMTPFile);
- if (!$dev) {
- &logit ("can't stat $SMTPFile");
- warn "$progname: can't stat $SMTPFile\n";
- return 1;
- }
- printf "SMTPFD: smtp_ino=%s vs. ino=%s\tsmtp_size=%s vs. size=%s\n", $smtp_ino, $ino, $smtp_size, $size if $debug;
- if (($smtp_ino != $ino) || ($smtp_size > $size)) {
- undef $SMTPFD;
- printf "SMTP: file change on $SMTPFile\n" if $debug;
- $SMTPFD = new IO::File "$SMTPFile", "r";
- if (!defined ($SMTPFD)) {
- &logit ("can't re-open $SMTPFile");
- warn "$progname: can't re-open $SMTPFile\n";
- $smtp_ino = $smtp_size = 0;
- return 2;
+if ($Options{debug}) {
+ while ( ($service, $params) = each %Services) {
+ print "$service:\n";
+ while ( ($par, $val) = each %$params) {
+ print "\t$par=$val\n";
+ }
+ print "\n";
}
- $smtp_ino = $ino;
- $smtp_size = $size;
- }
-
- return 0;
}
-
-# -------------------------------------------------------------------
-#
-# init smtp vars
#
-# usage: &init_smtp_vars();
+# Get the options
#
+GetOptions(%PrgOptions) || usage();
+usage() if $Options{help};
-sub init_smtp_vars() {
- $smtp_froms = 0;
- $smtp_MaxSize = 0;
- $smtp_sizes = 0;
-
- $smtp_MaxSeconds = 0;
- $smtp_seconds = 0;
- $smtp_sent = 0;
-
- $smtp_fail = 0;
- $smtp_retries = 0;
- $smtp_queued = 0;
- $smtp_t_or_f = 0;
-
- $smtp_check_mail = 0;
- $smtp_check_rcpt = 0;
- $smtp_notifies = 0;
- $smtp_dsns = 0;
- $smtp_undefs = 0;
-}
-
-
-# -------------------------------------------------------------------
#
-# Parse smtp log line
+# Look if the options succesfully set
#
-# usage: &process_smtp_line ($buf);
-#
-
-sub process_smtp_line () {
- my ($line) = @_;
-
-
- if ($line !~ / sendmail\[\d+\]: /) {
- return 0;
- }
-
-
- # from
-# Jul 16 03:22:12 server123 sendmail[4977]: e6G2M7O04977: from=<jsmith at server321.domain.com>, size=981, class=0, nrcpts=1, msgid=<200007152000.VAA24441 at server321.domain.com>, proto=ESMTP, daemon=MTA, relay=server321.domain.com [10.0.0.65]
-# 0 Month, 1 Day, 2 hh:mm:ss, 3 nodename, 4 sendmail[NNNNN]:, 5 msg-id:, 6 from=FROM\,, 7 size=NNNNN\,, ...
- if ($line =~ /: from=.*, size=(\d+)/i) {
- $smtp_froms ++;
- $size = $1;
- $smtp_sizes += $size;
- if ($size > $smtp_MaxSize) {
- $smtp_MaxSize = $size;
+if ($Options{debug}) {
+ while ( ($options) = each %PrgOptions) {
+ print "$options => $PrgOptions{$options}\n";
}
- printf "SMTP_FROM: %s", $line if $debug;
-# printf "smtp_froms=%s, size=%s, smtp_sizes=%s, smtp_MaxSize=%s\n", $smtp_froms, $size, $smtp_sizes, $smtp_MaxSize if $debug;
- return 0;
- }
+ print "\n";
- # to
-#Jul 16 03:26:32 server123 sendmail[5060]: e6G2PqO05058: to=<info at domain1.pt>, delay=00:00:35, xdelay=00:00:35, mailer=esmtp, pri=120745, relay=server321.domain.com. [10.0.0.65], dsn=2.0.0, stat=Sent (DAA19487 Message accepted for delivery)
-#Jul 16 03:15:16 server123 sendmail[4828]: e6EBXrO12616: to=<sales at mail.domain2.pt>, delay=1+14:41:13, xdelay=00:00:55, mailer=esmtp, pri=3001977, relay=mail.domain2.pt. [11.0.0.130], dsn=4.0.0, stat=Deferred: Connection refused by mail.domain2.pt.
-#Jul 16 22:31:20 server123 sendmail[881]: e6GLUxP00881: to=<info at domain3.pt>, delay=00:00:11, xdelay=00:00:11, mailer=esmtp, pri=37973, relay=mail.domain4.pt. [12.0.0.15], dsn=5.0.0, stat=Service unavailable
-#Jul 24 18:33:05 server999 sendmail[15932]: SAA15929: to=<jsmith at domain4.pt>, ctladdr=<jjjj at domain9.pt> (16306/1984), delay=00:00:10, xdelay=00:00:09, mailer=esmtp, relay=mail.domain4.pt. [13.0.0.3], stat=Sent (Ok)
- if ($line =~ /: to=/) {
- if ($line =~ /, delay=(\d+)*\+*(\d+):(\d+):(\d+), .*, stat=Sent/i) {
- $seconds = 86400*$1 + 3600*$2 + 60*$3 + $4;
-
- $smtp_seconds += $seconds;
- if ($seconds > $smtp_MaxSeconds) {
- $smtp_MaxSeconds = $seconds;
- }
- $smtp_sent ++;
- printf "SMTP_SENT: %s", $line if $debug;
-# printf "seconds=%s, smtp_seconds=%s, smtp_MaxSeconds=%s, smtp_sent=%s\n", $seconds, $smtp_seconds, $smtp_MaxSeconds, $smtp_sent if $debug;
- return 0;
- }
- if ($line =~ /, dsn=5/i) {
- $smtp_fail++;
- printf "SMTP_FAIL: %s", $line if $debug;
-# printf "smtp_fail=%s\n", $smtp_fail if $debug;
- return 0;
- }
- if (($line =~ /, dsn=4/i) || ($line =~ /, stat=Deferred:/i)) {
- $smtp_retries++;
- printf "SMTP_RETRY: %s", $line if $debug;
-# printf "smtp_retries=%s\n", $smtp_retries if $debug;
- return 0;
+ while ( ($options) = each %Options) {
+ print "$options => $Options{$options}\n";
}
- if ($line =~ /, stat=queued/i) {
- $smtp_queued++;
- printf "SMTP_QUEUE: %s", $line if $debug;
-# printf "smtp_queued=%s\n", $smtp_queued if $debug;
- return 0;
- }
- $smtp_t_or_f++;
- printf "SMTP_T_OR_F: %s", $line if $debug;
-# printf "smtp_t_or_f=%s\n", $smtp_t_or_f if $debug;
- return 0;
- }
-
- # ruleset=check_mail
-#Jul 16 22:24:43 server123 sendmail[604]: e6GLNMO00604: ruleset=check_mail, arg1=<Mary.Wilson at domain10.pt>, relay=server321.domain.com [10.0.0.65], reject=451 4.1.8 <Mary.Wilson at domain10.pt>... Domain of sender address Mary.Wilson at domain10.pt does not resolve
- if ($line =~ /: ruleset=check_mail, /i) {
- $smtp_check_mail ++;
- printf "SMTP_CHECK_MAIL: %s", $line if $debug;
-# printf "smtp_check_mail=%s\n", $smtp_check_mail if $debug;
- return 0;
- }
-
- # ruleset=check_rcpt
-#Jul 19 16:54:55 server123 sendmail[11437]: e6JFsoO11437: ruleset=check_rcpt, arg1=<xyz at domain777.net>, relay=a.b.c.net [6.1.6.7], reject=550 5.7.1 <xyz at domain777.net>... Relaying denied
-#Jul 19 17:34:54 server123 sendmail[12479]: e6JGYKO12479: ruleset=check_rcpt, arg1=<Edgar.Silva at mail.soso.domain8888.pt>, relay=individual [10.0.0.67], reject=450 4.7.1 <Edgar.Silva at mail.soso.domain8888.pt>... Can not check MX records for recipient host mail.soso.domain8888.pt
- if ($line =~ /: ruleset=check_rcpt, /i) {
- $smtp_check_rcpt ++;
- printf "SMTP_CHECK_RCPT: %s", $line if $debug;
-# printf "smtp_check_rcpt=%s\n", $smtp_check_rcpt if $debug;
- return 0;
- }
-
- # postmaster notify:
-#Jul 17 05:30:04 server123 sendmail[10016]: e6EKWRO24933: e6H401o10016: postmaster notify: Cannot send message within 2 days
- if ($line =~ /: postmaster notify: /i) {
- $smtp_notifies ++;
- printf "SMTP_NOTIFIES: %s", $line if $debug;
-# printf "smtp_notifies=%s\n", $smtp_notifies if $debug;
- return 0;
- }
-
- # DSN
-#Jul 18 22:28:58 server123 sendmail[7172]: e6ILQlO07170: e6ILSwO07172: DSN: Service unavailable
-#Jul 19 14:38:00 server123 sendmail[1846]: e6HBWSO21997: e6JDU0t01846: DSN: Cannot send message within 2 days
-#Jul 19 17:33:51 server123 sendmail[12272]: e6JGTlO12270: e6JGXpO12272: DSN: Return receipt
- if ($line =~ /: DSN: /i) {
- $smtp_dsns ++;
- printf "SMTP_DSN: %s", $line if $debug;
-# printf "smtp_dsns=%s\n", $smtp_dsns if $debug;
- return 0;
- }
-
- $smtp_undefs ++;
- printf "SMTP_UNDEF: %s", $line if $debug;
-# printf "smtp_undefs=%s\n", $smtp_undefs if $debug;
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Put the smtp values for output
-#
-# usage: &put_smtp();
-#
-
-sub put_smtp() {
-
- &put_output("smtp_from", sprintf("%8.2f", $smtp_froms));
- &put_output("smtp_tops", sprintf("%8.2f", $smtp_MaxSize));
- if ($smtp_froms) {
- &put_output("smtp_sizes", sprintf("%8.2f", $smtp_sizes/$smtp_froms));
- } else {
- &put_output("smtp_sizes", sprintf("%8.2f", 0));
- }
- &put_output("smtp_sent", sprintf("%8.2f", $smtp_sent));
- &put_output("smtp_maxd", sprintf("%8.2f", $smtp_MaxSeconds));
- if ($smtp_sent) {
- &put_output("smtp_delay", sprintf("%8.2f", $smtp_seconds/$smtp_sent));
- } else {
- &put_output("smtp_delay", sprintf("%8.2f", 0));
- }
- &put_output("smtp_fail", sprintf("%8.2f", $smtp_fail));
- &put_output("smtp_rtrs", sprintf("%8.2f", $smtp_retries));
- &put_output("smtp_queued", sprintf("%8.2f", $smtp_queued));
- &put_output("smtp_torf", sprintf("%8.2f", $smtp_t_or_f));
- &put_output("smtp_c_ml", sprintf("%8.2f", $smtp_check_mail));
- &put_output("smtp_c_rt", sprintf("%8.2f", $smtp_check_rcpt));
- &put_output("smtp_ntfs", sprintf("%8.2f", $smtp_notifies));
- &put_output("smtp_dsns", sprintf("%8.2f", $smtp_dsns));
-
- &put_output("smtp_undf", sprintf("%8.2f", $smtp_undefs));
-
- return 0;
+ print "\n";
}
-
-# -------------------------------------------------------------------
-#
-# Get values for mailq columns
-#
-# usage: &measure_mailq( );
-#
-
-sub measure_mailq () {
-
- open (MFD, "$MAILQCMD |");
- $line = <MFD>;
- close (MFD);
-
- if ($line =~ /(\d+)/i) {
- $mailq_t = $1;
- } else {
- $mailq_t = 0;
- }
- $mailq_total += $mailq_t;
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# init mailq vars
-#
-# usage: &init_mailq_vars();
-#
-
-sub init_mailq_vars() {
- $mailq_total = 0;
+if ($Options{debug} == 0) {
+ exit if fork;
}
-
-# -------------------------------------------------------------------
#
-# Put the mailq values for output
+# Create the ouput dir structure
#
-# usage: &put_mailq();
-#
-
-sub put_mailq() {
-
- &put_output("mailq_total", sprintf("%8.2f", $mailq_total));
+system ("mkdir $Options{outputdir} 2>/dev/null"); # ignore return value
+system ("chmod 0755 $Options{outputdir} 2>/dev/null"); # if you can change these
+ # two systems bye the perl
+ # syscall ... :-)
+system ("mkdir $Options{outputdir}/$nodename 2>/dev/null"); # ignore return value
+system ("chmod 0755 $Options{outputdir}/$nodename 2>/dev/null");
- return 0;
+&logit ("ready (pid $$)");
+if (open(P, "> $Options{pidfile}")) {
+ print P "$$\n";
+ close P;
+} else {
+ &logit("can't save pid (can't write to \`$Options{pidfile}')");
+ warn "$progname: can't save pid (can't write to \`$Options{pidfile}')\n";
}
-# -------------------------------------------------------------------
-#
-# init merit_radius vars
-#
-# usage: &init_merit_radius_vars();
-#
-
-sub init_merit_radius_vars() {
- $merit_radius_auth = 0;
- $merit_radius_auth_ok = 0;
- $merit_radius_auth_nok = 0;
-
- $merit_radius_acct_start = 0;
- $merit_radius_acct_stop = 0;
-
- $merit_radius_rem_auth = 0;
- $merit_radius_rem_auth_ok = 0;
- $merit_radius_rem_auth_nok = 0;
-
- $merit_radius_undefs = 0;
-}
-
-# -------------------------------------------------------------------
#
-# Get values for merit_radius columns
+# init the services
#
-# usage: &measure_merit_radius( );
-#
-
-sub measure_merit_radius () {
-
-
- #################################### insert bail out for too much
- #################################### time spent ??
- $buf = <$Merit_RADIUSFD>;
- while ($buf) {
- ## process line read and check for eof
- if ($buf) {
- &process_merit_radius_line ($buf);
- }
- if ($Merit_RADIUSFD->eof) {
- printf "Merit_RADIUS: eof on $Merit_RADIUSFile\n" if $debug;
- last; # get out of while($buf)
- }
- $buf = <$Merit_RADIUSFD>;
- } ## while ($buf)
-
-
- # test for file change via different inode or filesize decrease
- $dev = $ino = $mode = $nlink = $uid = $gid = $rdev =
- $size = $atime = $mtime = $ctime = $blksize = $blocks = '';
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($Merit_RADIUSFile);
- if (!$dev) {
- &logit ("can't stat $Merit_RADIUSFile");
- warn "$progname: can't stat $Merit_RADIUSFile\n";
- return 1;
- }
- printf "Merit_RADIUSFD: merit_radius_ino=%s vs. ino=%s\tmerit_radius_size=%s vs. size=%s\n", $merit_radius_ino, $ino, $merit_radius_size, $size if $debug;
- if (($merit_radius_ino != $ino) || ($merit_radius_size > $size)) {
- undef $Merit_RADIUSFD;
- printf "Merit_RADIUS: file change on $Merit_RADIUSFile\n" if $debug;
- $Merit_RADIUSFD = new IO::File "$Merit_RADIUSFile", "r";
- if (!defined ($Merit_RADIUSFD)) {
- &logit ("can't re-open $Merit_RADIUSFile");
- warn "$progname: can't re-open $Merit_RADIUSFile\n";
- $merit_radius_ino = $merit_radius_size = 0;
- return 2;
+print "Initializing : ";
+while ( ($service) = each %Services) {
+ if ($Services{$service}{File} !~ /^off$/i) {
+ my $func= $Services{$service}{Init};
+ if ($func eq "") {
+ next;
+ }
+ $Services{$service}{Ok} = &$func($Services{$service}{File});
}
- $merit_radius_ino = $ino;
- $merit_radius_size = $size;
- }
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Parse merit_radius log line
-#
-# usage: &process_merit_radius_line ($buf);
-#
-
-sub process_merit_radius_line () {
- my ($line) = @_;
-
-
-### AUTH RECEIVED
-# Mon Jul 24 00:02:16 2000: Received-Authentication: 214/28832 'luser' from 13.12.15.17 port 25 PPP
-
- if ($line =~ /: Received-Authentication: .* from /i) {
- $merit_radius_auth ++;
- printf "Merit_RADIUS_AUTH: %s", $line if $debug;
- printf "merit_radius_auth=%s\n", $merit_radius_auth if $debug;
- return 0;
- }
-
-### AUTH OK
-# Mon Jul 24 00:02:16 2000: Authentication: 214/28832 'luser2' from 13.12.25.17 port 35 PPP - OK -- total 0, holding 0
-
- if ($line =~ /: Authentication: .* from .* OK /i) {
- $merit_radius_auth_ok ++;
- printf "Merit_RADIUS_AUTH_OK: %s", $line if $debug;
- printf "merit_radius_auth_ok=%s\n", $merit_radius_auth_ok if $debug;
- return 0;
- }
-
-### AUTH FAILED
-# Mon Jul 24 01:49:20 2000: Authentication: 201/29347 'luser3' from 13.16.19.20 port 2 PPP - FAILED Authentication failure -- total 0, holding 0
-
- if ($line =~ /: Authentication: .* from .* FAILED Authentication /i) {
- $merit_radius_auth_nok ++;
- printf "Merit_RADIUS_AUTH_NOK: %s", $line if $debug;
- printf "merit_radius_auth_nok=%s\n", $merit_radius_auth_nok if $debug;
- return 0;
- }
-
-### ACCT START RECEIVED
-# Mon Jul 24 00:02:16 2000: Received-Accounting: 215/8376 'luser4' from 13.16.15.17 port 35 $"5200DB70" PPP/13.16.19.25 Start
-### ACCT STOP RECEIVED
-# Mon Jul 24 00:02:19 2000: Received-Accounting: 176/8377 'luser5' from 13.16.11.18 port 1 $"040065AE" PPP/13.16.24.22 Stop/User-Request
-# Wed Aug 9 16:55:15 2000: getpwnam: good line for luser6 on file
- if ( ($line =~ /: Received-Accounting: .* from /i) ||
- ($line =~ /: getpwnam: good line for /i) ){
- printf "Merit_RADIUS_IGNORE: %s", $line if $debug;
- return 0;
- }
-
-### ACCT START OK
-# Mon Jul 24 00:02:16 2000: Accounting: 215/8376 'luser6' from 13.16.15.17 port 35 $"5200DB70" PPP/13.16.19.24 Start - OK -- total 0, holding 0
-
- if ($line =~ /: Accounting: .* from .* Start - OK /i) {
- $merit_radius_acct_start ++;
- printf "Merit_RADIUS_ACCT_START: %s", $line if $debug;
- printf "merit_radius_acct_start=%s\n", $merit_radius_acct_start if $debug;
- return 0;
- }
-
-### ACCT STOP OK
-# Mon Jul 24 00:02:19 2000: Accounting: 176/8377 'luser7' from 13.16.11.18 port 1 $"040065AE" PPP/13.16.24.22 Stop/User-Request - OK -- total 0, holding 0
-
- if ($line =~ /: Accounting: .* from .* Stop.* OK /i) {
- $merit_radius_acct_stop ++;
- printf "Merit_RADIUS_ACCT_STOP: %s", $line if $debug;
- printf "merit_radius_acct_stop=%s\n", $merit_radius_acct_stop if $debug;
- return 0;
- }
-
-### REMOTE AUTH RECEIVED
-# Mon Jul 24 20:53:38 2000: Received-AUTHENTICATE: 167/44566 'luser9 at realm.com' via some.host.com from some.nas.com port 6 PPP
-
- if ($line =~ /: Received-AUTHENTICATE: .* via .* from /i) {
- $merit_radius_rem_auth ++;
- printf "Merit_RADIUS_REM_AUTH: %s", $line if $debug;
- printf "merit_radius_rem_auth=%s\n", $merit_radius_rem_auth if $debug;
- return 0;
- }
-
-### REMOTE AUTH OK
-# Mon Jul 24 20:53:38 2000: AUTHENTICATE: 167/44566 'luser9 at realm.com' via some.host.com from some.nas.com port 6 PPP - OK -- total 0, holding 0
-
- if ($line =~ /: AUTHENTICATE: .* via .* from .* OK /i) {
- $merit_radius_rem_auth_ok ++;
- printf "Merit_RADIUS_REM_AUTH_OK: %s", $line if $debug;
- printf "merit_radius_rem_auth_ok=%s\n", $merit_radius_rem_auth_ok if $debug;
- return 0;
- }
-
-### REMOTE AUTH FAILED
-# Mon Jul 24 14:05:56 2000: AUTHENTICATE: 230/37578 'luser9 at realm.com' via some.host.com from i-Pass VNAS\0\0\0\0 port 1 - FAILED Authentication failure -- total 0, holding 0
-
- if ($line =~ /: AUTHENTICATE: .* via .* from .* FAILED Authentication /i) {
- $merit_radius_rem_auth_nok ++;
- printf "Merit_RADIUS_REM_AUTH_NOK: %s", $line if $debug;
- printf "merit_radius_rem_auth_nok=%s\n", $merit_radius_rem_auth_nok if $debug;
- return 0;
- }
-
-
- $merit_radius_undefs ++;
- printf "Merit_RADIUS_UNDEF: %s", $line if $debug;
- printf "merit_radius_undefs=%s\n", $merit_radius_undefs if $debug;
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Put the merit_radius values for output
-#
-# usage: &put_merit_radius();
-#
-
-sub put_merit_radius() {
-
- &put_output("merit_radius_auth", sprintf("%8.2f", $merit_radius_auth));
- &put_output("merit_radius_auth_ok", sprintf("%8.2f", $merit_radius_auth_ok));
- &put_output("merit_radius_auth_nok", sprintf("%8.2f", $merit_radius_auth_nok));
- &put_output("merit_radius_acct_start", sprintf("%8.2f", $merit_radius_acct_start));
- &put_output("merit_radius_acct_stop", sprintf("%8.2f", $merit_radius_acct_stop));
- &put_output("merit_radius_rem_auth", sprintf("%8.2f", $merit_radius_rem_auth));
- &put_output("merit_radius_rem_auth_ok", sprintf("%8.2f", $merit_radius_rem_auth_ok));
- &put_output("merit_radius_rem_auth_nok", sprintf("%8.2f", $merit_radius_rem_auth_nok));
-
- &put_output("merit_radius_undefs", sprintf("%8.2f", $merit_radius_undefs));
-
- return 0;
-}
-
-
-
-# -------------------------------------------------------------------
-#
-# init pop vars
-#
-# usage: &init_pop_vars();
-#
-
-sub init_pop_vars() {
- $pop_connect = 0;
- $pop_login = 0;
- $pop_logout = 0;
-
- $pop_failure = 0;
- $pop_refused = 0;
-
- $pop_net_error = 0;
- $pop_local_error = 0;
-
- $pop_undefs = 0;
+ print "$service($Services{$service}{Ok}) ";
}
+print "\n";
+while () {
+ my $outputfile_ok = 0;
+ my ($now, $sleep_till);
-# -------------------------------------------------------------------
-#
-# Get values for pop columns
-#
-# usage: &measure_pop( );
-#
-
-sub measure_pop () {
-
-
- #################################### insert bail out for too much
- #################################### time spent ??
- $buf = <$POPFD>;
- while ($buf) {
- ## process line read and check for eof
- if ($buf) {
- &process_pop_line ($buf);
- }
- if ($POPFD->eof) {
- printf "POP: eof on $POPFile\n" if $debug;
- last; # get out of while($buf)
- }
- $buf = <$POPFD>;
- } ## while ($buf)
-
-
- # test for file change via different inode or filesize decrease
- $dev = $ino = $mode = $nlink = $uid = $gid = $rdev =
- $size = $atime = $mtime = $ctime = $blksize = $blocks = '';
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($POPFile);
- if (!$dev) {
- &logit ("can't stat $POPFile");
- warn "$progname: can't stat $POPFile\n";
- return 1;
- }
- printf "POPFD: pop_ino=%s vs. ino=%s\tpop_size=%s vs. size=%s\n", $pop_ino, $ino, $pop_size, $size if $debug;
- if (($pop_ino != $ino) || ($pop_size > $size)) {
- undef $POPFD;
- printf "POP: file change on $POPFile\n" if $debug;
- $POPFD = new IO::File "$POPFile", "r";
- if (!defined ($POPFD)) {
- &logit ("can't re-open $POPFile");
- warn "$progname: can't re-open $POPFile\n";
- $pop_ino = $pop_size = 0;
- return 2;
+ $now = time;
+ $sleep_till = ($now/$Options{interval}) * $Options{interval};
+ while ($sleep_till < $now + $Options{interval}*0.5) {
+ $sleep_till += $Options{interval};
}
- $pop_ino = $ino;
- $pop_size = $size;
- }
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Parse pop log line
-#
-# usage: &process_pop_line ($buf);
-#
-
-sub process_pop_line () {
- my ($line) = @_;
-
- if ($line !~ / ipop3d\[\d+\]: /) {
- return 0;
- }
+ &measure_head ($now);
-### connect
-# Aug 11 07:01:50 host1 ipop3d[13929]: connect from 14.5.8.10
-
- if ($line =~ /: connect from /i) {
- $pop_connect ++;
- printf "POP_CONNECT: %s", $line if $debug;
- printf "pop_connect=%s\n", $pop_connect if $debug;
- return 0;
- }
-
-### login + auth
-# Aug 11 07:01:57 host1 ipop3d[13928]: Login user=luser2 host=host.domain.pt [13.16.6.27] nmsgs=0/0
-# Aug 11 07:02:06 host1 ipop3d[13936]: Auth user=luser3 host=2-4-4.domain.pt [13.16.2.18] nmsgs=0/0
-
- if ( ($line =~ /: Login user=/i) ||
- ($line =~ /: Auth user=/i) ) {
- $pop_login ++;
- printf "POP_LOGIN: %s", $line if $debug;
- printf "pop_login=%s\n", $pop_login if $debug;
- return 0;
- }
-
-### logout
-# Aug 11 07:01:50 host1 ipop3d[13929]: Logout user=luser4 host=[14.6.8.10] nmsgs=0 ndele=0
-# Aug 11 11:20:24 host1 ipop3d[1866]: Autologout user=luser5 host=3-0-0.domain.pt [13.16.1.18]
-
- if ($line =~ /: .*[lL]ogout user=/i) {
- $pop_logout ++;
- printf "POP_LOGOUT: %s", $line if $debug;
- printf "pop_LOGOUT=%s\n", $pop_logout if $debug;
- return 0;
- }
-
-### failure
-# Aug 11 09:19:19 host1 ipop3d[22171]: Login failure user=luser44 host=4-0-0.domain.pt [13.16.12.1]
-# Aug 11 09:19:22 host1 ipop3d[22171]: AUTHENTICATE LOGIN failure host=4-0-0.domain.pt [13.16.12.1]
-# Aug 11 09:47:47 host1 ipop3d[25308]: AUTHENTICATE luser323 failure host=[13.12.24.24]
-
- if ($line =~ / failure /i) {
- $pop_failure ++;
- printf "POP_FAILURE: %s", $line if $debug;
- printf "pop_failure=%s\n", $pop_failure if $debug;
- return 0;
- }
-
-### refused
-# Aug 11 13:32:14 host1 ipop3d[28886]: refused connect from 13.17.8.28
-
- if ($line =~ /: refused connect from /i) {
- $pop_refused ++;
- printf "POP_REFUSED: %s", $line if $debug;
- printf "pop_refused=%s\n", $pop_refused if $debug;
- return 0;
- }
-
-### local_error
-# Aug 11 11:50:36 host1 ipop3d[13132]: Error opening or locking INBOX user=luser10 host=3-4-3.domain.pt [13.16.4.7]
-
- if ($line =~ /: Error opening or locking INBOX user=/i) {
- $pop_local_error ++;
- printf "POP_LOCAL_ERROR: %s", $line if $debug;
- printf "pop_local_error=%s\n", $pop_local_error if $debug;
- return 0;
- }
-
-### net_error
-# Aug 11 07:36:14 host1 ipop3d[15759]: Command stream end of file while reading line user=luser234 host=9-9-9-domain.pt [13.16.4.5]
-# Aug 11 09:50:09 host1 ipop3d[24960]: Connection reset by peer while reading line user=luser555 host=[12.5.19.16]
-# Aug 11 12:15:01 host1 ipop3d[16601]: Connection timed out while reading line user=luser7985 host=4-5-6.domain.pt [13.16.1.15]
-
- if ( ($line =~ /: Command stream end of file while reading line user=/i) ||
- ($line =~ /: Connection reset by peer while reading line user=/i) ||
- ($line =~ /: Connection timed out while reading line user=/i) ){
- $pop_net_error ++;
- printf "POP_NET_ERROR: %s", $line if $debug;
- printf "pop_net_error=%s\n", $pop_net_error if $debug;
- return 0;
- }
-
-
- $pop_undefs ++;
- printf "POP_UNDEF: %s", $line if $debug;
- printf "pop_undefs=%s\n", $pop_undefs if $debug;
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Put the pop values for output
-#
-# usage: &put_pop();
-#
-
-sub put_pop() {
-
- &put_output("pop_connect", sprintf("%8.2f", $pop_connect));
- &put_output("pop_login", sprintf("%8.2f", $pop_login));
- &put_output("pop_logout", sprintf("%8.2f", $pop_logout));
-
- &put_output("pop_failure", sprintf("%8.2f", $pop_failure));
- &put_output("pop_refused", sprintf("%8.2f", $pop_refused));
-
- &put_output("pop_net_error", sprintf("%8.2f", $pop_net_error));
- &put_output("pop_local_error", sprintf("%8.2f", $pop_local_error));
-
- &put_output("pop_undefs", sprintf("%8.2f", $pop_undefs));
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Get values for radiator radius columns
-#
-# usage: &measure_radius( );
-#
-
-sub measure_radius () {
- #################################### insert bail out for too much
- #################################### time spent ??
-
- my $upper_ts= time;
-
-#Begin GET Accounting
-
- $query = "SELECT ACCT_SESSION_TIME,ACCT_STATUS_TYPE FROM ACCOUNTING ";
- $query .= " WHERE ACCT_STATUS_TYPE = 'Stop'";
- $query .= " AND TIMESTAMP > $radius_base_ts";
- $query .= " AND TIMESTAMP < $upper_ts";
-
- ($rad_time,$rad_sessions) = calculateRadVals($query);
-
- ## incremental/accumulated values
-## $radius_inc_time += $rad_time;
-## $radius_inc_sessions += $rad_sessions;
-
-#END GET Accounting
-
-## `$ECHO "$radius_inc_time:$radius_inc_sessions" > $ACCUM_radius_DB`;
- $radius_base_ts += ($upper_ts - $radius_base_ts);
- return 0;
-}
-
-##
-# IN: query
-# RET: time, sessions
-##
-sub calculateRadVals{
- my $query = shift(@_);
-
-#print "radius query: $query\n";
-
- my ($rad_t,$rad_s)= (0,0);
- $sth = $RADdbh->prepare($query);
- $sth ->execute();
-
- $"=" \t ";
- while ( @row = $sth -> fetchrow_array()){
- #print "$row[0].$row[1]: $eca\n";
- $rad_t += $row[0];
- $rad_s++;
- }
-
- #print "Time: $rad_t seconds\t Sess: $rad_s sessions\n";
- return ($rad_t,$rad_s);
-}
-
-
-# -------------------------------------------------------------------
-#
-# Put the radiator radius values for output
-#
-# usage: &put_radius();
-#
-
-sub put_radius() {
-
- &put_output("rad_time", sprintf("%8.2f", $rad_time));
- &put_output("rad_sessions", sprintf("%8.2f", $rad_sessions));
-
-#incremental graph
-## &put_output("radius_inc_time", sprintf("%8.2f", $radius_inc_time));
- ## &put_output("radius_inc_sessions", sprintf("%8.2f", $radius_inc_sessions));
-
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# Get values for dns columns
-#
-# usage: &measure_dns( );
-#
-
-sub measure_dns () {
-
-
- #################################### insert bail out for too much
- #################################### time spent ??
- $buf = <$DNSFD>;
- while ($buf) {
- ## process line read and check for eof
- if ($buf) {
- &process_dns_line ($buf);
- }
- if ($DNSFD->eof) {
- printf "DNS: eof on $DNSFile\n" if $debug;
- last; # get out of while($buf)
+ #
+ # Init the services vars
+ #
+ while ( ($service) = each %Services) {
+ if ($Services{$service}{Ok} == 0) {
+ my $func= $Services{$service}{Init_Vars};
+ if ($func eq "") {
+ next;
+ }
+ &$func();
+ }
}
- $buf = <$DNSFD>;
- } ## while ($buf)
+ #
+ # call the measure routines...
+ #
+ &measure ($sleep_till);
- # test for file change via different inode or filesize decrease
- $dev = $ino = $mode = $nlink = $uid = $gid = $rdev =
- $size = $atime = $mtime = $ctime = $blksize = $blocks = '';
- ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks) = stat($DNSFile);
- if (!$dev) {
- &logit ("can't stat $DNSFile");
- warn "$progname: can't stat $DNSFile\n";
- return 1;
- }
- printf "DNSFD: dns_ino=%s vs. ino=%s\tdns_size=%s vs. size=%s\n", $dns_ino, $ino, $dns_size, $size if $debug;
- if (($dns_ino != $ino) || ($dns_size > $size)) {
- undef $DNSFD;
- printf "DNS: file change on $DNSFile\n" if $debug;
- $DNSFD = new IO::File "$DNSFile", "r";
- if (!defined ($DNSFD)) {
- &logit ("can't re-open $DNSFile");
- warn "$progname: can't re-open $DNSFile\n";
- $dns_ino = $dns_size = 0;
- return 2;
+ while ( ($service) = each %Services) {
+ if ($Services{$service}{Ok} == 0) {
+ my $func= $Services{$service}{Put};
+ if ($func eq "") {
+ next;
+ }
+ &$func();
+ }
}
- $dns_ino = $ino;
- $dns_size = $size;
- }
-
- return 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# init dns vars
-#
-# usage: &init_dns_vars();
-#
-sub init_dns_vars() {
+ $outputfile_ok = &check_output ("$Options{outputdir}/$nodename");
- $dns_usage_started = 0;
- $dns_nstats_started = 0;
- $dns_xstats_started = 0;
+ &flush_output ();
- &init_dns_usage_vars();
- &init_dns_nstats_vars();
- &init_dns_xstats_vars();
-
- &init_odns_vars();
-}
-sub init_dns_usage_vars () {
- $dns_cpu_u = 0;
- $dns_cpu_s = 0;
- $dns_ccpu_u = 0;
- $dns_ccpu_s = 0;
-}
-sub init_dns_nstats_vars () {
- $dns_a = 0;
- $dns_ptr = 0;
- $dns_mx = 0;
- $dns_any = 0;
-
- $dns_ns = 0;
- $dns_soa = 0;
- $dns_axfr = 0;
- $dns_aaaa = 0;
- $dns_other = 0;
-}
-sub init_dns_xstats_vars () {
- $dns_rr = 0;
- $dns_rq = 0;
- $dns_rother = 0;
-
- $dns_sans = 0;
- $dns_snaans = 0;
- $dns_snxd = 0;
- $dns_sother = 0;
-}
-
-
-# -------------------------------------------------------------------
-#
-# init odns vars (save old values)
-#
-# usage: &init_odns_vars();
-#
-
-sub init_odns_vars() {
- &init_odns_usage_vars();
- &init_odns_nstats_vars();
- &init_odns_xstats_vars();
-}
-
-sub init_odns_usage_vars() {
- $odns_cpu_u = $dns_cpu_u ;
- $odns_cpu_s = $dns_cpu_s ;
- $odns_ccpu_u = $dns_ccpu_u ;
- $odns_ccpu_s = $dns_ccpu_s ;
-
- &init_dns_usage_vars();
-}
-sub init_odns_nstats_vars() {
- $odns_a = $dns_a ;
- $odns_ptr = $dns_ptr ;
- $odns_mx = $dns_mx ;
- $odns_any = $dns_any ;
-
- $odns_ns = $dns_ns ;
- $odns_soa = $dns_soa ;
- $odns_axfr = $dns_axfr ;
- $odns_aaaa = $dns_aaaa ;
- $odns_other = $dns_other ;
-
- &init_dns_nstats_vars();
-}
-sub init_odns_xstats_vars() {
- $odns_rr = $dns_rr ;
- $odns_rq = $dns_rq ;
- $odns_rother = $dns_rother ;
-
- $odns_sans = $dns_sans ;
- $odns_snaans = $dns_snaans ;
- $odns_snxd = $dns_snxd ;
- $odns_sother = $dns_sother ;
-
- &init_dns_xstats_vars();
}
+# got here ? how ??
+exit 0;
-# -------------------------------------------------------------------
-#
-# calc dns delta
#
-# usage: &calc_dns_delta();
+# The usage stuff
#
+sub usage {
+ print "Usage: $progname [options]\n";
+ print "($progname uses the GNU extended POSIX option format)\n";
+ print "\n";
+
+ while ( ($helpline) = each %HelpText) {
+ print "$HelpText{$helpline} $helpline)\n";
+ }
+ print "--help, --version this option summary\n";
+
+ print "\n";
+ print "Note: use filename 'off' to turn off the specific service\n";
+ print "\n";
+ print " This is $progname version $VERSION\n";
+ print "\n";
-sub calc_dns_delta() {
- &calc_dns_usage_delta();
- &calc_dns_nstats_delta();
- &calc_dns_xstats_delta();
-}
-
-sub calc_dns_usage_delta() {
- my $temp = 0;
-
- if ($dns_cpu_u < $odns_cpu_u) {
- $odns_cpu_u = $dns_cpu_u;
- } else {
- $temp = $dns_cpu_u; $dns_cpu_u = $dns_cpu_u - $odns_cpu_u; $odns_cpu_u = $temp;
- }
- if ($dns_cpu_s < $odns_cpu_s) {
- $odns_cpu_s = $dns_cpu_s;
- } else {
- $temp = $dns_cpu_s; $dns_cpu_s = $dns_cpu_s - $odns_cpu_s; $odns_cpu_s = $temp;
- }
- if ($dns_ccpu_u < $odns_ccpu_u) {
- $odns_ccpu_u = $dns_ccpu_u;
- } else {
- $temp = $dns_ccpu_u; $dns_ccpu_u = $dns_ccpu_u - $odns_ccpu_u; $odns_ccpu_u = $temp;
- }
- if ($dns_ccpu_s < $odns_ccpu_s) {
- $odns_ccpu_s = $dns_ccpu_s;
- } else {
- $temp = $dns_ccpu_s; $dns_ccpu_s = $dns_ccpu_s - $odns_ccpu_s; $odns_ccpu_s = $temp;
- }
-}
-sub calc_dns_nstats_delta() {
- my $temp = 0;
-
- if ($dns_a < $odns_a) {
- $odns_a = $dns_a;
- } else {
- $temp = $dns_a; $dns_a = $dns_a - $odns_a; $odns_a = $temp;
- }
- if ($dns_ptr < $odns_ptr) {
- $odns_ptr = $dns_ptr;
- } else {
- $temp = $dns_ptr; $dns_ptr = $dns_ptr - $odns_ptr; $odns_ptr = $temp;
- }
- if ($dns_mx < $odns_mx) {
- $odns_mx = $dns_mx;
- } else {
- $temp = $dns_mx; $dns_mx = $dns_mx - $odns_mx; $odns_mx = $temp;
- }
- if ($dns_any < $odns_any) {
- $odns_any = $dns_any;
- } else {
- $temp = $dns_any; $dns_any = $dns_any - $odns_any; $odns_any = $temp;
- }
-
- if ($dns_ns < $odns_ns) {
- $odns_ns = $dns_ns;
- } else {
- $temp = $dns_ns; $dns_ns = $dns_ns - $odns_ns; $odns_ns = $temp;
- }
- if ($dns_soa < $odns_soa) {
- $odns_soa = $dns_soa;
- } else {
- $temp = $dns_soa; $dns_soa = $dns_soa - $odns_soa; $odns_soa = $temp;
- }
- if ($dns_axfr < $odns_axfr) {
- $odns_axfr = $dns_axfr;
- } else {
- $temp = $dns_axfr; $dns_axfr = $dns_axfr - $odns_axfr; $odns_axfr = $temp;
- }
- if ($dns_aaaa < $odns_aaaa) {
- $odns_aaaa = $dns_aaaa;
- } else {
- $temp = $dns_aaaa; $dns_aaaa = $dns_aaaa - $odns_aaaa; $odns_aaaa = $temp;
- }
- if ($dns_other < $odns_other) {
- $odns_other = $dns_other;
- } else {
- $temp = $dns_other; $dns_other = $dns_other - $odns_other; $odns_other = $temp;
- }
-}
-sub calc_dns_xstats_delta() {
- my $temp = 0;
-
- if ($dns_rr < $odns_rr) {
- $odns_rr = $dns_rr;
- } else {
- $temp = $dns_rr; $dns_rr = $dns_rr - $odns_rr; $odns_rr = $temp;
- }
- if ($dns_rq < $odns_rq) {
- $odns_rq = $dns_rq;
- } else {
- $temp = $dns_rq; $dns_rq = $dns_rq - $odns_rq; $odns_rq = $temp;
- }
- if ($dns_rother < $odns_rother) {
- $odns_rother = $dns_rother;
- } else {
- $temp = $dns_rother; $dns_rother = $dns_rother - $odns_rother; $odns_rother = $temp;
- }
-
- if ($dns_sans < $odns_sans) {
- $odns_sans = $dns_sans;
- } else {
- $temp = $dns_sans; $dns_sans = $dns_sans - $odns_sans; $odns_sans = $temp;
- }
- if ($dns_snaans < $odns_snaans) {
- $odns_snaans = $dns_snaans;
- } else {
- $temp = $dns_snaans; $dns_snaans = $dns_snaans - $odns_snaans; $odns_snaans = $temp;
- }
- if ($dns_snxd < $odns_snxd) {
- $odns_snxd = $dns_snxd;
- } else {
- $temp = $dns_snxd; $dns_snxd = $dns_snxd - $odns_snxd; $odns_snxd = $temp;
- }
- if ($dns_sother < $odns_sother) {
- $odns_sother = $dns_sother;
- } else {
- $temp = $dns_sother; $dns_sother = $dns_sother - $odns_sother; $odns_sother = $temp;
- }
+ exit;
}
-
-# -------------------------------------------------------------------
-#
-# Parse dns log line
#
-# usage: &process_dns_line ($buf);
-#
-
-sub process_dns_line () {
- my ($line) = @_;
-
+# Cycle several measurables
#
-# Oct 24 14:27:49 Ns named[17279]: USAGE 972394069 970586866 CPU=188.82u/82.79s CHILDCPU=0u/0s
-# Oct 24 14:27:49 Ns named[17279]: NSTATS 972394069 970586866 0=6 A=322014 NS=25 SOA=415 PTR=35772 MX=111 SRV=110 ANY=238
-# Oct 24 14:27:49 Ns named[17279]: XSTATS 972394069 970586866 RR=293985 RNXD=22941 RFwdR=205718 RDupR=3603 RFail=508 RFErr=0 RErr=141 RAXFR=0 RLame=2636 ROpts=0 SSysQ=58851 SAns=205888 SFwdQ=169140 SDupQ=23529 SErr=0 RQ=358773 RIQ=0 RFwdQ=0 RDupQ=8397 RTCP=206 SFwdR=205718 SFail=3 SFErr=0 SNaAns=204478 SNXD=45736
+# usage: &measure( $sleep_till );
#
- if ($line !~ / named\[\d+\]: (USAGE|NSTATS|XSTATS) /) {
- return 0;
- }
-
-
-# Oct 24 14:27:49 Ns named[17279]: USAGE 972394069 970586866 CPU=188.82u/82.79s CHILDCPU=0u/0s
- if ($line =~ /: USAGE \d+ \d+ CPU=([\d\.]+)u\/([\d\.]+)s CHILDCPU=([\d\.]+)u\/([\d\.]+)s/) {
-
- $dns_cpu_u = $1;
- $dns_cpu_s = $2;
- $dns_ccpu_u = $3;
- $dns_ccpu_s = $4;
-
- printf "DNS_USAGE: %s", $line if $debug;
- printf "dns_cpu_u=%s, dns_cpu_s=%s, dns_ccpu_u=%s, dns_ccpu_s=%s\n", $dns_cpu_u, $dns_cpu_s, $dns_ccpu_u, $dns_ccpu_s if $debug;
-
- if ($dns_usage_started) {
- &calc_dns_usage_delta(); # puts delta into vars to print -&- saves into old
- } else {
- $dns_usage_started = 1;
- &init_odns_usage_vars(); # saves old and cleans current values
- }
-
-# Oct 24 14:27:49 Ns named[17279]: NSTATS 972394069 970586866 0=6 A=322014 NS=25 SOA=415 PTR=35772 MX=111 SRV=110 ANY=238
- } elsif ($line =~ /: NSTATS \d+ \d+ /) {
- my $l;
-
- ($l = $line) =~ s/^.*: NSTATS \d+ \d+ //; # trim beginning
- chop $l;
-
- @types = split(' ',$l);
-
- $dns_other = 0;
- while (@types) {
- ($t,$v) = split ('=', pop @types);
- if ($t eq 'A') {
- $dns_a = $v;
- } elsif ($t eq 'PTR') {
- $dns_ptr = $v;
- } elsif ($t eq 'MX') {
- $dns_mx = $v;
- } elsif ($t eq 'ANY') {
- $dns_any = $v;
- } elsif ($t eq 'NS') {
- $dns_ns = $v;
- } elsif ($t eq 'SOA') {
- $dns_soa = $v;
- } elsif ($t eq 'AXFR') {
- $dns_axfr = $v;
- } elsif ($t eq 'AAAA') {
- $dns_aaaa = $v;
- } else {
- $dns_other += $v;
- }
- }
-
- printf "DNS_NSTATS: %s", $line if $debug;
- printf "dns_a=%s, dns_ptr=%s, dns_mx=%s, dns_any=%s, dns_ns=%s, dns_soa=%s, dns_axfr=%s, dns_aaaa=%s, dns_other=%s\n", $dns_a, $dns_ptr, $dns_mx, $dns_any, $dns_ns, $dns_soa, $dns_axfr, $dns_aaaa, $dns_other if $debug;
-
- if ($dns_nstats_started) {
- &calc_dns_nstats_delta(); # puts delta into vars to print -&- saves into old
- } else {
- $dns_nstats_started = 1;
- &init_odns_nstats_vars(); # saves old and cleans current values
- }
+sub measure () {
+ my ($sleep_till) = @_;
+ $now = time;
-# Oct 24 14:27:49 Ns named[17279]: XSTATS 972394069 970586866 RR=293985 RNXD=22941 RFwdR=205718 RDupR=3603 RFail=508 RFErr=0 RErr=141 RAXFR=0 RLame=2636 ROpts=0 SSysQ=58851 SAns=205888 SFwdQ=169140 SDupQ=23529 SErr=0 RQ=358773 RIQ=0 RFwdQ=0 RDupQ=8397 RTCP=206 SFwdR=205718 SFail=3 SFErr=0 SNaAns=204478 SNXD=45736
- } elsif ($line =~ /: XSTATS \d+ \d+ /) {
- my $l;
-
- ($l = $line) =~ s/^.*: XSTATS \d+ \d+ //; # trim beginning
- chop $l;
-
- @types = split(' ',$l);
-
- $dns_rother = $dns_sother = 0;
- while (@types) {
- ($t,$v) = split ('=', pop @types);
- if ($t eq 'RR') {
- $dns_rr = $v;
- } elsif ($t eq 'RQ') {
- $dns_rq = $v;
- } elsif ($t =~ /^R/) {
- $dns_rother += $v;
- } elsif ($t eq 'SAns') {
- $dns_sans = $v;
- } elsif ($t eq 'SNaAns') {
- $dns_snaans = $v;
- } elsif ($t eq 'SNXD') {
- $dns_snxd = $v;
- } elsif ($t =~ /^S/) {
- $dns_sother += $v;
- }
- }
+ while ($now < $sleep_till) {
+ printf "MEASURE: sleeping for 5\n" if $Options{debug};
+ sleep(5);
+ $now = time;
+
+ # measure...
+ while ( ($service) = each %Services) {
+ if ($Services{$service}{Ok} == 0 && $Services{$service}{External} == 0) {
+ my $func= $Services{$service}{Measure};
+ if ($func eq "") {
+ next;
+ }
+ &$func();
+ }
+ }
+ # measure...
- printf "DNS_XSTATS: %s", $line if $debug;
- printf "dns_rr=%s, dns_rq=%s, dns_rother=%s, dns_sans=%s, dns_snaans=%s, dns_snxd=%s, dns_sother=%s\n", $dns_rr, $dns_rq, $dns_rother, $dns_sans, $dns_snaans, $dns_snxd, $dns_sother if $debug;
+ $now = time;
+ } # while ($now < $sleep_till)
- if ($dns_xstats_started) {
- &calc_dns_xstats_delta(); # puts delta into vars to print -&- saves into old
- } else {
- $dns_xstats_started = 1;
- &init_odns_xstats_vars(); # saves old and cleans current values
+ #
+ # put in the end... calls external prog.
+ #
+ while ( ($service) = each %Services) {
+ if ($Services{$service}{Ok} == 0 && $Services{$service}{External} == 1) {
+ my $func= $Services{$service}{Measure};
+ if ($func eq "") {
+ next;
+ }
+ &$func();
+ }
+ #
+ # some internal services has something extra to check
+ #
+ if (defined($Services{$service}{Extra})) {
+ my $func= $Services{$service}{Extra};
+ if ($func eq "") {
+ next;
+ }
+ &$func();
+ }
}
- }
-
- return 0;
+ return 0;
}
-
-# -------------------------------------------------------------------
#
-# Put the dns values for output
+# measure_head -- put first values
#
-# usage: &put_dns();
+# usage: &measure_head($time)
#
+sub measure_head() {
+ my ($time) = @_;
-sub put_dns() {
-
- &put_output("dns_cpu_u", sprintf("%8.2f", $dns_cpu_u));
- &put_output("dns_cpu_s", sprintf("%8.2f", $dns_cpu_s));
- &put_output("dns_ccpu_u", sprintf("%8.2f", $dns_ccpu_u));
- &put_output("dns_ccpu_s", sprintf("%8.2f", $dns_ccpu_s));
-
- &put_output("dns_a", sprintf("%8.2f", $dns_a));
- &put_output("dns_ptr", sprintf("%8.2f", $dns_ptr));
- &put_output("dns_mx", sprintf("%8.2f", $dns_mx));
- &put_output("dns_any", sprintf("%8.2f", $dns_any));
-
- &put_output("dns_ns", sprintf("%8.2f", $dns_ns));
- &put_output("dns_soa", sprintf("%8.2f", $dns_soa));
- &put_output("dns_axfr", sprintf("%8.2f", $dns_axfr));
- &put_output("dns_aaaa", sprintf("%8.2f", $dns_aaaa));
- &put_output("dns_other", sprintf("%8.2f", $dns_other));
-
- &put_output("dns_rr", sprintf("%8.2f", $dns_rr));
- &put_output("dns_rq", sprintf("%8.2f", $dns_rq));
- &put_output("dns_rother", sprintf("%8.2f", $dns_rother));
-
- &put_output("dns_sans", sprintf("%8.2f", $dns_sans));
- &put_output("dns_snaans", sprintf("%8.2f", $dns_snaans));
- &put_output("dns_snxd", sprintf("%8.2f", $dns_snxd));
- &put_output("dns_sother", sprintf("%8.2f", $dns_sother));
-
- return 0;
+ $now_string = strftime "%T", localtime;
+ &put_output(" timestamp", sprintf("%10d", $time));
+ &put_output("locltime", $now_string);
}
-
Modified: branches/orca/import_orca_services_2.0/data_gatherers/orca_services/stop_orca_services.sh.in
==============================================================================
--- branches/orca/import_orca_services_2.0/data_gatherers/orca_services/stop_orca_services.sh.in (original)
+++ branches/orca/import_orca_services_2.0/data_gatherers/orca_services/stop_orca_services.sh.in 2003-03-08 10:26:15.000000000 -0800
@@ -1,18 +1,27 @@
#!/bin/sh
AWK=@AWK@
+UNAME=/usr/bin/uname
-# Kill any running orca_services.
-pids=`/usr/ucb/ps auxww | $AWK '/orca_services/ && !/awk/ {print $2}'`
+OPERSYS=`$UNAME -s`
+
+# Kill any running orcallators.
+if test "${OPERSYS}" = "Linux"; then
+ PSCMD="/bin/ps"
+else
+ PSCMD="/usr/ucb/ps" # Solaris
+fi
+
+pids=`$PSCMD auxww | $AWK '/orca_services/ && !/awk/ && !/stop_orca_services/ && !/ \/etc\/init\.d/ && !/ \/etc\/rc/ {print $2}'`
if test "$pids" != ""; then
echo "Killing pids $pids."
kill -HUP $pids
sleep 1
- pids=`/usr/ucb/ps auxww | $AWK '/orca_services/ && !/awk/ {print $2}'`
+ pids=`$PSCMD auxww | $AWK '/orca_services/ && !/awk/ && !/stop_orca_services/ && !/ \/etc\/init\.d/ && !/ \/etc\/rc/ {print $2}'`
if test "$pids" != ""; then
kill -TERM $pids
sleep 1
- pids=`/usr/ucb/ps auxww | $AWK '/orca_services/ && !/awk/ {print $2}'`
+ pids=`$PSCMD auxww | $AWK '/orca_services/ && !/awk/ && !/stop_orca_services/ && !/ \/etc\/init\.d/ && !/ \/etc\/rc/ {print $2}'`
if test "$pids" != ""; then
kill -9 $pids
sleep 1
Modified: branches/orca/import_orca_services_2.0/data_gatherers/orca_services/S99orca_services.sh.in
==============================================================================
--- branches/orca/import_orca_services_2.0/data_gatherers/orca_services/S99orca_services.sh.in (original)
+++ branches/orca/import_orca_services_2.0/data_gatherers/orca_services/S99orca_services.sh.in 2003-03-08 10:26:15.000000000 -0800
@@ -6,17 +6,19 @@
case "$1" in
'start')
- if [ -x $bindir/start_orca_services ]; then
+ if [ -x $bindir/start_orca_services.sh ]; then
umask 022
- $bindir/start_orca_services
+ $bindir/start_orca_services.sh
else
- echo "$0: $bindir/start_orca_services does not exist or is not executable."
+ echo "$0: $bindir/start_orca_services.sh does not exist or is not executable."
fi
;;
'stop')
- if [ -x $bindir/stop_orca_services ]; then
- $bindir/stop_orca_services
+ if [ -x $bindir/stop_orca_services.sh ]; then
+ $bindir/stop_orca_services.sh
+ else
+ echo "$0: $bindir/stop_orca_services.sh does not exist or is not executable."
fi
;;
Modified: branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.cfg.in
==============================================================================
--- branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.cfg.in (original)
+++ branches/orca/import_orca_services_2.0/data_gatherers/orca_services/orca_services.cfg.in 2003-03-08 10:26:15.000000000 -0800
@@ -39,6 +39,14 @@
warn_email root at localhost
late_interval interval + 30
+# These parameters specify which plots to generate.
+generate_hourly_plot 1
+generate_daily_plot 1
+generate_weekly_plot 1
+generate_monthly_plot 1
+generate_quarterly_plot 1
+generate_yearly_plot 1
+
# This defines where the find the source data files and the format of
# those files. Notes about the fields:
# find_files
@@ -53,9 +61,8 @@
# The interval here must match the interval used by orca_services to
# record data. Do not change this, as it has an effect on the
# generated RRD data files.
-
group orca_services {
-find_files @VAR_DIR@/orca_services/(.*)/(?:(?:orca_services)|(?:percol))-\d{4}-\d{2}-\d{2}(?:\.(?:Z|gz|bz2))?
+find_files @VAR_DIR@/orca_services/(.*)/(?:(?:orca_services)|(?:orcaservices))-\d{4}-\d{2}-\d{2}(?:-\d{3,})?(?:\.(?:Z|gz|bz2))?
column_description first_line
date_source column_name timestamp
interval 300
@@ -75,17 +82,12 @@
#
# ATTENTION: change this to your values
#
-html_top_title Services Status
+html_top_title Orca_services Status
#
# ATTENTION: change this to your values
#
-html_page_header
- <a href="http://www.kpnQwest.pt/">
- <img border=0 alt="kpnQwest Portugal"
- src="http://www.kpnqwest.pt/images/kqlogopt_mini.gif"
- width=101 height=61></a>
- <spacer type=vertical size=4>
+html_page_header <h3>Put your site's logo here.</h3>
html_page_footer
<spacer type=vertical size=20>
@@ -120,6 +122,36 @@
}
plot {
+title %g SMTP Virus & Spam in 5 minutes
+source orca_services
+data smtp_virus
+data smtp_spam
+legend Virus (5m)
+legend Spam Messages (5m)
+y_legend Number of Messages
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html
+}
+
+plot {
+title %g SMTP Failed
+source orca_services
+data smtp_torf
+data smtp_c_ml
+data smtp_c_rt
+data smtp_ntfs
+legend Temp or Fatal Error (5m)
+legend Check Mail (5m)
+legend Check Rcpt (5m)
+legend Portmaster Notifies (5m)
+y_legend Number of Messages
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html#SMTP_Failed
+}
+
+plot {
title %g SMTP Size
source orca_services
data smtp_sizes
@@ -163,33 +195,27 @@
}
plot {
-title %g SMTP Failed
+title %g SMTP DSN and Undefs
source orca_services
-data smtp_torf
-data smtp_c_ml
-data smtp_c_rt
-data smtp_ntfs
-legend Temp or Fatal Error (5m)
-legend Check Mail (5m)
-legend Check Rcpt (5m)
-legend Portmaster Notifies (5m)
+data smtp_dsns
+data smtp_undf
+legend Number of DSNs (5m)
+legend Undefined log (5m)
y_legend Number of Messages
data_min 0
data_max U
-href http://o-s.kpnqwest.pt/orca_services.html#SMTP_Failed
+href http://o-s.kpnqwest.pt/orca_services.html#SMTP_DSN_and_Undefs
}
plot {
-title %g SMTP DSN and Undefs
+title %g SMTP Over Quota in 5 minutes
source orca_services
-data smtp_dsns
-data smtp_undf
-legend Number of DSNs (5m)
-legend Undefined log (5m)
+data smtp_overquota
+legend Over Quota (5m)
y_legend Number of Messages
data_min 0
data_max U
-href http://o-s.kpnqwest.pt/orca_services.html#SMTP_DSN_and_Undefs
+href http://o-s.kpnqwest.pt/orca_services.html
}
@@ -307,7 +333,19 @@
title %g Radius time usage
source orca_services
line_type line2
-data rad_time/60
+data rad_time / 60
+legend Time consumption (5 min)
+y_legend Minutes
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html#Radius_time_usage
+}
+
+plot {
+title %g Radius accumulated time usage
+source orca_services
+line_type line2
+data radius_inc_time / 60
legend Time consumption (5 min)
y_legend Minutes
data_min 0
@@ -327,10 +365,22 @@
href http://o-s.kpnqwest.pt/orca_services.html#Radius_sessions
}
+plot {
+title %g Radius accumulated sessions
+source orca_services
+line_type line2
+data radius_inc_sessions
+legend Number of Sessions (5 min)
+y_legend Terminated Sessions
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html#Radius_sessions
+}
+
plot {
-title %g NAMED CPU Usage in 1 hour
+title %g NAMED CPU Usage in 10 minutes
source orca_services
data dns_cpu_u
data dns_cpu_s
@@ -344,7 +394,7 @@
legend System
legend Child User
legend Child System
-y_legend Seconds in 1 hour
+y_legend Seconds in 10 minutes
data_min 0
data_max U
href http://o-s.kpnqwest.pt/orca_services.html#NAMED_CPU_Usage_in_1_hour
@@ -365,7 +415,7 @@
legend PTR
legend MX
legend ANY
-y_legend Units in 1 hour
+y_legend Units in 10 minutes
data_min 0
data_max U
href http://o-s.kpnqwest.pt/orca_services.html#NAMED_Major_queries
@@ -389,7 +439,7 @@
legend AXFR
legend AAAA
legend OTHER
-y_legend Units in 1 hour
+y_legend Units in 10 minutes
data_min 0
data_max U
href http://o-s.kpnqwest.pt/orca_services.html#NAMED_Minor_queries
@@ -407,7 +457,7 @@
legend R-Responses
legend R-Queries
legend R-OTHER
-y_legend Units in 1 hour
+y_legend Units in 10 minutes
data_min 0
data_max U
href http://o-s.kpnqwest.pt/orca_services.html#NAMED_Received
@@ -428,8 +478,117 @@
legend S-NA Answer
legend S-Negative
legend S-OTHER
-y_legend Units in 1 hour
+y_legend Units in 10 minutes
data_min 0
data_max U
href http://o-s.kpnqwest.pt/orca_services.html#NAMED_Sent
}
+
+plot {
+title %g HTTP Processes
+source orca_services
+data http_procs
+line_type line2
+legend HTTP Processes
+y_legend Number of processes
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html#HTTP_Processes
+}
+
+plot {
+title %g HTTP requests
+source orca_services
+data http_hits
+data http_condgets
+data http_gets
+data http_heads
+data http_posts
+data http_errors
+data http_undefs
+line_type line2
+line_type line2
+line_type line2
+line_type line2
+line_type line2
+line_type line2
+line_type line2
+legend HIT
+legend cond GET
+legend GET
+legend HEAD
+legend POST
+legend Errors
+legend Undefs
+y_legend Units in 5 minutes
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html#HTTP_requests
+}
+
+plot {
+title %g HTTP Bps
+source orca_services
+data http_Bps
+line_type line2
+legend HTTP bandwidth
+y_legend BYTES per Second
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html#HTTP_Bps
+}
+
+plot {
+title %g HTTP request size
+source orca_services
+data http_1k * 100
+data http_10k * 100
+data http_100k * 100
+data http_1000k * 100
+data http_1M * 100
+line_type area
+line_type stack
+line_type stack
+line_type stack
+line_type stack
+legend % of < 1Kb requests
+legend % of < 10Kb requests
+legend % of < 100Kb requests
+legend % of < 1000Kb requests
+legend % of > 1Mb requests
+y_legend Percent
+data_min 0
+data_max 120
+href http://o-s.kpnqwest.pt/orca_services.html#HTTP_request_size
+}
+
+
+
+plot {
+title %g NNTP Statistics in 5 minutes
+source orca_services
+data nntpcache_connects
+data nntpcache_groups
+data nntpcache_articles
+legend Connects (5m)
+legend GROUPs (5m)
+legend ARTICLEs (5m)
+y_legend Units in 5 minutes
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html
+}
+
+plot {
+title %g SLAPD Statistics in 5 minutes
+source orca_services
+data slapd_binds
+data slapd_searchs
+legend BINDs (5m)
+legend SRCHs (5m)
+y_legend Units in 5 minutes
+data_min 0
+data_max U
+href http://o-s.kpnqwest.pt/orca_services.html
+}
+
More information about the Orca-checkins
mailing list