File: data_sendmsg

package info (click to toggle)
spong 2.7.7-19
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,880 kB
  • ctags: 1,224
  • sloc: perl: 6,640; sh: 2,247; makefile: 237
file content (117 lines) | stat: -rw-r--r-- 3,362 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
=head1 NAME

B<data_sendmsg> - spong-network module that sends copies of update messages to
other spong-servers

=head1 DESCRIPTION

This is a plugin module for the Spong L<spong-server> program. This module
sends incoming update messages to other spong-servers. It's purpose is to set
up regional Spong configurations that feed incoming status messages to 
upper level Spong configurations.

=cut

# data_sendmsg - plugins module for spong-server
# This module copies/clones all of a subset of status messages to other
# spong-servers. Typical use would be to setup Spong regions and feeding all
# regional status messages to a top level server.

# $Id: data_sendmsg,v 1.2 2001/05/07 14:48:17 sljohnson Exp $

use Spong::Status "0.02";

# Register the routine with the plugin registry
$DATAFUNCS{'sendmsg'} = \&data_sendmsg;

my $SENDMSG_SERVERS = "spong-server-2.my-inc.com:10998 spong-top.my-inc.com";

# These are list of hostname to send/not-send to other servers. There are
# lists of perl regular expressions

# List of hosts to send to other servers
my @SENDMSG_INC_HOSTS = ( '.*' );

# List of hosts to exclude 
my @SENDMSG_EXCL_HOSTS = (  );

sub data_sendmsg {
   my( $host, $service, $color, $start, $time, $sum, $message ) = @_;

   # Check the list of hosts to exclude
   foreach my $re (@SENDMSG_EXCL_HOSTS) {
      if ( $host =~ /$re/o ) { return; }  # If we get a hit, return
   }

   # Check the lists of hosts to include
   my $hit=0;
   foreach my $re (@SENDMSG_INC_HOSTS) {
      if ( $host =~ /$re/o ) { $hit=1; last; } # If we get a hit, set flag
   }
   return unless $hit;  # Return unless we got a hit

   my $msg = "status $host $service $color $time $sum\n$message\n";

   my $errmsg = Spong::Status::SendMsg( $SENDMSG_SERVERS,
                                        $main::SPONG_UPDATE_PORT, $msg );

   main::error("data_sendmsg: $errmsg") if $errmsg;

}

1;


__END__

=head2 Configuration

=over 4

=item $SENDMSG_SERVERS

A string that has the list of other Spong  Servers that you want to the
status update messages to. The syntax is "hostname[:port] hostname[:port] ...".
If the :port is not specified, Spong::Status::SendMsg defaults to
$main::SPONG_UPDATE_PORT variable passed in the procedure call. See
L<spong.conf/"$SPONG_UPDATE_PORT"> for more details.

=item @SENDMSG_INC_HOSTS

This is ia list of hosts who's status messages are sent to the other Spong
Server specified in $SENDMSG_SERVERS. These entries can be partial host names
or Perl regular expressions.

=item @SENDMSG_EXCL_HOSTS

This is a list of hosts that should be exclude from send to the other Spong
Servers specified in $SENDMSG_SERVERS. These entries can be partial host names
or Perl regulare expressions.

=back

=head1 EXAMPLES

 $SENDMSG_SERVERS = "spong-reg1.myinc.com:1998 spong-toplevel.myinc.com:1998
                     spong-proxy.myinc.com:19980";

 $SENDMSG_INC_HOSTS = ( '.*', );

 $SENDMSG_EXCL_HOSTS = ( 'test1', 'test2', '.engr.myinc.com$', );


=head1 SEE ALSO

L<spong-server>, L<spong.conf>,
L<Spong Developer Guide|developer-guide>

=head1 RESTRICTIONS

B<data_sendmsg> uses the C<Spong::Status> library module to work.  It uses the
new capability to send a status message to multiple servers. It is only
available in versions 0.02 and up of the Spong::Status module.

=head1 AUTHOR

Stephen L Johnson <F<sjohnson@monsters.org>>.