summaryrefslogtreecommitdiff
path: root/server/server_status.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/server_status.cc')
-rw-r--r--server/server_status.cc59
1 files changed, 19 insertions, 40 deletions
diff --git a/server/server_status.cc b/server/server_status.cc
index 88bd35c..b1837b8 100644
--- a/server/server_status.cc
+++ b/server/server_status.cc
@@ -3,7 +3,7 @@
* server_status.cc
*
* Fri Apr 29 13:58:26 CEST 2005
- * Copyright 2005 Bent Bisballe
+ * Copyright 2005 Bent Bisballe Nyeng
* deva@aasimon.org
****************************************************************************/
@@ -24,52 +24,31 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "server_status.h"
-#include "info.h"
-#include <stdio.h>
-ServerStatus::ServerStatus()
-{
- gettimeofday(&oldtime, NULL);
-
- for(int cnt = 0; cnt < BUFFERSIZE; cnt++) {
- frametime[cnt] = 41660;
- }
-
- gettimeofday(&time, NULL);
+#include "udp_socket.h"
+#include "status.h"
- interval = 0;
-}
-
-ServerStatus::~ServerStatus()
+int server_status(int port)
{
-}
+ status_t s;
+ status_request_t r;
-void ServerStatus::checkPoint()
-{
- for(int cnt = BUFFERSIZE - 1; cnt > 0; cnt--) {
- frametime[cnt] = frametime[cnt-1];
- }
- frametime[0] = (1000000 * time.tv_sec + time.tv_usec) - (1000000 * oldtime.tv_sec + oldtime.tv_usec);
+ s.diskspace_max = 0xff;
+ s.diskspace = 0;
+
+ s.load_max = 0xff;
+ s.load = 0;
- oldtime.tv_sec = time.tv_sec;
- oldtime.tv_usec = time.tv_usec;
+ while(1) {
+ UDPSocket socket(port);
- gettimeofday(&time, NULL);
+ if(socket.read(&r, sizeof(r)) == -1) fprintf(stderr, "ERROR! READ %s\n", socket.error().c_str());
+ if(socket.write(&s, sizeof(s)) == -1) fprintf(stderr, "ERROR! WRITE %s\n", socket.error().c_str());
- interval += frametime[0];
- if(interval > UPD) {
- interval = 0;
- double total = 0.0;
- for(int cnt = 0; cnt < BUFFERSIZE; cnt++) {
- total += (double)frametime[cnt];
- }
- MIaV::info->info("Status - fps: %f", 1000000.0 / (total / (double)BUFFERSIZE));
+ s.diskspace++;
+ s.load++;
}
-
-}
-/*
-date(1), gettimeofday(2), ctime(3), ftime(3)
-*/
+ return 0;
+}