Skip to content

Commit

Permalink
移除不必要的注释
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Apr 18, 2022
1 parent 0d6cc57 commit 4a92fa1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 150 deletions.
70 changes: 0 additions & 70 deletions task/bt-psutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,53 +268,6 @@ int get_process_info(int pid,struct process_info *p_info){
return 0;
}

// /**
// * @brief 获取进程CPU使用率
// * @author hwliang
// * @param pid <int> 进程ID
// * @return float <float> 进程CPU使用率
// */
// float get_process_cpu_percent(int pid){

// if (process_old_list.count(pid) == 0){
// struct process_info p_info;
// get_process_info(pid, &p_info);
// if(p_info.pid == 0) p_info.pid = pid;
// process_old_list[pid] = p_info;
// }

// int cpu_count = get_cpu_count();
// struct process_info p_info2;
// get_process_info(pid, &p_info2);

// int cycle = p_info2.read_time - process_old_list[pid].read_time;
// if (cycle == 0) cycle = 1;
// float cpu_percent = ((p_info2.user + p_info2.system + p_info2.children_system + p_info2.children_user) - (process_old_list[pid].user + process_old_list[pid].system + process_old_list[pid].children_system + process_old_list[pid].children_user)) / cycle / cpu_count * 100.00;
// process_old_list[pid] = p_info2;
// return cpu_percent;
// }

// /**
// * @brief 获取PID列表
// * @author hwliang
// * @param pids <vector<int>> 用于存储PID列表的vector
// * @return int 成功返回0
// */
// int get_pids(int *pids){
// DIR *dir;
// struct dirent *ptr;
// dir = opendir("/proc");
// if (dir == NULL) return -1;
// while ((ptr = readdir(dir)) != NULL){
// if (ptr->d_name[0] >= '0' && ptr->d_name[0] <= '9') {
// pids.push_back(atoi(ptr->d_name));
// }
// }
// closedir(dir);
// free(ptr);
// return 0;
// }

/**
* @brief 获取磁盘IO信息
* @author hwliang
Expand Down Expand Up @@ -363,14 +316,6 @@ int get_disk_info(struct disk_info *disk_info_list){
n++;
}
fclose(fp);
// unsigned long long total_read_bytes = 0;
// for(int i = 0; i < n; i++){
// char s = disk_info_list[i].name[strlen(disk_info_list[i].name) -1];
// char e = disk_info_list[i].name[strlen(disk_info_list[i].name) -2];
// if(e != '-' && (s > '0' && s < '9')) continue;
// total_read_bytes += disk_info_list[i].read_bytes;
// printf("name: %s, read_bytes: %ld, write_bytes: %ld, write_count: %ld, read_count: %ld\n", disk_info_list[i].name, disk_info_list[i].read_bytes, disk_info_list[i].write_bytes, disk_info_list[i].write_count, disk_info_list[i].read_count);
// }
return n;
}

Expand Down Expand Up @@ -429,15 +374,6 @@ void get_disk_io(struct disk_info_all *disk_io,int cycle) {
disk_io->write_bytes = disk_io2.write_bytes - disk_io1.write_bytes;
disk_io->write_time = disk_io2.write_time - disk_io1.write_time;

// printf("disk_io->read_count:%ld\n",disk_io->read_count);
// printf("disk_io->read_merged_count:%ld\n",disk_io->read_merged_count);
// printf("disk_io->read_bytes:%ld\n",disk_io->read_bytes);
// printf("disk_io->read_time:%ld\n",disk_io->read_time);
// printf("disk_io->write_count:%ld\n",disk_io->write_count);
// printf("disk_io->write_merged_count:%ld\n",disk_io->write_merged_count);
// printf("disk_io->write_bytes:%ld\n",disk_io->write_bytes);
// printf("disk_io->write_time:%ld\n",disk_io->write_time);

}


Expand Down Expand Up @@ -536,16 +472,13 @@ void get_network_io(struct network_info_all *network_io,int cycle){
network_io2.packets_sent += network_info_list2[i].packets_sent;
network_io2.errout += network_info_list2[i].errout;
network_io2.dropout += network_info_list2[i].dropout;
// network_info_list2[i].name[strlen(network_info_list2[i].name)-1] = '\0';
sprintf(j_str, "\"%s\":%.2f,", network_info_list2[i].name, (network_info_list2[i].bytes_sent - network_info_list1[i].bytes_sent) / 1024.0);
strcat(network_io->sent_json, j_str);
sprintf(j_str, "\"%s\":%.2f,", network_info_list2[i].name, (network_info_list2[i].bytes_recv - network_info_list1[i].bytes_recv) / 1024.0);
strcat(network_io->recv_json, j_str);
}
network_io->sent_json[strlen(network_io->sent_json) - 1] = '}';
network_io->recv_json[strlen(network_io->recv_json) - 1] = '}';
// printf("network_io->sent_json:%s\n",network_io->sent_json);
// printf("network_io->recv_json:%s\n",network_io->recv_json);

network_io->total_bytes_sent = network_io2.bytes_sent;
network_io->total_bytes_recv = network_io2.bytes_recv;
Expand Down Expand Up @@ -587,9 +520,6 @@ void get_load_average(struct load_average_info *load_average){
// 分割活动进程数/总进程数
char **p1;
char delim1[] = "/";
// split(p, delim1, p1);
// load_average->running_processes = atoi(p1[0]);
// load_average->total_processes = atoi(p1[1]);
}else if(i == 4){
load_average->last_pid = atoi(p);
}
Expand Down
3 changes: 0 additions & 3 deletions task/bt-task.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#include <dirent.h>
#include <pthread.h>
#include <signal.h>
// #include <map>
// #include <vector>
// using namespace std;
#include <sys/types.h>
#include <sys/stat.h>
#include "cJSON.c"
Expand Down
78 changes: 1 addition & 77 deletions task/public.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,87 +17,11 @@
#include <regex.h>
#include <unistd.h>
#include <time.h>
// #include <curl/curl.h>
#include "md5.h"



const char panel_path[] = "/www/server/panel";
int curl_buff_size = 1024;
// /**
// * @brief CURL写入数据回调函数
// * @author hwliang<2022-04-01>
// * @param ptr
// * @param size
// * @param nmemb
// * @param stream
// * @return size_t
// */
// size_t write_data(char *ptr, size_t size, size_t nmemb, char *stream)
// {
// size_t sizes = size * nmemb;
// if (sizes > curl_buff_size)
// {
// curl_buff_size = sizes + 1;
// stream = (char *)realloc(stream, curl_buff_size);
// }
// // memcpy(stream, ptr, sizes);
// strncat(stream,ptr,sizes);
// return sizes;
// }


// /**
// * @brief 以GET方式请求
// * @author hwliang<2022-04-01>
// * @param url URL地址
// * @param data 返回的数据
// * @param timeout 超时时间
// * @return int
// */
// int http_get(char *url, char *data,int timeout){
// CURL *curl = curl_easy_init();
// data[0] = '\0';
// strcpy(data, "");
// curl_easy_setopt(curl, CURLOPT_URL, url);
// curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
// // curl_easy_setopt(curl, CURLOPT_VERBOSE,1L);
// CURLcode res = curl_easy_perform(curl);
// curl_easy_cleanup(curl);
// return res;
// }

// /**
// * @brief 以POST方式请求
// * @author hwliang<2022-04-01>
// * @param url URL地址
// * @param pdata POST数据
// * @param data 返回的数据
// * @param timeout 超时时间
// * @return int
// */
// int http_post(char *url,char *pdata,char *data,int timeout){
// CURL *curl = curl_easy_init();
// data[0] = '\0';
// strcpy(data, "");
// curl_easy_setopt(curl, CURLOPT_URL, url);
// curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
// curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
// curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
// curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
// curl_easy_setopt(curl, CURLOPT_POST, 1L);
// curl_easy_setopt(curl, CURLOPT_POSTFIELDS, pdata);
// // curl_easy_setopt(curl, CURLOPT_VERBOSE,1L);
// CURLcode res = curl_easy_perform(curl);
// curl_easy_cleanup(curl);
// curl_global_cleanup();
// return res;
// }


/**
* @brief 取数组长度
Expand Down

0 comments on commit 4a92fa1

Please sign in to comment.