Has anyone already created a new class for tcp_query that will allow multiple sends and recvs ? I want to be able to do a POP3 or IMAP login to test a service, currently, this doesn't appear possible. Or if it is, I can't see how. If this functionality doesn't exist, I am considering coding it.
Enhanced tcp_query
godzone-nz · 4 jul 2008, 2:51 · 7 mensajes · 46 visitas
- Inicio del debate
OK, Here is a patch I have written against 1.3.1 that allows a conversation. In the monitor definition for a pop3 connection that actually tests the login, TCP Send = |user abcdefg^M|pass xxxxxx^M|quit^M TCP Receive = ok|ok|ok|ok As soon as a response doesn't match, the monitor fails. Seems to work for me pretty well. *** pandora_network.orig 2008-07-04 10:57:31.000000000 +1200 --- pandora_network 2008-07-04 14:59:21.000000000 +1200 *************** *** 349,354 **** --- 349,361 ---- Blocking=>0 ); # Non blocking !!, very important ! if (defined($handle)){ + my @tcp_send = split( /|/, $tcp_send ); + my @tcp_rcv = split( /|/, $tcp_rcv ); + + next_pair: + $tcp_send = shift( @tcp_send ); + $tcp_rcv = shift( @tcp_rcv ); + if ($tcp_send ne ""){ # its Expected to sending data ? # Send data $handle->autoflush(1); *************** *** 370,376 **** } if ($id_tipo_modulo == 9){ # only for TCP Proc if ($temp2 =~ /$tcp_rcv/i){ # String match ! ! $$module_data = 1; $$module_result = 0; $counter = $pa_config->{'tcp_checks'}; } else { --- 377,386 ---- } if ($id_tipo_modulo == 9){ # only for TCP Proc if ($temp2 =~ /$tcp_rcv/i){ # String match ! ! if ( @tcp_send ) { # still more pairs ! goto next_pair; ! } ! $$module_data = 1; $$module_result = 0; $counter = $pa_config->{'tcp_checks'}; } else {
Nice! We're gonna take a look at your patch and decide whether we should commit it to SVN We'll let you know! Thanks again!
OK, Here is a patch I have written against 1.3.1 that allows a conversation. In the monitor definition for a pop3 connection that actually tests the login, TCP Send = |user abcdefg^M|pass xxxxxx^M|quit^M TCP Receive = ok|ok|ok|ok As soon as a response doesn't match, the monitor fails. Seems to work for me pretty well. ...code....
Hey, this seems to be very interesting contribution. I have some problems adding patch to 1.3.1 code, could you send me se entire pandora_network file by mail ? slerena (@@) gmail (..) com Thanks.
OK, complete file sent :-) I have now used this for: POP3 - login and list inbox IMAP - login and list inbox FTP - login and pwd to check directory From my perspective just checking the port is open doesn't check enough to give me confidence that users can actually do things. Hence this patch NB: Keep up the good work, I like pandora and have used nagios and zenoss before it.
Here are a couple of examples of how my patch can be used. To check an FTP server, I started with the std FTP check and set tcp_send: |user myuser^M|pass mypass^M|pwd^M|quit^M tcp_recv: 220|331|230|257|221 NB: There is a 'null' send as part of the first pair as opening the connection results in the server sending its welcome message. To check POP3 server, I again started with the std POP3 check and set tcp_send: |USER myuser^M|PASS mypass^M|LIST^M|QUIT^M tcp_recv: ok|ok|ok|ok|ok My patch splits the send and recv values into an array, each successive pair is then actioned i.e. send something and then wait for the response. If a response times out or does not match, then the entire conversation is deemed to have failed. I hope others find this useful as well.
Great. Many thanks, I'll include this in the next version documentation !
Entra en tu cuenta para publicar.
