Hola chicos, alguno podria echarme una mano?<br><br><br>This project is a checking (healthcheck) of the flow of SQL sentences, from one node to a main one.<br>The structure are developed as follows:<br><br>1 Main node plus 3 client nodes who reports events by sql (mysql) to the main node, the process who<br>
sends the events are written in java so i dont have any mechanism to check if it fails/frozen this application,<br>so i need to make a workaround to check if process are sending this sqls and check the log files.<br><br>So i need the following:<br>
<br>Flow:<br>1. INSERT of a given event in sql format to introduce in the sql flow in the 3 Slave Nodes to Master node every <br><br>5 minutes.<br><br>2. Checking by an sql instruction who arrived fine (in time) if not arrives, something goes wrong.<br>
This happens by a micro-cut of the communications, or something the technical product are still checking.<br>So the solution is to check if this events arrives, if all its fine, i dont do anything, if fails,<br>ill call into the system to a script who kills the process and start again the node process.<br>
a) Ill stop the slave node, b) ill stop the master node till the log file says that are stoped (i read this <br><br>word), then c) ill start-up the master node (read again the log to see its completelly up &amp;running) and<br>
d) i run every slave node ni order, first 1, 2nd 2..and 3rd 3.<br>And i read on every node his log file to chech that are up&amp;running (i read im ready on the log file for ex.)<br><br>Sometimes when i read the log files on Slave Nodes i have the following text:<br>
&quot;Connection lost with the Central Server&quot;<br>This happens some times by no reasson, so i need to correct it calling kill-my-process.sh to kill it <br><br>completelly, waiting to read into the log &quot;Please connect your client to the web server on port: 7070&quot;<br>
Before sending the kill signal to the process, some times it re-establish by itself, so i have to &quot;sleep 60&quot;<br>checking if i have in log files: &quot;Connection re-established with the Central Server&quot; then ill dont do anything, <br>
<br>only keep sending the SQL events every 5minutes.<br><br>3. When i have fully restarted the app it writes down a log where you can read his status, this is the<br>phrase:&quot;Please connect your client to the web server on port: 9090&quot; i need to write an auxiliar file<br>
where in every moment writes me the status of the nodes, (master and slaves) to read it before act,<br>this status are the following: if i read on the log file in the lastest (usually 2/3 phrases):<br>&quot;Please connect your client to the web server on port: 7070&quot; --&gt; STATUS:UP&amp;RUNNING<br>
&quot;Server Successfully Shut Down&quot; --&gt; STATUS:DOWN<br>&quot;Server modules started with problems&quot; --&gt; STATUS:PROBLEMS<br><br>I need to drop the last status line from the original log file to an auxiliar file which latest status<br>
of the process (in main node and in slave nodes too)<br><br>When im up&amp;running i&#39;ll dont do anything<br>When im down i&#39;ll check to the others nodes to stop before start up the main node again.<br>When im reading problems, i restart again the process to start up all nodes again, (stop main node,<br>
stop slave nodes, start up main node, start up slave node1, slave node 2, slave node 3) wait in the bucle..<br><br><br>The idea of the flow is that from every slave node it sends a witness (testigo: a sql sentence) to the main<br>
node to check if it arrives correctly, for example every 5 minutes, the main node receives this witness<br>and prints in log &quot;node 1 are ok&quot; and do anything, the same from node 2 &amp; 3.<br><br>If im having problems receiving this witness its supposed that im having problems with Node x, then i need to<br>
re-start the nodes in an order: 1st: master node, 2nd slave node1, 3rd slave node2, 4th slave node3.<br>When are are down (i read from auxiliary log file his status) i can re-start in order, 1s node1, then node2, <br><br>
stop and check if node 2 are up and then node3.<br>To send the kill command, i need i must send a remote system call, i dont care if its by RSH::Net or<br>system_call($command) to call a file called kill_node_process.sh &lt;- this script kills the node and start up<br>
again, all i need is to wait it restarts again and read the log file that tells me all is fine.<br>And of course, i&#39;ll check the node sql events again to check that are syncronizing again the node.<br><br>Suddendly i can read on the master node log the following:<br>
&quot;Connection lost with the Client Server&quot; then i must send the kill process to node slave 1, 2 and 3.<br>And then i wait if events arrives fine.<br><br><br><br><br>Table in MYSQL from a Node server<br><br><br>desc Event;<br>
<br>----+-----+---------+-------+<br>| Field&nbsp;&nbsp;&nbsp;&nbsp; | Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Null | Key | Default | Extra |<br>+-----------+--------------+------+-----+---------+-------+<br>| ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | int(11)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | PRI | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
| TEXT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| CATEGORY&nbsp; | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| DDOMAIN&nbsp;&nbsp; | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| NETWORK&nbsp;&nbsp; | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
| NODE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| ENTITY&nbsp;&nbsp;&nbsp; | varchar(150) |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | MUL |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| SEVERITY&nbsp; | int(11)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| TTIME&nbsp;&nbsp;&nbsp;&nbsp; | bigint(20)&nbsp;&nbsp; | YES&nbsp; | MUL | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
| SOURCE&nbsp;&nbsp;&nbsp; | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| HELPURL&nbsp;&nbsp; | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| WEBNMS&nbsp;&nbsp;&nbsp; | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| GROUPNAME | varchar(100) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
| OWNERNAME | varchar(25)&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | PRI |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>+-----------+--------------+------+-----+---------+-------+<br>14 rows in set (0.01 sec)<br><br><br>How i can make the INSERT in the table?<br>As you can see i need to read the LAST ID 1st and the add 1 ($ID+1)<br>
<br>select id from Event order by ttime desc limit 1;<br><br>This select it gives me the ID to add later the sql statement:<br>I make the time (TTIME) this style: 1234343883752,<br>I think its with time() * 1000 to make the time on the insert, but im not sure (and i dont care) but i want it <br>
<br>to check lately, check the SQL that arrived in less than 5 min (300seg), and rest from the localtime this way:<br><br>$node1_time=1234343883752 (SELECT TTIME from table...);<br>$local_time=time()*1000;<br>$finish_time=$node1_time - $local_time = $difference<br>
if $difference &gt; 300 do sign_kill_signal_to_node1 ....<br>&nbsp;&nbsp; ... <br><br>&nbsp;&nbsp;&nbsp;&nbsp; ....<br><br><br><br><br>This is a real SELECT from the table Event:<br><br>&nbsp;&nbsp;&nbsp;&nbsp; | 10.33.109.189.barajas_dms_1&nbsp; | 1234465208249 |<br>|&nbsp; 55558 | Process Memory usage threshold exceeded Of Instance --&gt;oracle.4134 Value: 339320 Data: <br>
<br>ProcessMemoryUsage : 10.33.109.189.barajas_dms_1 : 25.5.1.1.2 Threshold Type: maxMajor Threshold : 204800Major <br><br>Rearm Value: 204799 <br><br><br>What i really mind is the following values:<br><br>ID: (generated with select sql given before)<br>
<br>select id from Event order by TTIME desc limit 1;&nbsp; (remember: INSERT $ID+1)<br>+-------+<br>| id&nbsp;&nbsp;&nbsp; |<br>+-------+<br>| 70857 |<br>+-------+<br><br>NODE:<br>bar_dms_1 for node slave1<br>leg_dms_2 for node slave2<br>cas_dms_3for node slave3.<br>
<br>TTIME, generated by $time=time()*1000; (or maybe 999 to fit into the numbers i get from the select) to then <br><br>rest to the localtime and if &gt; 300 this means im waiting for more than 5min the waitness, so i send the kill<br>
process remotelly.<br><br>TEXT: I need the following text: &quot;Alert: Filesystem: /cosa : 100 % used&quot;<br><br><br><br><br><br><br><br>----------Script that adds the SQL to a temporary file: (FAILING)--------------------------------<br>
<br>#!/usr/bin/perl<br><br>use DBI;<br><br><br># Main Server DB connection data<br>$db=&quot;CentralDB&quot;;<br>$host=&quot;localhost&quot;;<br>$puerto=&quot;3306&quot;;<br>$usuario=&quot;root&quot;;<br>$password=&quot;&quot;;<br>
<br># Prepare database query<br>$DatosConexion=&quot;DBI:mysql:database=$db;$host:$puerto&quot;;<br>$dbh=DBI-&gt;connect($DatosConexion,$usuario,$password);<br><br># QUERY<br><br>$sth=$dbh-&gt;prepare(q{ SELECT ID,TTIME,NODE,TEXT from Event where<br>
&nbsp;lower(text) like &#39;%cosa%&#39; Order By TTIME desc limit 1 });<br><br>$sth-&gt;execute(&nbsp; );<br><br>### Open the output file<br>open FILE, &quot;&gt;results.txt&quot; or die &quot;Can&#39;t open results.lis: $!&quot;;<br>
<br>### Dump the formatted results to the file<br>$rows = $sth-&gt;dump_results(1,\*FILE );&nbsp;&nbsp; &lt;------------This fails...to put me in the auxiliary file (status)<br><br>### Close the output file<br>close FILE or die &quot;Error closing result file: $!\n&quot;;<br>
<br>---------------------------------------------------------------------------------------------------------------<br><br>--------<br><br>OUTPUT:<br>MAIN_NODE# perl printmefiles.pl<br>&#39;1...&#39;, &#39;1...&#39;, &#39;1...&#39;, &#39;A...&#39;<br>
1 rows<br><br>---------------------------------------------------------------------------------------------------------------<br><br>