-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHiloPsAux.java
More file actions
48 lines (45 loc) · 1.36 KB
/
HiloPsAux.java
File metadata and controls
48 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Thread;
import java.io.*;
// CORREGIR ESTE HILO, TIENE QUE PARSEAR /PROC/MEMINFO
public class HiloPsAux implements Runnable{
public void parseoPsAux(){
synchronized(Agente.lock){
if(Agente.hayTarea == true){
try{
System.out.println("hiloPsAux, bloqueada, hay tarea del supervisor, punto de log");
Agente.lock.wait();
} catch (Exception e){
e.printStackTrace();
}
}
try{
File archivo = new File("log.txt");
FileWriter arch = new FileWriter(archivo,false);
String line;
Process p = Runtime.getRuntime().exec("ps aux");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
arch.write(line);
//System.out.println(line); //<-- Parse data here.
}
input.close();
System.out.println("hiloPsAux, en ejecucion, sin tarea del supervisor, punto de log");
Agente.lock.notifyAll();
} catch (IOException e){
e.printStackTrace();
}
}
}
public void run(){
while(true){
parseoPsAux();
try {
Thread.sleep(3000);
} catch (InterruptedException err) {
err.printStackTrace();
}
}
}
}