How to check if zabbix agent insstalled at all infrastructure hosts

We use LXC containers at PH hosts.
containers named like:
rolename$RoleVersion-$InstanceNumber

For example
at host sXX2
appserver1-1
db1-1
db1-2
zabbix3-1

We need to check, if zabbix agents are installed at all infrastructure. One way – user fabric, Luke, as all 80 level DevOps do, or use ssh as all 40 level DevOps do.
Sorry for a little bit 🙂 “hindi” code 🙂 no review was done 🙂

#!/bin/bash
for i in sXX2 sXX3 sXX5;
do
 echo "host = $i"

 for container in  `ssh $i.it.randomthemes.com lxc-list | grep .-. | awk '{print $1}';`
 do
  echo "container = $container"
  zabbix_installed=`ssh $i.it.randomthemes.com "ssh $container dpkg -l | grep zabbix" | awk '{print $1}'`

  if [[ $zabbix_installed != ii ]] ; then echo "ZABBIX NOT INSTALLED at $container"; fi
 done
  echo "--------------";
done

Output example:

host = sXX2
container = dbslave1-1
container = gitbackup1-1
container = ldapslave1-1
container = repo1-1
ZABBIX NOT INSTALLED at repo1-1
container = snamed1-1
--------------
host = sXX3
container = appserver1-1
container = appserver1-2
ZABBIX NOT INSTALLED at appserver1-2
container = appserver1-4
ZABBIX NOT INSTALLED at appserver1-4
container = cdn1-1
container = chef1-1
container = db1-1

Looks qute 🙂 🙂 🙂 God, bless scripting!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>