Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RamSailopal committed Feb 11, 2022
0 parents commit 476b0a5
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clearlock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
source /usr/share/cockpit/yottadb/envfile
source $yotta_inst/ydb_env_set
/usr/local/yottadb/lke << EOF > /dev/null
clear pid=$1
Y
exit
EOF
1 change: 1 addition & 0 deletions envfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export yotta_inst="/usr/local/yottadb"
4 changes: 4 additions & 0 deletions freecnt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
source /usr/share/cockpit/yottadb/envfile
source $yotta_inst/ydb_env_set
ydb <<< 'D ^%FREECNT' | awk '/^---/ { mrk=1;next } mrk==1 { sub(")","",$5);print $1":"$2":"$3":"$5":"$6;mrk=0 }'
4 changes: 4 additions & 0 deletions journfiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
source /root/.local/share/cockpit/yottafree1/envfile
source $yotta_inst/ydb_env_set
find "$ydb_dir/$ydb_rel/g" -name "yottadb.mjl*" -exec ls -l '{}' \; | awk '{ print $9"@"$5"@"$6" "$7" "$8 }'
4 changes: 4 additions & 0 deletions locks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
source /usr/share/cockpit/yottadb/envfile
source $yotta_inst/ydb_env_set
$ydb_dist/lke show -all 2>&1 | awk '/Owned/ { print $1":"$5}'
10 changes: 10 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": 0,

"tools": {
"yottafree": {
"label": "YottaDB",
"path": "yottafree.html"
}
}
}
2 changes: 2 additions & 0 deletions openports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
ss -lnp | awk '/yottadb/ { split($5,arr,":");printf "%s:",arr[4],split($7,arr,",");split(arr[2],arr1,"=");printf "%s",arr1[2];proc=arr1[2] } END { while("cat /proc/"proc"/net/netstat" | getline var) { } split(var,net," ");printf ":%s:%s",net[4],net[5];close("cat /proc/"proc"/net/netstat") }'
59 changes: 59 additions & 0 deletions yottafree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<title>YottaDB Statistics</title>
<meta charset="utf-8">
<link href="../base1/patternfly.css" type="text/css" rel="stylesheet">
<link href="system.css" type="text/css" rel="stylesheet">
<link href="services.css" type="text/css" rel="stylesheet">
<script src="../base1/cockpit.js"></script>
</head>
<body>
</br>
</br>
<div>
<button id="refresh">Refresh</button>
</div>
</br>
</br>
<div><h1>Free Count</h1></div>
<div class="my-table">
<table class="table table-hover" id="yottatab">
<tr><th>Region</th><th>Free</th><th>Total</th><th>%Free</th><th>Location</th></tr>
</table>
</div>
</br>
</br>
<div><h1>Processes</h1></div>
<div>
<table class="table table-hover" id="yottatab2">
<tr><th>PID</th><th>USER</th><th>PR</th><th>NI</th><th>VIRT</th><th>RES</th><th>SHR</th><th>S</th><th>%CPU</th><th>%MEM</th><th>TIME+</th></tr>
</table>
</div>
</br>
</br>
<div><h1>Open Ports</h1></div>
<div>
<table class="table table-hover" id="yottatab3">
<tr><th>PORT</th><th>PID</th><th>In Bound MultiCast Packets</th><th>Out Bound MultiCast Packets</th></tr>
</table>
</div>
</br>
</br>
<div><h1>Journal Files</h1></div>
<div>
<table class="table table-hover" id="yottatab4">
<tr><th>Location</th><th>Size</th><th>Date Created</th></tr>
</table>
</div>
</br>
</br>
<div><h1>Database Locks</h1></div>
<div>
<table class="table table-hover" id="yottatab5">
<tr><th>Global</th><th>PID</th><th></th></tr>
</table>
</div>
<script src="yottafree.js"></script>
</body>
</html>
183 changes: 183 additions & 0 deletions yottafree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
const yottatab = document.getElementById("yottatab");
const yottatab1 = document.getElementById("yottatab2");
const yottatab2 = document.getElementById("yottatab3");
const yottatab3 = document.getElementById("yottatab4");
const yottatab4 = document.getElementById("yottatab5");
const button = document.getElementById("refresh");

function yottafree_run() {
var rowCount = yottatab1.rows.length;
for (var i = rowCount; i > 1; i--) {
yottatab1.deleteRow(i-1);
}
var rowCount = yottatab.rows.length;
for (var i = rowCount; i > 1; i--) {
yottatab.deleteRow(i-1);
}
var rowCount = yottatab2.rows.length;
for (var i = rowCount; i > 1; i--) {
yottatab2.deleteRow(i-1);
}
var rowCount = yottatab3.rows.length;
for (var i = rowCount; i > 1; i--) {
yottatab3.deleteRow(i-1);
}
var rowCount = yottatab4.rows.length;
for (var i = rowCount; i > 1; i--) {
yottatab4.deleteRow(i-1);
}



cockpit.spawn(["/bin/bash", "-c", "/usr/share/cockpit/yottadb/freecnt.sh"])
.stream(yottafree_output)
cockpit.spawn(["/bin/bash", "-c", "/usr/share/cockpit/yottadb/yottaprocs.sh"])
.stream(yottaproc_output)
cockpit.spawn(["/bin/bash", "-c", "/usr/share/cockpit/yottadb/openports.sh"])
.stream(yottaports_output)
cockpit.spawn(["/bin/bash", "-c", "/usr/share/cockpit/yottadb/journfiles.sh"])
.stream(yottajourn_output)
cockpit.spawn(["/bin/bash", "-c", "/usr/share/cockpit/yottadb/locks.sh"])
.stream(yottalocks_output)

}

function remlock_output(data) {
console.log(data);
}

function remlock_fail(data) {
console.log(data);
}


function remlock(pid) {
cockpit.spawn(["/bin/bash", "-c", "/usr/share/cockpit/yottadb/clearlock.sh " + pid])
.stream(remlock_output)
.catch(remlock_fail)


}

function yottaports_output(data) {
portlines=data.split("\n");
for (i=0;i<portlines.length;i++) {
var row = yottatab2.insertRow(1);
var row = yottatab2.rows[1];
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
const portarray = portlines[i].split(":");
cell1.innerHTML=portarray[0];
cell2.innerHTML=portarray[1];
cell3.innerHTML=portarray[2];
cell4.innerHTML=portarray[3];
}
}


function yottalocks_output(data) {
locklines=data.split("\n");
for (i=0;i<locklines.length;i++) {
var row = yottatab4.insertRow(1);
var row = yottatab4.rows[1];
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
if (locklines[i] != "") {
const lockarray = locklines[i].split(":");
cell1.innerHTML=lockarray[0];
cell2.innerHTML=lockarray[1];
cell3.innerHTML="<input type=\"button\" value=\"Remove\" id=\"lock" + i + "\"'/>";
document.getElementById('lock'+i).addEventListener("click", function() { remlock(lockarray[1]);
setTimeout(() => { button.click(); }, 1000);

});
}
}
}


function yottajourn_output(data) {
const journlines=data.split("\n");
for (i=0;i<journlines.length;i++) {
var row = yottatab3.insertRow(1);
var row = yottatab3.rows[1];
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
if (journlines[i] != "") {
const journarray = journlines[i].split("@");
cell1.innerHTML=journarray[0];
cell2.innerHTML=journarray[1];
cell3.innerHTML=journarray[2];
}
}
}


function yottafree_output(data) {
var row = yottatab.insertRow(1);
var row = yottatab.rows[1];
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);
const freearray = data.split(":");
cell1.innerHTML=freearray[0];
cell2.innerHTML=freearray[1];
cell3.innerHTML=freearray[2];
cell4.innerHTML=freearray[3];
cell5.innerHTML=freearray[4];
}


function yottaproc_output(data) {
if (data.substring(0,3)=="PID") {
return;
}
var row = yottatab1.insertRow(1);
const procarray = data.split("\n");
var arrayLength = procarray.length-1;
for (var i = 0; i < arrayLength; i++) {
const procarray1 = procarray[i].split("#");
var cell1=row.insertCell(0);
cell1.innerHTML=procarray1[0];
var cell2=row.insertCell(1);
cell2.innerHTML=procarray1[1];
var cell3=row.insertCell(2);
cell3.innerHTML=procarray1[2];
var cell4=row.insertCell(3);
cell4.innerHTML=procarray1[3];
var cell5=row.insertCell(4);
cell5.innerHTML=procarray1[4];
var cell6=row.insertCell(5);
cell6.innerHTML=procarray1[5];
var cell7=row.insertCell(6);
cell7.innerHTML=procarray1[6];
var cell8=row.insertCell(7);
cell8.innerHTML=procarray1[7];
var cell9=row.insertCell(8);
cell9.innerHTML=procarray1[8];
var cell10=row.insertCell(9);
cell10.innerHTML=procarray1[9];
var cell11=row.insertCell(10);
cell11.innerHTML=procarray1[10];





}
}


// Connect the button to starting the "ping" process
button.addEventListener("click", yottafree_run);

document.addEventListener('DOMContentLoaded', yottafree_run);

// Send a 'init' message. This tells integration tests that we are ready to go
cockpit.transport.wait(function() { });
5 changes: 5 additions & 0 deletions yottaprocs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
while read proc
do
xargs top -b -n 1 -p <<< "$proc" | awk 'END { print $1"#"$2"#"$3"#"$4"#"$5"#"$6"#"$7"#"$8"#"$9"#"$10"#"$11 }'
done <<< "$(ps -ef | grep yottadb | grep -v "grep" | awk '{ print $2 }')"

0 comments on commit 476b0a5

Please sign in to comment.