Update of /cvsroot/playerstage/code/player/client_libs/libplayerc
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8365/client_libs/libplayerc
Modified Files:
Makefile.am playerc.h
Added Files:
dev_health.c
Log Message:
Added health proxy for monitoring system statistics
Index: Makefile.am
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/Makefile.am,v
retrieving revision 1.91
retrieving revision 1.92
diff -C2 -d -r1.91 -r1.92
*** Makefile.am 2 Aug 2006 17:24:51 -0000 1.91
--- Makefile.am 7 Aug 2006 14:17:59 -0000 1.92
***************
*** 36,39 ****
--- 36,40 ----
dev_graphics3d.c \
dev_gripper.c \
+ dev_health.c \
dev_ir.c \
dev_laser.c \
Index: playerc.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/playerc.h,v
retrieving revision 1.203
retrieving revision 1.204
diff -C2 -d -r1.203 -r1.204
*** playerc.h 2 Aug 2006 17:24:51 -0000 1.203
--- playerc.h 7 Aug 2006 14:17:59 -0000 1.204
***************
*** 1519,1522 ****
--- 1519,1564 ----
/**************************************************************************/
+ /***************************************************************************/
+ /** @ingroup playerc_proxies
+ * @defgroup playerc_proxy_health health
+
+ The health proxy provides an interface to the HEALTH Module.
+ @{
+ */
+
+
+ /** Note: the structure describing the HEALTH's data packet is declared in
+ Player. */
+
+
+ /** @brief HEALTH proxy data. */
+ typedef struct
+ {
+ /** Device info; must be at the start of all device structures. */
+ playerc_device_t info;
+ /** The current cpu usage */
+ player_health_cpu_t cpu_usage;
+ /** The memory stats */
+ player_health_memory_t mem;
+ /** The swap stats
*/
+ player_health_memory_t swap;
+ } playerc_health_t;
+
+
+ /** @brief Create a health proxy. */
+ playerc_health_t *playerc_health_create(playerc_client_t *client, int index);
+
+ /** @brief Destroy a health proxy. */
+ void playerc_health_destroy(playerc_health_t *device);
+
+ /** @brief Subscribe to the health device. */
+ int playerc_health_subscribe(playerc_health_t *device, int access);
+
+ /** @brief Un-subscribe from the health device. */
+ int playerc_health_unsubscribe(playerc_health_t *device);
+
+
+ /** @} */
+ /***************************************************************************/
--- NEW FILE: dev_health.c ---
/*
* libplayerc : a Player client library
* Copyright (C) Andrew Howard 2002-2003
*
* 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.
*
*/
/***************************************************************************
* Desc: HEALTH proxy
* Author: M. Ruoss
* Date: 18 Juli 2006
**************************************************************************/
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "playerc.h"
#include "error.h"
// Process incoming data
void playerc_health_putmsg (playerc_health_t *device,
player_msghdr_t *header,
player_health_data_t *data, size_t len);
// Create a new health proxy
playerc_health_t *playerc_health_create(playerc_client_t *client, int index)
{
playerc_health_t *device;
device = malloc(sizeof(playerc_health_t));
memset(device, 0, sizeof(playerc_health_t));
playerc_device_init(&device->info, client, PLAYER_HEALTH_CODE, index,
(playerc_putmsg_fn_t) playerc_health_putmsg);
return device;
}
// Destroy a health proxy
void playerc_health_destroy(playerc_health_t *device)
{
playerc_device_term(&device->info);
free(device);
}
// Subscribe to the health device
int playerc_health_subscribe(playerc_health_t *device, int access)
{
return playerc_device_subscribe(&device->info, access);
}
// Un-subscribe from the health device
int playerc_health_unsubscribe(playerc_health_t *device)
{
return playerc_device_unsubscribe(&device->info);
}
// Process incoming data
void playerc_health_putmsg (playerc_health_t *device,
player_msghdr_t *header,
player_health_data_t *data, size_t len)
{
if((header->type == PLAYER_MSGTYPE_DATA) &&
(header->subtype == PLAYER_HEALTH_DATA))
{
device->cpu_usage.idle = data->cpu_usage.idle;
device->cpu_usage.system = data->cpu_usage.system;
device->cpu_usage.user = data->cpu_usage.user;
device->mem.total = data->mem.total;
device->mem.used = data->mem.used;
device->mem.free = data->mem.free;
device->swap.total = data->swap.total;
device->swap.used = data->swap.used;
device->swap.free = data->swap.free;
}
else
PLAYERC_WARN2("skipping health message with unknown type/subtype:
%d/%d\n",
header->type, header->subtype);
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit