./nagzilla-2.0/0000755000000000000000000000000011232756112012007 5ustar rootroot./nagzilla-2.0/nagzillad.cfg0000755000000000000000000000226311213102011014421 0ustar rootroot####Configuration File for Nagzillad ### ###(c)2008 Hurricane Labs, LLC ######### #Nagzillad Server Settings #IP to bind to BindAddr = 127.0.0.1 #Port to bind to BindPort = 49776 #Username to run as BindUser = nagzilla #Run as daemon, use 1 - to run in foreground use 0 Daemon = 1 #To log server starts and stop and messages sent use 1 To_Log = 1 #Where would you like to log to today? Log_Directory = /var/log/nagzilla #Default error log level Error_Log_Level = 6 #Nagzillad Access Control {comma separated list of IP addresses allowed to connect} AllowedIPAddr = 127.0.0.1 #Jabber Server Settings #Jabber Server to connect to JabberServer = naggydev #Jabber Port JabberPort = 5222 #Debug Messages on or off JabberDebug = 0 #Jabber User JabberUser = #Jabber Password JabberPass = #Jabber Resource to use JabberResource = #Time to wait between sending message JabberMaxWait = 2 #To use TLS or not JabberTLS = 1 #To use SSL or not JabberSSL = 0 #To use SASL or not JabberSASL = 1 #Conference Server Settings #Jabber Conference Server ConfServer = conference.naggydev #comma separated list of conference room names ConfRooms = #Nick to use in the conference rooms ConfNick = nagzilla ./nagzilla-2.0/VERSION0000755000000000000000000000014111232755033013057 0ustar rootrootNagzilla Client/Server 2.0 (beta 1) (c) 2006-2009 Hurricane Labs, LLC by Bill Mathews (Billford) ./nagzilla-2.0/LICENSE0000755000000000000000000003503611213102011013004 0ustar rootroot The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ./nagzilla-2.0/CHANGELOG0000755000000000000000000000304211232755502013225 0ustar rootroot07/24/2009 -- Added command line options and some documenation/help for nagzillc2.pl 07/22/2009 -- Added presence ability to nagzillad 07/06/2009 -- Added the ability to send color coded messages 06/07/2009 -- Added patches from rhonda@debian for config files(bind to localhost), logrotate and arv issue 05/28/2009 -- Removed external loading of config file options 05/27/2009 -- Added some rudimentary IP address access control 05/26/2009 -- finished up multiple client support (Thanks for the troubleshooting Lebbeous and Steve!) -- added a utilities directory with a couple stress testing bash scripts (see TODO) 05/18/2009 -- Added patches from 01/10/2009 -- Removed specfics from and commented config file -- User to run as is now hard coded (nobody) -- will change later -- Added a sample log rotate script to archive 01/09/2009 -- Added user change -- Added liblog-loglite-perl module to help with logging -- Added very simple logging 12/13/2008 -- Replaced old guy code with some young guy code (array handling and such) -- Added the ability for Nagzilla to accept subscription requests for roster addition -- -- Above feature currently requires a restart -- hopefully next release will be cooler 10/24/2008 -- Applied Patch from hakamadare via Google Code -- fixed config file issues -- added require directive to a couple modules -- added SSL / TLS / SASL -- added debug option for connection to Jabber server -- applied by BM ./nagzilla-2.0/extras/0000755000000000000000000000000011232754556013327 5ustar rootroot./nagzilla-2.0/extras/nagzillac-php-lib.php0000644000000000000000000000077211232754556017343 0ustar rootroot//Sample function to create a php based nagzilla client //(c)2009 Hurricane Labs //by: Billford function shout_it_nagzilla ($room,$message,$poster) { $host = "nagzilla_server"; $port = 49776; $timeout = 30; $mess_too = $poster . " shouted ".$message; $send = "room^".$room."^".$mess_too; $nag=fsockopen($host,$port,$errnum,$errstr,$timeout); if (!is_resource($nag)) { exit("Connection to Nagzilla Server failed ".$errnum . " ".$errstr); }else { fputs($nag,$send); } fclose($nag); } ./nagzilla-2.0/extras/.svn/0000755000000000000000000000000011232756112014201 5ustar rootroot./nagzilla-2.0/extras/.svn/format0000444000000000000000000000000211224725700015402 0ustar rootroot9 ./nagzilla-2.0/extras/.svn/prop-base/0000755000000000000000000000000011224725700016071 5ustar rootroot./nagzilla-2.0/extras/.svn/props/0000755000000000000000000000000011224725700015344 5ustar rootroot./nagzilla-2.0/extras/.svn/entries0000444000000000000000000000063611232756053015604 0ustar rootroot9 dir 20 https://nagzilla.googlecode.com/svn/branches/nagzilla-2.0/extras https://nagzilla.googlecode.com/svn 2009-07-26T04:21:10.719669Z 18 billford svn:special svn:externals svn:needs-lock 8473c688-9fee-11dd-a5cd-697bfd0a0cef 0 nagzillac-php-lib.php file 2009-07-26T04:19:58.000000Z ff0e016a1b733d357720b28768617ddb 2009-07-26T04:21:10.719669Z 18 billford 506 ./nagzilla-2.0/extras/.svn/all-wcprops0000444000000000000000000000033011232756053016365 0ustar rootrootK 25 svn:wc:ra_dav:version-url V 45 /svn/!svn/ver/18/branches/nagzilla-2.0/extras END nagzillac-php-lib.php K 25 svn:wc:ra_dav:version-url V 67 /svn/!svn/ver/18/branches/nagzilla-2.0/extras/nagzillac-php-lib.php END ./nagzilla-2.0/extras/.svn/text-base/0000755000000000000000000000000011232754667016112 5ustar rootroot./nagzilla-2.0/extras/.svn/text-base/nagzillac-php-lib.php.svn-base0000444000000000000000000000077211232754666023640 0ustar rootroot//Sample function to create a php based nagzilla client //(c)2009 Hurricane Labs //by: Billford function shout_it_nagzilla ($room,$message,$poster) { $host = "nagzilla_server"; $port = 49776; $timeout = 30; $mess_too = $poster . " shouted ".$message; $send = "room^".$room."^".$mess_too; $nag=fsockopen($host,$port,$errnum,$errstr,$timeout); if (!is_resource($nag)) { exit("Connection to Nagzilla Server failed ".$errnum . " ".$errstr); }else { fputs($nag,$send); } fclose($nag); } ./nagzilla-2.0/extras/.svn/tmp/0000755000000000000000000000000011232756053015005 5ustar rootroot./nagzilla-2.0/extras/.svn/tmp/prop-base/0000755000000000000000000000000011224725700016671 5ustar rootroot./nagzilla-2.0/extras/.svn/tmp/props/0000755000000000000000000000000011224725700016144 5ustar rootroot./nagzilla-2.0/extras/.svn/tmp/text-base/0000755000000000000000000000000011232754667016712 5ustar rootroot./nagzilla-2.0/TODO-2.00000755000000000000000000000157611232754144013013 0ustar rootrootnagzillac/d should be SSL based with shared secrets nagzillad should send back some confirmation of message, etc to nagzillac -- not entirely sure what's going to happen here, perhaps some magic nagzillad should accept rawxml messages (patch provided from rhonda@debian.at but needs improvement) -- I'm thinking of just offering some command line stuff to change colors/text, etc. -- I still haven't found a way to allow InsertRawXML safely -- Color codes via command line done -- 07/24/2009 nagzillad should announce her presence -- completed 07/22/2009 -- some code for this was written back in the old days, I'm going to re-integrate it in this release -- this accepts subscription requests on every message nagzillac should allow command line options -- completed 7/25/2009 -- command line option code completed with getopt::long -- this should make new options easier to add ./nagzilla-2.0/patches/0000755000000000000000000000000011213102011013414 5ustar rootroot./nagzilla-2.0/patches/steve.patch0000644000000000000000000002441511213102011015571 0ustar rootrootdiff -ruN ../nagzilla-1.5.5-pre/nagzillad.pl ./nagzillad.pl --- ../nagzilla-1.5.5-pre/nagzillad.pl 2009-05-27 19:56:52.000000000 +0000 +++ ./nagzillad.pl 2009-05-27 22:22:48.000000000 +0000 @@ -5,7 +5,6 @@ #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Bot Server - #import our required Perl modules require Config::Simple; require Data::Dumper; @@ -13,154 +12,199 @@ use IO::Socket; use IO::Socket::INET; use IO::Select; -use Net::Jabber qw(Client) ; -use Net::Jabber qw(Message) ; -use Net::Jabber qw(Protocol) ; -use Net::Jabber qw(Presence) ; +use Net::Jabber qw(Client); +use Net::Jabber qw(Message); +use Net::Jabber qw(Protocol); +use Net::Jabber qw(Presence); -#bring in our configuration variables $CONFDIR = "/etc/nagzillad"; + # DO NOT EDIT ANYTHING BEYOND THIS POINT!! do "$CONFDIR/nagzillad-config.pl"; -my $log = new Log::LogLite($LOG_DIRECTORY."/nagzillad.log", $ERROR_LOG_LEVEL); +my $log = new Log::LogLite( $LOG_DIRECTORY . "/nagzillad.log", $ERROR_LOG_LEVEL ); + +# make_access_checker - returns a function which checks if an IP address +# should be allowed to connect to this nagzillad. +# +# It takes a reference to an an array of IP addresses (dotted quad strings). +# +# It returns a function which takes an IP address (also a dotted quad +# string). That function will return 1 if the IP address is allowed and +# undef if it isn't. +# +sub make_access_checker { + my $ok_addrs = shift; + my %ok_addr_set = map { $_ => 1 } @{$ok_addrs}; + return sub { + my $addr = shift; + return $ok_addr_set{$addr}; + } +} + +my $check_access = make_access_checker(\@allowedipaddr); -#taken from a Perl tutorial somewhere a million years ago so direct reference escapes me. +#taken from a Perl tutorial somewhere a million years ago so direct reference escapes me. sub daemonize { - chdir '/' or die "Can't chdir to /: $!"; - open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; - open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; - open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; - defined(my $pid = fork) or die "Can't fork: $!"; - #setsid - from McMaster's salvia; - if ($pid != 0) - { - open (PIDFILE, '>/var/run/nagzillad.pid'); - print PIDFILE "$pid\n"; - close (PIDFILE); - chown $uid, 0, "/var/run/nagzillad.pid"; - chmod oct("0644"), "/var/run/nagzillad.pid"; + chdir '/' or die "Can't chdir to /: $!"; + open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; + open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; + open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; + defined( my $pid = fork ) or die "Can't fork: $!"; + + #setsid - from McMaster's salvia; + if( $pid != 0 ) { + open( PIDFILE, '>/var/run/nagzillad.pid' ); + print PIDFILE "$pid\n"; + close(PIDFILE); + chown $uid, 0, "/var/run/nagzillad.pid"; + chmod oct("0644"), "/var/run/nagzillad.pid"; + # Change user ID - automagically - my $uid = (getpwnam('nobody'))[2]; + my $uid = ( getpwnam('nobody') )[2]; $> = $uid; - exit(0); - } - setsid or die "Can't start a new session: $!"; - umask 0; + exit(0); + } + setsid or die "Can't start a new session: $!"; + umask 0; } -if ($daemon eq 1) -{ -&daemonize; -# Change user ID - automagically -my $uid = (getpwnam('nobody'))[2]; -$> = $uid; -} +if ($daemon eq 1) { + &daemonize; + # Change user ID - automagically + my $uid = ( getpwnam('nobody') )[2]; + $> = $uid; +} #Let's make us a socket -$local = IO::Socket::INET->new( Proto => 'tcp', - LocalAddr => $bindaddr, - LocalPort => $bindport, - Reuse => 1 - ) or die "$!"; -$local->listen(); #Tell our socket to listen -$local->autoflush(1); #This is on by default with newer versions of IO::Socket but for bc let's turn it on anyway - -if ($to_log eq 1) { - -$log->write("Nagzillad Server Started", 5); +$local = IO::Socket::INET->new( + Proto => 'tcp', + LocalAddr => $bindaddr, + LocalPort => $bindport, + Reuse => 1 +) or die "$!"; +$local->listen(); #Tell our socket to listen +#This is on by default with newer versions of IO::Socket but for bc let's turn it on anyway +$local->autoflush(1); +if ($to_log eq 1) { + $log->write( "Nagzillad Server Started", 5 ); } - #Start Jabber Stuff - my $connection = Net::Jabber::Client -> new( debugLevel => $jabberdebug ); #Creates a new connection to the jabber server - $connection -> Connect( "hostname" => $jabberserver, "port" => $jabberport, "tls" => $jabbertls, "ssl" => $jabberssl ) or die "Cannot connect ($!)\n"; #Return an error on failure +# Creates a new connection to the jabber server +my $connection = Net::Jabber::Client->new( debugLevel => $jabberdebug ); +$connection->Connect( + "hostname" => $jabberserver, + "port" => $jabberport, + "tls" => $jabbertls, + "ssl" => $jabberssl +) or die "Cannot connect ($!)\n"; #Return an error on failure + +my @result; +if ($jabbersasl) { + @result = $connection->AuthSend( + "username" => $jabberuser, + "password" => $jabberpass, + "resource" => $jabberresource + ); + +} else { + @result = $connection->AuthIQAuth( + "username" => $jabberuser, + "password" => $jabberpass, + "resource" => $jabberresource + ); +} + +if ($result[0] ne "ok") { + #Send an auth request, return on failure + die "Ident/Auth with server failed: $result[0] - $result[1]\n"; +} - my @result; - if ( $jabbersasl ) { - @result = $connection->AuthSend( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); - - } - else { - @result = $connection->AuthIQAuth( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); - - } - - if ($result[0] ne "ok") { - die "Ident/Auth with server failed: $result[0] - $result[1]\n"; #Send an auth request, return on failure - } #Allow the daemon to hang out in as many rooms as needed (defined in config file) #Depending on your Jabber server setup specifying a non-existent room will create that room foreach $confs (@confrooms) { - - my $room = $connection->MUCJoin(room=>"$confs", - server=>"$confserver", #Conference server - nick=>"$confnick"); #Join a room + my $room = $connection->MUCJoin( + room => "$confs", + server => "$confserver", #Conference server + nick => "$confnick" + ); #Join a room } $readable_handles = new IO::Select(); $readable_handles->add($local); while (1) { - ($new_readable) = IO::Select->select($readable_handles, undef, undef, undef); + ($new_readable) = IO::Select->select( $readable_handles, undef, undef, undef ); + + foreach $sock (@$new_readable) { + if ($sock == $local) { + $new_sock = $sock->accept(); + my $client_name = $new_sock->peeraddr; + $ip = inet_ntoa($client_name); + + next if not defined $new_sock; + + # check if the new peer's IP address is permitted via + # the AllowedIPAddr conf statement. + if ($check_access->($ip)) { + $log->write("accepted connection from $ip",1); + $readable_handles->add($new_sock); + } else { + $log->write("rejected connection from $ip - not in AllowedIPAddr",5); + close $new_sock; + } + } else { + $buf = <$sock>; + + $readable_handles->remove($sock); + close $sock; + + if ($buf) { + + my ( $style, $roomy, $mess ) = split( /\^/, $buf, 3 ); + + my $message = Net::Jabber::Message->new(); + if ($style eq "room") { + $message->SetMessage( + "type" => 'groupchat', + "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", + "type" => 'chat', + "body" => $mess + ); + + } + else { + $message->SetMessage( + "to" => $roomy =~ /@/ ? $roomy: "$roomy\@$jabberserver", + "subject" => "Monitoring Alert", + "type" => 'chat', + "body" => "$mess" + ); + + } + + #Send message from STDIN -- probably should add some error handling + #There is some bug in at least ejabberd that causes messages to + #be sent "offline". They get flushed on nagzilla restart + #I don't know of a good way to check if this is happening yet + #More to come - BM + $connection->Send($message); + + if ($to_log eq 1) { + $log->write( "--$mess-- sent to $roomy from $ip", 5 ); -foreach $sock (@$new_readable) { - if ($sock == $local){ - $new_sock = $sock->accept(); - my $client_name = $new_sock->peeraddr; - $ip = inet_ntoa($client_name); - #print "$ip \n"; - next if not defined $new_sock; - $readable_handles->add($new_sock); - }else{ - if (grep {$_ eq $ip} @allowedipaddr) { - - $buf = <$sock>; - - $readable_handles->remove($sock); - close $sock; - - if ($buf) { - -my ($style, $roomy, $mess) = split(/\^/, $buf, 3); - - my $message = Net::Jabber::Message->new(); - if ($style eq "room") { - $message->SetMessage( "type" => 'groupchat', - "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", - "type" => 'chat', - "body" => $mess ); - - } else { - $message->SetMessage ( "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$jabberserver", - "subject" => "Monitoring Alert", - "type" => 'chat', - "body" => "$mess" ); - - } - $connection->Send($message); #Send message from STDIN -- probably should add some error handling - #There is some bug in at least ejabberd that causes messages to - #be sent "offline". They get flushed on nagzilla restart - #I don't know of a good way to check if this is happening yet - #More to come - BM - - if ($to_log eq 1) { - $log->write("--$mess-- sent to $roomy from $ip", 5); - + } + } } - -} - - } -} -} - sleep (MAXWAIT); #Creates a sleep timer so many messages can be handled without issue - } - \ No newline at end of file + #Creates a sleep timer so many messages can be handled without issue + sleep(MAXWAIT); +} + diff -ruN ../nagzilla-1.5.5-pre/README ./README --- ../nagzilla-1.5.5-pre/README 2009-05-27 20:02:59.000000000 +0000 +++ ./README 2009-05-27 21:18:06.000000000 +0000 @@ -23,10 +23,10 @@ IO::Socket IO::Socket::INET - Net::Jabber - Config::Simple + Net::Jabber (Ubuntu package: libnet-jabber-perl) + Config::Simple (Ubuntu package: libconfig-simple-perl) Data::Dumper - Log::LogLite + Log::LogLite (Ubuntu package: liblog-loglite-perl) Nagzillad Installation ./nagzilla-2.0/patches/06_adjust-config-files0000644000000000000000000000256411213102011017510 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Adjust config files to have some more sensible defaults Index: nagzilla-1.5.5-1/nagzillac.cfg =================================================================== --- nagzilla-1.5.5-1.orig/nagzillac.cfg +++ nagzilla-1.5.5-1/nagzillac.cfg @@ -1,7 +1,7 @@ #nagzillac configuration file #Nagzilla server to connect to -NagzillaServer = +NagzillaServer = 127.0.0.1 #Nagzilla Server port to use NagzillaPort = 49776 Index: nagzilla-1.5.5-1/nagzillad.cfg =================================================================== --- nagzilla-1.5.5-1.orig/nagzillad.cfg +++ nagzilla-1.5.5-1/nagzillad.cfg @@ -3,22 +3,22 @@ #Nagzillad Server Settings #IP to bind to -BindAddr = +BindAddr = 127.0.0.1 #Port to bind to BindPort = 49776 #Username to run as -BindUser = nobody +BindUser = nagzilla #Run as daemon, use 1 - to run in foreground use 0 Daemon = 1 #To log server starts and stop and messages sent use 1 To_Log = 1 #Where would you like to log to today? -Log_Directory = /var/log +Log_Directory = /var/log/nagzilla #Default error log level Error_Log_Level = 6 -#Nagzillad Access Control -AllowedIPAddr = {comma separated list of IP addresses allowed to connect} +#Nagzillad Access Control {comma separated list of IP addresses allowed to connect} +AllowedIPAddr = 127.0.0.1 #Jabber Server Settings ./nagzilla-2.0/patches/01_chat-message-fix0000644000000000000000000000165311213102011016771 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Allows handing over complete JIDs for room and chat types Index: nagzilla-1.5.4-2/nagzilla/nagzillad.pl =================================================================== --- nagzilla-1.5.4-2.orig/nagzilla/nagzillad.pl +++ nagzilla-1.5.4-2/nagzilla/nagzillad.pl @@ -116,12 +116,12 @@ $mess = "@clientin[2]"; my $message = Net::Jabber::Message->new(); if ($style eq "room") { $message->SetMessage( "type" => 'groupchat', - "to" => "$roomy\@$confserver", + "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", "type" => 'chat', "body" => "$mess" ); } else { - $message->SetMessage ( "to" => "$roomy\@$jabberserver", + $message->SetMessage ( "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$jabberserver", "subject" => "Monitoring Alert", "type" => 'chat', "body" => "$mess" ); ./nagzilla-2.0/patches/04_fix-ARGV00000644000000000000000000000115111213102011015243 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Fix ARGV[0] to not contain the interpreter Index: nagzilla-1.5.5-1/nagzillad.pl =================================================================== --- nagzilla-1.5.5-1.orig/nagzillad.pl +++ nagzilla-1.5.5-1/nagzillad.pl @@ -21,6 +21,8 @@ $CONFDIR = "/etc/nagzillad"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! +$0.=''; # so that the init script is able to detect the process + ##############Config File Setup##################### Config::Simple->import_from('nagzillad.cfg', \%Config); $cfg = new Config::Simple("$CONFDIR/nagzillad.cfg"); ./nagzilla-2.0/patches/02_allow-carret-in-message0000644000000000000000000000105611213102011020264 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Allow ^ being part of the message instead of message cut point Index: nagzilla-1.5.4-2/nagzilla/nagzillad.pl =================================================================== --- nagzilla-1.5.4-2.orig/nagzilla/nagzillad.pl +++ nagzilla-1.5.4-2/nagzilla/nagzillad.pl @@ -108,7 +108,7 @@ while ($addr = $local->accept() ) { while (<$addr>) { -@clientin = split(/\^/, $_); +@clientin = split(/\^/, $_, 3); $style = "@clientin[0]"; $roomy = "@clientin[1]"; $mess = "@clientin[2]"; ./nagzilla-2.0/patches/.svn/0000755000000000000000000000000011232756112014322 5ustar rootroot./nagzilla-2.0/patches/.svn/format0000444000000000000000000000000211213102011015501 0ustar rootroot9 ./nagzilla-2.0/patches/.svn/prop-base/0000755000000000000000000000000011213102011016170 5ustar rootroot./nagzilla-2.0/patches/.svn/props/0000755000000000000000000000000011213102011015443 5ustar rootroot./nagzilla-2.0/patches/.svn/entries0000444000000000000000000000224311232756053015721 0ustar rootroot9 dir 20 https://nagzilla.googlecode.com/svn/branches/nagzilla-2.0/patches https://nagzilla.googlecode.com/svn 2009-06-08T03:13:13.756158Z 12 billford svn:special svn:externals svn:needs-lock 8473c688-9fee-11dd-a5cd-697bfd0a0cef 06_adjust-config-files file 2009-06-08T03:22:49.000000Z 62baaa1301b198a636ffd54e5dffcf60 2009-06-08T03:13:13.756158Z 12 billford 1396 02_allow-carret-in-message file 2009-06-08T03:22:49.000000Z 2aaeef7e1378802e270f2c45a890f36d 2009-05-27T02:54:24.631590Z 2 billford 558 steve.patch file 2009-06-08T03:22:49.000000Z f2e76371ad93f6dcb1e41ff5824f2c15 2009-05-28T02:45:40.797661Z 7 billford 10509 01_chat-message-fix file 2009-06-08T03:22:49.000000Z c08c123e9e8e2aef7c809126e7bcf8cd 2009-05-27T02:54:24.631590Z 2 billford 939 05_fix-logrotate-file file 2009-06-08T03:22:49.000000Z d4b1fe0c0c749dd8a3965a337cf0ad06 2009-06-08T03:13:13.756158Z 12 billford 652 04_fix-ARGV0 file 2009-06-08T03:22:49.000000Z ccfd856d083f386f88a5340dc8a2477d 2009-06-08T03:13:13.756158Z 12 billford 617 ./nagzilla-2.0/patches/.svn/all-wcprops0000444000000000000000000000151311213102011016464 0ustar rootrootK 25 svn:wc:ra_dav:version-url V 46 /svn/!svn/ver/14/branches/nagzilla-2.0/patches END 06_adjust-config-files K 25 svn:wc:ra_dav:version-url V 69 /svn/!svn/ver/14/branches/nagzilla-2.0/patches/06_adjust-config-files END 02_allow-carret-in-message K 25 svn:wc:ra_dav:version-url V 73 /svn/!svn/ver/14/branches/nagzilla-2.0/patches/02_allow-carret-in-message END steve.patch K 25 svn:wc:ra_dav:version-url V 58 /svn/!svn/ver/14/branches/nagzilla-2.0/patches/steve.patch END 01_chat-message-fix K 25 svn:wc:ra_dav:version-url V 66 /svn/!svn/ver/14/branches/nagzilla-2.0/patches/01_chat-message-fix END 05_fix-logrotate-file K 25 svn:wc:ra_dav:version-url V 68 /svn/!svn/ver/14/branches/nagzilla-2.0/patches/05_fix-logrotate-file END 04_fix-ARGV0 K 25 svn:wc:ra_dav:version-url V 59 /svn/!svn/ver/14/branches/nagzilla-2.0/patches/04_fix-ARGV0 END ./nagzilla-2.0/patches/.svn/text-base/0000755000000000000000000000000011213102011016174 5ustar rootroot./nagzilla-2.0/patches/.svn/text-base/04_fix-ARGV0.svn-base0000444000000000000000000000115111213102011021536 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Fix ARGV[0] to not contain the interpreter Index: nagzilla-1.5.5-1/nagzillad.pl =================================================================== --- nagzilla-1.5.5-1.orig/nagzillad.pl +++ nagzilla-1.5.5-1/nagzillad.pl @@ -21,6 +21,8 @@ $CONFDIR = "/etc/nagzillad"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! +$0.=''; # so that the init script is able to detect the process + ##############Config File Setup##################### Config::Simple->import_from('nagzillad.cfg', \%Config); $cfg = new Config::Simple("$CONFDIR/nagzillad.cfg"); ./nagzilla-2.0/patches/.svn/text-base/05_fix-logrotate-file.svn-base0000444000000000000000000000121411213102011023635 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Create logrotate files with nagzilla user writeable Index: nagzilla-1.5.5-1/nagzillad =================================================================== --- nagzilla-1.5.5-1.orig/nagzillad +++ nagzilla-1.5.5-1/nagzillad @@ -1,11 +1,11 @@ -/var/log/nagzillad.log { +/var/log/nagzilla/nagzillad.log { daily missingok rotate 356 compress delaycompress notifempty - create 640 root adm + create 640 nagzilla adm sharedscripts postrotate /etc/init.d/nagzillad restart > /dev/null ./nagzilla-2.0/patches/.svn/text-base/02_allow-carret-in-message.svn-base0000444000000000000000000000105611213102011024557 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Allow ^ being part of the message instead of message cut point Index: nagzilla-1.5.4-2/nagzilla/nagzillad.pl =================================================================== --- nagzilla-1.5.4-2.orig/nagzilla/nagzillad.pl +++ nagzilla-1.5.4-2/nagzilla/nagzillad.pl @@ -108,7 +108,7 @@ while ($addr = $local->accept() ) { while (<$addr>) { -@clientin = split(/\^/, $_); +@clientin = split(/\^/, $_, 3); $style = "@clientin[0]"; $roomy = "@clientin[1]"; $mess = "@clientin[2]"; ./nagzilla-2.0/patches/.svn/text-base/06_adjust-config-files.svn-base0000444000000000000000000000256411213102011024003 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Adjust config files to have some more sensible defaults Index: nagzilla-1.5.5-1/nagzillac.cfg =================================================================== --- nagzilla-1.5.5-1.orig/nagzillac.cfg +++ nagzilla-1.5.5-1/nagzillac.cfg @@ -1,7 +1,7 @@ #nagzillac configuration file #Nagzilla server to connect to -NagzillaServer = +NagzillaServer = 127.0.0.1 #Nagzilla Server port to use NagzillaPort = 49776 Index: nagzilla-1.5.5-1/nagzillad.cfg =================================================================== --- nagzilla-1.5.5-1.orig/nagzillad.cfg +++ nagzilla-1.5.5-1/nagzillad.cfg @@ -3,22 +3,22 @@ #Nagzillad Server Settings #IP to bind to -BindAddr = +BindAddr = 127.0.0.1 #Port to bind to BindPort = 49776 #Username to run as -BindUser = nobody +BindUser = nagzilla #Run as daemon, use 1 - to run in foreground use 0 Daemon = 1 #To log server starts and stop and messages sent use 1 To_Log = 1 #Where would you like to log to today? -Log_Directory = /var/log +Log_Directory = /var/log/nagzilla #Default error log level Error_Log_Level = 6 -#Nagzillad Access Control -AllowedIPAddr = {comma separated list of IP addresses allowed to connect} +#Nagzillad Access Control {comma separated list of IP addresses allowed to connect} +AllowedIPAddr = 127.0.0.1 #Jabber Server Settings ./nagzilla-2.0/patches/.svn/text-base/01_chat-message-fix.svn-base0000444000000000000000000000165311213102011023264 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Allows handing over complete JIDs for room and chat types Index: nagzilla-1.5.4-2/nagzilla/nagzillad.pl =================================================================== --- nagzilla-1.5.4-2.orig/nagzilla/nagzillad.pl +++ nagzilla-1.5.4-2/nagzilla/nagzillad.pl @@ -116,12 +116,12 @@ $mess = "@clientin[2]"; my $message = Net::Jabber::Message->new(); if ($style eq "room") { $message->SetMessage( "type" => 'groupchat', - "to" => "$roomy\@$confserver", + "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", "type" => 'chat', "body" => "$mess" ); } else { - $message->SetMessage ( "to" => "$roomy\@$jabberserver", + $message->SetMessage ( "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$jabberserver", "subject" => "Monitoring Alert", "type" => 'chat', "body" => "$mess" ); ./nagzilla-2.0/patches/.svn/text-base/steve.patch.svn-base0000444000000000000000000002441511213102011022064 0ustar rootrootdiff -ruN ../nagzilla-1.5.5-pre/nagzillad.pl ./nagzillad.pl --- ../nagzilla-1.5.5-pre/nagzillad.pl 2009-05-27 19:56:52.000000000 +0000 +++ ./nagzillad.pl 2009-05-27 22:22:48.000000000 +0000 @@ -5,7 +5,6 @@ #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Bot Server - #import our required Perl modules require Config::Simple; require Data::Dumper; @@ -13,154 +12,199 @@ use IO::Socket; use IO::Socket::INET; use IO::Select; -use Net::Jabber qw(Client) ; -use Net::Jabber qw(Message) ; -use Net::Jabber qw(Protocol) ; -use Net::Jabber qw(Presence) ; +use Net::Jabber qw(Client); +use Net::Jabber qw(Message); +use Net::Jabber qw(Protocol); +use Net::Jabber qw(Presence); -#bring in our configuration variables $CONFDIR = "/etc/nagzillad"; + # DO NOT EDIT ANYTHING BEYOND THIS POINT!! do "$CONFDIR/nagzillad-config.pl"; -my $log = new Log::LogLite($LOG_DIRECTORY."/nagzillad.log", $ERROR_LOG_LEVEL); +my $log = new Log::LogLite( $LOG_DIRECTORY . "/nagzillad.log", $ERROR_LOG_LEVEL ); + +# make_access_checker - returns a function which checks if an IP address +# should be allowed to connect to this nagzillad. +# +# It takes a reference to an an array of IP addresses (dotted quad strings). +# +# It returns a function which takes an IP address (also a dotted quad +# string). That function will return 1 if the IP address is allowed and +# undef if it isn't. +# +sub make_access_checker { + my $ok_addrs = shift; + my %ok_addr_set = map { $_ => 1 } @{$ok_addrs}; + return sub { + my $addr = shift; + return $ok_addr_set{$addr}; + } +} + +my $check_access = make_access_checker(\@allowedipaddr); -#taken from a Perl tutorial somewhere a million years ago so direct reference escapes me. +#taken from a Perl tutorial somewhere a million years ago so direct reference escapes me. sub daemonize { - chdir '/' or die "Can't chdir to /: $!"; - open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; - open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; - open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; - defined(my $pid = fork) or die "Can't fork: $!"; - #setsid - from McMaster's salvia; - if ($pid != 0) - { - open (PIDFILE, '>/var/run/nagzillad.pid'); - print PIDFILE "$pid\n"; - close (PIDFILE); - chown $uid, 0, "/var/run/nagzillad.pid"; - chmod oct("0644"), "/var/run/nagzillad.pid"; + chdir '/' or die "Can't chdir to /: $!"; + open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; + open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; + open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; + defined( my $pid = fork ) or die "Can't fork: $!"; + + #setsid - from McMaster's salvia; + if( $pid != 0 ) { + open( PIDFILE, '>/var/run/nagzillad.pid' ); + print PIDFILE "$pid\n"; + close(PIDFILE); + chown $uid, 0, "/var/run/nagzillad.pid"; + chmod oct("0644"), "/var/run/nagzillad.pid"; + # Change user ID - automagically - my $uid = (getpwnam('nobody'))[2]; + my $uid = ( getpwnam('nobody') )[2]; $> = $uid; - exit(0); - } - setsid or die "Can't start a new session: $!"; - umask 0; + exit(0); + } + setsid or die "Can't start a new session: $!"; + umask 0; } -if ($daemon eq 1) -{ -&daemonize; -# Change user ID - automagically -my $uid = (getpwnam('nobody'))[2]; -$> = $uid; -} +if ($daemon eq 1) { + &daemonize; + # Change user ID - automagically + my $uid = ( getpwnam('nobody') )[2]; + $> = $uid; +} #Let's make us a socket -$local = IO::Socket::INET->new( Proto => 'tcp', - LocalAddr => $bindaddr, - LocalPort => $bindport, - Reuse => 1 - ) or die "$!"; -$local->listen(); #Tell our socket to listen -$local->autoflush(1); #This is on by default with newer versions of IO::Socket but for bc let's turn it on anyway - -if ($to_log eq 1) { - -$log->write("Nagzillad Server Started", 5); +$local = IO::Socket::INET->new( + Proto => 'tcp', + LocalAddr => $bindaddr, + LocalPort => $bindport, + Reuse => 1 +) or die "$!"; +$local->listen(); #Tell our socket to listen +#This is on by default with newer versions of IO::Socket but for bc let's turn it on anyway +$local->autoflush(1); +if ($to_log eq 1) { + $log->write( "Nagzillad Server Started", 5 ); } - #Start Jabber Stuff - my $connection = Net::Jabber::Client -> new( debugLevel => $jabberdebug ); #Creates a new connection to the jabber server - $connection -> Connect( "hostname" => $jabberserver, "port" => $jabberport, "tls" => $jabbertls, "ssl" => $jabberssl ) or die "Cannot connect ($!)\n"; #Return an error on failure +# Creates a new connection to the jabber server +my $connection = Net::Jabber::Client->new( debugLevel => $jabberdebug ); +$connection->Connect( + "hostname" => $jabberserver, + "port" => $jabberport, + "tls" => $jabbertls, + "ssl" => $jabberssl +) or die "Cannot connect ($!)\n"; #Return an error on failure + +my @result; +if ($jabbersasl) { + @result = $connection->AuthSend( + "username" => $jabberuser, + "password" => $jabberpass, + "resource" => $jabberresource + ); + +} else { + @result = $connection->AuthIQAuth( + "username" => $jabberuser, + "password" => $jabberpass, + "resource" => $jabberresource + ); +} + +if ($result[0] ne "ok") { + #Send an auth request, return on failure + die "Ident/Auth with server failed: $result[0] - $result[1]\n"; +} - my @result; - if ( $jabbersasl ) { - @result = $connection->AuthSend( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); - - } - else { - @result = $connection->AuthIQAuth( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); - - } - - if ($result[0] ne "ok") { - die "Ident/Auth with server failed: $result[0] - $result[1]\n"; #Send an auth request, return on failure - } #Allow the daemon to hang out in as many rooms as needed (defined in config file) #Depending on your Jabber server setup specifying a non-existent room will create that room foreach $confs (@confrooms) { - - my $room = $connection->MUCJoin(room=>"$confs", - server=>"$confserver", #Conference server - nick=>"$confnick"); #Join a room + my $room = $connection->MUCJoin( + room => "$confs", + server => "$confserver", #Conference server + nick => "$confnick" + ); #Join a room } $readable_handles = new IO::Select(); $readable_handles->add($local); while (1) { - ($new_readable) = IO::Select->select($readable_handles, undef, undef, undef); + ($new_readable) = IO::Select->select( $readable_handles, undef, undef, undef ); + + foreach $sock (@$new_readable) { + if ($sock == $local) { + $new_sock = $sock->accept(); + my $client_name = $new_sock->peeraddr; + $ip = inet_ntoa($client_name); + + next if not defined $new_sock; + + # check if the new peer's IP address is permitted via + # the AllowedIPAddr conf statement. + if ($check_access->($ip)) { + $log->write("accepted connection from $ip",1); + $readable_handles->add($new_sock); + } else { + $log->write("rejected connection from $ip - not in AllowedIPAddr",5); + close $new_sock; + } + } else { + $buf = <$sock>; + + $readable_handles->remove($sock); + close $sock; + + if ($buf) { + + my ( $style, $roomy, $mess ) = split( /\^/, $buf, 3 ); + + my $message = Net::Jabber::Message->new(); + if ($style eq "room") { + $message->SetMessage( + "type" => 'groupchat', + "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", + "type" => 'chat', + "body" => $mess + ); + + } + else { + $message->SetMessage( + "to" => $roomy =~ /@/ ? $roomy: "$roomy\@$jabberserver", + "subject" => "Monitoring Alert", + "type" => 'chat', + "body" => "$mess" + ); + + } + + #Send message from STDIN -- probably should add some error handling + #There is some bug in at least ejabberd that causes messages to + #be sent "offline". They get flushed on nagzilla restart + #I don't know of a good way to check if this is happening yet + #More to come - BM + $connection->Send($message); + + if ($to_log eq 1) { + $log->write( "--$mess-- sent to $roomy from $ip", 5 ); -foreach $sock (@$new_readable) { - if ($sock == $local){ - $new_sock = $sock->accept(); - my $client_name = $new_sock->peeraddr; - $ip = inet_ntoa($client_name); - #print "$ip \n"; - next if not defined $new_sock; - $readable_handles->add($new_sock); - }else{ - if (grep {$_ eq $ip} @allowedipaddr) { - - $buf = <$sock>; - - $readable_handles->remove($sock); - close $sock; - - if ($buf) { - -my ($style, $roomy, $mess) = split(/\^/, $buf, 3); - - my $message = Net::Jabber::Message->new(); - if ($style eq "room") { - $message->SetMessage( "type" => 'groupchat', - "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", - "type" => 'chat', - "body" => $mess ); - - } else { - $message->SetMessage ( "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$jabberserver", - "subject" => "Monitoring Alert", - "type" => 'chat', - "body" => "$mess" ); - - } - $connection->Send($message); #Send message from STDIN -- probably should add some error handling - #There is some bug in at least ejabberd that causes messages to - #be sent "offline". They get flushed on nagzilla restart - #I don't know of a good way to check if this is happening yet - #More to come - BM - - if ($to_log eq 1) { - $log->write("--$mess-- sent to $roomy from $ip", 5); - + } + } } - -} - - } -} -} - sleep (MAXWAIT); #Creates a sleep timer so many messages can be handled without issue - } - \ No newline at end of file + #Creates a sleep timer so many messages can be handled without issue + sleep(MAXWAIT); +} + diff -ruN ../nagzilla-1.5.5-pre/README ./README --- ../nagzilla-1.5.5-pre/README 2009-05-27 20:02:59.000000000 +0000 +++ ./README 2009-05-27 21:18:06.000000000 +0000 @@ -23,10 +23,10 @@ IO::Socket IO::Socket::INET - Net::Jabber - Config::Simple + Net::Jabber (Ubuntu package: libnet-jabber-perl) + Config::Simple (Ubuntu package: libconfig-simple-perl) Data::Dumper - Log::LogLite + Log::LogLite (Ubuntu package: liblog-loglite-perl) Nagzillad Installation ./nagzilla-2.0/patches/.svn/tmp/0000755000000000000000000000000011232756053015126 5ustar rootroot./nagzilla-2.0/patches/.svn/tmp/prop-base/0000755000000000000000000000000011213102011016770 5ustar rootroot./nagzilla-2.0/patches/.svn/tmp/props/0000755000000000000000000000000011213102011016243 5ustar rootroot./nagzilla-2.0/patches/.svn/tmp/text-base/0000755000000000000000000000000011213102011016774 5ustar rootroot./nagzilla-2.0/patches/05_fix-logrotate-file0000644000000000000000000000121411213102011017342 0ustar rootrootAuthor: Gerfried Fuchs vim:ft=diff: Description: Create logrotate files with nagzilla user writeable Index: nagzilla-1.5.5-1/nagzillad =================================================================== --- nagzilla-1.5.5-1.orig/nagzillad +++ nagzilla-1.5.5-1/nagzillad @@ -1,11 +1,11 @@ -/var/log/nagzillad.log { +/var/log/nagzilla/nagzillad.log { daily missingok rotate 356 compress delaycompress notifempty - create 640 root adm + create 640 nagzilla adm sharedscripts postrotate /etc/init.d/nagzillad restart > /dev/null ./nagzilla-2.0/README0000755000000000000000000000722711232756046012710 0ustar rootroot10/20/2008 -- Nagzilla client/server 01/10/2009 -- Updated 05/26/2009 -- Updated 05/27/2009 -- Updated 07/06/2009 -- Updated 07/26/2009 -- Updated DISCLAIMER: This is provided AS-IS with no warranty expressed or implied. I nor the company are responsible for anything you do with it so don't expect us to be. LICENSE: GPL v2. See LICENSE File Overview: Nagzilla was designed to be a Jabber relay "bot" in that it sits quietly in a room until it gets a message to relay to either a chatroom or a person. The early work was based on several simple examples out on the internets but didn't quite meet our needs. Namely they would just keep logging into a room every time they had something to say. That forced us to make it a daemon. This also allows us to now get nagzilla alerts from various systems and event creators. Nagzillac (the client program") accepts any string input and makes into a Jabber message. This should work with Google Talk (as it's Jabber based) but that's not been tested. The only platform this has been tested on is ejabberd running on Ubuntu. I have no doubts it SHOULD work on other Jabber/Linux/Perl platforms as well. Nagzilla provides some rudimentary security. You have to have your IP address defined in nagzillad.cfg to send messages but on a local LAN spoofing is trivial. You should still use your firewall wisely in this case and allow access only from those clients who should have it. Installation: Nagzilla consists of two components nagzillad (the server) and nagzillac (the client). They do not have to live on the same machine at all but require the same perl modules be installed. Required Perl Modules: IO::Socket IO::Socket::INET Net::Jabber (Ubuntu package: libnet-jabber-perl) Config::Simple (Ubuntu package: libconfig-simple-perl) Data::Dumper (Ubuntu Package: libdata-dumper-simple-perl) Log::LogLite (Ubuntu package: liblog-loglite-perl) Getopt::Long Pod::Usage Nagzillad Installation mkdir /etc/nagzillad/ cp nazillad.cfg and nagzillad-config.pl to /etc/nagzillad cp nagzillad.pl to /usr/local/sbin (or wherever on your system you want it to live) Edit nagzillad.cfg to suit your needs (file should be self-explanatory) start nagzillad.pl with & or add an init script (next version?) Nagzillac Installation mkdir /etc/nagzillac cp nagzillac.cfg and nagzillac-config.pl to /etc/nagzillac cp nagzillac.pl to /usr/local/bin (or wherever on your system you want it to live) Edit nagzillac.cfg to suit your needs Make the magic happen: nagzillac.pl "TYPE^TO^MESSAGE^COLOROFMESSAGE" TYPE: This can be either 'groupchat' or 'chat' -- groupchat == a chatroom and chat == an individual TO: What room or person to send to (can be full JID or just a nick with defined jabberserver sent) MESSAGE: Your message (which should avoid having ^ in it) COLOROFMESSAGE: Useful for nagios messages, current colors are red, yellow and green -- completely optional EXAMPLE: nagzillac.pl "groupchat^chatroom^Hi guys a server is down in some far away place^red" Usage: Nagzillac connects to and sends messages to nagzillad which relays them to Jabber Arguments: -t Type: either groupchat or chat REQUIRED -r Room: Either chatroom name or JID of an individual REQUIRED -m Message: The messages you would like to send enclosed in quotes REQUIRED -c Color: The color of your message (currently only red, yellow and green work) OPTIONAL -h Prints this message EXAMPLE: nagzillac2.pl -t groupchat -r chatroom -m "hello server is down" -c red That's it. Not a bad little hack if you have to monitor stuff and sit in IM all day (or a chat room). ./nagzilla-2.0/nagzillac.cfg0000755000000000000000000000021511213102011014413 0ustar rootroot#nagzillac configuration file #Nagzilla server to connect to NagzillaServer = 127.0.0.1 #Nagzilla Server port to use NagzillaPort = 49776 ./nagzilla-2.0/nagzillac.pl0000755000000000000000000000166211213102011014276 0ustar rootroot#!/usr/bin/perl #(c)2007-2009 Hurricane Labs #Author: Billford #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Client require Config::Simple; require Data::Dumper; use IO::Socket; use IO::Socket::INET; #bring in our configuration variables $CONFDIR = "/etc/nagzillac"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! ##################Begin Config Setup######################## Config::Simple->import_from('nagzillac.cfg', \%Config); $cfg = new Config::Simple("$CONFDIR/nagzillac.cfg"); #Nagzillac Nagzilla Server Settings $nagzillaserver = $cfg->param("NagzillaServer"); $nagzillaport = $cfg->param("NagzillaPort"); ##################End Config Setup########################## #Let's make us a socket connection $remote = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => "$nagzillaserver", PeerPort => "$nagzillaport", Reuse => 1 ) or die "$!"; $remote->autoflush(1); print $remote $ARGV[0]; close $remote; ./nagzilla-2.0/TODO0000755000000000000000000000342611232756053012513 0ustar rootrootnagzillad should require some sort of authentication with its clients (perhaps ssl certs or shared secrets, oh my) - started 5/27/09 -- currently only IP of client is checked nagzillad should accept rawxml messages (patch provided from rhonda@debian.at but needs improvement) -- This is somewhat ready, still improving nagzillad should offer browser support (still have some thinking to do about this) -- web client is nearly done nagzillad should support SSL to it's client (nagzillac) Added some stress testing bash scripts, nothing fancy will improve later -- initially completed 5/26/2009 nagzillad should handle multiple connections -- completed and tested with 15000 multiple connections -- 05/26/2009 nagzillad needs to read from a config file -- completed -- 09/28/08 nagzillad should be able to sit in multiple rooms without issue -- proof of concept proven - completed --10/1/08 nagzillad should NOT run as root - add a check at startup for this -- completed -- 01/09/09 nagzillad /nagzillac communications should be encrypted -- Not sure this will happen in this release nagzillad should be able to write messages to a log file / maybe a web view? -- logs for messages completed -- 01/09/09 nagzilla should be renamed to nagzillac - completed - 09/28/08 nagzillac should take several command line arguments - completed - 10/20/08 a) server to connect to b) port to connect to c) room/person to send message to d) message (must escape control characters) nagzillac will stay command line based as to allow for easier "scriptability" with zenoss and nagios alerts This should allow for messaging of whoever for whatever purpose General error checking should be improved -- connectivity, presence and room tests -- started 06/20/2009 Code needs to be tidied up -- perltidy FTW -- thanks steve! ./nagzilla-2.0/nagzillad0000755000000000000000000000045211213102011013661 0ustar rootroot/var/log/nagzilla/nagzillad.log { daily missingok rotate 356 compress delaycompress notifempty create 640 nagzilla adm sharedscripts postrotate /etc/init.d/nagzillad restart > /dev/null endscript } ./nagzilla-2.0/utilities/0000755000000000000000000000000011213102011014000 5ustar rootroot./nagzilla-2.0/utilities/stresstest2.sh0000755000000000000000000000016511213102011016646 0ustar rootroot#!/bin/bash i="0" while [ $i -lt 1000 ] do /usr/local/bin/nagzillac.pl "room^test^stresstesting2" i=$[$i+1] done ./nagzilla-2.0/utilities/stresstest.sh0000755000000000000000000000016411213102011016563 0ustar rootroot#!/bin/bash i="0" while [ $i -lt 1000 ] do /usr/local/bin/nagzillac.pl "room^test^stresstesting" i=$[$i+1] done ./nagzilla-2.0/utilities/.svn/0000755000000000000000000000000011232756112014706 5ustar rootroot./nagzilla-2.0/utilities/.svn/format0000444000000000000000000000000211213102011016065 0ustar rootroot9 ./nagzilla-2.0/utilities/.svn/prop-base/0000755000000000000000000000000011213102011016554 5ustar rootroot./nagzilla-2.0/utilities/.svn/prop-base/stresstest.sh.svn-base0000444000000000000000000000003511213102011023044 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/utilities/.svn/prop-base/stresstest2.sh.svn-base0000444000000000000000000000003511213102011023126 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/utilities/.svn/props/0000755000000000000000000000000011213102011016027 5ustar rootroot./nagzilla-2.0/utilities/.svn/entries0000444000000000000000000000107011232756053016302 0ustar rootroot9 dir 20 https://nagzilla.googlecode.com/svn/branches/nagzilla-2.0/utilities https://nagzilla.googlecode.com/svn 2009-05-27T02:54:24.631590Z 2 billford svn:special svn:externals svn:needs-lock 8473c688-9fee-11dd-a5cd-697bfd0a0cef stresstest.sh file 2009-06-08T03:22:49.000000Z 2067bbcbf518d794fd51fb1bfd44b634 2009-05-27T02:54:24.631590Z 2 billford has-props 116 stresstest2.sh file 2009-06-08T03:22:49.000000Z 812fbc871501b2cec5b7d7db01b960f2 2009-05-27T02:54:24.631590Z 2 billford has-props 117 ./nagzilla-2.0/utilities/.svn/all-wcprops0000444000000000000000000000050511213102011017050 0ustar rootrootK 25 svn:wc:ra_dav:version-url V 48 /svn/!svn/ver/14/branches/nagzilla-2.0/utilities END stresstest.sh K 25 svn:wc:ra_dav:version-url V 62 /svn/!svn/ver/14/branches/nagzilla-2.0/utilities/stresstest.sh END stresstest2.sh K 25 svn:wc:ra_dav:version-url V 63 /svn/!svn/ver/14/branches/nagzilla-2.0/utilities/stresstest2.sh END ./nagzilla-2.0/utilities/.svn/text-base/0000755000000000000000000000000011213102011016560 5ustar rootroot./nagzilla-2.0/utilities/.svn/text-base/stresstest.sh.svn-base0000444000000000000000000000016411213102011023053 0ustar rootroot#!/bin/bash i="0" while [ $i -lt 1000 ] do /usr/local/bin/nagzillac.pl "room^test^stresstesting" i=$[$i+1] done ./nagzilla-2.0/utilities/.svn/text-base/stresstest2.sh.svn-base0000444000000000000000000000016511213102011023136 0ustar rootroot#!/bin/bash i="0" while [ $i -lt 1000 ] do /usr/local/bin/nagzillac.pl "room^test^stresstesting2" i=$[$i+1] done ./nagzilla-2.0/utilities/.svn/tmp/0000755000000000000000000000000011232756053015512 5ustar rootroot./nagzilla-2.0/utilities/.svn/tmp/prop-base/0000755000000000000000000000000011213102011017354 5ustar rootroot./nagzilla-2.0/utilities/.svn/tmp/props/0000755000000000000000000000000011213102011016627 5ustar rootroot./nagzilla-2.0/utilities/.svn/tmp/text-base/0000755000000000000000000000000011213102011017360 5ustar rootroot./nagzilla-2.0/.svn/0000755000000000000000000000000011232756112012673 5ustar rootroot./nagzilla-2.0/.svn/format0000444000000000000000000000000211213102007014057 0ustar rootroot9 ./nagzilla-2.0/.svn/prop-base/0000755000000000000000000000000011232754735014574 5ustar rootroot./nagzilla-2.0/.svn/prop-base/LICENSE.svn-base0000444000000000000000000000003511213102010017256 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/nagzillad.cfg.svn-base0000444000000000000000000000003511213102010020677 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/CHANGELOG.svn-base0000444000000000000000000000003511213102011017464 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/nagzillad.pl.svn-base0000444000000000000000000000003511213102010020553 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/nagzillac.pl.svn-base0000444000000000000000000000003511213102011020553 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/nagzillac.cfg.svn-base0000444000000000000000000000003511213102010020676 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/TODO.svn-base0000444000000000000000000000003511213102010016741 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/nagzillac2.pl.svn-base0000444000000000000000000000003611232754675020674 0ustar rootrootK 14 svn:executable V 1 * END ./nagzilla-2.0/.svn/prop-base/README.svn-base0000444000000000000000000000003511213102011017132 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/nagzillad.svn-base0000444000000000000000000000003511213102011020142 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/prop-base/TODO-2.0.svn-base0000444000000000000000000000003611213112203017244 0ustar rootrootK 14 svn:executable V 1 * END ./nagzilla-2.0/.svn/prop-base/VERSION.svn-base0000444000000000000000000000003511213102010017321 0ustar rootrootK 14 svn:executable V 0 END ./nagzilla-2.0/.svn/props/0000755000000000000000000000000011232754735014047 5ustar rootroot./nagzilla-2.0/.svn/entries0000444000000000000000000000421011232756111014261 0ustar rootroot9 dir 20 https://nagzilla.googlecode.com/svn/branches/nagzilla-2.0 https://nagzilla.googlecode.com/svn 2009-07-26T04:23:10.126900Z 20 billford svn:special svn:externals svn:needs-lock 8473c688-9fee-11dd-a5cd-697bfd0a0cef nagzillad.pl file 2009-07-26T04:09:23.000000Z 0e60b1a64c2ab4b5c4ae0dec2dec4da0 2009-07-26T04:21:10.719669Z 18 billford has-props 8380 archive dir LICENSE file 2009-06-08T03:22:49.000000Z 9c3ec65d82e9998e31f7e515c48e2cde 2009-05-27T02:54:24.631590Z 2 billford has-props 14878 VERSION file 2009-07-26T04:22:51.000000Z 373050371ea2c629ada9565c54978f48 2009-07-26T04:23:10.126900Z 20 billford has-props 97 CHANGELOG file 21 2009-07-26T04:27:46.000000Z 74902e64d029dea567e7239a79085d1d 2009-07-26T04:32:09.386184Z 21 billford has-props 1570 patches dir README file 21 2009-07-26T04:31:34.000000Z ed35f0da25b24e793bd5dd7207e36816 2009-07-26T04:32:09.386184Z 21 billford has-props 3735 nagzillac2.pl file 2009-07-26T02:19:51.000000Z 28b0fa7e555600d50003268ec12929d5 2009-07-26T04:21:49.628017Z 19 billford has-props 2599 TODO-2.0 file 2009-07-26T04:15:32.000000Z c7fafcc81b3f88ef4eab9a594aeb66be 2009-07-26T04:21:10.719669Z 18 billford has-props 894 nagzillac.cfg file 2009-06-08T03:22:49.000000Z b5f9a901f038fbd9dd92e8dfc4624cbd 2009-06-08T03:13:13.756158Z 12 billford has-props 141 nagzillad.cfg file 2009-06-08T03:22:49.000000Z 072d0ef0faa47c4930e1f767ac342f07 2009-06-08T03:13:13.756158Z 12 billford has-props 1203 nagzillad file 2009-06-08T03:22:49.000000Z 313551b5b3435757179988917e66b325 2009-06-08T03:13:13.756158Z 12 billford has-props 298 TODO file 2009-07-26T04:31:39.000000Z 2abb386269f8d91a0e0fc1f6e550f7d3 2009-07-07T20:12:58.927863Z 17 billford has-props 1814 extras dir utilities dir nagzillac.pl file 2009-06-08T03:22:49.000000Z 106c6453973e16ec1b5f1cd06f24620d 2009-05-28T19:21:39.772154Z 11 billford has-props 946 ./nagzilla-2.0/.svn/all-wcprops0000444000000000000000000000237511232756111015065 0ustar rootrootK 25 svn:wc:ra_dav:version-url V 38 /svn/!svn/ver/20/branches/nagzilla-2.0 END nagzillad.pl K 25 svn:wc:ra_dav:version-url V 51 /svn/!svn/ver/18/branches/nagzilla-2.0/nagzillad.pl END nagzillac2.pl K 25 svn:wc:ra_dav:version-url V 52 /svn/!svn/ver/19/branches/nagzilla-2.0/nagzillac2.pl END LICENSE K 25 svn:wc:ra_dav:version-url V 46 /svn/!svn/ver/14/branches/nagzilla-2.0/LICENSE END nagzillac.cfg K 25 svn:wc:ra_dav:version-url V 52 /svn/!svn/ver/14/branches/nagzilla-2.0/nagzillac.cfg END TODO-2.0 K 25 svn:wc:ra_dav:version-url V 47 /svn/!svn/ver/18/branches/nagzilla-2.0/TODO-2.0 END nagzillad.cfg K 25 svn:wc:ra_dav:version-url V 52 /svn/!svn/ver/14/branches/nagzilla-2.0/nagzillad.cfg END VERSION K 25 svn:wc:ra_dav:version-url V 46 /svn/!svn/ver/20/branches/nagzilla-2.0/VERSION END TODO K 25 svn:wc:ra_dav:version-url V 43 /svn/!svn/ver/17/branches/nagzilla-2.0/TODO END nagzillad K 25 svn:wc:ra_dav:version-url V 48 /svn/!svn/ver/14/branches/nagzilla-2.0/nagzillad END CHANGELOG K 25 svn:wc:ra_dav:version-url V 48 /svn/!svn/ver/21/branches/nagzilla-2.0/CHANGELOG END README K 25 svn:wc:ra_dav:version-url V 45 /svn/!svn/ver/21/branches/nagzilla-2.0/README END nagzillac.pl K 25 svn:wc:ra_dav:version-url V 51 /svn/!svn/ver/14/branches/nagzilla-2.0/nagzillac.pl END ./nagzilla-2.0/.svn/text-base/0000755000000000000000000000000011232754735014600 5ustar rootroot./nagzilla-2.0/.svn/text-base/LICENSE.svn-base0000444000000000000000000003503611213102010017273 0ustar rootroot The GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ./nagzilla-2.0/.svn/text-base/nagzillad.cfg.svn-base0000444000000000000000000000226311213102010020710 0ustar rootroot####Configuration File for Nagzillad ### ###(c)2008 Hurricane Labs, LLC ######### #Nagzillad Server Settings #IP to bind to BindAddr = 127.0.0.1 #Port to bind to BindPort = 49776 #Username to run as BindUser = nagzilla #Run as daemon, use 1 - to run in foreground use 0 Daemon = 1 #To log server starts and stop and messages sent use 1 To_Log = 1 #Where would you like to log to today? Log_Directory = /var/log/nagzilla #Default error log level Error_Log_Level = 6 #Nagzillad Access Control {comma separated list of IP addresses allowed to connect} AllowedIPAddr = 127.0.0.1 #Jabber Server Settings #Jabber Server to connect to JabberServer = naggydev #Jabber Port JabberPort = 5222 #Debug Messages on or off JabberDebug = 0 #Jabber User JabberUser = #Jabber Password JabberPass = #Jabber Resource to use JabberResource = #Time to wait between sending message JabberMaxWait = 2 #To use TLS or not JabberTLS = 1 #To use SSL or not JabberSSL = 0 #To use SASL or not JabberSASL = 1 #Conference Server Settings #Jabber Conference Server ConfServer = conference.naggydev #comma separated list of conference room names ConfRooms = #Nick to use in the conference rooms ConfNick = nagzilla ./nagzilla-2.0/.svn/text-base/CHANGELOG.svn-base0000444000000000000000000000304211232756110017511 0ustar rootroot07/24/2009 -- Added command line options and some documenation/help for nagzillc2.pl 07/22/2009 -- Added presence ability to nagzillad 07/06/2009 -- Added the ability to send color coded messages 06/07/2009 -- Added patches from rhonda@debian for config files(bind to localhost), logrotate and arv issue 05/28/2009 -- Removed external loading of config file options 05/27/2009 -- Added some rudimentary IP address access control 05/26/2009 -- finished up multiple client support (Thanks for the troubleshooting Lebbeous and Steve!) -- added a utilities directory with a couple stress testing bash scripts (see TODO) 05/18/2009 -- Added patches from 01/10/2009 -- Removed specfics from and commented config file -- User to run as is now hard coded (nobody) -- will change later -- Added a sample log rotate script to archive 01/09/2009 -- Added user change -- Added liblog-loglite-perl module to help with logging -- Added very simple logging 12/13/2008 -- Replaced old guy code with some young guy code (array handling and such) -- Added the ability for Nagzilla to accept subscription requests for roster addition -- -- Above feature currently requires a restart -- hopefully next release will be cooler 10/24/2008 -- Applied Patch from hakamadare via Google Code -- fixed config file issues -- added require directive to a couple modules -- added SSL / TLS / SASL -- added debug option for connection to Jabber server -- applied by BM ./nagzilla-2.0/.svn/text-base/nagzillad.pl.svn-base0000444000000000000000000002027411232754664020623 0ustar rootroot#!/usr/bin/perl #(c)2007-2009 Hurricane Labs #Author: Billford #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Bot Server #import our required Perl modules require Config::Simple; require Data::Dumper; require Log::LogLite; use IO::Socket; use IO::Socket::INET; use IO::Select; use Net::Jabber qw(Client); use Net::Jabber qw(Message); use Net::Jabber qw(Protocol); use Net::Jabber qw(Presence); #Point me to your nagzillad.pl directory $CONFDIR = "/etc/nagzillad"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! $0.=''; # so that the init script is able to detect the process ##############Config File Setup##################### Config::Simple->import_from('nagzillad.cfg', \%Config); $cfg = new Config::Simple("$CONFDIR/nagzillad.cfg"); #Nagzillad Server Settings $bindaddr = $cfg->param("BindAddr"); $bindport = $cfg->param("BindPort"); $binduser = $cfg->param("BindUser"); $daemon = $cfg->param("Daemon"); $to_log = $cfg->param("To_Log"); $LOG_DIRECTORY = $cfg->param("Log_Directory"); $ERROR_LOG_LEVEL = $cfg->param("Error_Log_Level"); #Nagzillad Access Control @allowedipaddr = $cfg->param("AllowedIPAddr"); #Jabber Server Settings $jabberserver = $cfg->param("JabberServer"); $jabberport = $cfg->param("JabberPort"); $jabberdebug = $cfg->param("JabberDebug"); $jabbertls = $cfg->param("JabberTLS"); $jabberssl = $cfg->param("JabberSSL"); $jabbersasl = $cfg->param("JabberSASL"); $jabberuser = $cfg->param("JabberUser"); $jabberpass = $cfg->param("JabberPass"); $jabberresource = $cfg->param("JabberResource"); $jabbermaxwait = $cfg->param("JabberMaxWait"); #conference server settings $confserver = $cfg->param("ConfServer"); @confrooms = $cfg->param("ConfRooms"); $confnick = $cfg->param("ConfNick"); @roominess = @confrooms; ###########End Config Setup##################### my $log = new Log::LogLite( $LOG_DIRECTORY . "/nagzillad.log", $ERROR_LOG_LEVEL ); ###########Function Setups####################### # make_access_checker - returns a function which checks if an IP address # should be allowed to connect to this nagzillad. # # It takes a reference to an an array of IP addresses (dotted quad strings). # # It returns a function which takes an IP address (also a dotted quad # string). That function will return 1 if the IP address is allowed and # undef if it isn't. # sub make_access_checker { my $ok_addrs = shift; my %ok_addr_set = map { $_ => 1 } @{$ok_addrs}; return sub { my $addr = shift; return $ok_addr_set{$addr}; } } my $check_access = make_access_checker(\@allowedipaddr); sub send_plain_chat { our $message = Net::Jabber::Message->new(); $message->SetMessage( "type" => $style, "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", "body" => $mess ); }#end send_plain_chat sub send_color_chat { #make some pretty colors if ($col eq "red"){ $col = "\#ff0c00\;"; }elsif ($col eq "yellow"){ $col = "\#fff00\;"; }elsif ($col eq "green"){ $col = "\#00ff00\;"; }elsif ($col eq ""){ $col = "\#000000\;"; }; our $message = Net::Jabber::Message->new(); my $bod = "hello$mess"; $message->RemoveBody(); $bod =~ s/^\^SetMessage( "type" => $style, "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver" ); $message->InsertRawXML($bod); }#end send_color_chat sub PresenceReceived { my ($sid, $presence) = @_; my $from = $presence->GetFrom(); my $type = $presence->GetType(); return "" if ($type eq ''); $log->write( "Received presence notification of type '$type' from '$from'", 5 ); if ($type eq 'subscribe') { $connection->Subscription ( type => 'subscribed', to => $from ); } elsif ($type eq 'unsubscribe') { $connection->Subscription ( type => 'unsubscribed', to => $from ); } $connection->PresenceSend(); }#End PresenceReceived ##########End Function Setups################### #taken from a Perl tutorial somewhere a million years ago so direct reference escapes me. sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; defined( my $pid = fork ) or die "Can't fork: $!"; #setsid - from McMaster's salvia; if( $pid != 0 ) { open( PIDFILE, '>/var/run/nagzillad.pid' ); print PIDFILE "$pid\n"; close(PIDFILE); chown $uid, 0, "/var/run/nagzillad.pid"; chmod oct("0644"), "/var/run/nagzillad.pid"; # Change user ID - automagically my $uid = ( getpwnam('nobody') )[2]; $> = $uid; exit(0); } setsid or die "Can't start a new session: $!"; umask 0; } if ($daemon eq 1) { &daemonize; # Change user ID - automagically my $uid = ( getpwnam('nobody') )[2]; $> = $uid; } #Let's make us a socket $local = IO::Socket::INET->new( Proto => 'tcp', LocalAddr => $bindaddr, LocalPort => $bindport, Reuse => 1 ) or die "$!"; $local->listen(); #Tell our socket to listen #This is on by default with newer versions of IO::Socket but for bc let's turn it on anyway $local->autoflush(1); if ($to_log eq 1) { $log->write( "Nagzillad Server Started", 5 ); } #Start Jabber Stuff # Creates a new connection to the jabber server our $connection = Net::Jabber::Client->new( debugLevel => $jabberdebug ); $connection->Connect( "hostname" => $jabberserver, "port" => $jabberport, "tls" => $jabbertls, "ssl" => $jabberssl ) or die "Cannot connect ($!)\n"; #Return an error on failure my @result; if ($jabbersasl) { @result = $connection->AuthSend( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); } else { @result = $connection->AuthIQAuth( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); } $connection->PresenceSend(); if ($result[0] ne "ok") { #Send an auth request, return on failure die "Ident/Auth with server failed: $result[0] - $result[1]\n"; } #Allow the daemon to hang out in as many rooms as needed (defined in config file) #Depending on your Jabber server setup specifying a non-existent room will create that room foreach $confs (@confrooms) { my $room = $connection->MUCJoin( room => "$confs", server => "$confserver", #Conference server nick => "$confnick" ); #Join a room } $connection->SetCallBacks ( presence => \&PresenceReceived ); $readable_handles = new IO::Select(); $readable_handles->add($local); while (1) { ($new_readable) = IO::Select->select( $readable_handles, undef, undef, undef ); foreach $sock (@$new_readable) { if ($sock == $local) { $new_sock = $sock->accept(); my $client_name = $new_sock->peeraddr; $ip = inet_ntoa($client_name); next if not defined $new_sock; # check if the new peer's IP address is permitted via # the AllowedIPAddr conf statement. if ($check_access->($ip)) { $log->write("accepted connection from $ip",1); $readable_handles->add($new_sock); } else { $log->write("rejected connection from $ip - not in AllowedIPAddr",5); close $new_sock; } } else { $buf = <$sock>; $readable_handles->remove($sock); close $sock; if ($buf) { our ( $style, $roomy, $mess, $col ) = split( /\^/, $buf, 4 ); if ($style && $roomy && $mess) { send_color_chat( $style, $roomy, $mess, $col ); $connection->Process(); } } #Send message from STDIN -- probably should add some error handling #There is some bug in at least ejabberd that causes messages to #be sent "offline". They get flushed on nagzilla restart #I don't know of a good way to check if this is happening yet #More to come - BM $connection->Send($message); if ($to_log eq 1) { $log->write( "--$mess-- sent to $roomy from $ip", 5 ); } } } } #Creates a sleep timer so many messages can be handled without issue #sleep(MAXWAIT); ./nagzilla-2.0/.svn/text-base/nagzillac.pl.svn-base0000444000000000000000000000166211213102011020566 0ustar rootroot#!/usr/bin/perl #(c)2007-2009 Hurricane Labs #Author: Billford #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Client require Config::Simple; require Data::Dumper; use IO::Socket; use IO::Socket::INET; #bring in our configuration variables $CONFDIR = "/etc/nagzillac"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! ##################Begin Config Setup######################## Config::Simple->import_from('nagzillac.cfg', \%Config); $cfg = new Config::Simple("$CONFDIR/nagzillac.cfg"); #Nagzillac Nagzilla Server Settings $nagzillaserver = $cfg->param("NagzillaServer"); $nagzillaport = $cfg->param("NagzillaPort"); ##################End Config Setup########################## #Let's make us a socket connection $remote = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => "$nagzillaserver", PeerPort => "$nagzillaport", Reuse => 1 ) or die "$!"; $remote->autoflush(1); print $remote $ARGV[0]; close $remote; ./nagzilla-2.0/.svn/text-base/nagzillac.cfg.svn-base0000444000000000000000000000021511213102010020702 0ustar rootroot#nagzillac configuration file #Nagzilla server to connect to NagzillaServer = 127.0.0.1 #Nagzilla Server port to use NagzillaPort = 49776 ./nagzilla-2.0/.svn/text-base/TODO.svn-base0000444000000000000000000000342611224726112016775 0ustar rootrootnagzillad should require some sort of authentication with its clients (perhaps ssl certs or shared secrets, oh my) - started 5/27/09 -- currently only IP of client is checked nagzillad should accept rawxml messages (patch provided from rhonda@debian.at but needs improvement) -- This is somewhat ready, still improving nagzillad should offer browser support (still have some thinking to do about this) -- web client is nearly done nagzillad should support SSL to it's client (nagzillac) Added some stress testing bash scripts, nothing fancy will improve later -- initially completed 5/26/2009 nagzillad should handle multiple connections -- completed and tested with 15000 multiple connections -- 05/26/2009 nagzillad needs to read from a config file -- completed -- 09/28/08 nagzillad should be able to sit in multiple rooms without issue -- proof of concept proven - completed --10/1/08 nagzillad should NOT run as root - add a check at startup for this -- completed -- 01/09/09 nagzillad /nagzillac communications should be encrypted -- Not sure this will happen in this release nagzillad should be able to write messages to a log file / maybe a web view? -- logs for messages completed -- 01/09/09 nagzilla should be renamed to nagzillac - completed - 09/28/08 nagzillac should take several command line arguments - completed - 10/20/08 a) server to connect to b) port to connect to c) room/person to send message to d) message (must escape control characters) nagzillac will stay command line based as to allow for easier "scriptability" with zenoss and nagios alerts This should allow for messaging of whoever for whatever purpose General error checking should be improved -- connectivity, presence and room tests -- started 06/20/2009 Code needs to be tidied up -- perltidy FTW -- thanks steve! ./nagzilla-2.0/.svn/text-base/nagzillac2.pl.svn-base0000444000000000000000000000504711232754735020704 0ustar rootroot#!/usr/bin/perl -w #(c)2007-2009 Hurricane Labs #Author: Billford #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Client use strict; require Config::Simple; require Data::Dumper; use IO::Socket; use IO::Socket::INET; use Getopt::Long; use Pod::Usage; #bring in our configuration variables my $CONFDIR = "/etc/nagzillac"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! ##################Begin Config Setup######################## our %Config; Config::Simple->import_from('nagzillac.cfg', \%Config); my $cfg = new Config::Simple("$CONFDIR/nagzillac.cfg"); #Nagzillac Nagzilla Server Settings my $nagzillaserver = $cfg->param("NagzillaServer"); my $nagzillaport = $cfg->param("NagzillaPort"); ##################End Config Setup########################## ##################Get Some Options and set up pod2usage##### my ($opt_type, $opt_room, $opt_mess, $opt_color, $opt_help, $opt_man); GetOptions ( 't=s' => \$opt_type, 'r=s' => \$opt_room, 'm=s' => \$opt_mess, 'c:s' => \$opt_color, 'help|?' => \$opt_help, 'man!' => \$opt_man ) or pod2usage(-verbose =>1) && exit; #End GetOptions no warnings 'uninitialized'; pod2usage(-verbose => 1) && exit if defined $opt_help; pod2usage(-verbose => 1) && exit if ($opt_type eq '' || $opt_room eq '' || $opt_mess eq ''); pod2usage(-verbose => 2) && exit if defined $opt_man; ##################End Options############################### my $send2nagd; if ($opt_color eq '') { $send2nagd = "$opt_type^$opt_room^$opt_mess"; } else { $send2nagd = "$opt_type^$opt_room^$opt_mess^$opt_color"; } print "$send2nagd \n"; ##################Make socket connection############################### #Let's make us a socket connection my $remote = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => "$nagzillaserver", PeerPort => "$nagzillaport", Reuse => 1 ) or die "$!"; $remote->autoflush(1); print $remote $send2nagd; close $remote; ##################End socket stuff############################### =head1 NAME nagzillac2.pl =head1 SYNOPSIS Nagzillac connects to and sends messages to nagzillad which relays them to Jabber =head1 ARGUMENTS -t Type: either groupchat or chat REQUIRED -r Room: Either chatroom name or JID of an individual REQUIRED -m Message: The messages you would like to send enclosed in quotes REQUIRED -c Color: The color of your message (currently only red, yellow and green work) OPTIONAL -h Prints this message =head1 AUTHOR Billford@Hurricane Labs =head1 CREDITS McMaster@Hurricane Labs - some code and sounding board Steve@Hurricane Labs - some stupid checking =cut ./nagzilla-2.0/.svn/text-base/README.svn-base0000444000000000000000000000722711232756110017170 0ustar rootroot10/20/2008 -- Nagzilla client/server 01/10/2009 -- Updated 05/26/2009 -- Updated 05/27/2009 -- Updated 07/06/2009 -- Updated 07/26/2009 -- Updated DISCLAIMER: This is provided AS-IS with no warranty expressed or implied. I nor the company are responsible for anything you do with it so don't expect us to be. LICENSE: GPL v2. See LICENSE File Overview: Nagzilla was designed to be a Jabber relay "bot" in that it sits quietly in a room until it gets a message to relay to either a chatroom or a person. The early work was based on several simple examples out on the internets but didn't quite meet our needs. Namely they would just keep logging into a room every time they had something to say. That forced us to make it a daemon. This also allows us to now get nagzilla alerts from various systems and event creators. Nagzillac (the client program") accepts any string input and makes into a Jabber message. This should work with Google Talk (as it's Jabber based) but that's not been tested. The only platform this has been tested on is ejabberd running on Ubuntu. I have no doubts it SHOULD work on other Jabber/Linux/Perl platforms as well. Nagzilla provides some rudimentary security. You have to have your IP address defined in nagzillad.cfg to send messages but on a local LAN spoofing is trivial. You should still use your firewall wisely in this case and allow access only from those clients who should have it. Installation: Nagzilla consists of two components nagzillad (the server) and nagzillac (the client). They do not have to live on the same machine at all but require the same perl modules be installed. Required Perl Modules: IO::Socket IO::Socket::INET Net::Jabber (Ubuntu package: libnet-jabber-perl) Config::Simple (Ubuntu package: libconfig-simple-perl) Data::Dumper (Ubuntu Package: libdata-dumper-simple-perl) Log::LogLite (Ubuntu package: liblog-loglite-perl) Getopt::Long Pod::Usage Nagzillad Installation mkdir /etc/nagzillad/ cp nazillad.cfg and nagzillad-config.pl to /etc/nagzillad cp nagzillad.pl to /usr/local/sbin (or wherever on your system you want it to live) Edit nagzillad.cfg to suit your needs (file should be self-explanatory) start nagzillad.pl with & or add an init script (next version?) Nagzillac Installation mkdir /etc/nagzillac cp nagzillac.cfg and nagzillac-config.pl to /etc/nagzillac cp nagzillac.pl to /usr/local/bin (or wherever on your system you want it to live) Edit nagzillac.cfg to suit your needs Make the magic happen: nagzillac.pl "TYPE^TO^MESSAGE^COLOROFMESSAGE" TYPE: This can be either 'groupchat' or 'chat' -- groupchat == a chatroom and chat == an individual TO: What room or person to send to (can be full JID or just a nick with defined jabberserver sent) MESSAGE: Your message (which should avoid having ^ in it) COLOROFMESSAGE: Useful for nagios messages, current colors are red, yellow and green -- completely optional EXAMPLE: nagzillac.pl "groupchat^chatroom^Hi guys a server is down in some far away place^red" Usage: Nagzillac connects to and sends messages to nagzillad which relays them to Jabber Arguments: -t Type: either groupchat or chat REQUIRED -r Room: Either chatroom name or JID of an individual REQUIRED -m Message: The messages you would like to send enclosed in quotes REQUIRED -c Color: The color of your message (currently only red, yellow and green work) OPTIONAL -h Prints this message EXAMPLE: nagzillac2.pl -t groupchat -r chatroom -m "hello server is down" -c red That's it. Not a bad little hack if you have to monitor stuff and sit in IM all day (or a chat room). ./nagzilla-2.0/.svn/text-base/nagzillad.svn-base0000444000000000000000000000045211213102011020151 0ustar rootroot/var/log/nagzilla/nagzillad.log { daily missingok rotate 356 compress delaycompress notifempty create 640 nagzilla adm sharedscripts postrotate /etc/init.d/nagzillad restart > /dev/null endscript } ./nagzilla-2.0/.svn/text-base/TODO-2.0.svn-base0000444000000000000000000000157611232754665017313 0ustar rootrootnagzillac/d should be SSL based with shared secrets nagzillad should send back some confirmation of message, etc to nagzillac -- not entirely sure what's going to happen here, perhaps some magic nagzillad should accept rawxml messages (patch provided from rhonda@debian.at but needs improvement) -- I'm thinking of just offering some command line stuff to change colors/text, etc. -- I still haven't found a way to allow InsertRawXML safely -- Color codes via command line done -- 07/24/2009 nagzillad should announce her presence -- completed 07/22/2009 -- some code for this was written back in the old days, I'm going to re-integrate it in this release -- this accepts subscription requests on every message nagzillac should allow command line options -- completed 7/25/2009 -- command line option code completed with getopt::long -- this should make new options easier to add ./nagzilla-2.0/.svn/text-base/VERSION.svn-base0000444000000000000000000000014111232755055017353 0ustar rootrootNagzilla Client/Server 2.0 (beta 1) (c) 2006-2009 Hurricane Labs, LLC by Bill Mathews (Billford) ./nagzilla-2.0/.svn/tmp/0000755000000000000000000000000011232756111013472 5ustar rootroot./nagzilla-2.0/.svn/tmp/prop-base/0000755000000000000000000000000011213102011015341 5ustar rootroot./nagzilla-2.0/.svn/tmp/props/0000755000000000000000000000000011232754675014652 5ustar rootroot./nagzilla-2.0/.svn/tmp/text-base/0000755000000000000000000000000011232756111015366 5ustar rootroot./nagzilla-2.0/archive/0000755000000000000000000000000011232754622013434 5ustar rootroot./nagzilla-2.0/archive/TODO0000755000000000000000000000342611232754174014136 0ustar rootrootnagzillad should require some sort of authentication with its clients (perhaps ssl certs or shared secrets, oh my) - started 5/27/09 -- currently only IP of client is checked nagzillad should accept rawxml messages (patch provided from rhonda@debian.at but needs improvement) -- This is somewhat ready, still improving nagzillad should offer browser support (still have some thinking to do about this) -- web client is nearly done nagzillad should support SSL to it's client (nagzillac) Added some stress testing bash scripts, nothing fancy will improve later -- initially completed 5/26/2009 nagzillad should handle multiple connections -- completed and tested with 15000 multiple connections -- 05/26/2009 nagzillad needs to read from a config file -- completed -- 09/28/08 nagzillad should be able to sit in multiple rooms without issue -- proof of concept proven - completed --10/1/08 nagzillad should NOT run as root - add a check at startup for this -- completed -- 01/09/09 nagzillad /nagzillac communications should be encrypted -- Not sure this will happen in this release nagzillad should be able to write messages to a log file / maybe a web view? -- logs for messages completed -- 01/09/09 nagzilla should be renamed to nagzillac - completed - 09/28/08 nagzillac should take several command line arguments - completed - 10/20/08 a) server to connect to b) port to connect to c) room/person to send message to d) message (must escape control characters) nagzillac will stay command line based as to allow for easier "scriptability" with zenoss and nagios alerts This should allow for messaging of whoever for whatever purpose General error checking should be improved -- connectivity, presence and room tests -- started 06/20/2009 Code needs to be tidied up -- perltidy FTW -- thanks steve! ./nagzilla-2.0/archive/.svn/0000755000000000000000000000000011232756112014314 5ustar rootroot./nagzilla-2.0/archive/.svn/format0000444000000000000000000000000211232754622015521 0ustar rootroot9 ./nagzilla-2.0/archive/.svn/prop-base/0000755000000000000000000000000011232754667016221 5ustar rootroot./nagzilla-2.0/archive/.svn/prop-base/TODO.svn-base0000444000000000000000000000003611232754622020412 0ustar rootrootK 14 svn:executable V 1 * END ./nagzilla-2.0/archive/.svn/props/0000755000000000000000000000000011232754667015474 5ustar rootroot./nagzilla-2.0/archive/.svn/entries0000444000000000000000000000056411232756053015717 0ustar rootroot9 dir 20 https://nagzilla.googlecode.com/svn/branches/nagzilla-2.0/archive https://nagzilla.googlecode.com/svn 2009-07-26T04:21:10.719669Z 18 billford svn:special svn:externals svn:needs-lock 0 TODO file 2009-07-26T04:15:56.000000Z 2abb386269f8d91a0e0fc1f6e550f7d3 2009-07-26T04:21:10.719669Z 18 billford has-props 1814 ./nagzilla-2.0/archive/.svn/all-wcprops0000444000000000000000000000027011232754667016514 0ustar rootrootK 25 svn:wc:ra_dav:version-url V 46 /svn/!svn/ver/18/branches/nagzilla-2.0/archive END TODO K 25 svn:wc:ra_dav:version-url V 51 /svn/!svn/ver/18/branches/nagzilla-2.0/archive/TODO END ./nagzilla-2.0/archive/.svn/text-base/0000755000000000000000000000000011232754667016225 5ustar rootroot./nagzilla-2.0/archive/.svn/text-base/TODO.svn-base0000444000000000000000000000342611232754665020433 0ustar rootrootnagzillad should require some sort of authentication with its clients (perhaps ssl certs or shared secrets, oh my) - started 5/27/09 -- currently only IP of client is checked nagzillad should accept rawxml messages (patch provided from rhonda@debian.at but needs improvement) -- This is somewhat ready, still improving nagzillad should offer browser support (still have some thinking to do about this) -- web client is nearly done nagzillad should support SSL to it's client (nagzillac) Added some stress testing bash scripts, nothing fancy will improve later -- initially completed 5/26/2009 nagzillad should handle multiple connections -- completed and tested with 15000 multiple connections -- 05/26/2009 nagzillad needs to read from a config file -- completed -- 09/28/08 nagzillad should be able to sit in multiple rooms without issue -- proof of concept proven - completed --10/1/08 nagzillad should NOT run as root - add a check at startup for this -- completed -- 01/09/09 nagzillad /nagzillac communications should be encrypted -- Not sure this will happen in this release nagzillad should be able to write messages to a log file / maybe a web view? -- logs for messages completed -- 01/09/09 nagzilla should be renamed to nagzillac - completed - 09/28/08 nagzillac should take several command line arguments - completed - 10/20/08 a) server to connect to b) port to connect to c) room/person to send message to d) message (must escape control characters) nagzillac will stay command line based as to allow for easier "scriptability" with zenoss and nagios alerts This should allow for messaging of whoever for whatever purpose General error checking should be improved -- connectivity, presence and room tests -- started 06/20/2009 Code needs to be tidied up -- perltidy FTW -- thanks steve! ./nagzilla-2.0/archive/.svn/tmp/0000755000000000000000000000000011232756053015120 5ustar rootroot./nagzilla-2.0/archive/.svn/tmp/prop-base/0000755000000000000000000000000011232754622017010 5ustar rootroot./nagzilla-2.0/archive/.svn/tmp/props/0000755000000000000000000000000011232754622016263 5ustar rootroot./nagzilla-2.0/archive/.svn/tmp/text-base/0000755000000000000000000000000011232754667017025 5ustar rootroot./nagzilla-2.0/nagzillad.pl0000755000000000000000000002027411232753363014326 0ustar rootroot#!/usr/bin/perl #(c)2007-2009 Hurricane Labs #Author: Billford #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Bot Server #import our required Perl modules require Config::Simple; require Data::Dumper; require Log::LogLite; use IO::Socket; use IO::Socket::INET; use IO::Select; use Net::Jabber qw(Client); use Net::Jabber qw(Message); use Net::Jabber qw(Protocol); use Net::Jabber qw(Presence); #Point me to your nagzillad.pl directory $CONFDIR = "/etc/nagzillad"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! $0.=''; # so that the init script is able to detect the process ##############Config File Setup##################### Config::Simple->import_from('nagzillad.cfg', \%Config); $cfg = new Config::Simple("$CONFDIR/nagzillad.cfg"); #Nagzillad Server Settings $bindaddr = $cfg->param("BindAddr"); $bindport = $cfg->param("BindPort"); $binduser = $cfg->param("BindUser"); $daemon = $cfg->param("Daemon"); $to_log = $cfg->param("To_Log"); $LOG_DIRECTORY = $cfg->param("Log_Directory"); $ERROR_LOG_LEVEL = $cfg->param("Error_Log_Level"); #Nagzillad Access Control @allowedipaddr = $cfg->param("AllowedIPAddr"); #Jabber Server Settings $jabberserver = $cfg->param("JabberServer"); $jabberport = $cfg->param("JabberPort"); $jabberdebug = $cfg->param("JabberDebug"); $jabbertls = $cfg->param("JabberTLS"); $jabberssl = $cfg->param("JabberSSL"); $jabbersasl = $cfg->param("JabberSASL"); $jabberuser = $cfg->param("JabberUser"); $jabberpass = $cfg->param("JabberPass"); $jabberresource = $cfg->param("JabberResource"); $jabbermaxwait = $cfg->param("JabberMaxWait"); #conference server settings $confserver = $cfg->param("ConfServer"); @confrooms = $cfg->param("ConfRooms"); $confnick = $cfg->param("ConfNick"); @roominess = @confrooms; ###########End Config Setup##################### my $log = new Log::LogLite( $LOG_DIRECTORY . "/nagzillad.log", $ERROR_LOG_LEVEL ); ###########Function Setups####################### # make_access_checker - returns a function which checks if an IP address # should be allowed to connect to this nagzillad. # # It takes a reference to an an array of IP addresses (dotted quad strings). # # It returns a function which takes an IP address (also a dotted quad # string). That function will return 1 if the IP address is allowed and # undef if it isn't. # sub make_access_checker { my $ok_addrs = shift; my %ok_addr_set = map { $_ => 1 } @{$ok_addrs}; return sub { my $addr = shift; return $ok_addr_set{$addr}; } } my $check_access = make_access_checker(\@allowedipaddr); sub send_plain_chat { our $message = Net::Jabber::Message->new(); $message->SetMessage( "type" => $style, "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver", "body" => $mess ); }#end send_plain_chat sub send_color_chat { #make some pretty colors if ($col eq "red"){ $col = "\#ff0c00\;"; }elsif ($col eq "yellow"){ $col = "\#fff00\;"; }elsif ($col eq "green"){ $col = "\#00ff00\;"; }elsif ($col eq ""){ $col = "\#000000\;"; }; our $message = Net::Jabber::Message->new(); my $bod = "hello$mess"; $message->RemoveBody(); $bod =~ s/^\^SetMessage( "type" => $style, "to" => $roomy =~ /@/ ? $roomy : "$roomy\@$confserver" ); $message->InsertRawXML($bod); }#end send_color_chat sub PresenceReceived { my ($sid, $presence) = @_; my $from = $presence->GetFrom(); my $type = $presence->GetType(); return "" if ($type eq ''); $log->write( "Received presence notification of type '$type' from '$from'", 5 ); if ($type eq 'subscribe') { $connection->Subscription ( type => 'subscribed', to => $from ); } elsif ($type eq 'unsubscribe') { $connection->Subscription ( type => 'unsubscribed', to => $from ); } $connection->PresenceSend(); }#End PresenceReceived ##########End Function Setups################### #taken from a Perl tutorial somewhere a million years ago so direct reference escapes me. sub daemonize { chdir '/' or die "Can't chdir to /: $!"; open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; open STDERR, '>>/dev/null' or die "Can't write to /dev/null: $!"; defined( my $pid = fork ) or die "Can't fork: $!"; #setsid - from McMaster's salvia; if( $pid != 0 ) { open( PIDFILE, '>/var/run/nagzillad.pid' ); print PIDFILE "$pid\n"; close(PIDFILE); chown $uid, 0, "/var/run/nagzillad.pid"; chmod oct("0644"), "/var/run/nagzillad.pid"; # Change user ID - automagically my $uid = ( getpwnam('nobody') )[2]; $> = $uid; exit(0); } setsid or die "Can't start a new session: $!"; umask 0; } if ($daemon eq 1) { &daemonize; # Change user ID - automagically my $uid = ( getpwnam('nobody') )[2]; $> = $uid; } #Let's make us a socket $local = IO::Socket::INET->new( Proto => 'tcp', LocalAddr => $bindaddr, LocalPort => $bindport, Reuse => 1 ) or die "$!"; $local->listen(); #Tell our socket to listen #This is on by default with newer versions of IO::Socket but for bc let's turn it on anyway $local->autoflush(1); if ($to_log eq 1) { $log->write( "Nagzillad Server Started", 5 ); } #Start Jabber Stuff # Creates a new connection to the jabber server our $connection = Net::Jabber::Client->new( debugLevel => $jabberdebug ); $connection->Connect( "hostname" => $jabberserver, "port" => $jabberport, "tls" => $jabbertls, "ssl" => $jabberssl ) or die "Cannot connect ($!)\n"; #Return an error on failure my @result; if ($jabbersasl) { @result = $connection->AuthSend( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); } else { @result = $connection->AuthIQAuth( "username" => $jabberuser, "password" => $jabberpass, "resource" => $jabberresource ); } $connection->PresenceSend(); if ($result[0] ne "ok") { #Send an auth request, return on failure die "Ident/Auth with server failed: $result[0] - $result[1]\n"; } #Allow the daemon to hang out in as many rooms as needed (defined in config file) #Depending on your Jabber server setup specifying a non-existent room will create that room foreach $confs (@confrooms) { my $room = $connection->MUCJoin( room => "$confs", server => "$confserver", #Conference server nick => "$confnick" ); #Join a room } $connection->SetCallBacks ( presence => \&PresenceReceived ); $readable_handles = new IO::Select(); $readable_handles->add($local); while (1) { ($new_readable) = IO::Select->select( $readable_handles, undef, undef, undef ); foreach $sock (@$new_readable) { if ($sock == $local) { $new_sock = $sock->accept(); my $client_name = $new_sock->peeraddr; $ip = inet_ntoa($client_name); next if not defined $new_sock; # check if the new peer's IP address is permitted via # the AllowedIPAddr conf statement. if ($check_access->($ip)) { $log->write("accepted connection from $ip",1); $readable_handles->add($new_sock); } else { $log->write("rejected connection from $ip - not in AllowedIPAddr",5); close $new_sock; } } else { $buf = <$sock>; $readable_handles->remove($sock); close $sock; if ($buf) { our ( $style, $roomy, $mess, $col ) = split( /\^/, $buf, 4 ); if ($style && $roomy && $mess) { send_color_chat( $style, $roomy, $mess, $col ); $connection->Process(); } } #Send message from STDIN -- probably should add some error handling #There is some bug in at least ejabberd that causes messages to #be sent "offline". They get flushed on nagzilla restart #I don't know of a good way to check if this is happening yet #More to come - BM $connection->Send($message); if ($to_log eq 1) { $log->write( "--$mess-- sent to $roomy from $ip", 5 ); } } } } #Creates a sleep timer so many messages can be handled without issue #sleep(MAXWAIT); ./nagzilla-2.0/nagzillac2.pl0000755000000000000000000000504711232736507014411 0ustar rootroot#!/usr/bin/perl -w #(c)2007-2009 Hurricane Labs #Author: Billford #License: See LICENSE file GPL v2 #Nagzilla Jabber Relay Client use strict; require Config::Simple; require Data::Dumper; use IO::Socket; use IO::Socket::INET; use Getopt::Long; use Pod::Usage; #bring in our configuration variables my $CONFDIR = "/etc/nagzillac"; # DO NOT EDIT ANYTHING BEYOND THIS POINT!! ##################Begin Config Setup######################## our %Config; Config::Simple->import_from('nagzillac.cfg', \%Config); my $cfg = new Config::Simple("$CONFDIR/nagzillac.cfg"); #Nagzillac Nagzilla Server Settings my $nagzillaserver = $cfg->param("NagzillaServer"); my $nagzillaport = $cfg->param("NagzillaPort"); ##################End Config Setup########################## ##################Get Some Options and set up pod2usage##### my ($opt_type, $opt_room, $opt_mess, $opt_color, $opt_help, $opt_man); GetOptions ( 't=s' => \$opt_type, 'r=s' => \$opt_room, 'm=s' => \$opt_mess, 'c:s' => \$opt_color, 'help|?' => \$opt_help, 'man!' => \$opt_man ) or pod2usage(-verbose =>1) && exit; #End GetOptions no warnings 'uninitialized'; pod2usage(-verbose => 1) && exit if defined $opt_help; pod2usage(-verbose => 1) && exit if ($opt_type eq '' || $opt_room eq '' || $opt_mess eq ''); pod2usage(-verbose => 2) && exit if defined $opt_man; ##################End Options############################### my $send2nagd; if ($opt_color eq '') { $send2nagd = "$opt_type^$opt_room^$opt_mess"; } else { $send2nagd = "$opt_type^$opt_room^$opt_mess^$opt_color"; } print "$send2nagd \n"; ##################Make socket connection############################### #Let's make us a socket connection my $remote = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => "$nagzillaserver", PeerPort => "$nagzillaport", Reuse => 1 ) or die "$!"; $remote->autoflush(1); print $remote $send2nagd; close $remote; ##################End socket stuff############################### =head1 NAME nagzillac2.pl =head1 SYNOPSIS Nagzillac connects to and sends messages to nagzillad which relays them to Jabber =head1 ARGUMENTS -t Type: either groupchat or chat REQUIRED -r Room: Either chatroom name or JID of an individual REQUIRED -m Message: The messages you would like to send enclosed in quotes REQUIRED -c Color: The color of your message (currently only red, yellow and green work) OPTIONAL -h Prints this message =head1 AUTHOR Billford@Hurricane Labs =head1 CREDITS McMaster@Hurricane Labs - some code and sounding board Steve@Hurricane Labs - some stupid checking =cut