Question: This program should be in C or C++, anything will help! The /proc directory contain files and directories which provide the required information. You will
This program should be in C or C++, anything will help!
The /proc directory contain files and directories which provide the required information. You will write a C or C++ program to open appropriate file, read information from the file, extract & format the required data, and display the information with appropriate label. Your program should provide the following information about the system:
-
The time when system was last booted. (File name: /proc/stat). Look for line with the label btime. Time is in seconds since 1970-01-01 (epoch time). Display the time in the format yyyy-mm-dd hh:mm:ss.
-
The amount of time since system was last booted (File name: /proc/uptime). This file contains two numbers: the uptime of the system in seconds and the amount of time spent in idle process in seconds. Display the amount of time since system was last booted in the form dd:hh:mm:ss.
-
Amount of time that the CPU has spent in user mode and system mode. (File name: /proc/stat). Use the line with label cpu. The first number is the time spent in user mode and the third number is the time spent in system mode.
-
The total amount of memory in the system and the amount of memory currently available. (File name: /proc/meminfo). Use the lines with labels MemTotal and MemAvailable.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
