Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.


Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.


Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.


Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Hadoop

Monitoring Solr Cores

Submitted by on November 1, 2016 – 10:50 pm

The Cloud tab of the Solr Web UI is convenient, but not for monitoring purposes. Just like you, I hate XML and parsing it from shell is more convoluted that it needed to be. But there are some helpful tools. Here’s a quick example of monitoring Solr cores with a shell script.


getinfo() {
	xmlstarlet sel -T -t -m response`awk 'BEGIN{for(c=0;c<7;c++) printf "/lst"}'` \
	-v "concat(str[@name='core'],' ',@name,' ',str[@name='node_name'],' ',str[@name='state'],' ',str[@name='leader'], '@')" \
	<<<$(wget -q -O - "${solr_url}") | \
	sed -e 's/@/\n/g' -e 's/\.krazyworks\.local:8983_solr//g' | \
	awk '{if(NF < 5) print $0, "false"; else print $0}' | \
	(echo "REPLICA CORE NODE STATE LEADER" && cat) | column -t

setarray() {
	unset a
	IFS=$'\n' ; a=($(getinfo)) ; unset IFS

printarray() {
	for ((i = 0; i < ${#a[@]}; i++)) ; do echo "${a[$i]}" ; done


This will give a shell array containing the status of your Solr cores. You can use the printarray function to recall this data for further processing without having to use temp files or repeatedly query Solr servers. Sample output:
REPLICA                      CORE         NODE    STATE   LEADER
test01_core_shard1_replica1  core_node1   solr03  active  true
test01_core_shard2_replica1  core_node2   solr05  active  true
test01_core_shard3_replica1  core_node3   solr02  active  true
test01_core_shard4_replica1  core_node4   solr04  active  true
test01_core_shard5_replica1  core_node5   solr01  active  true
test02_core_shard1_replica1  core_node15  solr06  active  false
test02_core_shard1_replica2  core_node3   solr10  active  true
test02_core_shard2_replica1  core_node19  solr08  active  true
test02_core_shard2_replica2  core_node12  solr03  active  false
test02_core_shard3_replica1  core_node17  solr07  active  false
test02_core_shard3_replica2  core_node21  solr02  active  true
test02_core_shard4_replica2  core_node4   solr05  active  false


Print Friendly, PDF & Email

Leave a Reply