1 | /* $Id: sysdeps.c,v 1.1.1.2 2004-10-03 04:59:48 ghudson Exp $ */ |
---|
2 | |
---|
3 | /* Copyright (C) 1998-99 Martin Baulig |
---|
4 | This file is part of LibGTop 1.0. |
---|
5 | |
---|
6 | Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998. |
---|
7 | |
---|
8 | LibGTop is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2 of the License, |
---|
11 | or (at your option) any later version. |
---|
12 | |
---|
13 | LibGTop is distributed in the hope that it will be useful, but WITHOUT |
---|
14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
16 | for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with LibGTop; see the file COPYING. If not, write to the |
---|
20 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include <locale.h> |
---|
25 | #include <libintl.h> |
---|
26 | #include <stdio.h> |
---|
27 | |
---|
28 | #include <glibtop.h> |
---|
29 | #include <glibtop/open.h> |
---|
30 | #include <glibtop/close.h> |
---|
31 | #include <glibtop/sysdeps.h> |
---|
32 | |
---|
33 | #include <glibtop/parameter.h> |
---|
34 | |
---|
35 | #ifndef PROFILE_COUNT |
---|
36 | #define PROFILE_COUNT 1 |
---|
37 | #endif |
---|
38 | |
---|
39 | int |
---|
40 | main (int argc, char *argv []) |
---|
41 | { |
---|
42 | glibtop_sysdeps sysdeps; |
---|
43 | unsigned method, count, port; |
---|
44 | char buffer [BUFSIZ]; |
---|
45 | |
---|
46 | count = PROFILE_COUNT; |
---|
47 | |
---|
48 | setlocale (LC_ALL, ""); |
---|
49 | bindtextdomain (GETTEXT_PACKAGE, GTOPLOCALEDIR); |
---|
50 | textdomain (GETTEXT_PACKAGE); |
---|
51 | |
---|
52 | glibtop_init_r (&glibtop_global_server, 0, GLIBTOP_INIT_NO_OPEN); |
---|
53 | |
---|
54 | glibtop_get_parameter (GLIBTOP_PARAM_METHOD, &method, sizeof (method)); |
---|
55 | |
---|
56 | printf ("Method = %d\n", method); |
---|
57 | |
---|
58 | count = glibtop_get_parameter (GLIBTOP_PARAM_COMMAND, buffer, BUFSIZ); |
---|
59 | buffer [count] = 0; |
---|
60 | |
---|
61 | printf ("Command = '%s'\n", buffer); |
---|
62 | |
---|
63 | count = glibtop_get_parameter (GLIBTOP_PARAM_HOST, buffer, BUFSIZ); |
---|
64 | buffer [count] = 0; |
---|
65 | |
---|
66 | glibtop_get_parameter (GLIBTOP_PARAM_PORT, &port, sizeof (port)); |
---|
67 | |
---|
68 | printf ("Host = '%s' - %u\n\n", buffer, port); |
---|
69 | |
---|
70 | glibtop_init_r (&glibtop_global_server, 0, 0); |
---|
71 | |
---|
72 | glibtop_get_sysdeps (&sysdeps); |
---|
73 | |
---|
74 | #define FEATURE_CHECK(f) ((sysdeps.features & (1L << GLIBTOP_SYSDEPS_##f)) ? 1 : 0) |
---|
75 | |
---|
76 | printf ("Sysdeps (0x%08lx):\n\n" |
---|
77 | "\tfeatures:\t\t0x%08lx\n\n" |
---|
78 | "\tcpu:\t\t%d\t0x%08lx\n" |
---|
79 | "\tmem:\t\t%d\t0x%08lx\n" |
---|
80 | "\tswap:\t\t%d\t0x%08lx\n\n" |
---|
81 | "\tuptime:\t\t%d\t0x%08lx\n" |
---|
82 | "\tloadavg:\t%d\t0x%08lx\n\n" |
---|
83 | "\tshm_limits:\t%d\t0x%08lx\n" |
---|
84 | "\tmsg_limits:\t%d\t0x%08lx\n" |
---|
85 | "\tsem_limits:\t%d\t0x%08lx\n\n" |
---|
86 | "\tproclist:\t%d\t0x%08lx\n\n" |
---|
87 | "\tproc_state:\t%d\t0x%08lx\n" |
---|
88 | "\tproc_uid:\t%d\t0x%08lx\n" |
---|
89 | "\tproc_mem:\t%d\t0x%08lx\n" |
---|
90 | "\tproc_time:\t%d\t0x%08lx\n" |
---|
91 | "\tproc_signal:\t%d\t0x%08lx\n" |
---|
92 | "\tproc_kernel:\t%d\t0x%08lx\n" |
---|
93 | "\tproc_segment:\t%d\t0x%08lx\n\n" |
---|
94 | "\tproc_args:\t%d\t0x%08lx\n" |
---|
95 | "\tproc_map:\t%d\t0x%08lx\n\n" |
---|
96 | "\tmountlist:\t%d\t0x%08lx\n" |
---|
97 | "\tfsusage:\t%d\t0x%08lx\n\n" |
---|
98 | "\tnetload:\t%d\t0x%08lx\n" |
---|
99 | "\tppp:\t\t%d\t0x%08lx\n\n", |
---|
100 | (unsigned long) sysdeps.flags, |
---|
101 | (unsigned long) sysdeps.features, |
---|
102 | FEATURE_CHECK(CPU), |
---|
103 | (unsigned long) sysdeps.cpu, |
---|
104 | FEATURE_CHECK(MEM), |
---|
105 | (unsigned long) sysdeps.mem, |
---|
106 | FEATURE_CHECK(SWAP), |
---|
107 | (unsigned long) sysdeps.swap, |
---|
108 | FEATURE_CHECK(UPTIME), |
---|
109 | (unsigned long) sysdeps.uptime, |
---|
110 | FEATURE_CHECK(LOADAVG), |
---|
111 | (unsigned long) sysdeps.loadavg, |
---|
112 | FEATURE_CHECK(SHM_LIMITS), |
---|
113 | (unsigned long) sysdeps.shm_limits, |
---|
114 | FEATURE_CHECK(MSG_LIMITS), |
---|
115 | (unsigned long) sysdeps.msg_limits, |
---|
116 | FEATURE_CHECK(SEM_LIMITS), |
---|
117 | (unsigned long) sysdeps.sem_limits, |
---|
118 | FEATURE_CHECK(PROCLIST), |
---|
119 | (unsigned long) sysdeps.proclist, |
---|
120 | FEATURE_CHECK(PROC_STATE), |
---|
121 | (unsigned long) sysdeps.proc_state, |
---|
122 | FEATURE_CHECK(PROC_UID), |
---|
123 | (unsigned long) sysdeps.proc_uid, |
---|
124 | FEATURE_CHECK(PROC_MEM), |
---|
125 | (unsigned long) sysdeps.proc_mem, |
---|
126 | FEATURE_CHECK(PROC_TIME), |
---|
127 | (unsigned long) sysdeps.proc_time, |
---|
128 | FEATURE_CHECK(PROC_SIGNAL), |
---|
129 | (unsigned long) sysdeps.proc_signal, |
---|
130 | FEATURE_CHECK(PROC_KERNEL), |
---|
131 | (unsigned long) sysdeps.proc_kernel, |
---|
132 | FEATURE_CHECK(PROC_SEGMENT), |
---|
133 | (unsigned long) sysdeps.proc_segment, |
---|
134 | FEATURE_CHECK(PROC_ARGS), |
---|
135 | (unsigned long) sysdeps.proc_args, |
---|
136 | FEATURE_CHECK(PROC_MAP), |
---|
137 | (unsigned long) sysdeps.proc_map, |
---|
138 | FEATURE_CHECK(MOUNTLIST), |
---|
139 | (unsigned long) sysdeps.mountlist, |
---|
140 | FEATURE_CHECK(FSUSAGE), |
---|
141 | (unsigned long) sysdeps.fsusage, |
---|
142 | FEATURE_CHECK(NETLOAD), |
---|
143 | (unsigned long) sysdeps.netload, |
---|
144 | FEATURE_CHECK(PPP), |
---|
145 | (unsigned long) sysdeps.ppp); |
---|
146 | |
---|
147 | glibtop_close (); |
---|
148 | |
---|
149 | exit (0); |
---|
150 | } |
---|