Скрипты в Nagios

Проблемы установки, настройки и работы Правильной Операционной Системы

Модератор: terminus

Правила форума
Убедительная просьба юзать теги [cоde] при оформлении листингов.
Сообщения не оформленные должным образом имеют все шансы быть незамеченными.
Аватара пользователя
kron
ефрейтор
Сообщения: 64
Зарегистрирован: 2008-10-07 13:02:36

Скрипты в Nagios

Непрочитанное сообщение kron » 2009-10-01 20:45:14

Возникла такая трабла, поднял и настроил Nagios, все ворк файн, а тут решил еще и самбу мониторить, так как в стандартных плагинах check_smb не имееться, взял башевский скрипт с сайта и сунул в папочку с плагинами, дал права нагиосу, разрешил выполнение, но как-то не пашет.

Код: Выделить всё

SAMBA   CRITICAL	10-01-2009 21:33:37	0d 22h 51m 49s	4/4	(Return code of 127 is out of bounds - plugin may be missing) 
Собственно добавление в command.cfg

Код: Выделить всё

# 'check_smb' command defination
define command{
        command_name    check_smb
        command_line    $USER1$/check_smb -H $HOSTADDRESS$
        }
service.cfg

Код: Выделить всё

#SMB Definition BDC
define service{    
use                     generic-service
host_name               bdc.c-es.ru    
service_description     SAMBA          
is_volatile             0              
check_period            24x7           
max_check_attempts      4              
normal_check_interval   1              
retry_check_interval    1              
contact_groups          domain-admins  
notification_interval   120            
notification_period     24x7           
notification_options    c,r            
check_command           check_smb      
}
check_smb

Код: Выделить всё

#!/bin/bash                                 
#                                           
#    Program : check_smb                    ls -l
total 1612
-r-xr-xr-x  1 nagios  wheel   83096 Sep 29 17:27 check_apt
-r-xr-xr-x  1 nagios  wheel    2285 Sep 29 17:27 check_breeze
-r-xr-xr-x  1 nagios  wheel   30128 Sep 29 17:27 check_by_ssh
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_clamd -> check_tcp
-r-xr-xr-x  1 nagios  wheel   18692 Sep 29 17:27 check_cluster           
-r-sr-xr-x  1 nagios  wheel   30252 Sep 29 17:27 check_dhcp              
-r-xr-xr-x  1 nagios  wheel   27120 Sep 29 17:27 check_dig               
-r-xr-xr-x  1 nagios  wheel   96772 Sep 29 17:27 check_disk              
-r-xr-xr-x  1 nagios  wheel    8168 Sep 29 17:27 check_disk_smb          
-r-xr-xr-x  1 nagios  wheel   30256 Sep 29 17:27 check_dns               
-r-xr-xr-x  1 nagios  wheel   11860 Sep 29 17:27 check_dummy             
-r-xr-xr-x  1 nagios  wheel    3148 Sep 29 17:27 check_file_age          
-r-xr-xr-x  1 nagios  wheel    6400 Sep 29 17:27 check_flexlm            
-r-xr-xr-x  1 nagios  wheel   27888 Sep 29 17:27 check_fping             
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_ftp -> check_tcp  
-r-xr-xr-x  1 nagios  wheel   27056 Sep 29 17:27 check_hpjd              
-r-xr-xr-x  1 nagios  wheel  130180 Sep 29 17:27 check_http              
-r-sr-xr-x  1 nagios  wheel   35200 Sep 29 17:27 check_icmp              
-r-xr-xr-x  1 nagios  wheel   15315 Sep 29 17:27 check_ifoperstatus      
-r-xr-xr-x  1 nagios  wheel   12858 Sep 29 17:27 check_ifstatus          
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_imap -> check_tcp 
-r-xr-xr-x  1 nagios  wheel    7453 Sep 29 17:27 check_ircd              
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_jabber -> check_tcp
-r-xr-xr-x  1 nagios  wheel   25740 Sep 29 17:27 check_ldap               
lrwxr-xr-x  1 root    wheel      10 Sep 29 17:27 check_ldaps -> check_ldap
-r-xr-xr-x  1 nagios  wheel   22860 Sep 29 17:27 check_load               
-r-xr-xr-x  1 nagios  wheel    6082 Sep 29 17:27 check_log                
-r-xr-xr-x  1 nagios  wheel   20372 Sep 29 17:27 check_mailq              
-r-xr-xr-x  1 nagios  wheel   22852 Sep 29 17:27 check_mrtg               
-r-xr-xr-x  1 nagios  wheel   21156 Sep 29 17:27 check_mrtgtraf           
-r-xr-xr-x  1 nagios  wheel   25740 Sep 29 17:27 check_mysql              
-r-xr-xr-x  1 nagios  wheel   24012 Sep 29 17:27 check_mysql_query        
-r-xr-xr-x  1 nagios  wheel   23020 Sep 29 17:27 check_nagios             
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_nntp -> check_tcp  
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_nntps -> check_tcp 
-r-xr-xr-x  1 nagios  wheel   32108 Sep 29 17:27 check_nt                 
-r-xr-xr-x  1 nagios  wheel   31404 Sep 29 17:27 check_ntp                
-r-xr-xr-x  1 nagios  wheel   30156 Sep 29 17:27 check_ntp_peer           
-r-xr-xr-x  1 nagios  wheel   27436 Sep 29 17:27 check_ntp_time
-r-xr-xr-x  1 nagios  wheel   44332 Sep 29 17:27 check_nwstat
-r-xr-xr-x  1 nagios  wheel    8366 Sep 29 17:27 check_oracle
-r-xr-xr-x  1 nagios  wheel   26092 Sep 29 17:27 check_overcr
-r-xr-xr-x  1 nagios  wheel   32848 Sep 29 17:27 check_ping
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_pop -> check_tcp
-r-xr-xr-x  1 nagios  wheel   90804 Sep 29 17:27 check_procs
-r-xr-xr-x  1 nagios  wheel   24908 Sep 29 17:27 check_real
-r-xr-xr-x  1 nagios  wheel    9712 Sep 29 17:27 check_rpc
-r-xr-xr-x  1 nagios  wheel    1176 Sep 29 17:27 check_sensors
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_simap -> check_tcp
-rwxr-xr-x  1 nagios  wheel    2633 Oct  1 10:02 check_smb.sh
-r-xr-xr-x  1 nagios  wheel  100388 Sep 29 17:27 check_smtp
-r-xr-xr-x  1 nagios  wheel  126104 Sep 29 17:27 check_snmp
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_spop -> check_tcp
-r-xr-xr-x  1 nagios  wheel   22924 Sep 29 17:27 check_ssh
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_ssmtp -> check_tcp
-r-xr-xr-x  1 nagios  wheel   24780 Sep 29 17:27 check_swap
-r-xr-xr-x  1 nagios  wheel   32728 Sep 29 17:27 check_tcp
-r-xr-xr-x  1 nagios  wheel   24012 Sep 29 17:27 check_time
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_udp -> check_tcp
-r-xr-xr-x  1 nagios  wheel   29100 Sep 29 17:27 check_ups
-r-xr-xr-x  1 nagios  wheel   21484 Sep 29 17:27 check_users
-r-xr-xr-x  1 nagios  wheel    3024 Sep 29 17:27 check_wave
-r-xr-xr-x  1 nagios  wheel   23212 Sep 29 17:27 negate
-r-xr-xr-x  1 nagios  wheel   21740 Sep 29 17:27 urlize
-r-xr-xr-x  1 nagios  wheel    2075 Sep 29 17:27 utils.pm
-r-xr-xr-x  1 nagios  wheel     880 Sep 29 17:27 utils.sh

#            :                              
#     Author : Cal Evans <cal@calevans.com> 
#            :                              
#    Purpose : Nagios plugin to return the number of users logged into a smb
#            : server and the number of files open.                         
#            :                                                              
# Parameters : --help                                                       
#            : --version                                                    
#            :                                                              
#    Returns : Standard Nagios status_* codes as defined in utils.sh        
#            :                                                              
#      Notes :                                                              
#============:==============================================================
#        1.0 : 06/27/2002                                                   
#            : Initial coding                                               
#            :                                                              
#        1.1 : 06/28/2002                                                   
#            : Re-wrote the user counter to match the file-lock counter.    
#            :                                                              

#
# Shamelessly stolen from other Nagios plugins.
#                                              
PROGNAME=`basename $0`                         
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION=`echo '$Revision: 71 $' | sed -e 's/[^0-9.]//g'` 


. $PROGPATH/utils.sh

print_usage() {
        echo "Usage: $PROGNAME --help"
        echo "Usage: $PROGNAME --version"
}                                        

print_help() {
        print_revision $PROGNAME $REVISION
        echo ""                           
        print_usage                       
        echo ""                           
        echo "Samba status check."        
        echo ""                           
        support                           
}                                         

# No command line arguments are required for this script. We accept only 2,
# --help and --version.  If more than 1 is passed in then we have an error 
# condition.                                                               

if [ $# -gt 1 ]; then
        print_usage  
        exit $STATE_UNKNOWN
fi                         


#
# If we have arguments, process them.
#                                    
exitstatus=$STATE_WARNING #default   
while test -n "$1"; do               
        case "$1" in                 
                --help)              
                        print_help   
                        exit $STATE_OK
                        ;;            
                -h)                   
                        print_help    
                        exit $STATE_OK
                        ;;            
                --version)            
                        print_revision $PROGNAME $REVISION
                        exit $STATE_OK                    
                        ;;                                
                -V)                                       
                        print_revision $PROGNAME $REVISION
                        exit $STATE_OK                    
                        ;;                                

                *)
                        echo "Unknown argument: $1"
                        print_usage
                        exit $STATE_UNKNOWN
                        ;;
        esac
        shift
done

#
# No arguments.  Let's kick this pig.
#
total_users=$(smbstatus -b | grep "^[0-9]" | wc -l)

#
# Ok, now let's grab a count of the files.
#
total_files=$(smbstatus | grep "^[0-9]" | wc -l)

#
# now for the dismount.
#
echo "Total Users:$total_users Total Files:$total_files"

#
# let Nagios know that everything is ok.
#
exit $STATE_OK
Есть подозрение что нерабочий сам скрипт, потому как

Код: Выделить всё

./check_smb -H localhost     
./check_smb: Command not found.
%./check_smb.sh -h localhost   
./check_smb.sh: Command not found.

Ну и ls -l скриптов

Код: Выделить всё

ls -l
total 1612
-r-xr-xr-x  1 nagios  wheel   83096 Sep 29 17:27 check_apt
-r-xr-xr-x  1 nagios  wheel    2285 Sep 29 17:27 check_breeze
-r-xr-xr-x  1 nagios  wheel   30128 Sep 29 17:27 check_by_ssh
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_clamd -> check_tcp
-r-xr-xr-x  1 nagios  wheel   18692 Sep 29 17:27 check_cluster           
-r-sr-xr-x  1 nagios  wheel   30252 Sep 29 17:27 check_dhcp              
-r-xr-xr-x  1 nagios  wheel   27120 Sep 29 17:27 check_dig               
-r-xr-xr-x  1 nagios  wheel   96772 Sep 29 17:27 check_disk              
-r-xr-xr-x  1 nagios  wheel    8168 Sep 29 17:27 check_disk_smb          
-r-xr-xr-x  1 nagios  wheel   30256 Sep 29 17:27 check_dns               
-r-xr-xr-x  1 nagios  wheel   11860 Sep 29 17:27 check_dummy             
-r-xr-xr-x  1 nagios  wheel    3148 Sep 29 17:27 check_file_age          
-r-xr-xr-x  1 nagios  wheel    6400 Sep 29 17:27 check_flexlm            
-r-xr-xr-x  1 nagios  wheel   27888 Sep 29 17:27 check_fping             
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_ftp -> check_tcp  
-r-xr-xr-x  1 nagios  wheel   27056 Sep 29 17:27 check_hpjd              
-r-xr-xr-x  1 nagios  wheel  130180 Sep 29 17:27 check_http              
-r-sr-xr-x  1 nagios  wheel   35200 Sep 29 17:27 check_icmp              
-r-xr-xr-x  1 nagios  wheel   15315 Sep 29 17:27 check_ifoperstatus      
-r-xr-xr-x  1 nagios  wheel   12858 Sep 29 17:27 check_ifstatus          
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_imap -> check_tcp 
-r-xr-xr-x  1 nagios  wheel    7453 Sep 29 17:27 check_ircd              
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_jabber -> check_tcp
-r-xr-xr-x  1 nagios  wheel   25740 Sep 29 17:27 check_ldap               
lrwxr-xr-x  1 root    wheel      10 Sep 29 17:27 check_ldaps -> check_ldap
-r-xr-xr-x  1 nagios  wheel   22860 Sep 29 17:27 check_load               
-r-xr-xr-x  1 nagios  wheel    6082 Sep 29 17:27 check_log                
-r-xr-xr-x  1 nagios  wheel   20372 Sep 29 17:27 check_mailq              
-r-xr-xr-x  1 nagios  wheel   22852 Sep 29 17:27 check_mrtg               
-r-xr-xr-x  1 nagios  wheel   21156 Sep 29 17:27 check_mrtgtraf           
-r-xr-xr-x  1 nagios  wheel   25740 Sep 29 17:27 check_mysql              
-r-xr-xr-x  1 nagios  wheel   24012 Sep 29 17:27 check_mysql_query        
-r-xr-xr-x  1 nagios  wheel   23020 Sep 29 17:27 check_nagios             
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_nntp -> check_tcp  
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_nntps -> check_tcp 
-r-xr-xr-x  1 nagios  wheel   32108 Sep 29 17:27 check_nt                 
-r-xr-xr-x  1 nagios  wheel   31404 Sep 29 17:27 check_ntp                
-r-xr-xr-x  1 nagios  wheel   30156 Sep 29 17:27 check_ntp_peer           
-r-xr-xr-x  1 nagios  wheel   27436 Sep 29 17:27 check_ntp_time
-r-xr-xr-x  1 nagios  wheel   44332 Sep 29 17:27 check_nwstat
-r-xr-xr-x  1 nagios  wheel    8366 Sep 29 17:27 check_oracle
-r-xr-xr-x  1 nagios  wheel   26092 Sep 29 17:27 check_overcr
-r-xr-xr-x  1 nagios  wheel   32848 Sep 29 17:27 check_ping
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_pop -> check_tcp
-r-xr-xr-x  1 nagios  wheel   90804 Sep 29 17:27 check_procs
-r-xr-xr-x  1 nagios  wheel   24908 Sep 29 17:27 check_real
-r-xr-xr-x  1 nagios  wheel    9712 Sep 29 17:27 check_rpc
-r-xr-xr-x  1 nagios  wheel    1176 Sep 29 17:27 check_sensors
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_simap -> check_tcp
-rwxr-xr-x  1 nagios  wheel    2633 Oct  1 10:02 check_smb.sh
-r-xr-xr-x  1 nagios  wheel  100388 Sep 29 17:27 check_smtp
-r-xr-xr-x  1 nagios  wheel  126104 Sep 29 17:27 check_snmp
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_spop -> check_tcp
-r-xr-xr-x  1 nagios  wheel   22924 Sep 29 17:27 check_ssh
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_ssmtp -> check_tcp
-r-xr-xr-x  1 nagios  wheel   24780 Sep 29 17:27 check_swap
-r-xr-xr-x  1 nagios  wheel   32728 Sep 29 17:27 check_tcp
-r-xr-xr-x  1 nagios  wheel   24012 Sep 29 17:27 check_time
lrwxr-xr-x  1 root    wheel       9 Sep 29 17:27 check_udp -> check_tcp
-r-xr-xr-x  1 nagios  wheel   29100 Sep 29 17:27 check_ups
-r-xr-xr-x  1 nagios  wheel   21484 Sep 29 17:27 check_users
-r-xr-xr-x  1 nagios  wheel    3024 Sep 29 17:27 check_wave
-r-xr-xr-x  1 nagios  wheel   23212 Sep 29 17:27 negate
-r-xr-xr-x  1 nagios  wheel   21740 Sep 29 17:27 urlize
-r-xr-xr-x  1 nagios  wheel    2075 Sep 29 17:27 utils.pm
-r-xr-xr-x  1 nagios  wheel     880 Sep 29 17:27 utils.sh
Что я забыл куда прописать или что сделать? :cz2:
Тормоза долго не живут, они стираются.

Хостинговая компания Host-Food.ru
Хостинг HostFood.ru
 

Услуги хостинговой компании Host-Food.ru

Хостинг HostFood.ru

Тарифы на хостинг в России, от 12 рублей: https://www.host-food.ru/tariffs/hosting/
Тарифы на виртуальные сервера (VPS/VDS/KVM) в РФ, от 189 руб.: https://www.host-food.ru/tariffs/virtualny-server-vps/
Выделенные сервера, Россия, Москва, от 2000 рублей (HP Proliant G5, Intel Xeon E5430 (2.66GHz, Quad-Core, 12Mb), 8Gb RAM, 2x300Gb SAS HDD, P400i, 512Mb, BBU):
https://www.host-food.ru/tariffs/vydelennyi-server-ds/
Недорогие домены в популярных зонах: https://www.host-food.ru/domains/

Аватара пользователя
kron
ефрейтор
Сообщения: 64
Зарегистрирован: 2008-10-07 13:02:36

Re: Скрипты в Nagios

Непрочитанное сообщение kron » 2009-10-01 20:54:29

Вопрос снят #!/bin/sh
и /usr/bin/sed

Незаметил что линуксовый скрипт
Тормоза долго не живут, они стираются.