Meu primeiro Plugin !
Nesta época, trabalhava em uma empresa de óleo e gás, existiam vários canteiros de obra onde acessavam o desktop virtual da Citrix, esta tecnologia estava apresentando muito problema, diversas indisponibilidades durante o dia e todos reclamavam, imagina, empresa composta de engenheiros.
Desenvolvi um script que caso o serviço falhasse, o Nagios reiniciava automaticamente o serviço e tudo voltava ao normal.
Mais tarde o sistema foi atualizado resolvendo o problema.
O Script é confuso mas fantástico.
If CPU equal 100% –> Restart Service responsible.
###### 1º
Install easy plugin “http://gnomux.com.br/nagios/NRPE_Agent_1.2.0_Installer.exe”
notepad C:Program FilesNagios NRPE Agentbinnrpe.cfg
Include lines
allowed_hosts=x.x.x.x (Ip Nagios Server)
command[restartctx]=c:windowsrestartctx.bat
###### 2º
create bath file in c:windowsrestartctx.bat
net stop Citrix Deployment Server
net stop Citrix Deployment Server
exit
###### 3º
Nagios Server
x.x.x.x = Ip remote Server
vi /usr/local/nagios/libexec/check_CpuAndRestart.sh
#!/bin/sh
loadaac=`/usr/local/nagios/libexec/check_nt -H x.x.x.x -v CPULOAD -l 5,80,90 | dos2unix | awk ‘{print $3}’ | cut -d% -f1`
if [ “$loadaac” = “100” ]
then
echo “Service was restarted (CPU 100%)”
/usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c restartctx
exit 2
else
echo “Server Citrix AAC OK”
exit 0
fi
###### 4º
vi /usr/local/nagios/etc/objects/commands.cfg
Include Line
# ‘check_restartservicectx’ command definition
define command{
command_name check_CpuAndRestart
command_line $USER1$/check_CpuAndRestart.sh -H $HOSTADDRESS$
}
###### 5º
vi /usr/local/nagios/etc/objects/services.cfg
# Service definition
define service{
use generic-service ; Name of service template to use
host_name HOSTNAME_SERVER
service_description Citrix Deployment Server
is_volatile 0
check_period 24×7
max_check_attempts 1
normal_check_interval 1
retry_check_interval 1
contact_groups citrix-admins
flap_detection_enabled 0
notification_interval 120
notification_period 24×7
notification_options c,r
check_command check_CpuAndRestart
}
Posted in: Plugin
Leave a Comment (0) ↓