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 &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&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>
"Connection lost with the Central Server"<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 "Please connect your client to the web server on port: 7070"<br>
Before sending the kill signal to the process, some times it re-establish by itself, so i have to "sleep 60"<br>checking if i have in log files: "Connection re-established with the Central Server" 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:"Please connect your client to the web server on port: 9090" 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>"Please connect your client to the web server on port: 7070" --> STATUS:UP&RUNNING<br>
"Server Successfully Shut Down" --> STATUS:DOWN<br>"Server modules started with problems" --> 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&running i'll dont do anything<br>When im down i'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 "node 1 are ok" and do anything, the same from node 2 & 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 <- 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'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>
"Connection lost with the Client Server" 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 | Type | Null | Key | Default | Extra |<br>+-----------+--------------+------+-----+---------+-------+<br>| ID | int(11) | | PRI | 0 | |<br>
| TEXT | text | YES | | NULL | |<br>| CATEGORY | varchar(100) | YES | | NULL | |<br>| DDOMAIN | varchar(100) | YES | | NULL | |<br>| NETWORK | varchar(100) | YES | | NULL | |<br>
| NODE | varchar(100) | YES | | NULL | |<br>| ENTITY | varchar(150) | | MUL | | |<br>| SEVERITY | int(11) | YES | | NULL | |<br>| TTIME | bigint(20) | YES | MUL | NULL | |<br>
| SOURCE | varchar(100) | YES | | NULL | |<br>| HELPURL | varchar(100) | YES | | NULL | |<br>| WEBNMS | varchar(100) | YES | | NULL | |<br>| GROUPNAME | varchar(100) | YES | | NULL | |<br>
| OWNERNAME | varchar(25) | | PRI | | |<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 > 300 do sign_kill_signal_to_node1 ....<br> ... <br><br> ....<br><br><br><br><br>This is a real SELECT from the table Event:<br><br> | 10.33.109.189.barajas_dms_1 | 1234465208249 |<br>| 55558 | Process Memory usage threshold exceeded Of Instance -->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; (remember: INSERT $ID+1)<br>+-------+<br>| id |<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 > 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: "Alert: Filesystem: /cosa : 100 % used"<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="CentralDB";<br>$host="localhost";<br>$puerto="3306";<br>$usuario="root";<br>$password="";<br>
<br># Prepare database query<br>$DatosConexion="DBI:mysql:database=$db;$host:$puerto";<br>$dbh=DBI->connect($DatosConexion,$usuario,$password);<br><br># QUERY<br><br>$sth=$dbh->prepare(q{ SELECT ID,TTIME,NODE,TEXT from Event where<br>
lower(text) like '%cosa%' Order By TTIME desc limit 1 });<br><br>$sth->execute( );<br><br>### Open the output file<br>open FILE, ">results.txt" or die "Can't open results.lis: $!";<br>
<br>### Dump the formatted results to the file<br>$rows = $sth->dump_results(1,\*FILE ); <------------This fails...to put me in the auxiliary file (status)<br><br>### Close the output file<br>close FILE or die "Error closing result file: $!\n";<br>
<br>---------------------------------------------------------------------------------------------------------------<br><br>--------<br><br>OUTPUT:<br>MAIN_NODE# perl printmefiles.pl<br>'1...', '1...', '1...', 'A...'<br>
1 rows<br><br>---------------------------------------------------------------------------------------------------------------<br><br>