Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZRFE-910: Gather mdb_stat data if server is ldap #106

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion src/libexec/zmdiaglog
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use Digest::MD5;
use vars qw(
$VERSION $PID_FILE $DEFAULT_DEST $DLOGDIR $JMAP $JAVA $JINFO $DEFAULT_TIMEOUT
$HAVE_GCORE $HAVE_PSTACK $HAVE_LSOF $HAVE_DMESG $LOG_FILE $ZMSTAT_CONF
$ZMDUMPENV $ZMLOCALCONFIG $ZMPROV $ZMHOSTNAME $SU $HAVE_NETSTAT $HAVE_MYSQL $ZMMYTOP $ZMINNOTOP $HAVE_NETWORK
$ZMDUMPENV $ZMLOCALCONFIG $ZMPROV $ZMHOSTNAME $SU $HAVE_NETSTAT $HAVE_MYSQL $ZMMYTOP $ZMINNOTOP $HAVE_NETWORK $MDBSTAT
);

my $isMac = isMac();
Expand All @@ -58,6 +58,7 @@ $PID_FILE = '/opt/zimbra/log/zmmailboxd_java.pid';
$JMAP = '/opt/zimbra/common/bin/jmap';
$JAVA = '/opt/zimbra/common/lib/jvm/java/bin/java';
$JINFO = '/opt/zimbra/common/lib/jvm/java/bin/jinfo';
$MDBSTAT = '/opt/zimbra/common/bin/mdb_stat';
$Getopt::Std::STANDARD_HELP_VERSION = 1;
$VERSION = 0.1;
$HAVE_GCORE = has_cmd('gcore');
Expand Down Expand Up @@ -116,6 +117,29 @@ sub get_java_version() {
$version;
}

sub is_ldap_server(){
my $mdb;
my $ldapServiceInstalled = `sudo -i -u zimbra zmprov -l gs $ZMHOSTNAME zimbraServiceEnabled 2> /dev/null`;
my $isLDAPServer = 0;
# chomp($ldapServiceInstalled);
if (index($ldapServiceInstalled, "zimbraServiceEnabled") != -1) {
logmsg "This is an LDAP Server. Gathering LDAP diagnostic data.\n";
$isLDAPServer = 1;
}else{
if (index($ldapServiceInstalled, "") != -1) {
print "Attempting to identify if this is an LDAP server.\n";
$mdb = '/opt/zimbra/data/ldap/mdb/db/data.mdb';
if (-e $mdb) {
logmsg "This is (or was) an LDAP Server. Gathering LDAP diagnostic data.\n";
$isLDAPServer = 1;
}
}
}
if ($isLDAPServer){
system("bash -c '/opt/zimbra/common/bin/mdb_stat -a -e -f /opt/zimbra/data/ldap/mdb/db' > ldap_mdb_stat.txt 2>&1");
}
}

sub save_heap_info($$$$) {
my ( $version, $destination, $pid, $timeout ) = @_;
my $histo_cmd;
Expand Down Expand Up @@ -290,6 +314,7 @@ sub remove_data_dir($) {

# "main"
sub run() {

Getopt::Long::Configure ("bundling");
my %options = ('t' => $DEFAULT_TIMEOUT);
my $opt_result =
Expand Down Expand Up @@ -544,6 +569,7 @@ sub run() {
sleep(5);
}
}
is_ldap_server;

if ($HAVE_LSOF) {
logmsg "Saving output of LSOF\n";
Expand Down