mpd password
[monky] / solaris.c
1 /* doesn't work, feel free to finish this */
2 #include "conky.h"
3 #include <kstat.h>
4
5 static kstat_ctl_t *kstat;
6 static int kstat_updated;
7
8 static void update_kstat()
9 {
10         if (kstat == NULL) {
11                 kstat = kstat_open();
12                 if (kstat == NULL) {
13                         ERR("can't open kstat: %s", strerror(errno));
14                 }
15         }
16
17         if (kstat_chain_update(kstat) == -1) {
18                 perror("kstat_chain_update");
19                 return;
20         }
21 }
22
23 void prepare_update()
24 {
25         kstat_updated = 0;
26 }
27
28 double get_uptime()
29 {
30         kstat_t *ksp;
31
32         update_kstat();
33
34         ksp = kstat_lookup(kstat, "unix", -1, "system_misc");
35         if (ksp != NULL) {
36                 if (kstat_read(kstat, ksp, NULL) >= 0) {
37                         kstat_named_t *knp;
38                         knp =
39                             (kstat_named_t *) kstat_data_lookup(ksp,
40                                                                 "boot_time");
41                         if (knp != NULL) {
42                                 return get_time() -
43                                     (double) knp->value.ui32;
44                         }
45                 }
46         }
47 }
48
49 void update_meminfo()
50 {
51         /* TODO */
52 }