The home of Tobias Nirschl

frontpage arrow howtos arrow Servermonitoring per Conky
Freitag, 10 September 2010
Mainmenue
frontpage
about this site
blog
Motorrad
travels
howtos
gallery
guestbook
contact
Language
DeutschEnglish
 
 
new Article
 
 
Statistik
Heute: 0
Gestern: 15
Monat: 107
Gesamt: 10232
Bots heute: 4
Statistik seit: 2008-08-08

PayPal Donation

If you like my work, please donate for more free projects!

 
 
Weblinks
 
 
 

Skype Me

whyflyby1

 
 
   
     
 
 
Servermonitoring per Conky
Dienstag, 09 September 2008
Sorry, no translation available.

Servermonitoring per ConkyNach dem Servercrash am Wochenende und der anschliessenden Installationsorgie habe ich mir überlegt wie man auf dem Desktop einfach seine Serverstatus anzeigen kann.

Da ich sowieso schon Conky auf meinem Desktop einsetze, überlegte ich mir wie das am einfachsten zu Handhaben ist.

Ablauf ist wie folgt:

Per Ping wird überprüft ob der Server online ist. Je nach Status wird eine Datei mit der IP/Hostname angelegt und das ganze von Conky dann optisch dargestellt. Dazu kann man die History derServerstatus im Verzeichnis "/.status/history" je IP/Hostname verfolgen.

Meine .conkyrc:

 background yes
use_xft yes
xftfont Bitstream Vera Sans Mono:size=9
xftalpha 0.8
update_interval 5
total_run_times 0
own_window yes
own_window_type normal
own_window_transparent yes
own_window_colour black
own_window_hints undecorated,skip_pager,skip_taskbar
double_buffer yes
minimum_size 260 5
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
stippled_borders 0
border_margin 4
border_width 0
default_color white
default_shade_color black
default_outline_color black
#alignment top_left
alignment bottom_right
gap_x 12
gap_y 12
no_buffers yes
uppercase no
cpu_avg_samples 1
net_avg_samples 1
override_utf8_locale no
use_spacer yes
#mpd_host localhost
#mpd_portPort 6060
#mpd_password

TEXT
${font Verdana:style=Bold:size=16}${color #009bf9}${alignc}${time %a %d. %b %k:%M}
$font$color${alignc}$kernel
${color #009bf9}$stippled_hr
${color lightgrey}Processes:$color $processes  ${color grey}Running:$color $running_processes ${color lightgrey}Up:$color $uptime
${color #009bf9}CPU: $cpu% ${cpubar}
${cpugraph 16,300 009bf9 ffffff}
$font${color #009bf9}RAM: $mem/$memmax - $memperc% ${membar}
${color lightgrey}Swap: $swap/$swapmax - $swapperc% ${swapbar}
$font${color #009bf9}Connections${alignr}${color #009bf9}In:$color ${tcp_portmon 1 32767 count}  ${color #009bf9}Out:$color ${tcp_portmon 32768 61000 count}   ${color #009bf9}ALL:$color ${tcp_portmon 1 65535 count}
${color lightgrey}$stippled_hr
${color lightgrey}Down:$color ${downspeed eth0} k/s${color lightgrey} ${offset 80}Up:$color ${upspeed eth0} k/s
${downspeedgraph eth0 16,120 009bf9 ffffff} ${offset 40} ${upspeedgraph eth0 16,120 009bf9 ffffff}
${color #009bf9}LAN-IP:$color ${addr eth0}
${color #009bf9}WAN-IP:$color ${execi 7200 ~/.conky/publicip.sh}
${color lightgrey}$stippled_hr
${color #009bf9}Serverstatus$color
${color #98c2c7}<Server1>:   ${execi 1800 ~/.conky/ping.sh 1.2.3.4 "up" "down"}${if_existing /home/<USER>/.
conky/status/1.2.3.4.up}${color green}Server up$else${color red}Server down$endif
${color #98c2c7}<Server2>:   ${execi
1800 ~/.conky/ping.sh 82.211.8.97 "up" "down"}${if_existing /home/<USER>/.conky/status/82.211.8.97.up}${color green}Server up$else${color red}Server down$endif
${color #98c2c7}<NAS>: ${execi
1800 ~/.conky/ping.sh 192.168.0.1 "up" "down"}${if_existing /home/<USER>/.conky/status/192.168.0.1.up}${color green}Server up$else${color red}Server down$endif
${color #98c2c7}<NAS2>:     ${execi
1800 ~/.conky/silentping.sh 192.168.0.2 "up" "down"}${if_existing /home/<USER>/.conky/status/192.168.0.2.up}${color green}Server up$else${color red}Server down$endif
${color lightgrey}$stippled_hr
${color #009bf9}Festplattenbelegung
${color lightgrey}Root:   ${fs_used /}/ ${fs_size /}   ${fs_bar /}
${color lightgrey}Home:   ${fs_used /home}/ ${fs_size /home}  ${fs_bar /home}
${color lightgrey}Vista:  ${fs_used /media/hda1}/ ${fs_size /media/hda1}   ${fs_bar /media/hda1}
${color lightgrey}NFS  : ${fs_used /nfs_export}/ ${fs_size /nfs_export}   ${fs_bar /
nfs_export}
${color lightgrey}$stippled_hr

 

Dazu passend müssen im Verzeichnis ".conky" de beiden Dateien "publicip.sh" und "ping.sh" angelegt werden

publicip.sh

 #!/bin/bash
# eigene öffentliche ip anzeigen

wget http://checkip.dyndns.org/ -q -O - |
grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'

ping.sh

 #!/bin/bash
#CHDATE=`date +%F-%R`
echo $CHDATE;
#if  [["$#" != "3"]] ; then echo "Usage: silentping IP onsign offsign"; fi
# Get the status
STATUS="$(ping $1 -c 1 -w 2 | grep packets | sed "s/^.*tted, //;s/1/$2/;s/0/$3/;s/ re.*$//")"
# Create the directory
if [ ! -d ~/.conky/status ]; then mkdir ~/.conky/status; fi
if [ ! -d ~/.conky/status/history ]; then mkdir ~/.conky/status/history; fi
if [ ! -d ~/.conky/status/history/$1 ]; then mkdir ~/.conky/status/history/$1; fi
# Remove the old status
if [ "$STATUS" == "$2" ]; then
  if [ -f ~/.conky/status/$1.$3 ]; then mv ~/.conky/status/$1.$3 ~/.conky/status/history/$1/$1.$2.`date +%F-%R`; fi
else
  if [ -f ~/.conky/status/$1.$2 ]; then mv ~/.conky/status/$1.$2 ~/.conky/status/history/$1/$1.$3.`date +%F-%R`; fi
fi
# Create the new status file
if [ ! -f ~/.conky/status/$1.$STATUS ]; then touch ~/.conky/status/$1.$STATUS; fi


 


Tags:  Howtos Linuxhowtos Servermonitoring per Conky
 
< Prev   Next >
Bannerwerbung
Advertisement

 

© 2010 The home of Tobias Nirschl
powered by Nirschl-Online.NET.