summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-05-29 13:54:11 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2015-05-29 13:54:11 +0200
commit56dd21f443c86c3bf96a884c970ceed11a56409a (patch)
tree8108b48119e8964cec0904170d9f320832c338ef
parent135469a03d1a03903a57557decb99996aba835cb (diff)
downloadbiruda-56dd21f443c86c3bf96a884c970ceed11a56409a.tar.gz
biruda-56dd21f443c86c3bf96a884c970ceed11a56409a.tar.bz2
added more around physical memory (worker/coordingator data and cli data)
-rw-r--r--src/biruda.c2
-rw-r--r--src/cli.c4
-rw-r--r--src/coordinator.c5
-rw-r--r--src/system.c2
-rw-r--r--src/system.h2
-rw-r--r--src/worker.c7
6 files changed, 19 insertions, 3 deletions
diff --git a/src/biruda.c b/src/biruda.c
index 091bbbf..ff2f046 100644
--- a/src/biruda.c
+++ b/src/biruda.c
@@ -205,7 +205,7 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg )
puts( "Environment:" );
printf( " Number of CPUs: %d\n", nofCpus );
int physMem = system_phys_memory( );
- printf( " Physical memory available: %d kB\n", physMem );
+ printf( " Physically installed memory: %d kB\n", physMem );
char machine_arch[100];
system_arch( machine_arch, sizeof( machine_arch ) );
printf( " System architecture: %s\n", machine_arch );
diff --git a/src/cli.c b/src/cli.c
index 0ec95b1..f5bdcd1 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -400,6 +400,7 @@ void print_guessed_env( bool human_readable )
char hostname[100];
gethostname( hostname, sizeof( hostname ) );
unsigned int nofCpus = system_available_cpus( );
+ unsigned int nofPhysMem = system_phys_memory( );
char os_name[100];
system_os( os_name, sizeof( os_name ) );
char machine_arch[100];
@@ -410,6 +411,7 @@ void print_guessed_env( bool human_readable )
printf( "Operating system: %s\n", os_name );
printf( "Hostname: %s\n", hostname );
printf( "Number of CPUs: %d\n", nofCpus );
+ printf( "Physical memory in kB: %d\n", nofPhysMem );
} else {
json_object *obj = json_object_new_object( );
@@ -421,6 +423,8 @@ void print_guessed_env( bool human_readable )
json_object_object_add( obj, "host", host );
json_object *cpus = json_object_new_int( nofCpus );
json_object_object_add( obj, "cpus", cpus );
+ json_object *physMem = json_object_new_int( nofPhysMem );
+ json_object_object_add( obj, "physical_memory", physMem );
const char *msg = json_object_to_json_string( obj );
char *res = strdup( msg );
diff --git a/src/coordinator.c b/src/coordinator.c
index b1412e0..356a402 100644
--- a/src/coordinator.c
+++ b/src/coordinator.c
@@ -121,6 +121,11 @@ static char *create_register_answer( )
json_object *cpus = json_object_new_int( nofCpus );
json_object_object_add( obj, "cpus", cpus );
+ /* physically installed memory in kBytes */
+ unsigned int nofPhysMem = system_phys_memory( );
+ json_object *physMem = json_object_new_int( nofPhysMem );
+ json_object_object_add( obj, "physical_memory", physMem );
+
/* Operating system running on the coordinator, this is
* important so we know what we can run on the system
* directly
diff --git a/src/system.c b/src/system.c
index 9e2256d..96a07ab 100644
--- a/src/system.c
+++ b/src/system.c
@@ -383,7 +383,7 @@ void system_arch( char *name, size_t len )
#endif
}
-int system_phys_memory( )
+unsigned int system_phys_memory( )
{
#ifdef _WIN32
MEMORYSTATUSEX memState;
diff --git a/src/system.h b/src/system.h
index 1b84c5a..3ff2ebb 100644
--- a/src/system.h
+++ b/src/system.h
@@ -10,6 +10,6 @@ void system_os( char *name, size_t len );
void system_arch( char *name, size_t len );
/* in kilobytes */
-int system_phys_memory( );
+unsigned int system_phys_memory( );
#endif
diff --git a/src/worker.c b/src/worker.c
index 7529394..4360432 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -346,6 +346,13 @@ static char *expand_system_variables( const char *s )
strncpy( d, buf, strlen( buf ) );
d += strlen( buf );
state = COPYING;
+ } else if( strncmp( var, "PHYSICAL_MEMORY", 15 ) == 0 ) {
+ unsigned int physMem = system_phys_memory( );
+ char buf[12];
+ snprintf( buf, sizeof( buf ), "%d", physMem );
+ strncpy( d, buf, strlen( buf ) );
+ d += strlen( buf );
+ state = COPYING;
} else {
fprintf( stderr, "ERROR: Unknown variable '${%*s}' at position %d in '%s'\n", (int)( p-var ), var, (int)( p - s ), s );
state = _ERROR;