 |
pacemaker
2.0.1-9e909a5bdd
Scalable High-Availability cluster resource manager
|
Go to the documentation of this file.
18 #include <sys/types.h>
44 char procpath[128] = { 0 };
51 local_pid = atoi(entry->d_name);
52 if ((local_pid <= 0) || (strlen(entry->d_name) > 114)) {
60 strcpy(procpath,
"/proc/");
61 strcat(procpath, entry->d_name);
62 fd = open(procpath, O_RDONLY);
66 if (fstat(fd, &statbuf) < 0) {
73 if (!S_ISDIR(statbuf.st_mode)) {
82 strcat(procpath,
"/status");
83 file = fopen(procpath,
"r");
87 if (fscanf(file,
"Name:\t%15[^\n]", name) != 1) {
113 struct dirent *entry;
115 char entry_name[64] = { 0 };
117 dp = opendir(
"/proc");
119 crm_notice(
"Can not read /proc directory to track existing components");
123 while ((entry = readdir(dp)) != NULL) {
128 crm_info(
"Found %s active as process %d", name,
pid);
150 stream = fopen(
"/proc/stat",
"r");
151 if (stream == NULL) {
152 crm_perror(LOG_INFO,
"Could not open /proc/stat");
156 while (fgets(buffer,
sizeof(buffer), stream)) {
163 return cores? cores : 1;
int crm_pid_active(long pid, const char *daemon)
#define crm_notice(fmt, args...)
#define safe_str_eq(a, b)
unsigned int crm_procfs_num_cores(void)
int crm_procfs_process_info(struct dirent *entry, char *name, int *pid)
#define crm_info(fmt, args...)
int crm_procfs_pid_of(const char *name)
#define crm_perror(level, fmt, args...)
Log a system error message.
bool crm_starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.