conky script used to monitor server status remotely.

A typical Conky look
Image via Wikipedia

I was looking for something to monitor few details on the server. I thought about quite a lot of applications, some open source and some scripts developed in house. But my requirements were quite petty and the scripts and applications were quite heavy. So, I thought why not conky :).

 

So, with some quick work on conky script, I was able to get what I wanted and here it is for all of you.

This is a bash script, that will create the conky script and then start conky.

#!/bin/bash - 
#===============================================================================
#
#          FILE:  conky.sh
# 
#         USAGE:  ./conky.sh 
# 
#   DESCRIPTION:  Start conky to display who on all the servers.
# 
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Amit Agarwal (aka), [email protected]
#       COMPANY: Roamware India Pvt Ltd
#       CREATED: 12/21/2011 02:06:33 PM IST
# Last modified: Wed Dec 21, 2011  05:56PM
#      REVISION:  ---
#===============================================================================
echo killall conky processes
kill -9 $(ps -eaf|grep conkyrc|awk '{print $2}'|tr '\n' ' ')
conkyrc=~/.conkyrc.who
cat <$conkyrc
background no
alignment top_right
update_interval 50
double_buffer
short_units yes

#colors
#color black
#color0 ff6633
#color1 ffffff
#color2 cccccc
#color3 ffff66

#xft settings
use_xft yes
xftfont arial:size=10

cpu_avg_samples 2
net_avg_samples 2
#window settings
own_window yes
own_window_transparent no
own_window_colour black
#own_window_type
own_window_hints undecorated, sticky, skip_taskbar, below

#spacing
gap_x 0
gap_y 0
alignment top_left
#colors
color0 ffffff
color1 00FF97
color2 FF6D00
color3 FE003C
color4 FD9C00
color5 FDF700
color6 9101FE
color7 A2FF00
color8 FE003C
color9 000000

TEXT
EOF
count=1
for i in 1.1 1.2  1.3
do

    line1="$line1\${color$count}172.16.$i      "
    line2="$line2 \${color$count}Count : .....\${execi 50 ssh [email protected]72.16.$i \"who\"|wc -l}.. "
    line3="$line3 \${color$count}..\${execi 50 ssh [email protected]$i \"who\"|sed \"s/[    ].*//\" |sort |uniq -c|sort -nr|head -1|tr '\t' ' '|sed 's/ \\{2,\\}/ /g'}"
    line4="$line4 \${color$count}Processes:\${execi 50 ssh [email protected]$i ps -fu user|wc -l}"
    ((count++))
done 
echo $line1 >>$conkyrc
echo $line2 >> $conkyrc
echo $line3 >> $conkyrc
echo $line4 >> $conkyrc
conky -c $conkyrc  &
Enhanced by Zemanta

One thought on “conky script used to monitor server status remotely.”