Скрипт для получения статуса сервера
24.12.2009, 05:05
#1
Tech GM
Регистрация: 23.09.2007
Сообщения: 537
Вес репутации: 38
Скрипт для получения статуса сервера
При желании можно написать на любом другом языке, хоть десктоп-виджет для Windows 7, у меня вместо этого conky
Код:
narma@narma ~/.conkyrc.d/wow $ ./status.py wowacadem.org
Down
narma@narma ~/.conkyrc.d/wow $ cat status.py
#!/usr/bin/env python
import socket
import sys
def get_status(server_ip, port=8085):
port = int(port)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(0.25)
status = 'Up'
try:
s.connect((server_ip, port))
except socket.error:
status = 'Down'
else:
status = 'Up'
finally:
s.close()
return status
if __name__ == "__main__":
print get_status(*sys.argv[1:])
24.12.2009, 05:08
#2
BORN TO BE A SPAM BOT.
Регистрация: 15.02.2007
Адрес: Шлюз
Сообщения: 1,547
Вес репутации: 45
Цитата:
Сообщение от
narmo
десктоп-виджет для Windows 7
уиииииии!!!! мальчики кричат девочки хлопают в ладоши) хачу виджет
Цитата:
Сообщение от
version
вишлист что там хотелось бы видеть приветствуется.
мне с лихвой хватит 3х симафоров. хнет морг инет, с возможностью выбора, т.е. кому-то инет не нужен, кому-то морг и т.п.
Можно прикрутить ещё и смену реалм листа, но это излишне (ящитаю).
__________________
Последний раз редактировалось Tseirp, 24.12.2009 в 10:41 .
24.12.2009, 09:41
#3
Admin
Регистрация: 23.08.2007
Сообщения: 980
Вес репутации: 42
Цитата:
Сообщение от
Tseirp
уиииииии!!!! мальчики кричат девочки хлопают в ладоши) хачу виджет
вишлист что там хотелось бы видеть приветствуется.
24.12.2009, 16:45
#4
World GM
Регистрация: 14.03.2009
Сообщения: 267
Вес репутации: 34
Нарма, у тебя конфиг от конки лежал в хоме сразу или сам так сделал? А то я эту прилабуду поставил, мне понравилось, а вот что конфиг в /etc/conky/ не айс..
Хотелось бы баш скрипт для проверки апа О.о
__________________
25.12.2009, 00:44
#5
Tech GM
Регистрация: 23.09.2007
Сообщения: 537
Вес репутации: 38
Цитата:
Сообщение от
Троль
Нарма, у тебя конфиг от конки лежал в хоме сразу или сам так сделал? А то я эту прилабуду поставил, мне понравилось, а вот что конфиг в /etc/conky/ не айс..
Хотелось бы баш скрипт для проверки апа О.о
man conky
Код:
FILES
${sysconfdir}/conky/conky.conf
Default system-wide configuration file. The value of
${sysconfdir} depends on the compile-time options (most likely
/etc).
~/.conkyrc
Default personal configuration file.
но у меня так:
Код:
narma@narma ~/.conkyrc.d $ la
итого 28
drwxr-x--- 4 narma narma 2048 Дек 18 07:25 .
drwxr-xr-x 129 narma narma 8192 Дек 25 11:39 ..
-rw-r--r-- 1 narma narma 443 Дек 18 06:01 conkyrc-center
-rw-r--r-- 1 narma narma 3999 Дек 18 07:25 conkyrc-left
-rwxr-xr-x 1 narma narma 647 Дек 13 2005 emerge-current.sh
-rwxr-xr-x 1 narma narma 765 Дек 14 2005 emerge-progress.sh
-rwxr-xr-x 1 narma narma 1586 Дек 13 2005 emerge-status.sh
-rwxr-xr-x 1 narma narma 212 Дек 18 05:11 lastsync.py
drwxr-xr-x 2 narma narma 2048 Дек 18 05:23 weather
drwxr-xr-x 2 narma narma 2048 Дек 18 06:09 wow
в автозагрузку своей WM поставил conky -c ~/.conkyrc.d/conkyrc-left -y 30
conkyrc-left:
Код:
background yes
use_xft yes # Use Xft?
#xftfont Bitstream Vera Sans Mono:size=8
xftfont Terminus:size=9
xftalpha 1 # Text alpha when using Xft
update_interval 2 # Update interval in seconds
total_run_times 0
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes # Use double buffering (reduces flicker, may not work for everyone)
maximum_width 330
short_units no
draw_shades no
draw_outline no
draw_borders no
stippled_borders 8
border_inner_margin 4
border_width 1
default_color 565656
default_shade_color black
default_outline_color 686868
alignment top_left
gap_x 1
gap_y 1
no_buffers yes
uppercase no
cpu_avg_samples 4
net_avg_samples 5
override_utf8_locale yes
use_spacer right # Add spaces to keep things from moving about? This only affects certain objects.
top_cpu_separate yes
imap ***
TEXT
${offset 10}${image /home/narma/media/pictures/avatars/current}
${offset 160}live.mail: ${imap_unseen} new
${offset 160}WoW: ${execi 30 ~/.conkyrc.d/wow/status.py wowacadem.org}
${voffset 110}
${offset 10}${color slate grey}${time %Z}:${color }${time %a, %e %B %G %H:%M:%S}
${offset 10}${color slate grey}UpTime: ${color }$uptime
${offset 10}${color slate grey}Kern:${color }$kernel
${offset 10}${color slate grey}CPU0:${color } ${cpu cpu1}% | ${freq_g 1}Ghz | ${exec sensors | grep 'Core 0' | awk '{print $3}'}
${offset 10}${color slate grey}CPU1:${color } ${cpu cpu2}% | ${freq_g 2}Ghz | ${exec sensors | grep 'Core 1' | awk '{print $3}'}
${offset 10}${cpugraph cpu1 20,130 000055 ff0000}
${offset 10}${cpugraph cpu2 20,130 000055 ff0000}
${offset 10}${color slate grey}Highest CPU:
${offset 10}${color cc9900} ${top name 1}${top cpu 1}
${offset 10}${color darkgrey} ${top name 2}${top cpu 2}
${offset 10}${color darkgrey} ${top name 3}${top cpu 3}
${offset 10}${color darkgrey} ${top name 4}${top cpu 4}
${offset 10}${color darkgrey} ${top name 5}${top cpu 5}
${offset 10}${color darkgrey} ${top name 6}${top cpu 6}
${offset 10}${color darkgrey} ${top name 7}${top cpu 7}
${offset 10}${color darkgrey} ${top name 8}${top cpu 8}
${offset 10}${color darkgrey} ${top name 9}${top cpu 9}
${offset 10}${color slate grey}Highest MEM:
${offset 10}${color cc9900} ${top_mem name 1}${top_mem mem 1}
${offset 10}${color darkgrey} ${top_mem name 2}${top_mem mem 2}
${offset 10}${color darkgrey} ${top_mem name 3}${top_mem mem 3}
${offset 10}${color darkgrey} ${top_mem name 4}${top_mem mem 4}
${offset 10}${color darkgrey} ${top_mem name 5}${top_mem mem 5}
${offset 10}${color darkgrey} ${top_mem name 6}${top_mem mem 6}
${offset 10}${color darkgrey} ${top_mem name 7}${top_mem mem 7}
${offset 10}${color darkgrey} ${top_mem name 8}${top_mem mem 8}
${offset 10}${color darkgrey} ${top_mem name 9}${top_mem mem 9}
${offset 10}${color slate grey}MEM: ${color } $memperc% $mem/$memmax
${offset 10}${membar 3,100}
${offset 10}${color slate grey}SWAP: ${color }$swapperc% $swap/$swapmax
${offset 10}${swapbar 3,100}
${offset 10}${color slate grey}/: ${color }${fs_used /}/${fs_size /}
${offset 10}${fs_bar 3,100 /}
${offset 10}${color slate grey}/home: ${color }${fs_used /home}/${fs_size /home}
${offset 10}${fs_bar 3,100 /home}
${offset 10}${diskiograph 20,130 000000 ffffff}
${offset 10}${color slate grey}NET: ${color}Up: ${color }${upspeed eth1}${color} Down: ${color }${downspeed eth1}
${offset 10}${upspeedgraph eth1 20,130 000000 ffffff} ${downspeedgraph eth1 20,130 000000 ffffff}
${offset 10}Portage:
${offset 10}${color slate grey}Last Sync: ${execi 300 ~/.conkyrc.d/lastsync.py}
${offset 10}Progress: ${execibar 30 ~/.conkyrc.d/emerge-progress.sh}
${offset 10}Package: ${execi 30 ~/.conkyrc.d/emerge-current.sh}
${offset 10}Status: ${execi 30 ~/.conkyrc.d/emerge-status.sh}${color}
${offset 10}Gentoo security:
${offset 10}${color slate grey}${rss http://www.gentoo.org/rdf/en/glsa-index.rdf?num=5 5 item_titles}${color}
25.12.2009, 01:12
#6
Tech GM
Регистрация: 23.09.2007
Сообщения: 537
Вес репутации: 38
Цитата:
Сообщение от
Троль
Хотелось бы баш скрипт для проверки апа О.о
Код:
nc -z wowacadem.org 8085 && echo "Up" || echo "Down"
Использовать можно прям в conky:
Код:
${execi 10 nc -z wowacadem.org 8085 && echo "Up" || echo "Down"}
Слишком частый таймаут не ставь только
Последний раз редактировалось narmo, 25.12.2009 в 01:39 .
27.12.2009, 13:22
#7
World GM
Регистрация: 14.03.2009
Сообщения: 267
Вес репутации: 34
Цитата:
Сообщение от
narmo
Код:
${execi 10 nc -z wowacadem.org 8085 && echo "Up" || echo "Down"}
Надо наверно поменять Ап и даун местами =)
З.Ы. Разобрался с конфигом конки. Удобно =) Еще бы туда консоль впилить
__________________
28.12.2009, 05:48
#8
World GM
Регистрация: 14.03.2009
Сообщения: 267
Вес репутации: 34
Выложу свой конфиг. Нарма, твой конфиг
1) расчитан на 2 проца
2) не подходит для гнома
Код:
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_hints undecorated,below,skip_taskbar
background yes
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# fiddle with window
use_spacer yes
use_xft yes
# Update interval in seconds
update_interval 3.0
# Minimum size of text area
#minimum_size 500 5
# Draw shades?
draw_shades yes
# Text stuff
draw_outline no # amplifies text if yes
draw_borders no
uppercase no # set to yes if you want all text to be in uppercase
# Stippled borders?
stippled_borders 1
# border margins
border_margin 1
# border width
border_width 1
# Default colors and also border colors, grey90 == #e5e5e5
default_color white
default_shade_color black
default_outline_color white
own_window_colour brown
own_window_transparent yes
# Text alignment, other possible values are commented
#alignment top_left
#alignment top_right
alignment bottom_left
#alignment bottom_right
# Gap between borders of screen and text
gap_x 10
gap_y 170
#MPD
mpd_host localhost
mpd_port 6600
# stuff after 'TEXT' will be formatted on screen
override_utf8_locale yes
xftfont Terminus:size=8
xftalpha 0.8
TEXT
${offset 40}${color slate grey}${time %a, } ${color }${time %e %B %G}
${offset 40}${color slate grey}Time: ${color }${time %H:%M:%S}
${offset 40}${color slate grey}UpTime: ${color }$uptime
${offset 40}${color slate grey}CPU:${color } $cpu% ${acpitemp}C
${offset 40}${cpugraph 20,130 000000 ffffff}
${offset 40}${color slate grey}Load: ${color }$loadavg
${offset 40}${color slate grey}Processes: ${color }$processes
${offset 40}${color slate grey}Running: ${color }$running_processes
${offset 40}${color slate grey}Highest CPU:
${offset 40}${color #ddaa00} ${top name 1}${top_mem cpu 1}
${offset 40}${color lightgrey} ${top name 2}${top cpu 2}
${offset 40}${color lightgrey} ${top name 3}${top cpu 3}
${offset 40}${color lightgrey} ${top name 4}${top cpu 4}
${offset 40}${color slate grey}Highest MEM:
${offset 40}${color #ddaa00} ${top_mem name 1}${top_mem mem 1}
${offset 40}${color lightgrey} ${top_mem name 2}${top_mem mem 2}
${offset 40}${color lightgrey} ${top_mem name 3}${top_mem mem 3}
${offset 40}${color lightgrey} ${top_mem name 4}${top_mem mem 4}
${offset 40}${color slate grey}MEM: ${color } $memperc% $mem/$memmax
${offset 40}${membar 3,100}
${offset 40}${color slate grey}SWAP: ${color }$swapperc% $swap/$swapmax
${offset 40}${swapbar 3,100}
${offset 40}${color slate grey}ROOT: ${color }${fs_free /}/${fs_size /}
${offset 40}${fs_bar 3,100 /}
${offset 40}${color slate grey}NET:
${offset 40}${color}Up: ${color }${upspeed eth0} k/s
${offset 40}${upspeedgraph eth0 20,130 000000 ffffff}
${offset 40}${color}Down: ${color }${downspeed eth0}k/s${color}
${offset 40}${downspeedgraph eth0 20,130 000000 ffffff}
${offset 40}${color slate grey}MPD:${offset 10}${color slate grey}${mpd_artist}${color}-${mpd_title}# ${color slate grey}Elspsed: ${color}${mpd_elapsed}
${offset 40}${color slate grey}WoWAcadem Local: ${execi 10 nc -z 10.168.31.16:8085 && echo "Down" || echo "Up"}
__________________
30.12.2009, 02:45
#9
Tech GM
Регистрация: 23.09.2007
Сообщения: 537
Вес репутации: 38
Цитата:
Сообщение от
Троль
Надо наверно поменять Ап и даун местами =)
З.Ы. Разобрался с конфигом конки. Удобно =) Еще бы туда консоль впилить
Нифига не надо o_O
nc -z localhost <неработающий порт> проверь своим скриптом.
30.12.2009, 03:59
#10
World GM
Регистрация: 14.03.2009
Сообщения: 267
Вес репутации: 34
Цитата:
Сообщение от
narmo
Нифига не надо o_O
nc -z localhost <неработающий порт> проверь своим скриптом.
Риальне.. Вопрос: какой порт у хомяковского локала используется для логона? явно не тот который написан у тебя. Я бы nmap`ом прошелся, но боюсь зобанят
__________________
Опции темы
Опции просмотра
Линейный вид
Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения
HTML код Выкл.
Часовой пояс GMT +1, время: 00:05 .