Skip to content
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
1 change: 0 additions & 1 deletion .ci
Submodule .ci deleted from fd925d
1 change: 1 addition & 0 deletions README_devIocStats
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Analog In (ai) Records (DTYP = "IOC stats"), INP = @one of the following:
sys_cpuload - estimated percent CPU load on the system
no_of_cpus - number of CPU cores on the system
ioc_cpuload - estimated percent CPU utilization by this IOC
cpu_temperature - measured temperature of the CPU (only implemented for Linux IOC)
fd - number of file descriptors currently in use
maxfd - max number of file descriptors
Note - free_bytes, total_bytes, sys_cpuload, no_of_cpus can be instantiated once per system instead
Expand Down
1 change: 1 addition & 0 deletions devIocStats/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ SRCS += osdBootInfo.c
SRCS += osdSystemInfo.c
SRCS += osdHostInfo.c
SRCS += osdPIDInfo.c
SRCS += osdCpuTemp.c

OBJS_vxWorks += osdCpuUsageTest.o

Expand Down
3 changes: 3 additions & 0 deletions devIocStats/devIocStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@ extern int devIocStatsGetHostname (char **pval);
extern int devIocStatsGetPID (double *proc_id);
extern int devIocStatsGetPPID (double *proc_id);

/* CPU Temperature */
extern int devIocStatsGetCpuTemp (int *pval);

#endif /* devIocStats_H */
11 changes: 10 additions & 1 deletion devIocStats/devIocStatsAnalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static void statsWSAllocBytes(double*);
static void statsWSTotalBytes(double*);
static void statsCpuUsage(double*);
static void statsCpuUtilization(double*);
static void statsCpuTemperature(double*);
static void statsNoOfCpus(double*);
static void statsSuspendedTasks(double*);
static void statsFdUsage(double*);
Expand Down Expand Up @@ -231,7 +232,6 @@ static void statsCbMediumQOverruns(double*);
static void statsCbHighQHiWtrMrk(double*);
static void statsCbHighQUsed(double*);
static void statsCbHighQOverruns(double*);

struct {
char *name;
double scan_rate;
Expand Down Expand Up @@ -286,6 +286,7 @@ static validGetParms statsGetParms[]={
{ "cbHighQueueHiWtrMrk", statsCbHighQHiWtrMrk, QUEUE_TYPE },
{ "cbHighQueueUsed", statsCbHighQUsed, QUEUE_TYPE },
{ "cbHighQueueOverruns", statsCbHighQOverruns, QUEUE_TYPE },
{ "cpu_temperature", statsCpuTemperature, LOAD_TYPE },
{ NULL,NULL,0 }
};

Expand All @@ -307,6 +308,7 @@ static scanInfo scan[TOTAL_TYPES] = {{0}};
static fdInfo fdusage = {0,0};
static loadInfo loadinfo = {1,0.,0.};
static int susptasknumber = 0;
static int cputemperature = 0;
static int recordnumber = 0;
static clustInfo clustinfo[2] = {{{0}},{{0}}};
static int mbufnumber[2] = {0,0};
Expand Down Expand Up @@ -385,12 +387,15 @@ static void scan_time(int type)
{
loadInfo loadinfo_local = {1,0.,0.};
int susptasknumber_local = 0;
int cputemperature_local = 0;
devIocStatsGetCpuUsage(&loadinfo_local);
devIocStatsGetCpuUtilization(&loadinfo_local);
devIocStatsGetSuspTasks(&susptasknumber_local);
devIocStatsGetCpuTemp(&cputemperature_local);
epicsMutexLock(scan_mutex);
loadinfo = loadinfo_local;
susptasknumber = susptasknumber_local;
cputemperature = cputemperature_local;
epicsMutexUnlock(scan_mutex);
break;
}
Expand Down Expand Up @@ -747,6 +752,10 @@ static void statsCpuUtilization(double* val)
{
*val = loadinfo.iocLoad;
}
static void statsCpuTemperature(double* val)
{
*val = (double)cputemperature/1000.;
}
static void statsNoOfCpus(double* val)
{
*val = (double)loadinfo.noOfCpus;
Expand Down
40 changes: 40 additions & 0 deletions devIocStats/os/Linux/osdCpuTemp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*************************************************************************\
* Copyright (c) 2009 Helmholtz-Zentrum Berlin fuer Materialien und Energie.
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/

/* osdCpuTemp.c - Temperature of the CPU: default implementation = do nothing */

/*
* Author: Florian Feldbauer (RUB)
*
*/

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <devIocStats.h>

int devIocStatsGetCpuTemp (int *pval) {
FILE *pFile = fopen ( "/sys/class/thermal/thermal_zone0/temp", "r" );
if( !pFile ) {
fprintf( stderr, "\033[31;1m: Could not open file '/sys/class/thermal/thermal_zone0/temp': %s\033[0m\n",
strerror( errno ) );
return -1;
}

unsigned num = fscanf( pFile, "%d", pval );
if ( 1 != num ) {
fprintf( stderr, "\033[31;1mCould not parse value\033[0m\n" );
}
fclose( pFile );
return 0;
}
21 changes: 21 additions & 0 deletions devIocStats/os/default/osdCpuTemp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*************************************************************************\
* Copyright (c) 2009 Helmholtz-Zentrum Berlin fuer Materialien und Energie.
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/

/* osdCpuTemp.c - Temperature of the CPU: default implementation = do nothing */

/*
* Author: Florian Feldbauer (RUB)
*
*/

#include <devIocStats.h>

int devIocStatsGetCpuTemp (int *pval) { return -1; }