user-islocked.sh - ssh script by ActiveXperts Software
user-islocked.sh checks whether a user account is locked or unlocked.
Use user-islocked.sh directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select user-islocked.sh. Configure the required parameter, or press 'Load a working sample'.
In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.
user-islocked.sh script code
################################################################################# # ActiveXperts Network Monitor - Shell script checks # © 1999-2015, ActiveXperts Software B.V. # # For more information about ActiveXperts Network Monitor and SSH, please # visit the online ActiveXperts Network Monitor Shell Script Guidelines at: # http://www.activexperts.com/support/network-monitor/online/linux/ ################################################################################# # Script # user-islocked.sh # Description: # This script will check if a user account is locked or unlocked # Parameters: # 1) username (string) - Username to check # Usage: # user-islocked.sh <username> # Sample: # user-islocked.sh axuser ################################################################################# #!/bin/sh # Validate number of arguments if [ $# -ne 1 ] ; then echo "UNCERTAIN: Invalid number of arguments - Usage: user-islocked <username>" exit 1 fi # Checks if the user account is locked if id -u $1 >/dev/null 2>&1; then passwd -S $1 | awk '{ if( $9 == "locked.)" ) print "SUCCESS: Account [" $1 "] is locked" else print "ERROR: Account [" $1 "] is not locked" }' else echo "ERROR: User does not exist" fi