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:
#         USAGE:  ./ 
#   DESCRIPTION:  Start conky to display who on all the servers.
#       OPTIONS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Amit Agarwal (aka),
#       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' ' ')
cat <$conkyrc
background no
alignment top_right
update_interval 50
short_units yes

#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_hints undecorated, sticky, skip_taskbar, below

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

for i in 1.1 1.2  1.3

    line1="$line1\${color$count}172.16.$i      "
    line2="$line2 \${color$count}Count : .....\${execi 50 ssh user@172.16.$i \"who\"|wc -l}.. "
    line3="$line3 \${color$count}..\${execi 50 ssh user@172.16.$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 user@172.16.$i ps -fu user|wc -l}"
echo $line1 >>$conkyrc
echo $line2 >> $conkyrc
echo $line3 >> $conkyrc
echo $line4 >> $conkyrc
conky -c $conkyrc  &
Enhanced by Zemanta

About Amit Agarwal

1 Trackback on “conky script used to monitor server status remotely.”