Skip to content

Commit

Permalink
cpu utilisation
Browse files Browse the repository at this point in the history
  • Loading branch information
build-with-rishi committed Apr 19, 2022
1 parent 9b40e40 commit 98ab8dc
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 72 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
4 changes: 4 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,10 @@ h1, h2, h3, h4, h5, h6 {
.section-flag {
color: #7e7e7e;
}
.machine-metric {
color: #a5c5fe;
font-size: 1.5rem;
}
.section h6 {
color: #18d26e;
}
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ <h6>${value.ip}</h6>
document.getElementById('machineCount').innerHTML = machineCount;

//count average V-score
totalvscore += value.vscore;
avgVscore = totalvscore / machineCount;
document.getElementById('avgVscore').innerHTML = avgVscore;
totalvscore += parseInt(value.vscore);
avgVscore = (totalvscore / machineCount);
document.getElementById('avgVscore').innerHTML = Math.round(avgVscore);

$('#resultsContainer').append(machine);
});
Expand Down
171 changes: 102 additions & 69 deletions machine.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h5 class="card-title">V - Score</h5>
<div class="card machine-card">
<div class="dark-box">
<div class="section os">
<p class="section-flag">Disk Space</p>
<p class="section-flag machine-metric">Disk Space</p>
<h6 id="c-drive"></h6>
<div class="progress mt-3">
<div class="progress-bar disk-fill" role="progressbar" style="width: 0%" aria-valuenow="49" aria-valuemin="0" aria-valuemax="100" id="progressbar"></div>
Expand All @@ -94,10 +94,10 @@ <h6 id="c-drive"></h6>
<div class="card machine-card">
<div class="dark-box">
<div class="section os">
<p class="section-flag">CPU Utilisation</p>
<h6></h6>
<p class="section-flag machine-metric">CPU Utilisation</p>
<h6 id="cpupercent"></h6>
<div class="progress mt-3">
<div class="progress-bar bg-warning" role="progressbar" style="width: 88%" aria-valuenow="88" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-warning" id="cpubar" role="progressbar" style="width: 0%" aria-valuenow="88" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
Expand All @@ -109,10 +109,10 @@ <h6></h6>
<div class="card machine-card">
<div class="dark-box">
<div class="section os">
<p class="section-flag">Free RAM</p>
<h6></h6>
<p class="section-flag machine-metric">Free RAM</p>
<h6 id="rammb"></h6>
<div class="progress mt-3">
<div class="progress-bar bg-primary" role="progressbar" style="width: 92%" aria-valuenow="88" aria-valuemin="0" aria-valuemax="100"></div>
<div class="progress-bar bg-primary" id="rambar" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
Expand All @@ -127,69 +127,87 @@ <h6></h6>

<div class="col-lg-12 results-container">

<!-- Result Card -->
<div class="card">
<div class="card-body">
<!-- <h5 class="card-title" >System Metrics</h5> -->
<table class="table table-borderless machine-table">
<tr>
<td>#</td>
<th>Operating System</th>
<td>:</td>
<td id="os"></td>
</tr>
<tr>
<td>#</td>
<th>Local IP Address</th>
<td>:</td>
<td id="ip"></td>
</tr>
<tr>
<td>#</td>
<th>Mac Address</th>
<td>:</td>
<td id="mac"></td>
</tr>
<tr>
<td>#</td>
<th>Firewall Status</th>
<td>:</td>
<td id="firewall"></td>
</tr>
<tr>
<td>#</td>
<th>Antivirus Status</th>
<td>:</td>
<td id="av"></td>
</tr>
<tr>
<td>#</td>
<th>Windows Update Process Running</th>
<td>:</td>
<td id="update"></td>
</tr>
<tr>
<td>#</td>
<th>Open Ports</th>
<td>:</td>
<td id="ports"></td>
</tr>
<!-- <tr>
<td>#</td>
<th>Free RAM</th>
<td>:</td>
<td id="ram"></td>
</tr>
<tr>
<td>#</td>
<th>CPU Load</th>
<td>:</td>
<td id="cpu"></td>
</tr> -->
</table>
<!-- Result Card -->
<div class="card">
<div class="card-body">
<!-- <h5 class="card-title" >System Metrics</h5> -->
<table class="table table-borderless machine-table">
<tr>
<td>#</td>
<th>Operating System</th>
<td>:</td>
<td id="os"></td>
</tr>
<tr>
<td>#</td>
<th>Local IP Address</th>
<td>:</td>
<td id="ip"></td>
</tr>
<tr>
<td>#</td>
<th>Mac Address</th>
<td>:</td>
<td id="mac"></td>
</tr>
<tr>
<td>#</td>
<th>Firewall Status</th>
<td>:</td>
<td id="firewall"></td>
</tr>
<tr>
<td>#</td>
<th>Is Antivirus Installed ?</th>
<td>:</td>
<td id="av"></td>
</tr>
<tr>
<td>#</td>
<th>Antivirus Name</th>
<td>:</td>
<td id="avname"></td>
</tr>
<tr>
<td>#</td>
<th>Is Antivirus Enabled ?</th>
<td>:</td>
<td id="avActive"></td>
</tr>
<tr>
<td>#</td>
<th>Is Antivirus Outdated ?</th>
<td>:</td>
<td id="avOutdated"></td>
</tr>
<tr>
<td>#</td>
<th>Windows Update Process Running</th>
<td>:</td>
<td id="update"></td>
</tr>
<tr>
<td>#</td>
<th>Open Ports</th>
<td>:</td>
<td id="ports"></td>
</tr>
<!-- <tr>
<td>#</td>
<th>Free RAM</th>
<td>:</td>
<td id="ram"></td>
</tr>
<tr>
<td>#</td>
<th>CPU Load</th>
<td>:</td>
<td id="cpu"></td>
</tr> -->
</table>

</div>
</div>
</div>

</div>

Expand Down Expand Up @@ -369,7 +387,10 @@ <h3>Brave Browser</h3>
}

var deviceSpecificMacAddress = getQueryVariable('mac');

function round(value, precision) {
var multiplier = Math.pow(10, precision || 0);
return Math.round(value * multiplier) / multiplier;
}
$(document).ready(function () {
$.getJSON("https://v-shark.herokuapp.com/data",function (data) {
$.each(data, function (key, value) {
Expand All @@ -380,11 +401,23 @@ <h3>Brave Browser</h3>
document.getElementById('mac').innerHTML = value.mac;
document.getElementById('firewall').innerHTML = value.firewall_status;
document.getElementById('av').innerHTML = value.antivirus_installed;
document.getElementById('avname').innerHTML = value.av_name;
document.getElementById('avActive').innerHTML = value.av_enabled;
document.getElementById('avOutdated').innerHTML = value.av_outdated;
document.getElementById('update').innerHTML = value.update_process;
document.getElementById('ports').innerHTML = value.openport;
document.getElementById('c-drive').innerHTML = value.c_drive;
document.getElementById('machineName').innerHTML = value.machinename;
var badJson = value.running;
var correctJson = badJson.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/g, '"$2": ');
var stats = JSON.parse(correctJson);


document.getElementById('cpupercent').innerHTML = stats.cpu + "%";
document.getElementById("cpubar").setAttribute('style',`width:${stats.cpu}%;`);
document.getElementById('rammb').innerHTML = `${ round((parseInt(stats.ur)/(1024*1024)),1)} GB /`+` ${ round((parseInt(stats.tr)/(1024*1024)),1)} GB`
var per = (parseInt(stats.ur) / parseInt (stats.tr))*100;
document.getElementById("rambar").setAttribute('style',`width:${round(per,0)}%;`);
cDrive = value.c_drive;
var occupied = cDrive.split('/')[0].trim().slice(0,-2);
var total = cDrive.split('/')[1].trim().slice(0,-2);
Expand Down

0 comments on commit 98ab8dc

Please sign in to comment.