Redémarrage auto des services windows avec zabbix.

Créer un template : Tmp_service_Auto_Restart

Dans le template créer l’Item

Item : Service_Automatic_Restart

Dans la clé Key, mettre

services[automatic, stopped, "gupdate,RemoteRegistry,SysmonLog,CIMnotify,sppsvc,clr_optimization_v4.0.30319_64,clr_optimization_v4.0.30319_32"]

Liste des services non concerné entre «  » séparé par ,

Créer un trigger sur l’item

Trigger : TRG_services_automatic_stopped

Créer une Action (Configuration Action)
Action: TRG_services_automatic_stopped

Créer une opération (onglet opération)

Ajouter une étape (New step, bon sur l’exemple elle existe déjà)

Ne pas oublier Update à la fin de la création de l’étape.

Et Update de l’ACTION.

Sur les serveurs windows :

Voici les scripts à mettre sur les serveurs sur lesquels on veut redémarrer automatiquement les services qui tombent.

Il faut créer un dossier c:\temp\

c:\Batchs\Start_service_auto.bat

@echo off
cls
:: EF le 16/05/2012
:: MV le 17/01/2017 ajout du check for permissions, windows 2012 r2

setlocal enableDelayedExpansion

:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
 echo Requesting administrative privileges...
 goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
 echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
 echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

 "%temp%\getadmin.vbs"
 exit /B

:gotAdmin
 if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
 pushd "%CD%"
 CD /D "%~dp0"
:--------------------------------------

set fic_log=c:\temp\service_to_restart.log
set fic_temp=c:\temp\service_to_restart.txt
set fic_start=c:\temp\service_to_start.txt
set fic_bat=c:\temp\service_to_start.bat


del /F %fic_log%
del /F %fic_temp%
del /F %fic_start%
del /F %fic_bat%

TIMEOUT /T 3 /NOBREAK 1>nul

TYPE NUL > %fic_start%
TYPE NUL > %fic_bat%

wmic service where (state="stopped" and startmode="Auto") get name>%fic_temp%

for /f "delims= skip=1" %%i in ('type %fic_temp%') do (
 set w_serv=%%i
 echo net start %%i>> %fic_start%
 )

TIMEOUT /T 3 /NOBREAK 1>nul

for /f "tokens=1,2,3* delims= " %%i in (%fic_start%) do (
 set wstr=%%i %%j 
 set wser=%%k %%l
 for /l %%a in (11,1,100) do if "!wser:~-1!"==" " set wser=!wser:~0,-1!
 set w_ligne=!wstr!"!wser!"
 echo !w_ligne!
 echo !w_ligne!>>%fic_bat%
 echo TIMEOUT /T 5 /NOBREAK >> %fic_bat%
 )

%fic_bat% > %fic_log%

c:\Batchs\test.bat

@echo off
echo TEST > c:\temp\test.txt
echo %1 >> c:\temp\test.txt

Réseau backup PDTB21

ifconfig

eno2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
      inet 10.153.15.50 netmask 255.255.192.0 broadcast 10.153.63.255
      inet6 fe80::9657:a5ff:fe54:710d prefixlen 64 scopeid 0x20<link>
      ether 94:57:a5:54:71:0d txqueuelen 1000 (Ethernet)
      RX packets 30331372 bytes 2055699599 (1.9 GiB)
      RX errors 0 dropped 100 overruns 0 frame 0
      TX packets 229490189 bytes 348363421184 (324.4 GiB)
      TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

rechercher la carte eno2
locate eno2
/etc/sysconfig/network-scripts/ifcfg-eno2
cd /etc/sysconfig/network-scripts/
vi ifcfg-eno2

 Modifier les lignes suivants :
 IPADDR=10.153.15.50 (voir IP_range)
 PREFIX=18

ifdown ifcfg-eno2
ifup ifcfg-eno2
ifconfig

nombre de process insuffisant

Pb Vtom : Error setuid(500), Resource temporarily unavailable

Le user Vtom passé dans le job n’est pas pris en compte.

PDTB9
root 9316 0.0 0.0 6808 1308 pts/3 S 10:59 0:00 /opt/vtom/abm/bin/bdaemon
root 14882 0.0 0.0 108248 1500 pts/3 S 13:17 0:00 \_ -bash /opt/vtom/admin/tom_submit.bash
root 14898 0.0 0.0 108248 620 pts/3 S 13:17 0:00 \_ -bash /opt/vtom/admin/tom_submit.bash
root 14899 0.0 0.0 100952 468 pts/3 S 13:17 0:00 \_ sleep 60

PDTB4
root 19864 0.0 0.0 6808 1320 ? S Jun09 0:21 /opt/vtom/abm/bin/bdaemon
ora112 62072 0.0 0.0 108356 1668 ? S 13:18 0:00 \_ -bash /opt/vtom/admin/tom_submit.bash
ora112 62092 0.0 0.0 108356 780 ? S 13:18 0:00 \_ -bash /opt/vtom/admin/tom_submit.bash
ora112 62093 0.0 0.0 100952 468 ? S 13:18 0:00 \_ sleep 120

Le nombre de process max sur la machine est insuffisant (nproc).

Modification du fichier /etc/security/limits.d/90-nproc.conf pour augmenter le nombre de process sur la machine pour tous les users

passage de 1024 à 2048

cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     2048

incomplete startup packet

Message récurent dans le fichier /opt/vtom/serveurs.log

2017-03-29 14:29:07 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet
2017-03-29 14:30:32 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet
2017-03-29 14:31:51 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet
2017-03-29 14:33:29 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet
2017-03-29 14:34:47 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet
2017-03-29 14:36:06 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet
2017-03-29 14:37:26 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet
2017-03-29 14:38:44 CEST [[unknown]@[unknown]] > LOG: incomplete startup packet

L’origine du message vient de zabbix.

Il ne faut pas tester les ports 30007 et 30009

net.tcp.service[tcp,,30007]
net.tcp.service[tcp,,30009]

Mais tester les process

proc.num[,vtom,,/opt/vtom/vtom/bin/vtserver]
proc.num[,vtom,,/opt/vtom/vtom/bin/vtsgbd]

Check d’un process proc.num[]

Monitoring d’un process sous Linux avec Zabbix.

Exemple pour le process BIP.

zabbix_get -p 10050 -k proc.num[,seeasown,,/soft/BIP/runtime/jvm64/bin/java] -s vledi01p
3

ps -ef|grep BIP|grep -v grep
seeasown 30335 1 0 10:22 ? 00:00:00 /bin/sh /soft/BIP/bin/domain.sh
seeasown 30410 30335 0 10:22 ? 00:00:06 /soft/BIP/runtime/jvm64/bin/java -D[Process Controller] -server -Xms64m -Xmx512m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml -Dvm.bisas.db.ssl=false -Dorg.jboss.boot.log.file=/soft/BIP/log/BIP_VLEDI01P//process-controller.log -Dlogging.configuration=file:/soft/BIP/domain/configuration/logging.properties -jar /soft/BIP/jboss-modules.jar -mp /soft/BIP/modules org.jboss.as.process-controller -jboss-home /soft/BIP -jvm /soft/BIP/runtime/jvm64/bin/java -mp /soft/BIP/modules -- -Dorg.jboss.boot.log.file=/soft/BIP/log/BIP_VLEDI01P//host-controller.log -Dlogging.configuration=file:/soft/BIP/domain/configuration/logging.properties -server -Xms64m -Xmx512m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml -Dvm.bisas.db.ssl=false -- -default-jvm /soft/BIP/runtime/jvm64/bin/java
seeasown 30426 30410 0 10:22 ? 00:00:13 /soft/BIP/runtime/jvm64/bin/java -D[Host Controller] -Dorg.jboss.boot.log.file=/soft/BIP/log/BIP_VLEDI01P//host-controller.log -Dlogging.configuration=file:/soft/BIP/domain/configuration/logging.properties -server -Xms64m -Xmx512m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.domain.default.config=domain.xml -Djboss.host.default.config=host.xml -Dvm.bisas.db.ssl=false -jar /soft/BIP/jboss-modules.jar -mp /soft/BIP/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.host-controller -mp /soft/BIP/modules --pc-address localhost --pc-port 53430 -default-jvm /soft/BIP/runtime/jvm64/bin/java -Djboss.home.dir=/soft/BIP
seeasown 30494 30410 0 10:22 ? 00:01:12 /soft/BIP/runtime/jvm64/bin/java -D[Server:BIP_VLEDI01P] -Xms1G -Xmx2G -Xss1M -server -server -d64 -XX:+UseG1GC -XX:MaxMetaspaceSize=1G -XX:+HeapDumpOnOutOfMemoryError -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.PollSelectorProvider -Xverify:none -Dsun.java2d.noddraw=true -Djco.cpic_maxconv=204 -Doracle.jdbc.J2EE13Compliant=true -Djboss.modules.safe-jdk=true -Dcom.seeburger.conf.user=BISAS -Dcom.seeburger.conf.xml.fileprovider=Database -Dbisas.home=/soft/BIP -Dbisas.data=/soft/BIP/data -Dbisas.conf=/soft/BIP/conf -Dbisas.temp=/soft/BIP/temp -Dbisas.log=/soft/BIP/log -Dbisas.software=/soft/BIP/software -Dcom.seeburger.conf.xml.basedir=/soft/BIP/conf/SeeConfig -Ddir.pl.mappings=/soft/BIP/conf/pl -Dcom.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0 -Dcom.seeburger.licensing.path=/soft/BIP/conf/license -Djava.io.tmpdir=/soft/BIP/temp -Djava.endorsed.dirs=/soft/BIP/lib/charsets -Djava.rmi.server.hostname=vledi01p.ftdmz.local -Dmail.mime.multipart.bmparse=false -Dmail.mime.cachemultipart=false -Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.EPackageRegistryImpl -Dusehornetqstore=true -Dsecureedge.local.logger=seelogger -Duseinmemoryprocessing=true -Djgroups.bind_addr=vledi01p.ftdmz.local -Djgroups.use.jdk_logger=true -Dmaverick.workaroundEpollBug=true -Dsun.net.useExclusiveBind=false -Dcom.arjuna.ats.jta.xaAssumeRecoveryComplete=true -Dhibernate.dialect_resolvers=com.seeburger.hibernate.extensions.DialectResolver -Dinstance.id=BIP_VLEDI01P -Dinstance.group=Portal -Dinstance.roles=B2BPortal -Dsystem.id=vledi01p.ftdmz.local -Djboss.socket.binding.port-offset=0 -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.host.default.config=host.xml -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.home.dir=/soft/BIP -Dorg.jboss.resolver.warning=true -Dorg.apache.tomcat.util.http.Parameters.MAX_COUNT=10000 -Djboss.domain.default.config=domain.xml -Dsun.rmi.dgc.client.gcInterval=3600000 -Djava.awt.headless=true -D[Host Controller]=true -Dvm.bisas.db.ssl=false -Djboss.server.log.dir=/soft/BIP/domain/servers/BIP_VLEDI01P/log -Djboss.server.temp.dir=/soft/BIP/domain/servers/BIP_VLEDI01P/tmp -Djboss.server.data.dir=/soft/BIP/domain/servers/BIP_VLEDI01P/data -Dorg.jboss.boot.log.file=/soft/BIP/domain/servers/BIP_VLEDI01P/log/boot.log -Dlogging.configuration=file:/soft/BIP/domain/configuration/logging.properties -jar /soft/BIP/jboss-modules.jar -mp /soft/BIP/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.server

Il faut repérer le nom du process en rouge : /soft/BIP/runtime/jvm64/bin/java .
et le nom du user (facultatif) en bleu : seeasown

proc.num[,seeasown,,/soft/BIS/runtime/jvm64/bin/java] (Attention au virgules)

Type d’info : Numéric (float)

On positionne ensuite un trigger :

{VLEDI01P – DCC:proc.num[,seeasown,,/soft/BIP/runtime/jvm64/bin/java].last(0)}=0

Télédiffusion

Utiliser la télédiffusion.

1) Créer un lot
2)  Lancer la génération de ce lot pour télédiffusion
3) Intégrer le lot (lancer la télédiffusion)
3a) Lancer la simulation
3b) Lancer l’Intégration

1) Créer un lot

teledif1

En haut

– Créer ou dupliquer un lot

Dans la partie gauche
– Faire glisser un ENV
– Éventuellement supprimer de la sélection le(s) objet(s)  non concerné(s). (Clic droit sur l’objet, Traitement, Application)
– Appliquer les règles

Dans la partie Droite
-Créer une transformation (s’applique à un objet (nom du script, machine ..) ou un Alias (Remplacement d’une chaîne de caractère par une autre)
– Faire glisser la règle sur la partie gauche de l’écran

ENREGISTRER le lot.

2)  Lancer la génération de ce lot pour télédiffusion

teledif2

Sur l’onglet Génération
– Sélectionner le lot à traiter
– Clic sur Générer (en haut à droite)
– Cocher le lot à traiter
– Clic sur le bouton Transférer,

teledif3

– Clic sur le bouton Transférer

3) Intégrer le lot (lancer la télédiffusion)

– Cocher le lot à traiter
– Lancer la Simulation
teledif4
– Lancer l(Intégration

teledif5

 

Envoi de mail suite erreur job Vtom.

Windows

set retcode=%ERRORLEVEL%

echo ------------------ Fin Talend -----------------------
echo retcode : %retcode%

if %retcode%==0 goto :FIN

:ERREUR
L:
copy /Y %TOM_LOG_PATH_E% %TOM_LOG_PATH_E%.txt 2>nul
copy /Y %TOM_LOG_PATH_O% %TOM_LOG_PATH_O%.txt 2>nul

echo envoi de mail suite erreur job
%ABM_BIN%/tmail -c %ABM_BIN%/tmail.ini -to %w_dest% -cc %w_cc% -sub "VTOM : ERROR : %TOM_ENVIRONMENT% / %TOM_APPLICATION% / %TOM_JOB% job failed" -msg "ERROR : Job %TOM_JOB% Code retour (%retcode%) en erreur " -att %TOM_LOG_PATH_E%.txt;%TOM_LOG_PATH_O%.txt

:FIN
exit /B %retcode%

====================================================

Linux

err_sh=$?

echo "Valeur err_sh : "$err_sh

echo ""
dt_fin=`date +"%A %d/%m/%Y - %H:%M:%S"`
echo $dt_fin
echo ""

if [ $err_sh -eq 0 ] ; then
echo Job completed : OK
else
${ABM_BIN}/tmail -c ${ABM_BIN}/tmail.ini -to ${1} -cc ${2} -sub "ERROR :$TOM_JOB - ERROR" -msg "
******************* VTOM MESSAGE ERROR ***********************

The scheduler Vtom has completed with error.

Error code : $err_sh

Please verify log file joint.

Best Regards.

******************* END OF VTOM MESSAGE ERROR***********************" -att $TOM_LOG.o\;$TOM_LOG.e
fi
exit $err_sh

Fichier_non_vide

Sous Linux

#!/bin/bash
cd /exploit/logs
find *.e -type f -not -empty

Sous Windows

rem ——————————————– rem ce script rechercher les fichiers non vide rem pour un type (extension) donné rem dans une directorie donné rem ——————————————–

@Echo Off

echo extension : %1 echo dossier : %2

setlocal ENABLEDELAYEDEXPANSION

set /A P1=0 set fic=%1 set dossier=%2

for /R %dossier% %%i in (%fic%) do if « %%~zi » geq « 1 » ( echo %%~nxzi set /A P1=!P1!+1 )

echo Il y a !P1! fichiers non vide

set /A nb_fic=!P1!

if %nb_fic% equ 0 goto TERMINE goto ERREUR

:ERREUR Echo « il y a !P1! Pb sur ces serveurs » rem cd %ABM_LOGS% rem copy /Y %TOM_LOG_PATH_E% log_erreur.txt rem copy /Y %TOM_LOG_PATH_O% log_standard.txt rem %ABM_BIN%/tmail -c %ABM_BIN%/tmail.ini -to eric.fougere@faiveleytransport.com -sub « DCB – VTOM : ERREUR job : %TOM_JOB% » -msg « fichier log non vide MACHINE : %TOM_HOST% %TOM_JOB% : Les log errors ne sont pas vides. » -att log_standard.txt;log_erreur.txt

:TERMINE exit /b %nb_fic%

Del_non_vide.bat

rem --------------------------------------------
rem ce script rechercher les fichiers non vide 
rem pour un type (extension) donné
rem dans une directorie donné
rem --------------------------------------------
@Echo Off
echo extension : %1
echo dossier : %2
setlocal ENABLEDELAYEDEXPANSION
set fic=%1
set dossier=%2
for /R %dossier% %%i in (%fic%) do if "%%~zi" geq "1" (
echo %%~nxzi 
del /f %%i 
)
:TERMINE
exit /b %nb_fic%

connect_as400.bat

rem Tracking #63550
rem Test de connection à l'AS400
net use s: /delete /yes
net use s: \\ERPM3TWO\root\M3FileTransfer\M3Production\DE1\test vtomvtom /USER:erpm3two\DCXSERVICE
echo source =\\ERPM3TWO\root\M3FileTransfer\M3Production\DE1\test
rem set source=\\pfile.ft.grp\Distrib\_cco\EF\Documents
rem set cible=s:
set source=s:
set cible=\\pfile.ft.grp\Distrib\_cco\EF\test
echo %source% 
echo %cible%
set w_log=%cible\%TOM_JOB%.log
dir %source%
robocopy %source% %cible% /S /w:1 /r:1 test*.txt
dir %cible%

Convert secondes en heures minutes

en SQL Server

9294 s ==> 2.5816666 h ===> 02:34::53

SELECT
ElapsedTimeSeconds
,(CAST ( ElapsedTimeSeconds AS decimal(10,2))/ 3600)
,RIGHT(‘0’ + CAST (FLOOR((CAST ( ElapsedTimeSeconds AS decimal(10,4))/ 3600)) AS VARCHAR), 2) + ‘:’ +
RIGHT(‘0’ + CAST(FLOOR(((((CAST ( ElapsedTimeSeconds AS decimal(10,2))/ 3600) * 3600) % 3600) / 60)) AS VARCHAR), 2) + ‘:’ +
RIGHT(‘0’ + CAST (FLOOR(((CAST ( ElapsedTimeSeconds AS decimal(10,2))/ 3600) * 3600) % 60) AS VARCHAR), 2)
from BEDB.dbo.JobHistorySummary
where TaskTypeID = 200

 

9294 s ==> 2.34

SELECT
ElapsedTimeSeconds
,(CAST ( ElapsedTimeSeconds AS decimal(10,2))/ 3600)
,RIGHT(‘0’ + CAST (FLOOR((CAST ( ElapsedTimeSeconds AS decimal(10,4))/ 3600)) AS INT), 2) + ‘.’ +
RIGHT(‘0’ + CAST(FLOOR(((((CAST ( ElapsedTimeSeconds AS decimal(10,2))/ 3600) * 3600) % 3600) / 60)) AS VARCHAR), 2) –+ ‘:’ +
–RIGHT(‘0′ + CAST (FLOOR(((CAST ( ElapsedTimeSeconds AS decimal(10,2))/ 3600) * 3600) % 60) AS VARCHAR), 2)
–,DATEADD(mi, (ElapsedTimeSeconds – FLOOR(ElapsedTimeSeconds)) * 60, DATEADD(hh, FLOOR(ElapsedTimeSeconds), CAST (’00:00:00’ AS TIME)))
from BEDB.dbo.JobHistorySummary
where TaskTypeID = 200

Perf Counter Windows

11 Compteurs de performance Windows

Les compteurs de performance Windows peuvent être efficacement supervisés en utilisant perf_counter[].

Par exemple:

perf_counter["Processor(0)\Interrupts/sec"]

ou

perf_counter["Processor(0)\Interrupts/sec", 10]

Dans le but d’obtenir la liste complète des compteurs de performance disponibles pour la supervision vous pouvez exécuter la commande suivante:

typeperf -qx

Malheureusement, les paramètres locaux de nommage des compteurs de performances peuvent être différents sur les différents serveurs Windows. Ceci peut causer certains problèmes lors de la création d’un modèle pour superviser plusieurs machines Windows ayant différents paramètres locaux.

Chaque compteur de performance peut être traduit sous forme numérique, lequel est unique et exactement le même indifféremment de paramètres linguistiques.

Exécuter regedit, Ensuite trouver HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009. Les entrées de la base registre contiennent des informations telles que:

1
1847
2
System
4
Memory
6
% Processor Time
10
File Read Operations/sec
12
File Write Operations/sec
14
File Control Operations/sec
16
File Read Bytes/sec
18
File Write Bytes/sec
....

Donc, dans le but de traduire le nom (en chaîne de caractère) d’un compteur de performance sous une forme numérique,il faut trouver les nombres correspondant pour chaque partie du compteur de performance comme:

System -> 2
% Processor Time -> 6
\System\% Processor Time

Then use these numbers to create a numeric format:

\2\6

11.1 Paramètres utilisateurs simples

Dans le but de définir un nouveau paramètre pour la supervision, une ligne doit être ajoutée au fichier de configuration de Zabbix qui doit ensuite être redémarré. Par exemple:

   PerfCounter=UserPerfCounter1,"\Memory\Page Reads/sec",30
   ou
   PerfCounter=UserPerfCounter2,"\4\24",30

Ensuite, il est possible d’utiliser “UserPerfCounter1” et “UserPerfCounter2” comme des items habituels disponibles sur l’interface ou ailleurs, de façon similaire à UserParameter.