# Quickly Get 'alive' Member IPs in a Service Group

**URL:** <https://discourse.chef.io/t/quickly-get-alive-member-ips-in-a-service-group/18239>\
**Category:** Habitat Wiki\
**Created:** [October 9, 2018, 3:03pm UTC](https://discourse.chef.io/t/quickly-get-alive-member-ips-in-a-service-group/18239 "2018-10-09T15:03:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bixu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bixu/32/2907_2.png) [@bixu](https://discourse.chef.io/u/bixu)\
**Post date:** [October 9, 2018, 3:03pm UTC](https://discourse.chef.io/t/quickly-get-alive-member-ips-in-a-service-group/18239/1 "2018-10-09T15:03:31Z")

</div>

I often find myself wishing for a quick list of alive member IPs for a given service group. Here’s a shell function to do that, and another I use for parallel ssh into hosts running members of the service group:

```auto
service_group_ips() {
  local initial_peer="$1"
  local service_group="$2"
  curl --silent "$initial_peer":9631/census \
    | jq -r ".census_groups | .\"$service_group\" | .population | .[] | select(.alive == true) | .sys | .ip"
}

habssh() {
  local initial_peer="$1"
  local service_group="$2"
  local pssh_command="$3"
  service_group_ips "$initial_peer" "$service_group" > "$HOME/.$service_group.ips"
  pssh --inline --hosts="$HOME/.$service_group.ips" "$pssh_command"
}

```
