Bug 1209128

Summary: [RFE] Add a utility to get the status of Directory Server instances
Product: Red Hat Enterprise Linux 7 Reporter: Amita Sharma <amsharma>
Component: 389-ds-baseAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED ERRATA QA Contact: Viktor Ashirov <vashirov>
Severity: low Docs Contact: Petr Bokoc <pbokoc>
Priority: low    
Version: 7.3CC: kbanerje, nkinder, pbokoc, rmeggins
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 389-ds-base-1.3.5.10-4.el7 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.
Story Points: ---
Clone Of:
: 1300797 (view as bug list) Environment:
Last Closed: 2016-11-03 20:34:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1300797    

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 ::
/usr/sbin/start-dirsrv
/usr/sbin/stop-dirsrv
/usr/sbin/restart-dirsrv

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 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.

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

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

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

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

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 $?
2

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

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

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

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

reproducer.sh:
#!/bin/bash
set -x
main() {
    return -1
}
main
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
2

On Fedora24 with bash-4.3.42-5.fc24.x86_64:
$ bash reproducer.sh
+ main
+ return -1
+ echo 255
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 - 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
           └─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/1.3.5.10 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 $?
0
[root@test ~]# status-dirsrv NoInstace
Instance NoInstace not found.
[root@test ~]# echo $?
255

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.

https://rhn.redhat.com/errata/RHSA-2016-2594.html