35 void sysmonD::init_sysmonD()
40 qtiAirSerialNo = (std::string)(ConfigDictionary())[
"airTemp_serial_no"];
42 _logger->log(Logger::LOG_LEV_INFO,
"Set air temp probe ser. no. to: %s", qtiAirSerialNo.c_str());
44 catch(Config_File_Exception)
47 _logger->log(Logger::LOG_LEV_INFO,
"Air temp probe ser. no. not found");
53 qtiJoe47SerialNo = (std::string)(ConfigDictionary())[
"joe47Temp_serial_no"];
55 _logger->log(Logger::LOG_LEV_INFO,
"Set joe 47 temp probe ser. no. to: %s", qtiJoe47SerialNo.c_str());
57 catch(Config_File_Exception)
60 _logger->log(Logger::LOG_LEV_INFO,
"Joe 47 temp probe ser. no. not found");
66 qtiAmbSerialNo = (std::string)(ConfigDictionary())[
"ambTemp_serial_no"];
68 _logger->log(Logger::LOG_LEV_INFO,
"Set ambient temp probe ser. no. to: %s", qtiAmbSerialNo.c_str());
70 catch(Config_File_Exception)
73 _logger->log(Logger::LOG_LEV_INFO,
"Ambient temp probe ser. no. not found");
83 _logger->log(Logger::LOG_LEV_ERROR,
"Could not create status board.");
88 strncpy(bsb->appname, MyFullName().c_str(), 25);
92 _tempsLogger = Logger::get(
"VisAO Temperature", Logger::LOG_LEV_INFO,
"TELEMETRY");
97 core_temp_warn = (double)(ConfigDictionary())[
"core_temp_warn"];
98 core_temp_limit = (double)(ConfigDictionary())[
"core_temp_limit"];
99 hdd_used_warn = (double)(ConfigDictionary())[
"hdd_used_warn"];
100 hdd_used_limit = (double)(ConfigDictionary())[
"hdd_used_limit"];
101 hdd_temp_warn = (double)(ConfigDictionary())[
"hdd_temp_warn"];
102 hdd_temp_limit = (double)(ConfigDictionary())[
"hdd_temp_limit"];
103 gpu_temp_warn = (double)(ConfigDictionary())[
"gpu_temp_warn"];
104 gpu_temp_limit = (double)(ConfigDictionary())[
"gpu_temp_limit"];
105 air_temp_warn = (double)(ConfigDictionary())[
"air_temp_warn"];
106 air_temp_limit = (double)(ConfigDictionary())[
"air_temp_limit"];
107 joe_temp_warn = (double)(ConfigDictionary())[
"joe_temp_warn"];
108 joe_temp_limit = (double)(ConfigDictionary())[
"joe_temp_limit"];
110 catch(Config_File_Exception)
112 _logger->log(Logger::LOG_LEV_FATAL,
"Missing warning and limit data");
119 int sysmonD::get_sysstat()
121 double cpun, user, nice, sys, iowait, irq, soft, steal, intrs;
125 com += getenv(
"VISAO_ROOT");
126 com +=
"/bin/get_sysstat.sh";
132 fin.open(
"sysstat.txt");
136 fin >> core_temps[i];
148 std::cout <<
"mem_free: " << mem_free <<
"\n";
174 visao_mdstat(raid_stat);
179 int sysmonD::get_GPUstat()
182 system(
"nvidia-smi | grep Default > GPUstat.txt");
184 fin.open(
"GPUstat.txt");
192 for(
int i=0;i<6; i++) fin >> tmp;
202 int sysmonD::get_HDDstat()
206 system(
"/usr/sbin/smartctl /dev/sda --all | grep Temperature_Celsius > HDDstat.txt");
208 fin.open(
"HDDstat.txt");
210 for(
int i=0; i < 10;i++) fin >> tmp;
215 HDDTemp_a = atoi(tmp.c_str());
216 std::cout << HDDTemp_a <<
"\n";
218 system(
"/usr/sbin/smartctl /dev/sdb --all | grep Temperature_Celsius > HDDstat.txt");
219 fin.open(
"HDDstat.txt");
220 for(
int i=0; i < 10;i++) fin >> tmp;
223 HDDTemp_b = atoi(tmp.c_str());
228 sysmonD * global_sysmonD;
230 static void timeout_handler(
int sig, siginfo_t *si,
void *uc)
233 global_sysmonD->qtiTimeout();
237 std::cout <<
"caught in handler\n";
239 std::cout <<
"Sighandler returning" << std::endl;
244 int sysmonD::setupQTI()
248 struct itimerspec its, itsdisarm;
249 long long freq_nanosecs;
253 global_sysmonD =
this;
255 sa.sa_flags = SA_SIGINFO;
256 sa.sa_sigaction = timeout_handler;
257 sigemptyset(&sa.sa_mask);
258 sigaction(RTSIGTIMEOUT, &sa, NULL);
261 sev.sigev_notify = SIGEV_SIGNAL;
262 sev.sigev_signo = RTSIGTIMEOUT;
263 sev.sigev_value.sival_ptr = &timerid;
266 freq_nanosecs = (
long long) 2.*1e9;
267 its.it_value.tv_sec = freq_nanosecs/1000000000;
268 its.it_value.tv_nsec = freq_nanosecs % 1000000000;
269 its.it_interval.tv_sec = its.it_value.tv_sec;
270 its.it_interval.tv_nsec = its.it_value.tv_nsec;
272 itsdisarm.it_value.tv_sec = 0;
273 itsdisarm.it_value.tv_nsec = 0;
274 itsdisarm.it_interval.tv_sec = 0;
275 itsdisarm.it_interval.tv_nsec = 0;
287 timer_create(CLOCK_REALTIME, &sev, &timerid);
289 for(
int i=0; i < nprobes; i++)
291 snprintf(devpath,25,
"/dev/ttyACM%i", i);
292 std::cout <<
"Reading: " << devpath <<
"\n";
293 qtiProbes[i].setDevPath(devpath);
297 timer_settime(timerid, 0, &its, 0);
299 timer_settime(timerid, 0, &itsdisarm, 0);
312 std::cout <<
"Got: " << qtiProbes[i].getSerialNumber() <<
"\n";
322 for(
int i=0; i<nprobes; i++)
324 if(qtiProbes[i].getSerialNumber() == qtiAirSerialNo)
326 _logger->log(Logger::LOG_LEV_INFO,
"Found Air Temp. Probe.");
331 if(qtiAirIndex == -1)
333 _logger->log(Logger::LOG_LEV_INFO,
"Could not find Air Temp. Probe.");
340 for(
int i=0; i<nprobes; i++)
342 if(qtiProbes[i].getSerialNumber() == qtiJoe47SerialNo)
344 _logger->log(Logger::LOG_LEV_INFO,
"Found Joe 47 Temp. Probe.");
349 if(qtiJoe47Index == -1)
351 _logger->log(Logger::LOG_LEV_INFO,
"Could not find Joe47 Temp. Probe.");
358 for(
int i=0; i<nprobes; i++)
360 if(qtiProbes[i].getSerialNumber() == qtiAmbSerialNo)
362 _logger->log(Logger::LOG_LEV_INFO,
"Found Ambient Temp. Probe.");
367 if(qtiAmbIndex == -1)
369 _logger->log(Logger::LOG_LEV_INFO,
"Could not find Ambient Temp. Probe.");
373 std::cout <<
"Done initing QTI devices" << std::endl;
380 void sysmonD::qtiTimeout()
383 ERROR_REPORT(
"Timed out looking for QTI teperature devices.");
391 int sysmonD::get_QTITemps()
397 if(haveQTIAir && qtiAirIndex > -1)
399 airTemp = qtiProbes[qtiAirIndex].getTemperature();
400 if(airTemp < -100 || airTemp > 500) airTemp = 0.0;
402 else airTemp = -100.;
405 std::cout <<
"Timed out\n";
407 if(haveQTIJoe47 && qtiJoe47Index > -1)
409 joe47Temp = qtiProbes[qtiJoe47Index].getTemperature();
410 if(joe47Temp < -100 || joe47Temp > 500) joe47Temp = 0.0;
412 else joe47Temp = -100.;
413 if(joe47Temp == -1000)
415 std::cout <<
"Timed out\n";
418 if(haveQTIAmb && qtiAmbIndex > -1)
420 ambTemp = qtiProbes[qtiAmbIndex].getTemperature();
421 if(ambTemp < -100 || ambTemp > 500) ambTemp = 0.0;
422 std::cout << ambTemp <<
"\n";
424 else ambTemp = -100.;
436 ERROR_REPORT(
"Error installing main thread catcher.");
484 ssb->core_temps[i] = core_temps[i];
485 ssb->core_max[i] = core_max[i];
492 ssb->core_idle[i] = core_idle[i];
497 ssb->raid_stat[i] = raid_stat[i];
501 ssb->mem_tot = mem_tot;
502 ssb->mem_used = mem_used;
503 ssb->mem_free = mem_free;
504 ssb->mem_shared = mem_shared;
505 ssb->mem_buff = mem_buff;
506 ssb->mem_cached = mem_cached;
508 ssb->swap_tot = swap_tot;
509 ssb->swap_used = swap_used;
510 ssb->swap_free = swap_free;
512 ssb->dfroot_size = dfroot_size;
513 ssb->dfroot_used = dfroot_used;
514 ssb->dfroot_avail = dfroot_avail;
516 ssb->GPUTemp = GPUTemp;
517 ssb->GPUMemUsage = GPUMemUsage;
518 ssb->HDDTemp_a = HDDTemp_a;
519 ssb->HDDTemp_b = HDDTemp_b;
521 ssb->AirTemp = airTemp;
522 ssb->Joe47Temp = joe47Temp;
527 snprintf(logstr, 256,
"%s %i", logstr, (
int) core_temps[i]);
532 ssb->core_temp_warn = core_temp_warn;
533 ssb->core_temp_limit = core_temp_limit;
534 ssb->hdd_used_warn = hdd_used_warn;
535 ssb->hdd_used_limit = hdd_used_limit;
536 ssb->hdd_temp_warn = hdd_temp_warn;
537 ssb->hdd_temp_limit = hdd_temp_limit;
538 ssb->gpu_temp_warn = gpu_temp_warn;
539 ssb->gpu_temp_limit = gpu_temp_limit;
540 ssb->air_temp_warn = air_temp_warn;
541 ssb->air_temp_limit = air_temp_limit;
542 ssb->joe_temp_warn = joe_temp_warn;
543 ssb->joe_temp_limit = joe_temp_limit;
545 _tempsLogger->log(Logger::LOG_LEV_INFO,
"%s %i %i %i %0.2f %0.2f", logs.c_str(), (
int)GPUTemp, (
int)HDDTemp_a, (
int)HDDTemp_b, airTemp, joe47Temp);
Declarations for the sysmonD system monitor.
virtual int Run()
The main loop.
The standalone VisAO application, does not interface with the AO Supervisor.
void * statusboard_shmemptr
The pointer to the shared memory block for the statusboard.
virtual int update_statusboard()
Update the status board.
key_t statusboard_shmemkey
The key used to lookup the shared memory.
#define SYS_N_VCORES
Number of virtual processors in the system.
int TimeToDie
Global set by SIGTERM.
Logger * _tempsLogger
Temperature logger.
double pause_time
Time to pause during application main loop.
sysmonD(int argc, char **argv)
Command line constructor.
int create_statusboard(size_t sz)
Creates and attaches to the statusboard shared memory.
virtual int update_statusboard()
Update the status board.
int set_euid_called()
Changes the user id of the process to euid_called.
virtual int install_sig_mainthread_catcher()
Install the SIG_MAINTHREAD signal catcher.
#define SYS_N_LOGDRV
Number of logical drives in the system.
The namespace of VisAO software.
#define SYS_N_CORES
Number of physical processors in the system.
int set_euid_real()
Changes the user id fo the process to the real user id.