summaryrefslogtreecommitdiffstats
path: root/web/attachments/76454-check_pop3.diff
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/76454-check_pop3.diff')
-rw-r--r--web/attachments/76454-check_pop3.diff110
1 files changed, 110 insertions, 0 deletions
diff --git a/web/attachments/76454-check_pop3.diff b/web/attachments/76454-check_pop3.diff
new file mode 100644
index 0000000..3e50a14
--- /dev/null
+++ b/web/attachments/76454-check_pop3.diff
@@ -0,0 +1,110 @@
1--- check_pop3.pl 2004-01-05 16:43:27.000000000 -0600
2+++ /home/jason/sf/nagiosplug/contrib/check_pop3.pl 2002-02-28 00:42:53.000000000 -0600
3@@ -23,29 +23,6 @@
4 # with perl -wT and 'use strict'
5 # 2000/01/20 RM Corrected POP3 Exit State.
6 # 2000/01/21 RM Fix Exit Codes Again!!
7-# 2003/12/30 CZ Proper CRLF in communication w/server
8-# Fixed infinite loop
9-# Error checking on welcome banner, USER, PASS commands
10-# Better error condition handling
11-# This could probably be much much smaller using Net::POP3,
12-# but I haven't looked into its error conditions yet, and I
13-# don't think you can specify remote port.
14-
15-=cut
16-
17-use Net::POP3;
18-
19-my $pop = new Net::POP3("$ARGV[0]", Timeout => 60);
20-my $ret = $pop->login("$ARGV[1]","$ARGV[2]");
21-$pop->quit();
22-
23-do { print "some error msg\n"; exit 2; } unless defined $ret;
24-
25-print "POP3 OK - ".int($ret)." messages\n";
26-exit 0;
27-
28-=cut
29-
30 # ------------------------------------------------------------------------------
31
32 # -----------------------------------------------------------------[ Require ]--
33@@ -120,56 +97,47 @@
34 my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname);
35
36
37- err("no welcome banner\n") unless $_ = <ClientSocket>;
38- err("bad welcome banner: " . $_) unless $_ =~ /^\+OK/;
39+print ClientSocket "user $username\n";
40
41- print ClientSocket "USER $username\r\n";
42+#Debug Server
43+#print "user $username\n";
44
45- #Debug Server
46- #print "user $username\n";
47+#Sleep or 3 secs, incase server is slow.
48+sleep 3;
49
50- err("no response to USER command\n") unless $_ = <ClientSocket>;
51- err("bad response to USER: " . $_) unless $_ =~ /^\+OK/;
52+print ClientSocket "pass $password\n";
53
54- print ClientSocket "PASS $password\r\n";
55+#Debug Server
56+#print "pass $password\n";
57
58- #Debug Server
59- #print "pass $password\n";
60+while (<ClientSocket>) {
61
62- err("no response to PASS command\n") unless $_ = <ClientSocket>;
63- err("bad response to PASS: " . $_) unless $_ =~ /^\+OK/;
64+print ClientSocket "pass $password\n";
65
66- print ClientSocket "LIST\r\n";
67+#Debug Server
68+#print $_;
69
70- my $bad = 1;
71- my $msgs = 0;
72- while (<ClientSocket>) {
73- #Debug Server
74- #print $_;
75-
76- err(($1||' UNKNOWN')."\n") if (m/\-ERR(.*)/);
77- $bad = 0 if /^\+OK/;
78- $msgs = $1 if /^(\d+)\s+/;
79- last if /^\./;
80- }
81- &message("$msgs\n") unless $bad;
82- err("missing +OK to LIST command\n");
83+err($_) if (m/\-ERR\s+(.*)\s+.*/);
84+message($_) if (m/\+OK Mailbox open,\s+(.*\d)\s+messages.*/);
85+}
86 }
87
88 sub message
89 {
90- my $answer = "POP3 OK - Total Messages On Server: ".shift();
91+ my $answer = "UNKNOWN";
92+ $answer = "Pop3 OK - Total Messages On Server :- $1";
93 alarm(0);
94- print ClientSocket "QUIT\r\n";
95+ print ClientSocket "quit\n";
96 print "$answer";
97 exit 0;
98 }
99
100 sub err
101 {
102- my $answer = "POP3 Error:".shift();
103+ my $answer = "UNKNOWN";
104+ $answer = "Pop3 Error :- $1";
105 alarm(0);
106- print ClientSocket "QUIT\r\n";
107+ print ClientSocket "quit\n";
108 print "$answer";
109 exit 2;
110 }