Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yu/mac verison #27

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.8.12)
project(monitor)

set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)
include_directories(${CURSES_INCLUDE_DIRS})
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall -Werror -ansi -pedantic -pthread --std=c++11")
include_directories(includes libs/c++ /opt/homebrew/opt/ncurses/include)
link_directories(/opt/homebrew/opt/ncurses/lib)
link_libraries(ncurses)

# set(CURSES_NEED_NCURSES TRUE)
# find_package(ncurses REQUIRED)
# include_directories(${CURSES_INCLUDE_DIRS})

include_directories(include)
file(GLOB SOURCES "src/*.cpp")
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
CXXFLAGS += -W -Wextra -Wall -Werror -ansi -pedantic
CXXFLAGS += -pthread --std=c++11 -Iincludes -Ilibs/c++ -I/usr/local/opt/ncurses/include
LDFLAGS += -lncurses -L/usr/local/opt/ncurses/lib

# existing Makefile targets go here

.PHONY: all
all: format test build
all: format build

.PHONY: format
format:
Expand All @@ -22,3 +28,4 @@ debug:
.PHONY: clean
clean:
rm -rf build

1 change: 1 addition & 0 deletions include/linux_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ enum CPUStates {
kGuestNice_
};
std::vector<std::string> CpuUtilization();
float cpuProcessUtilization(int pid);
long Jiffies();
long ActiveJiffies();
long ActiveJiffies(int pid);
Expand Down
7 changes: 7 additions & 0 deletions include/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ It contains relevant attributes as shown below
*/
class Process {
public:
Process(int pid) : pid_(pid){};
int Pid(); // TODO: See src/process.cpp
std::string User(); // TODO: See src/process.cpp
std::string Command(); // TODO: See src/process.cpp
Expand All @@ -18,6 +19,12 @@ class Process {

// TODO: Declare any necessary private members
private:
int pid_;
std::string user_;
std::string command_;
float cpuUtilization_;
std::string ram_;
long int upTime_;
};

#endif
5 changes: 4 additions & 1 deletion include/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

class Processor {
public:
Processor() : prevTotal_(0), prevIdle_(0){};
float Utilization(); // TODO: See src/processor.cpp

// TODO: Declare any necessary private members
private:
float prevTotal_;
float prevIdle_;
};

#endif
#endif
18 changes: 13 additions & 5 deletions src/format.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#include <string>

#include "format.h"

#include <string>

using std::string;

// TODO: Complete this helper function
// DONE: Complete this helper function
// INPUT: Long int measuring seconds
// OUTPUT: HH:MM:SS
// REMOVE: [[maybe_unused]] once you define the function
string Format::ElapsedTime(long seconds[[maybe_unused]]) { return string(); }
string Format::ElapsedTime(long seconds) {
string timeFormat;
int hours = seconds / 3600;
int minutes = (seconds % 3600) / 60;
int sec = seconds % 60;
timeFormat = std::to_string(hours) + ":" + std::to_string(minutes) + ":" +
std::to_string(sec);

return timeFormat;
}
Loading
Loading