Ir ao conteúdo

Shell script ( conky linux )


Ir à solução Resolvido por Henrique - RJ,

Posts recomendados

Postado

Não estudo qualquer tipo de programação, apenas preciso de um simples script para fazer com que o monitor de hardware Conky me alerte quando algum item que monitora passar do estabelecido como normal.

 

O script que tenho ativo no conky é este abaixo.

 

# Conky, a system monitor, based on torsmo
#
# Any original torsmo code is licensed under the BSD license
#
# All code written since the fork of torsmo is licensed under the GPL
#
# Please see COPYING for details
#
# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
# Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

alignment no
background no
border_width 1
cpu_avg_samples 2
default_color black
default_outline_color black
default_shade_color black
draw_borders no
draw_graph_borders yes
draw_outline no
draw_shades no
use_xft yes
xftfont DejaVu Sans Mono:size=10
gap_x 770
gap_y 160
minimum_size 5 5
net_avg_samples 2
no_buffers yes
out_to_console no
out_to_stderr no
extra_newline no
own_window no
own_window_class Conky
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer none
show_graph_scale no
show_graph_range no

TEXT
Conky
$hr
${color black}Uptime:$color $uptime
${color black}Frequency (in MHz):$color $freq
${color black}Frequency (in GHz):$color $freq_g
${color black}RAM:$color $mem/$memmax - $memperc% ${membar 4}
${color black}Swap:$color $swap/$swapmax - $swapperc% ${swapbar 4}
${color black}CPU Usage:$color $cpu% ${cpubar 4}
${color black}CPU Fan:$color ${hwmon 1 fan 1}rpm Fan:$color ${hwmon 1 fan 2}rpm
$hr
${color black}Voltages:$color
Vcore:${hwmon 1 vol 0}V NB:${hwmon 1 vol 1}V +3,3V:${hwmon 1 vol 2}V
+5,0V:${hwmon 1 vol 3}V +12,0V:${hwmon 1 vol 4}V DRAM:${hwmon 1 vol 5}V
LDT:${hwmon 1 vol 6}V 3VSB:${hwmon 1 vol 7}V Vbat:${hwmon 1 vol 8}V
$hr
${color black}Temperatures:
CPU:$color ${hwmon 1 temp 1C NB:$color ${hwmon 1 temp 2C SB:$color ${hwmon 1 temp 3C
HDD:$color ${execi 5 hddtemp /dev/sda}
$hr
${color black}File systems:
/ $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
${color black}Networking:
Up:$color ${upspeed eth0} ${color black} - Down:$color ${downspeed eth0}
$hr
${color black}Name PID CPU%
${color black} ${top name 1} ${top pid 1} ${top cpu 1}
${color black} ${top name 2} ${top pid 2} ${top cpu 2}
${color black} ${top name 3} ${top pid 3} ${top cpu 3}
${color black} ${top name 4} ${top pid 4} ${top cpu 4}

 

O script que estou tentando incluir é este a seguir só que ele abre o zenity que é o alerta mas não respeita a margem de acionamento que é de 1,1 a 1,3 Volts abrindo o alarme com qualquer tensão e até sem nenhuma.

 

Vcore:${hwmon 1 vol 0}V ${if_match ${hwmon 1 vol 0} < 1,1 > 1,3} ${exec zenity --warning --text "Tensão do Vcore anormal"} ${endif} ${endif}

 

Tentei várias combinações diferentes mas não tive sucesso. Em alguma dessas combinações o conky até deixava de funcionar.

 

.

  • Solução
Postado

Consegui fazer com que o script funcionasse sem problemas. Apenas não pude usar valores fracionados ( só inteiros ) como no caso das tensões o que é um problema pois acima de 5% de variação dá defeito no sistema.

 

# Conky, a system monitor, based on torsmo
#
# Any original torsmo code is licensed under the BSD license
#
# All code written since the fork of torsmo is licensed under the GPL
#
# Please see COPYING for details
#
# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
# Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

alignment no
background no
border_width 1
cpu_avg_samples 2
default_color black
default_outline_color black
default_shade_color black
draw_borders no
draw_graph_borders yes
draw_outline no
draw_shades no
use_xft yes
xftfont DejaVu Sans Mono:size=10
gap_x 770
gap_y 160
minimum_size 5 5
net_avg_samples 2
no_buffers yes
out_to_console no
out_to_stderr no
extra_newline no
own_window no
own_window_class Conky
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer none
show_graph_scale no
show_graph_range no

TEXT
Conky
$hr
${color black}Uptime:$color $uptime
${color black}Frequency (in MHz):$color $freq
${color black}Frequency (in GHz):$color $freq_g
${color black}RAM:$color $mem/$memmax - $memperc% ${membar 4}
${color black}Swap:$color $swap/$swapmax - $swapperc% ${swapbar 4}
${color black}CPU Usage:$color $cpu% ${cpubar 4}
${color black}CPU Fan:$color ${hwmon 1 fan 1}rpm ${if_match ${hwmon 1 fan 1} < 1000} ${exec zenity --warning --text "CPU Fan abaixo do normal"} ${endif} Chassis Fan:$color ${hwmon 1 fan 2}rpm ${if_match ${hwmon 1 fan 2} < 1000} ${exec zenity --warning --text "Chassis Fan abaixo do normal"} ${endif}
$hr
${color black}Voltages:$color 
Vcore:${hwmon 1 vol 0}V ${if_match ${hwmon 1 vol 0} < 1} ${exec zenity --warning --text "Vcore abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 0} > 1} ${exec zenity --warning --text "Vcore acima do normal"} ${endif} NB:${hwmon 1 vol 1}V   ${if_match ${hwmon 1 vol 1} < 1} ${exec zenity --warning --text "NB abaixo do normal"} ${endif}  ${if_match ${hwmon 1 vol 1} > 1} ${exec zenity --warning --text "NB acima do normal"} ${endif}  +3,3V:${hwmon 1 vol 2}V  ${if_match ${hwmon 1 vol 2} < 3} ${exec zenity --warning --text "+3,3V abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 2} > 3} ${exec zenity --warning --text "+3,3V acima do normal"} ${endif} 
+5,0V:${hwmon 1 vol 3}V ${if_match ${hwmon 1 vol 3} < 3} ${exec zenity --warning --text "+5,0V abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 3} > 3} ${exec zenity --warning --text "+5,0V acima do normal"} ${endif} +12,0V:${hwmon 1 vol 4}V ${if_match ${hwmon 1 vol 4} < 3} ${exec zenity --warning --text "+12,0V abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 4} > 3} ${exec zenity --warning --text "+12,0V acima do normal"} ${endif} DRAM:${hwmon 1 vol 5}V ${if_match ${hwmon 1 vol 5} < 1} ${exec zenity --warning --text "DRAM abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 5} > 2} ${exec zenity --warning --text "DRAM acima do normal"} ${endif}
LDT:${hwmon 1 vol 6}V ${if_match ${hwmon 1 vol 6} < 1} ${exec zenity --warning --text "LDT abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 6} > 1} ${exec zenity --warning --text "LDT acima do normal"} ${endif}   3VSB:${hwmon 1 vol 7}V  ${if_match ${hwmon 1 vol 7} < 2} ${exec zenity --warning --text "3VSB abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 7} > 3} ${exec zenity --warning --text "3VSB acima do normal"} ${endif}  Vbat:${hwmon 1 vol 8}V ${if_match ${hwmon 1 vol 8} < 3} ${exec zenity --warning --text "Vbat abaixo do normal"} ${endif} ${if_match ${hwmon 1 vol 8} > 3} ${exec zenity --warning --text "Vbat acima do normal"} ${endif}
$hr
${color black}Temperatures:
CPU:$color ${hwmon 1 temp 1}°C ${if_match ${hwmon 1 temp 1} > 64} ${exec zenity --warning --text "CPU Temp acima do normal"} ${endif}  NB:$color ${hwmon 1 temp 2}°C   SB:$color ${hwmon 1 temp 3}°C
HDD:$color ${execi 5 hddtemp /dev/sda}
$hr
${color black}File systems:
 / $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
${color black}Networking:
Up:$color ${upspeed eth0} ${color black} - Down:$color ${downspeed eth0}
$hr
${color black}Name               PID   CPU%   
${color black} ${top name 1} ${top pid 1} ${top cpu 1} 
${color black} ${top name 2} ${top pid 2} ${top cpu 2} 
${color black} ${top name 3} ${top pid 3} ${top cpu 3} 
${color black} ${top name 4} ${top pid 4} ${top cpu 4} 

 

Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Mostrar mais  

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

Mostrar mais  
×
×
  • Criar novo...