Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 1209128 - [RFE] Add a utility to get the status of Directory Server instances
[RFE] Add a utility to get the status of Directory Server instances
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: 389-ds-base (Show other bugs)
7.3
All Linux
low Severity low
: rc
: ---
Assigned To: Noriko Hosoi
Viktor Ashirov
Petr Bokoc
: FutureFeature
Depends On:
Blocks: 1300797
  Show dependency treegraph
 
Reported: 2015-04-06 07:04 EDT by Amita Sharma
Modified: 2016-11-03 16:34 EDT (History)
4 users (show)

See Also:
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 16:34:58 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2594 normal SHIPPED_LIVE Moderate: 389-ds-base security, bug fix, and enhancement update 2016-11-03 08:11:08 EDT

  None (edit)
Description Amita Sharma 2015-04-06 07:04:02 EDT
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 19:12:48 EDT
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 13:06:26 EDT
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 19:30:33 EDT
^future^feature^
Comment 8 Kamlesh 2016-07-08 07:34:34 EDT
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 08:09:54 EDT
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 14:46:19 EDT
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 16:48:06 EDT
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 17:00:11 EDT
Agh...  Thanks a lot, Viktor!
Comment 13 Kamlesh 2016-07-18 06:18:34 EDT
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/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 16:34:58 EDT
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

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