--- projects/cms/source/ihost/libstatgrab/load_stat.c 2002/05/12 19:10:55 1.1 +++ projects/cms/source/ihost/libstatgrab/load_stat.c 2002/05/21 16:47:12 1.7 @@ -1,8 +1,31 @@ +/* + * i-scream central monitoring system + * http://www.i-scream.org.uk + * Copyright (C) 2000-2002 i-scream + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + #include #include +#ifdef SOLARIS +#include +#endif #include "ukcprog.h" -char* get_load_stats(){ +char *get_load_stats(){ double loadav[3]; char *xml_load_out; @@ -18,7 +41,10 @@ char* get_load_stats(){ return NULL; } - fscanf(f,"%lf %lf %lf", &loadav[0], &loadav[1], &loadav[2]); + if((fscanf(f,"%lf %lf %lf", &loadav[0], &loadav[1], &loadav[2])) != 3){ + errf("Failed to read in sufficent loads"); + return NULL; + } if ((fclose(f)) != 0) { errf("Failed to close file (%m)."); @@ -30,7 +56,7 @@ char* get_load_stats(){ } #endif - xml_load_out=strf("%.2lf%.2lf%.2lf\n", loadav[0], loadav[1], loadav[2]); + xml_load_out=strf("%.2lf%.2lf%.2lf", loadav[0], loadav[1], loadav[2]); return xml_load_out; }