Skip to content

Commit

Permalink
Merge pull request #8 from oslabs-beta/Eshaan
Browse files Browse the repository at this point in the history
Configured refreshRunning method to include image name as well
  • Loading branch information
GarimaB06 authored Jan 10, 2023
2 parents 007ffbe + 641af74 commit 1692cd6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/routes/loginRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ router.post('/',
// cookieController.setAdminCookie,
// bcryptController.hashCookie,
(req, res) => {
console.log(res.locals);
console.log('Active User Session -> User:',res.locals.user);
if (res.locals.error) return res.status(200).json(res.locals);
return res.status(200).json(res.locals.user);
}
Expand Down
15 changes: 8 additions & 7 deletions src/components/helper/commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ const getContainerDetails = async (containerId) => {
// we have all the data retrived from the original command and the individual container details fetch
const insideRefreshRunning = async () => {
const apiDataList = [];
const result = await promisifiedExec('docker stats --no-stream --format "{{json .}},"')
const result = await promisifiedExec('docker ps --format "{{json .}},"')
const dockerOutput = JSON.parse(`[${result
.trim()
.slice(0, -1)
.replaceAll(' ', '')}]`)
console.log("🚀 ~ file: commands.tsx:148 ~ insideRefreshRunning ~ dockerOutput", dockerOutput)

for (let each of dockerOutput) {
const containerData = await getContainerDetails(each.ID);
Expand All @@ -157,22 +158,21 @@ const insideRefreshRunning = async () => {
// MemPerc:"7.91%"
// MemUsage:"31.64MiB/400MiB"
// Name:"docketeer-db"
// Image:"postgres:15"
// NetIO:"690kB/636kB"
// PIDs:"11"

// PIDs:"6"
const container = {
ID: apiData.id.slice(0,12),
Name: apiData.name.slice(1),
ID: each.ID,
Name: each.Names,
Image: each.Image,
CPUPerc: `${fn(((apiData.cpu_stats.cpu_usage.total_usage - apiData.precpu_stats.cpu_usage.total_usage) / (apiData.cpu_stats.system_cpu_usage - apiData.precpu_stats.system_cpu_usage)) * apiData.cpu_stats.online_cpus * 100)}%`,
MemPerc: `${fn(((apiData.memory_stats.usage - apiData.memory_stats.stats.inactive_file) / apiData.memory_stats.limit) * 100)}%`,
MemUsage: `${fn((apiData.memory_stats.usage - apiData.memory_stats.stats.inactive_file) / 1048576)}MiB / ${fn(apiData.memory_stats.limit / 1048576)}MiB`,
NetIO: `${fn(apiData.networks.eth0.rx_bytes / 1000)}kB / ${fn(apiData.networks.eth0.tx_bytes / 1000)}kB`,
BlockIO: apiData.blkio_stats.io_service_bytes_recursive ? `${fn(apiData.blkio_stats.io_service_bytes_recursive[0].value / 1000)}kB / ${fn(apiData.blkio_stats.io_service_bytes_recursive[1].value / 1000)}kB` : `0kB / 0kB`,
PIDs: `${apiData.pids_stats.current}`,
// add new data

}

apiDataList.push(container);
}

Expand Down Expand Up @@ -621,6 +621,7 @@ export const writeToDb = () => {
containerParameters[container.Name] = {
ID: container.ID,
names: container.Name,
Image: container.Image,
cpu: container.CPUPerc,
mem: container.MemPerc,
memuse: container.MemUsage,
Expand Down

0 comments on commit 1692cd6

Please sign in to comment.