@Override
    public void execute(@Nonnull final SessionData data, Element command) {
        final Locale preferredLocale = SessionManager.getInstance().getLocaleForSession(data.getOwner());

        int maxItems = -1;
        final List<String> max_items_data = data.getData().get("max_items");
        if (max_items_data != null && !max_items_data.isEmpty()) {
            String max_items = max_items_data.get(0);
            if (max_items != null && !"none".equals(max_items)) {
                try {
                    maxItems = Integer.parseInt(max_items);
                } catch (NumberFormatException e) {
                    // Do nothing. Assume that all users are being requested
                }
            }
        }

        DataForm form = new DataForm(DataForm.Type.result);

        FormField field = form.addField();
        field.setType(FormField.Type.hidden);
        field.setVariable("FORM_TYPE");
        field.addValue("http://jabber.org/protocol/admin");

        field = form.addField();
        field.setType(FormField.Type.jid_multi);
        field.setLabel(LocaleUtils.getLocalizedString("commands.admin.getlistidleusers.form.field.activeuserjids.label", preferredLocale));
        field.setVariable("activeuserjids"); // The XEP uses this variable ('active') rather than something like 'idleuserjids'.

        // Make sure that we are only counting based on bareJIDs and not fullJIDs
        Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
        Set<String> users = new HashSet<>(sessions.size());
        for (ClientSession session : sessions) {
            if (!session.getPresence().isAvailable()) {
                users.add(session.getAddress().toBareJID());

                if (maxItems > 0 && users.size() >= maxItems) {
                    break;
                }
            }
        }

        // Add users to the result
        for (String user : users) {
            field.addValue(user);
        }
        command.add(form.getElement());
    }
Command that allows to retrieve the list of idle users. Idle users are those that are online, but not active.
Active users are those users that have sent an available presence.

@author Guus der Kinderen, guus@goodbytes.nl
@see <a href="https://xmpp.org/extensions/xep-0133.html#get-idle-users-list">XEP-0133 Service Administration: Get List of Idle Users</a>
xmppserver/src/main/java/org/jivesoftware/openfire/commands/admin/GetListIdleUsers.java