Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using konoha.proc.*; | ||
|
||
void apache_search() { | ||
p = new Proc(["/bin/pidof", "apache2"]); | ||
ins = p.getInputStream(); | ||
while (p.isAlive()) { | ||
str = ins.readLine(); | ||
OUT << str << EOL; | ||
if (|str| > 0) { | ||
pids = str.split(" "); | ||
foreach (String spid in pids) { | ||
procinfo = new ProcInfo((int)spid); | ||
if (procinfo.states["PPid"] == "1") { | ||
String procfilename = "/proc/" + spid + "/oom_adj"; | ||
OUT << procfilename << EOL; | ||
ous = new OutputStream(file:: procfilename); | ||
ous.write((Bytes)"15"); | ||
ous.close(); | ||
} | ||
} | ||
} | ||
} | ||
OUT << "done... " << EOL; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using konoha.actor.*; | ||
|
||
int main(String[] args) | ||
{ | ||
a1 = actor:192.168.0.5:50010; | ||
ins = new InputStream("proc.k"); | ||
buf = ""; | ||
foreach (String line in ins) { | ||
if (line == "") continue; | ||
buf = buf + line + EOL; | ||
} | ||
a1.eval(buf); | ||
//OUT << buf << EOL; | ||
|
||
ins = new InputStream("apache_search.k"); | ||
buf = ""; | ||
foreach (String line in ins) { | ||
if (line == "") continue; | ||
buf = buf + line + EOL; | ||
} | ||
a1.eval(buf); | ||
//OUT << buf << EOL; | ||
a1.eval("apache_search();"); | ||
|
||
|
||
a2 = actor:192.168.0.5:50011; | ||
ins = new InputStream("memstress.k"); | ||
buf = ""; | ||
foreach (String line in ins) { | ||
if (line == "") continue; | ||
buf = buf + line + EOL; | ||
} | ||
a2.eval(buf); | ||
OUT << buf << EOL; | ||
a2.eval("invoke_memstress();"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using konoha.proc.*; | ||
|
||
void invoke_memstress() { | ||
p = new Proc(["/home/tsunade/fault/memstress-1.0.0/memstress", "102400", "17000", "50"]); | ||
OUT << p.isAlive() << EOL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
class ProcInfo { | ||
int mypid; | ||
Map states; | ||
ProcInfo(int pid) { | ||
states = {}; | ||
mypid = pid; | ||
procfilename = "/proc/" + (String)pid + "/status"; | ||
ins = new InputStream(file:: procfilename); | ||
foreach (String line in ins) { | ||
m = line.split(":"); | ||
key = m[0].trim(); | ||
value = m[1].trim(); | ||
states[key] = value; | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters