btop/src/btop_linux.h

65 lines
1.5 KiB
C
Raw Normal View History

2021-05-11 09:46:41 +12:00
/* Copyright 2021 Aristocratos (jakob@qvantnet.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
indent = tab
tab-size = 4
*/
#pragma once
2021-05-11 09:46:41 +12:00
#include <string>
#include <vector>
#include <atomic>
#include <filesystem>
2021-05-20 09:21:56 +12:00
using std::string, std::vector, std::atomic;
2021-05-11 09:46:41 +12:00
namespace Global {
extern int coreCount;
}
2021-06-05 11:41:24 +12:00
namespace Tools {
double system_uptime();
}
2021-05-15 04:54:37 +12:00
namespace Proc {
extern std::filesystem::path proc_path;
extern size_t numpids;
extern atomic<bool> stop;
extern atomic<bool> collecting;
extern vector<string> sort_vector;
2021-05-15 04:54:37 +12:00
2021-06-13 04:49:27 +12:00
//* Container for process information
struct proc_info {
uint pid;
2021-06-05 11:41:24 +12:00
string name = "", cmd = "";
size_t threads = 0;
string user = "";
uint64_t mem = 0;
double cpu_p = 0.0, cpu_c = 0.0;
char state = '0';
int cpu_n = 0, p_nice = 0;
2021-06-13 04:49:27 +12:00
int ppid = -1;
string prefix = "";
};
2021-05-15 04:54:37 +12:00
extern vector<proc_info> current_procs;
2021-06-13 04:49:27 +12:00
//* Collects and sorts process information from /proc, saves to and returns reference to Proc::current_procs;
vector<proc_info>& collect();
//* Initialize needed variables for collect
void init();
}