| To: | pcp developers <pcp@xxxxxxxxxxx> |
|---|---|
| Subject: | [PATCH] ds389: make more resilient to server failures |
| From: | Marko Myllynen <myllynen@xxxxxxxxxx> |
| Date: | Mon, 20 Apr 2015 10:48:50 +0300 |
| Delivered-to: | pcp@xxxxxxxxxxx |
| Organization: | Red Hat |
| Reply-to: | myllynen@xxxxxxxxxx |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
Retry connecting to the server if a connection fails,
for example during server restart. Add a bit of logging.
---
src/pmdas/ds389/pmdads389.pl | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/pmdas/ds389/pmdads389.pl b/src/pmdas/ds389/pmdads389.pl
index d4a2287..5c00c29 100644
--- a/src/pmdas/ds389/pmdads389.pl
+++ b/src/pmdas/ds389/pmdads389.pl
@@ -40,13 +40,18 @@ my $ts_ur = 0;
sub ds389_connection_setup {
if (!defined($ldap)) {
+ $pmda->log("binding to $server");
$ldap = Net::LDAP->new($server);
- return if (!defined($ldap));
+ if (!defined($ldap)) {
+ $pmda->log("bind failed, server down?");
+ return;
+ }
my $mesg = $ldap->bind($binddn, password => $bindpw);
if ($mesg->code) {
$pmda->log("bind failed: " . $mesg->error);
- die;
+ return;
}
+ $pmda->log("bind to $server ok");
}
}
@@ -99,6 +104,7 @@ sub ds389_fetch {
$mesg = $ldap->search(scope => $scope, base => $cnbase,
filter => $filter);
if ($mesg->code) {
$pmda->log("search failed: " . $mesg->error);
+ undef $ldap;
return;
}
ds389_process_entry($mesg->entry, 'cn.', 0);
@@ -112,6 +118,7 @@ sub ds389_fetch {
$mesg = $ldap->search(scope => $scope, base => $urbase,
filter => $filter);
if ($mesg->code) {
$pmda->log("search failed: " . $mesg->error);
+ undef $ldap;
return;
}
ds389_process_entry($mesg->entry, 'userroot.', 1);
--
1.7.1
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH] ds389log: tabify, Marko Myllynen |
|---|---|
| Next by Date: | [PATCH] ds389/ds389log: make configuration variables actually configurable.., Marko Myllynen |
| Previous by Thread: | [PATCH] ds389log: tabify, Marko Myllynen |
| Next by Thread: | [PATCH] ds389/ds389log: make configuration variables actually configurable.., Marko Myllynen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |