diff --git a/gophernicus.h b/gophernicus.h index 2014e4f..0eb02e5 100644 --- a/gophernicus.h +++ b/gophernicus.h @@ -99,6 +99,7 @@ #include #include #include +#include #ifdef HAVE_SENDFILE #include diff --git a/platform.c b/platform.c index c2df811..2b0876e 100644 --- a/platform.c +++ b/platform.c @@ -152,6 +152,17 @@ void platform(state *st) } } + /* No DMI? Get possible hypervisor name */ + if (!*st->server_description && (fp = fopen("/sys/hypervisor/type" , "r"))) { + fgets(buf, sizeof(buf), fp); + fclose(fp); + + chomp(buf); + ucfirst(buf); + + if (*buf) snprintf(st->server_description, sizeof(st->server_description), "%s virtual machine", buf); + } + /* Identify Gentoo */ if (!*sysname && (fp = fopen("/etc/gentoo-release", "r"))) { fgets(sysname, sizeof(sysname), fp); diff --git a/string.c b/string.c index d1a2467..0d0f8bd 100644 --- a/string.c +++ b/string.c @@ -26,6 +26,16 @@ #include "gophernicus.h" +/* + * Make a string's first character uppercase + */ +void ucfirst(char *str) +{ + if (str == NULL || !*str) return; + *str = toupper(*str); +} + + /* * Repeat a character num times and zero-terminate */