Article
Contents:
Overview and Problem
The ZENworks Linux Management 7.3.x deployment involving a large number of devices requires an optimal configuration and tuning of ZENworks Linux Management Server and Agent parameters based on several factors to ensure effective operation in any environment. These recommendations and guidelines are captured in the ZENworks Linux Management Scalability guide, which is applied according to the nature of ZENworks Linux Management deployment in the customer environment.
The scalability document provides recommendations on the ideal count of total managed devices which can be configured or registered as per ZENworks Linux Management Server in the Management Zone. As part of the guidelines, there is no way to determine the total count of ZENworks Linux Management clients or managed devices that are registered or subscribed to each ZENworks Linux Management Server (Primary/Secondary) in the Management Zone.
This statistic is quite useful in deployment planning and limiting the number of devices per ZENworks Linux Management Server, so that the server load is evenly distributed for the devices being managed without impacting its performance or throughput. This solution is provided and acknowledged by a primary ZENworks Linux Management customer involved in scaling up their existing ZENworks Linux Management deployment into their environment by being inline with the ZENworks Linux Management Scalability guidelines.
This utility is developed to bridge the gap by meeting the real time requirement to generate a report on the total number of managed devices (active/inactive), registered to the ZENworks Linux Management Server. It also provides the count of devices by its device types i.e. Server / Workstation, which is managed by a specific ZENworks Linux Management Server(s).
The count of managed devices can only be computed once the agent is subscribed to any ZENworks Linux Management Server. It can then be distributed to manage according to the allowed limit and across the closest(location) of the ZENworks Linux Management Servers in the zone. Thus it reduces the risk of overloading the ZENworks Linux Management Servers without causing any outage or delay in the environment.
System Environment
Novell ZENworks 7.3.0 Linux Management Server or later, configured with PostgreSQL database
Configuration and Instructions
- The scripting utility should run (without any parameters) on the ZENworks Linux Management Primary Server having Postgres as its backend database.
- The postgres query in script uses psql command and hence should be automated using /root/.pgpass file and it need not prompt for 'zenadmin' password. In case of ZENworks Linux Management with local/embedded postgres, you can replace 127.0.0.1 entry in the /root/.pgpass file with string 'localhost' . You can further verify this by running the following command query on primary server device shell:
psql -dzenworks -Uzenadmin -c"select count(*) from zen_device" - User needs to provide the name of the ZENworks Linux Management Zone. You may use 'zlman zonename' command to get this detail directly.
The total agents count reported here does not directly relate to "Active Device Count" shown for the licensing information at ZENworks Control Center.
Solution
The script extracts the details of all the device objects from both eDirectory(objectstore) and Postgresql database and then performs its statistics computations to get the absolute device counts.
If is required to filter the inactive devices , you can isolate inactive devices by configuring inactive device cleanup schedule under ZCC -> Configuration section , based on the last contact time of the device at the ZLM server.
Script
Copy the below content to a file zlm-agentcount-utility.sh and execute as bash script
Usage:
sh zlm-agentcount-utility.sh
######################################################
#License : GPLv2 , Novell Inc.
#Author : tarvindkumar@novell.com
#######################################################
#Script to get the count total managed devices attached to every ZLM server
ZLM_PRIMARY=localhost
nrmXmlDumpFile=nrmXmlData.txt
RED='\033[31m'
GREEN='\033[32m'
BOLD='\033[1m'
NORMAL='\033[m'
BLUE='\033[0;34m'
usage()
{
echo -e "======================================================================"
echo -e "Usage : sh $0 "
cat<<EOM
Description: This script is used to list the count of managed devices
registered per ZLM Server (Primary/Secondary). The script displays the
name of the ZLM Server against the count of its registered managed
devices(active/inactive) as present in Object store(eDir).
Important: The tool should be run on the ZLM Primary server with Postgres.
The postgres query in script uses psql command and hence should be
automated using /root/.pgpass and need not prompt for 'zenadmin' password.
For local postgres on ZLM Server you can replace 127.0.0.1 entry in
/root/.pgpass file with string 'localhost'.
EOM
echo -e "======================================================================"
}
#echo -e "${BOLD}"
usage
#echo -e "${NORMAL}"
# DB Part Postgres Only
hibernate_cfg_file="/etc/opt/novell/zenworks/hibernate.cfg.xml";
function get_hostname_guid_from_db
{
serverguid=$1;
if [ -f $hibernate_cfg_file ];then
db=`grep 'jdbc:' $hibernate_cfg_file | awk -F ':' '{print $2}'`;
case $db in
postgresql)
db_ip=`grep 'jdbc:' $hibernate_cfg_file | awk -F ':' '{print $4}' | awk -F '<' '{print $1}'`
db_port=`echo $db_ip | awk -F '/' '{print $1}'`
db_name=`echo $db_ip | awk -F '/' '{print $2}'`
db_user=` grep 'username' $hibernate_cfg_file | awk -F '<' '{print $2}' | awk -F '>' '{print $2}'`;
db_pass=` grep 'password' $hibernate_cfg_file | awk -F '<' '{print $2}' | awk -F '>' '{print $2}'`;
db_host=`grep 'jdbc:' $hibernate_cfg_file | awk -F ':' '{print $3}' | awk -F '//' '{print $2}'`
if [ ! -z "$db_host" ];then
if [ "$db_host" == "127.0.0.1" ]; then
db_host="localhost"
fi
fi
# get the packages for the deployed bundle version or given the bundle version
if [ ! -z $serverguid ] ; then
serverguid=`/usr/bin/psql -A -h $db_host -p $db_port -d$db_name -U$db_user -c"select alias from zen_device where deviceguid='$serverguid'" -t ` ;
echo "$serverguid"
fi
if [ $? -ne 0 ]
then
echo -e "${BOLD}${RED}Error: Could not get the server details from the database $db_name on the server${NORMAL} !"
exit 1;
fi
echo "";;
oracle)
echo " Oracle DataStore detected but not currently supported with this tool !"
esac
fi
}
# Edir Part
echo ""
if [ -z $ZONE ];then
echo -ne "${BOLD}Enter the ZONE-NAME of ZLM Server (Use 'zlman zonename' command to get this detail if needed): ${NORMAL}"
read ZONE
fi
mkdir -p /tmp/zlm
rm -f reg_servers_guids
rm -f reg_device_types
start_time=`date '+%s'`
password="";
echo " "
echo -ne "${BOLD}Enter the ZONE password for the ZLM Administrator : ${NORMAL}"
read -s password
echo " "; echo ""
echo -e "${GREEN}${BOLD}Performing search into eDir for registered devices...(Step 1 of 3)${NORMAL}"
#search the devices in zlm tree
/usr/bin/ldapsearch -x -h $ZLM_PRIMARY -s sub -b "ou=$ZONE,o=cell" -D cn=admin,o=system -ZZ -p 10389 -w $password "(objectclass=nrmDevice)" nrmXmlData -LLL > $nrmXmlDumpFile
if [ $? -gt 0 ];then
echo -e "${RED}${BOLD}Unable perform ldapsearch(eDir) for the ZLM configured ZONE ($ZONE). ${NORMAL}"
exit 1;
fi
# process the base 64 encoded xmlData from search results
echo -e "${GREEN}${BOLD}Processing eDir Devices Object dump information...(Step 2 of 3)${NORMAL}"
xmlData="";
begin=0;
file=1;
if [ -f $nrmXmlDumpFile ];then
while read line
do
# if [[ "$line" =~ "^dn: nrmName=" ]];then
if [[ `echo $line | grep 'dn: nrmName='` ]]; then
# if [[ `expr match "$line" "dn: nrmName="` != "0" ]];then
if [ "$begin" == "1" ];then
echo -e "$xmlData" > "/tmp/zlm/xmlout-$file.txt"
file=$((file+1))
fi
begin=0;
continue;
fi
# if [[ "$line" =~ "^nrmXmlData::" ]];then
if [[ `echo $line | grep 'nrmXmlData::'` ]]; then
#if [[ `expr match "$line" "nrmXmlData::"` != "0" ]];then
xmlData=${line:13}
begin=1
continue;
fi
if [ "$begin" == "1" ];then
xmlData=${xmlData}'\n'${line}
fi
done < nrmXmlData.txt
if [ "$begin" == "1" ];then
echo -e "$xmlData" > "/tmp/zlm/xmlout-$file.txt"
fi
else
echo -e "${RED}${BOLD} Could not find the xmlData File '$nrmXmlDumpFile' containing the search data from eDir devices ! ${NORMAL}"
exit 1;
fi
echo -e "${GREEN}${BOLD}Filtering the registered devices information...(Step 3 of 3) ${NORMAL}"
# Convert the base64 content to xml and extract the required info per device
for file in /tmp/zlm/xmlout-*
do
cat $file > text.b64
/usr/bin/openssl base64 -d -in text.b64 -out text.txt
if [ $? -gt 0 ];then
echo -e "${RED}${BOLD}Error : Failed to run openssl command ! . ${NORMAL}"
exit 1;
fi
server_guid=`/usr/bin/xmllint --format text.txt | grep "RegisteredServer" | awk -F '<' '{print $2}' | awk -F '>' '{print $2}'`
device_type=`/usr/bin/xmllint --format text.txt | grep Type | grep -v Device | grep -v " Server" | awk -F '<' '{print $2}' | awk -F '>' '{print $2}'`
if [ ! -z $server_guid ];then
servername=`get_hostname_guid_from_db $server_guid`
echo "$servername" >> reg_servers_guids
echo "$device_type $servername" >> reg_device_types
fi
rm -f text.txt
done
finish_time=`date '+%s'`
duration=`expr $finish_time - $start_time`
if [ -f $reg_servers_guids ] && [ -f reg_device_types ];then
# Summarize the results to get the device counts per server (GUID)
echo ""
echo -e "${RED}${BOLD}--------------------------------------${NORMAL}"
echo -e "${BLUE} ${BOLD} # Agents | ZENworks-Server ${NORMAL}"
echo -e "${RED}${BOLD}--------------------------------------${NORMAL}"
cat reg_servers_guids | sort -k1 | uniq -c
echo -e "${RED}${BOLD}--------------------------------------${NORMAL}"
echo -e "${BLUE} ${BOLD} # Agents |Type| ZENworks-Server ${NORMAL}"
echo -e "${RED}${BOLD}--------------------------------------${NORMAL}"
cat reg_device_types | sort -k1 | uniq -c
echo -e "${RED}${BOLD}--------------------------------------${NORMAL}"
echo -e "${GREEN}${BOLD}Successfully captured the registered agents information in [$duration] seconds. ${NORMAL}"
else
echo -e "${RED}${BOLD}Could not capture the registered agents information. ${NORMAL}"
fi
rm -f nrmXmlData.txt
rm -f text.b64
rm -rf /tmp/zlm
echo ""
Acknowledgments
Reviewer: Akshtha Manu - Technical writer, Novell, Inc.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
- Computing the Bundle Content Payload Size for ZENworks 7.x Linux Management
- Removing Devices that haven't checked in to ZENworks Linux Management for awhile
- Renaming Managed Device Objects in ZENworks Linux Management 7
- Status-Checking Script for DirXML Remote Loader
- OES: Apply Patches Without New Kernel Patches Being Applied
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 2841 reads


0