Bug 1209128 - [RFE] Add a utility to get the status of Directory Server instances
Summary: [RFE] Add a utility to get the status of Directory Server instances
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: 389-ds-base
Version: 7.3
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Noriko Hosoi
QA Contact: Viktor Ashirov
Petr Bokoc
Depends On:
Blocks: 1300797
TreeView+ depends on / blocked
Reported: 2015-04-06 11:04 UTC by Amita Sharma
Modified: 2020-09-13 21:22 UTC (History)
4 users (show)

Fixed In Version: 389-ds-base-
Doc Type: Enhancement
Doc Text:
New utility for displaying status of Directory Server instances Directory Server now provides the "status-dirsrv" command line utility, which outputs the status of one or all instances. Use the following command to obtain a list of all existing instances: status-dirsrv To display the status of a specific instance, append the instance name to the command. See the *status-dirsrv(8)* man page for additional details and a list of return codes.
Clone Of:
: 1300797 (view as bug list)
Last Closed: 2016-11-03 20:34:58 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github 389ds 389-ds-base issues 1475 0 None None None 2020-09-13 21:22:38 UTC
Red Hat Product Errata RHSA-2016:2594 0 normal SHIPPED_LIVE Moderate: 389-ds-base security, bug fix, and enhancement update 2016-11-03 12:11:08 UTC

Description Amita Sharma 2015-04-06 11:04:02 UTC
Description of problem:
Add /usr/sbin/status-dirsrv script to get the status of the directory server instance.

Currently, we have these scripts ::

It is good to have status-dirsrv script which can give current status of directory server that is it started or stopped.

Comment 3 Mike McCune 2016-03-28 23:12:48 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune@redhat.com with any questions

Comment 5 Noriko Hosoi 2016-05-05 17:06:26 UTC
Additional future.

When one or more ns-slapd are down, the exit value or status-dirsrv shows the number of the down servers.

There are 3 DS instances are installed.
1) If all are up,
$ status-dirsrv
$ echo $?

2) If 2 is down,
$ status-dirsrv
$ echo $?

2) If all are down,
$ status-dirsrv
$ echo $?

Comment 6 Noriko Hosoi 2016-05-05 23:30:33 UTC

Comment 8 Kamlesh 2016-07-08 11:34:34 UTC
RFE Verified 
1) [root@test slapd-test]# status-dirsrv 
gave detail information about status of Directory server and Instance 

2) [root@test slapd-test]# status-dirsrv 'instance name'    
gave information about the instance

3) [root@test slapd-test]# man status-dirsrv
show man page for this command

4) Check addition feature mention in comment 5 
give result as mention

Comment 9 Kamlesh 2016-07-08 12:09:54 UTC
As mention in the Man page 
Exit code 255 is returned if the instance does not exist. 
but it return the 2 as exit code

[root@rhel7ds ~]# status-dirsrv rhel7dssfsf
Instance rhel7dssfsf not found.
/usr/sbin/status-dirsrv: line 14: return: -1: invalid option
return: usage: return [n]
[root@rhel7ds ~]# echo $?

Comment 10 Noriko Hosoi 2016-07-08 18:46:19 UTC
Can't reproduce the problem.

# status-dirsrv rhel7dssfsf
Instance rhel7dssfsf not found.
# echo $?

Could you provide the output of "sh -x status-dirsrv rhel7dssfsf"?

Comment 11 Viktor Ashirov 2016-07-08 20:48:06 UTC
The error comes from bash built-in `return`. bash version prior to 4.3 didn't support negative numbers as argument for `return`.
See for reference: http://wiki.bash-hackers.org/scripting/bashchanges

set -x
main() {
    return -1
echo $?

On RHEL7 with bash-4.2.46-19.el7.x86_64:
$ bash reproducer.sh 
+ main
+ return -1
reproducer.sh: line 4: return: -1: invalid option
return: usage: return [n]
+ echo 2

On Fedora24 with bash-4.3.42-5.fc24.x86_64:
$ bash reproducer.sh
+ main
+ return -1
+ echo 255

So in RHEL we need explicitly specify error code 255.

Comment 12 Noriko Hosoi 2016-07-08 21:00:11 UTC
Agh...  Thanks a lot, Viktor!

Comment 13 Kamlesh 2016-07-18 10:18:34 UTC
Bug Verified 
[root@test ~]# status-dirsrv test
● dirsrv@test.service - 389 Directory Server test.
   Loaded: loaded (/usr/lib/systemd/system/dirsrv@.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2016-07-18 14:16:51 IST; 1h 26min ago
 Main PID: 3836 (ns-slapd)
   Status: "slapd started: Ready to process requests"
   CGroup: /system.slice/system-dirsrv.slice/dirsrv@test.service
           └─3836 /usr/sbin/ns-slapd -D /etc/dirsrv/slapd-test -i /var/run/dirsrv/slapd-test.pid

Jul 18 14:16:51 test.example.com systemd[1]: Starting 389 Directory Server test....
Jul 18 14:16:51 test.example.com ns-slapd[3836]: [18/Jul/2016:14:16:51.178734301 +051800] 389-Directory/ B2016.197.39 starting up
Jul 18 14:16:51 test.example.com ns-slapd[3836]: [18/Jul/2016:14:16:51.572105005 +051800] slapd started.  Listening on All Interfaces port 389 for LDAP requests
Jul 18 14:16:51 test.example.com systemd[1]: Started 389 Directory Server test..
[root@test ~]# echo $?
[root@test ~]# status-dirsrv NoInstace
Instance NoInstace not found.
[root@test ~]# echo $?

Comment 15 errata-xmlrpc 2016-11-03 20:34:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.