ComposantsComponents › DiversMisc
Vérifie si une machine répond à un ping, ou si un port TCP accepte une connexion, et met la réponse (true ou false) dans une variable globale. Une machine absente, un port fermé ou un nom inconnu ne sont pas des erreurs : un lien Run if lit la variable et choisit la suite, par exemple lancer le chargement si la base répond, prévenir sinon.
Checks whether a host answers a ping, or whether a TCP port accepts a connection, and puts the answer (true or false) in a global variable. A missing host, a closed port or an unknown name are not errors: a Run if link reads the variable and chooses what comes next, for example start the load if the database answers, warn otherwise.
EntréeInput
Aucune : il commence son sous-job. Sinon un lien Iterate : une vérification par itération. None: it starts its subjob. Otherwise one Iterate link: one check per iteration.
SortieOutput
Pas de flux de données : la réponse est dans la variable globale. Un lien Iterate peut partir du composant : la suite s'exécute une fois. No data flow: the answer is in the global variable. One Iterate link can leave the component: what follows runs once.
Déclencheurs en sortieOutput triggers
On Subjob Ok On Subjob Error On Component Ok On Component Error Run if
On Subjob : seulement quand il commence son sous-job. On Subjob: only when it starts its subjob.
En Telnet sur le port de la base (5432, 3306…), condition du Run if : ((Boolean) globalMap.get("tServerAlive_1_SERVER_ALIVE_RESULT")). Si la base ne répond pas, le chargement n'est pas lancé et le job se termine normalement.
With Telnet on the port of the database (5432, 3306…), Run if condition: ((Boolean) globalMap.get("tServerAlive_1_SERVER_ALIVE_RESULT")). If the database does not answer, the load is not started and the job ends normally.
La même condition précédée de ! : le Run if ne passe que si le serveur ne répond pas. Les deux liens peuvent partir du même tServerAlive.
The same condition preceded by !: the Run if only goes through if the server does not answer. Both links can start from the same tServerAlive.
SERVER_ALIVE_RESULT.
Connect it to what comes next (right-click › Trigger › Run if) and write the link condition with the SERVER_ALIVE_RESULT global variable.
Les libellés sont ceux de l'onglet Composant ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Les valeurs sont des expressions Java. Labels are those of the Component tab; the technical name, in grey, is the parameter name in the job file. The values are Java expressions.
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| ProtocoleProtocolPROTOCOL | Ping | ToujoursAlways |
Ping : Java cherche l'adresse de l'hôte et lui demande s'il répond (InetAddress.isReachable). Telnet : le composant ouvre une connexion TCP vers l'hôte et le port, puis la ferme aussitôt. Rien n'est envoyé : n'importe quel service TCP convient (HTTP, base de données…), pas seulement telnet.
Ping: Java looks up the address of the host and asks it whether it answers (InetAddress.isReachable). Telnet: the component opens a TCP connection to the host and port, then closes it at once. Nothing is sent: any TCP service will do (HTTP, database…), not only telnet.
|
| HôteHostHOST | "" |
ToujoursAlways |
Nom ou adresse IP, entre guillemets : "db.example.com", "10.0.0.5", context.dbHost. Laissé vide, il désigne la machine elle-même, qui répond toujours (voir Pièges).
Name or IP address, in quotes: "db.example.com", "10.0.0.5", context.dbHost. Left empty, it means the machine itself, which always answers (see Pitfalls).
|
| PortPORT | 23 |
Telnet |
Un nombre entier, sans guillemets : 5432, ou une variable de contexte de type Integer. Entre guillemets, le job ne compile pas.
A whole number, without quotes: 5432, or a context variable of type Integer. In quotes, the job does not compile.
|
| Délai avant expirationTimeout IntervalTIMEOUT_INTERVAL | 5 |
ToujoursAlways |
Attente maximale, en secondes entières (le champ est suivi de second(s)) ; le composant la multiplie par 1000. Un nombre décimal ne compile pas. Avec 0, Telnet n'a plus de limite propre : c'est celle du système qui s'applique (voir les exemples).
Maximum wait, in whole seconds (the field is followed by second(s)); the component multiplies it by 1000. A decimal number does not compile. With 0, Telnet has no limit of its own: the one of the system applies (see the examples).
|
Un proxy SOCKS, en Telnet seulement. Il reste réglé pour tout le reste du job (voir Pièges). A SOCKS proxy, with Telnet only. It stays set for the whole rest of the job (see Pitfalls).
| ParamètreSetting | DéfautDefault | VisibleShown | Description |
|---|---|---|---|
| Activer un serveur proxyEnable proxy serverENABLE_PROXY_SERVER | NonNo | Telnet |
La connexion passe par un proxy SOCKS. Le composant écrit les propriétés système Java socksProxyHost, socksProxyPort, java.net.socks.username et java.net.socks.password.
The connection goes through a SOCKS proxy. The component writes the Java system properties socksProxyHost, socksProxyPort, java.net.socks.username and java.net.socks.password.
|
| Hôte du proxyProxy HostPROXY_HOST | "" |
Telnet, proxy activéTelnet, proxy enabled | Nom ou adresse du proxy, entre guillemets. Name or address of the proxy, in quotes. |
| Port du proxyProxy PortPROXY_PORT | "23" |
Telnet, proxy activéTelnet, proxy enabled |
Port du proxy. Contrairement à Port, il s'écrit entre guillemets : "1080".
Port of the proxy. Unlike Port, it is written in quotes: "1080".
|
| UtilisateurUsernamePROXY_USER | "" |
Telnet, proxy activéTelnet, proxy enabled | Utilisateur du proxy, s'il en demande un. User of the proxy, if it asks for one. |
| Mot de passePasswordPROXY_PASS | "" |
Telnet, proxy activéTelnet, proxy enabled |
Chiffré dans le fichier du job ; à l'exécution, il est déchiffré et rangé en clair dans la propriété système java.net.socks.password.
Encrypted in the job file; at run time, it is decrypted and stored in clear in the java.net.socks.password system property.
|
Écrite quand le composant s'exécute : avant, elle vaut null. À lire dans la condition d'un Run if ou dans les composants qui suivent.
Written when the component runs: before that, it is null. To read in the condition of a Run if or in the components that follow.
true si l'hôte a répondu au ping, ou si la connexion au port a réussi, dans le délai. false dans tous les autres cas : pas de réponse, port fermé, nom inconnu, ou toute autre erreur pendant la vérification.true if the host answered the ping, or if the connection to the port succeeded, within the timeout. false in every other case: no answer, closed port, unknown name, or any other error during the check.((Boolean) globalMap.get("tServerAlive_1_SERVER_ALIVE_RESULT"))
Sous Windows. Les sorties sont celles de la console, copiées depuis une exécution du job. 192.0.2.1 est une adresse réservée à la documentation (RFC 5737), où aucune machine ne répond ; nothing.invalid est un nom qui ne peut jamais exister (RFC 6761). Les durées viennent d'un tJava placé après chaque composant.
On Windows. The outputs are the console ones, copied from a run of the job. 192.0.2.1 is an address reserved for documentation (RFC 5737), where no machine answers; nothing.invalid is a name that can never exist (RFC 6761). The durations come from a tJava placed after each component.
// Run if → tJava_1
((Boolean) globalMap.get("tServerAlive_1_SERVER_ALIVE_RESULT"))
// Run if → tJava_2
!((Boolean) globalMap.get("tServerAlive_1_SERVER_ALIVE_RESULT"))
// tJava_1
System.out.println("The server answers");
// tJava_2
System.out.println("No answer");
Ping, Hôte : "127.0.0.1", la machine elle-même.
Ping, Host: "127.0.0.1", the machine itself.
The server answers
Ping, "192.0.2.1", délai : 2.
Ping, "192.0.2.1", timeout: 2.
No answer
Dans les deux cas, le job se termine avec le code 0 : un hôte qui ne répond pas n'est pas une erreur. In both cases, the job ends with exit code 0: a host that does not answer is not an error.
Dix tServerAlive à la suite, chacun suivi d'un tJava qui affiche son résultat. Délai : 5 pour les trois pings de la machine elle-même, 2 pour les autres. Pour avoir un port ouvert, le premier tJava en ouvre un sur la machine ; les tServerAlive 7 et 8 ont pour Port (Integer) globalMap.get("port"). Le port 9 est fermé. Le dernier tJava ferme le port ouvert.
Ten tServerAlive in a row, each followed by a tJava that prints its result. Timeout: 5 for the three pings of the machine itself, 2 for the others. To have an open port, the first tJava opens one on the machine; tServerAlive 7 and 8 have (Integer) globalMap.get("port") as Port. Port 9 is closed. The last tJava closes the open port.
// tJava_1
java.net.ServerSocket server = new java.net.ServerSocket(0, 50, java.net.InetAddress.getLoopbackAddress());
globalMap.put("server", server);
globalMap.put("port", server.getLocalPort());
System.out.println("Listening on " + server.getLocalSocketAddress());
globalMap.put("t0", System.currentTimeMillis());
// tJava_8, after tServerAlive_7
long ms = System.currentTimeMillis() - (Long) globalMap.get("t0");
System.out.println("Telnet 127.0.0.1:open port: "
+ globalMap.get("tServerAlive_7_SERVER_ALIVE_RESULT") + " (" + ms + " ms)");
globalMap.put("t0", System.currentTimeMillis());
// tJava_12
((java.net.ServerSocket) globalMap.get("server")).close();
System.out.println("Closed");
Listening on localhost/127.0.0.1:54052 Ping 127.0.0.1: true (0 ms) Ping localhost: true (0 ms) Ping empty host: true (0 ms) Ping 192.0.2.1: false (1552 ms) Ping nothing.invalid: false (23 ms) Telnet 127.0.0.1:9: false (0 ms) Telnet 127.0.0.1:open port: true (0 ms) Telnet localhost:open port: true (0 ms) Telnet 192.0.2.1:80: false (2009 ms) Telnet nothing.invalid:80: false (0 ms) Closed
Un port fermé et un nom inconnu donnent false tout de suite ; une adresse où personne ne répond fait attendre, jusqu'au délai. L'hôte vide ("") répond comme la machine elle-même.
A closed port and an unknown name give false at once; an address where nobody answers makes the job wait, up to the timeout. The empty host ("") answers like the machine itself.
Le même job, vers 192.0.2.1 (port 80 en Telnet), avec plusieurs délais :
The same job, to 192.0.2.1 (port 80 with Telnet), with several timeouts:
PING 192.0.2.1, timeout 1: false (907 ms) PING 192.0.2.1, timeout 2: false (2005 ms) PING 192.0.2.1, timeout 3: false (2999 ms) PING 192.0.2.1, timeout 5: false (4996 ms) TELNET 192.0.2.1, timeout 1: false (1005 ms) TELNET 192.0.2.1, timeout 3: false (3004 ms)
Quand rien ne répond, le job attend environ le délai avant de recevoir false.
When nothing answers, the job waits about the timeout before getting false.
Délai avant expiration : 0.
Timeout Interval: 0.
Ping 127.0.0.1, timeout 0: true (2 ms) Ping 192.0.2.1, timeout 0: false (983 ms) Telnet 192.0.2.1:80, timeout 0: false (21029 ms)
En Telnet, 0 veut dire « sans limite » : le job a attendu que Windows abandonne la connexion, 21 secondes. Donnez toujours un délai.
With Telnet, 0 means "no limit": the job waited for Windows to give up the connection, 21 seconds. Always set a timeout.
Telnet vers "127.0.0.1", port 9 (fermé). Les deux tJava affichent la variable ; un tJava_3, relié par On Component Error, écrit On Component Error.
Telnet to "127.0.0.1", port 9 (closed). Both tJava print the variable; a tJava_3, connected with On Component Error, writes On Component Error.
Before: null On Component Ok: false
Le port fermé n'est pas une erreur : On Component Ok est suivi, On Component Error ne l'est pas, et le job se termine avec le code 0. The closed port is not an error: On Component Ok is followed, On Component Error is not, and the job ends with code 0.
Ping vers "127.0.0.1" ; le tJava affiche la variable.
Ping to "127.0.0.1"; the tJava prints the variable.
Iterate: true
Le composant suivant s'exécute une fois, après la vérification, et peut lire son résultat. The next component runs once, after the check, and can read its result.
Le nom du job est remplacé par MyJob ; les messages de compilation sont abrégés.
The job name is replaced with MyJob; the compilation messages are shortened.
Les deux tServerAlive : Telnet vers "192.0.2.1", port 80, délai 2. Le premier passe par un proxy, Hôte du proxy "127.0.0.1" et Port du proxy "9", où aucun proxy n'écoute ; le second n'a pas de proxy. Les tJava affichent la propriété socksProxyHost, les résultats et leur durée ; tJava_3 essaie enfin une connexion par un simple java.net.Socket.
Both tServerAlive: Telnet to "192.0.2.1", port 80, timeout 2. The first one goes through a proxy, Proxy Host "127.0.0.1" and Proxy Port "9", where no proxy listens; the second one has no proxy. The tJava print the socksProxyHost property, the results and their duration; tJava_3 finally tries a connection with a plain java.net.Socket.
socksProxyHost before: null tServerAlive_1 (proxy 127.0.0.1:9): false (29 ms) socksProxyHost after: 127.0.0.1 tServerAlive_2 (no proxy): false (20 ms) Plain socket: java.net.SocketException: Can't connect to SOCKS proxy:Connection refused: getsockopt
Le proxy est écrit dans les propriétés système de Java, qui valent pour tout le job et ne sont jamais remises à zéro. Le second tServerAlive passe donc aussi par le proxy (il répond en 20 ms au lieu d'attendre 2 secondes), comme la connexion ouverte par le tJava : toute connexion Java ouverte ensuite dans le job peut être concernée. Réservez le proxy aux jobs où toutes les connexions doivent y passer. The proxy is written in the Java system properties, which apply to the whole job and are never reset. So the second tServerAlive also goes through the proxy (it answers in 20 ms instead of waiting 2 seconds), like the connection opened by the tJava: any Java connection opened later in the job can be affected. Keep the proxy for jobs where every connection must go through it.
Telnet, Port : "9".
Telnet, Port: "9".
MyJob.java:366: error: no suitable constructor found for InetSocketAddress(String,String)
java.net.InetSocketAddress address_tServerAlive_1 = new java.net.InetSocketAddress("127.0.0.1", "9");
^
constructor InetSocketAddress.InetSocketAddress(InetAddress,int) is not applicable
(argument mismatch; String cannot be converted to InetAddress)
…
Le port est passé tel quel à Java, qui attend un entier : écrivez 9. Le job ne compile pas et ne démarre pas.
The port is passed as is to Java, which expects an integer: write 9. The job does not compile and does not start.
Ping, Délai avant expiration : 0.5.
Ping, Timeout Interval: 0.5.
MyJob.java:366: error: incompatible types: possible lossy conversion from double to int
boolean isAlive_tServerAlive_1 = address_tServerAlive_1.isReachable(0.5 * 1000);
^
Le délai est en secondes entières : écrivez 1 plutôt que 0.5.
The timeout is in whole seconds: write 1 rather than 0.5.
trueEmpty host: always true
L'hôte par défaut, "", désigne la machine qui exécute le job : en Ping comme en Telnet vers un port ouvert, la réponse est true. Un hôte oublié, ou une variable de contexte vide, fait croire que le serveur répond.
The default host, "", means the machine that runs the job: with Ping, as with Telnet to an open port, the answer is true. A forgotten host, or an empty context variable, makes it look as if the server answers.
falseA misspelt name gives false
Toutes les erreurs sont gardées par le composant : un nom qui n'existe pas, un port fermé ou un serveur arrêté donnent le même false, sans message. Affichez l'hôte testé dans la branche « ne répond pas » pour savoir lequel était visé.
The component keeps every error to itself: a name that does not exist, a closed port or a stopped server give the same false, with no message. Print the tested host in the "does not answer" branch to know which one was meant.
Ping dit si la machine répond, pas si le service tourne : une base arrêtée sur une machine allumée répond au ping. Et un pare-feu peut bloquer le ping d'une machine qui fonctionne. Pour savoir si un composant pourra se connecter, prenez Telnet sur le port du service. Ping tells whether the machine answers, not whether the service runs: a stopped database on a running machine answers the ping. And a firewall can block the ping of a machine that works. To know whether a component will be able to connect, take Telnet on the port of the service.
Le délai est le temps perdu quand le serveur est absent ; un port fermé, lui, répond tout de suite. Sur un réseau local, une ou deux secondes suffisent en général. The timeout is the time lost when the server is missing; a closed port answers at once. On a local network, one or two seconds are usually enough.
Mettez l'hôte dans une variable de contexte de type String et le port dans une de type Integer (context.dbHost, context.dbPort), les mêmes que celles du composant de connexion : le test vise toujours le bon serveur.
Put the host in a context variable of type String and the port in one of type Integer (context.dbHost, context.dbPort), the same ones as the connection component: the check always aims at the right server.
Chaque tServerAlive a sa propre variable (tServerAlive_1_…, tServerAlive_2_…). Pour tester une liste, reliez-le par Iterate à un tLoop, ou à un tFlowToIterate pour une liste lue dans un fichier : la variable est réécrite à chaque itération.
Each tServerAlive has its own variable (tServerAlive_1_…, tServerAlive_2_…). To check a list, connect it with Iterate to a tLoop, or to a tFlowToIterate for a list read from a file: the variable is written again at each iteration.
tSleep · tLoop · attendre, puis vérifier de nouveauwait, then check againtRunJob · lancer le traitement si le serveur répondstart the processing if the server answerstSystem · lancer une commande du système (ping, tracert…)run a system command (ping, tracert…)tJava · afficher ou tester le résultatprint or test the resulttFileExist · le même principe pour un fichierthe same principle for a filetMsgBox · un autre composant de la famille Diversanother component of the Misc family