6bd63db34008946f3559fb5134270c2d33105d72
[monky] / src / solaris.c
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
9  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
10  *      (see AUTHORS)
11  * All rights reserved.
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  * You should have received a copy of the GNU General Public License
23  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24  *
25  * vim: ts=4 sw=4 noet ai cindent syntax=c
26  *
27  */
28
29 /* doesn't work, feel free to finish this */
30 #include "conky.h"
31 #include "common.h"
32 #include <kstat.h>
33
34 static kstat_ctl_t *kstat;
35 static int kstat_updated;
36
37 static void update_kstat()
38 {
39         if (kstat == NULL) {
40                 kstat = kstat_open();
41                 if (kstat == NULL) {
42                         ERR("can't open kstat: %s", strerror(errno));
43                 }
44         }
45
46         if (kstat_chain_update(kstat) == -1) {
47                 perror("kstat_chain_update");
48                 return;
49         }
50 }
51
52 void prepare_update()
53 {
54         kstat_updated = 0;
55 }
56
57 double get_uptime()
58 {
59         kstat_t *ksp;
60
61         update_kstat();
62
63         ksp = kstat_lookup(kstat, "unix", -1, "system_misc");
64         if (ksp != NULL) {
65                 if (kstat_read(kstat, ksp, NULL) >= 0) {
66                         kstat_named_t *knp;
67
68                         knp = (kstat_named_t *) kstat_data_lookup(ksp, "boot_time");
69                         if (knp != NULL) {
70                                 return get_time() - (double) knp->value.ui32;
71                         }
72                 }
73         }
74 }
75
76 void update_meminfo()
77 {
78         /* TODO */
79 }
80
81 int check_mount(char *s)
82 {
83         /* stub */
84         return 0;
85 }