debuggers.hg

view tools/xenstat/libxenstat/src/xenstat_netbsd.c @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 /* libxenstat: statistics-collection library for Xen
2 * Copyright (C) International Business Machines Corp., 2005
3 * Authors: Josh Triplett <josht@us.ibm.com>
4 * Judy Fischbach <jfisch@us.ibm.com>
5 * David Hendricks <dhendrix@us.ibm.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 */
18 /*
19 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
20 * Use is subject to license terms.
21 */
23 #include <fcntl.h>
24 #include <dirent.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
32 #include "xenstat_priv.h"
34 #define SYSFS_VBD_PATH "/sys/devices/xen-backend/"
36 struct priv_data {
37 FILE *procnetdev;
38 DIR *sysfsvbd;
39 };
41 static struct priv_data *
42 get_priv_data(xenstat_handle *handle)
43 {
44 if (handle->priv != NULL)
45 return handle->priv;
47 handle->priv = malloc(sizeof(struct priv_data));
48 if (handle->priv == NULL)
49 return (NULL);
51 ((struct priv_data *)handle->priv)->procnetdev = NULL;
52 ((struct priv_data *)handle->priv)->sysfsvbd = NULL;
54 return handle->priv;
55 }
57 /* Expected format of /proc/net/dev */
58 static const char PROCNETDEV_HEADER[] =
59 "Inter-| Receive |"
60 " Transmit\n"
61 " face |bytes packets errs drop fifo frame compressed multicast|"
62 "bytes packets errs drop fifo colls carrier compressed\n";
64 /* Collect information about networks */
65 int xenstat_collect_networks(xenstat_node * node)
66 {
67 /* XXX fixme: implement code to get stats from libkvm ! */
68 return 1;
69 }
71 /* Free network information in handle */
72 void xenstat_uninit_networks(xenstat_handle * handle)
73 {
74 struct priv_data *priv = get_priv_data(handle);
75 if (priv != NULL && priv->procnetdev != NULL)
76 fclose(priv->procnetdev);
77 }
79 static int read_attributes_vbd(const char *vbd_directory, const char *what, char *ret, int cap)
80 {
81 /* XXX implement */
82 return 0;
83 }
85 /* Collect information about VBDs */
86 int xenstat_collect_vbds(xenstat_node * node)
87 {
88 return 1;
89 }
91 /* Free VBD information in handle */
92 void xenstat_uninit_vbds(xenstat_handle * handle)
93 {
94 struct priv_data *priv = get_priv_data(handle);
95 if (priv != NULL && priv->sysfsvbd != NULL)
96 closedir(priv->sysfsvbd);
97 }