diff -cr xfce4-diskperf-plugin-2.3.0.orig/panel-plugin/devperf.c xfce4-diskperf-plugin-2.3.0/panel-plugin/devperf.c *** xfce4-diskperf-plugin-2.3.0.orig/panel-plugin/devperf.c Fri Jan 21 00:34:26 2011 --- xfce4-diskperf-plugin-2.3.0/panel-plugin/devperf.c Sun Jan 23 16:37:40 2011 *************** *** 1,5 **** --- 1,6 ---- /* Copyright (c) 2003 RogerSeguin * Copyright (c) 2003 Benedikt Meurer + * Copyright (c) 2011 Peter Tribble * * 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 *************** *** 380,388 **** return (0); } #else /**************************************************************/ /******************** Unsupported platform ***************/ /**************************************************************/ ! #error "Your plattform is not yet supported" #endif --- 381,454 ---- return (0); } + #elif defined (__sun__) + /* + * Solaris (and OpenSolaris derivatives) support via kstat + * Peter Tribble + */ + #include + static kstat_ctl_t *kc; + + int DevPerfInit () + { + kc = kstat_open (); + return (0); + } + + int DevCheckStatAvailability(char const **strptr) + { + return (0); + } + + int DevGetPerfData (const void *p_pvDevice, struct devperf_t *perf) + { + kstat_t *ksp; + kstat_io_t *kiot; + char *devname = (char *)p_pvDevice; + + if(!kc) + DevPerfInit(); + + /* + * Use the device name. This is something like "sd3", after the + * module and instance. The user is expected to work out the + * possible device names. The command "iostat -x" is one way to + * enumerate them. It would be really neat to have a way to present + * this list to the user and get them to pick the one they want. + */ + if(!(ksp = kstat_lookup (kc, NULL, -1, devname))) { + return (-1); + } + if (kstat_read(kc, ksp, 0) == -1) { + return (-1); + } + /* + * Just in case we accidentally matched something that wasn't + * an I/O device. + */ + if (ksp->ks_type != KSTAT_TYPE_IO) { + return (-1); + } + kiot = KSTAT_IO_PTR(ksp); + perf->timestamp_ns = (uint64_t)ksp->ks_snaptime; + perf->rbytes = (uint64_t)kiot->nread; + perf->wbytes = (uint64_t)kiot->nwritten; + /* + * Solaris keeps separate wait and run queues, but they aren't + * separated by read and write. So allocate half to each. + */ + perf->wbusy_ns = (uint64_t) (kiot->wtime + kiot->rtime) / 2ull; + perf->rbusy_ns = perf->wbusy_ns; + /* + * qlen isn't used, so set it to zero rather than calculate it. + */ + perf->qlen = 0; + return (0); + } + #else /**************************************************************/ /******************** Unsupported platform ***************/ /**************************************************************/ ! #error "Your platform is not yet supported" #endif diff -cr xfce4-diskperf-plugin-2.3.0.orig/panel-plugin/main.c xfce4-diskperf-plugin-2.3.0/panel-plugin/main.c *** xfce4-diskperf-plugin-2.3.0.orig/panel-plugin/main.c Wed Jan 19 00:25:30 2011 --- xfce4-diskperf-plugin-2.3.0/panel-plugin/main.c Sun Jan 23 16:42:05 2011 *************** *** 48,53 **** --- 48,55 ---- data, but only a single value combining both */ #if defined(__NetBSD__) #define SEPARATE_BUSY_TIMES 0 + #elif defined(__sun__) + #define SEPARATE_BUSY_TIMES 0 #elif defined(__linux__) #define SEPARATE_BUSY_TIMES 1 #else *************** *** 79,85 **** typedef struct param_t { /* Configurable parameters */ char acDevice[64]; ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) dev_t st_rdev; #endif int fTitleDisplayed; --- 81,87 ---- typedef struct param_t { /* Configurable parameters */ char acDevice[64]; ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__sun__) dev_t st_rdev; #endif int fTitleDisplayed; *************** *** 159,165 **** rbytes = wbytes = iRBusy_ns = iWBusy_ns = -1; memset (&oPerf, 0, sizeof (oPerf)); oPerf.qlen = -1; ! #if defined (__NetBSD__) || defined(__OpenBSD__) status = DevGetPerfData (poConf->acDevice, &oPerf); #else status = DevGetPerfData (&(poConf->st_rdev), &oPerf); --- 161,167 ---- rbytes = wbytes = iRBusy_ns = iWBusy_ns = -1; memset (&oPerf, 0, sizeof (oPerf)); oPerf.qlen = -1; ! #if defined (__NetBSD__) || defined(__OpenBSD__) || defined(__sun__) status = DevGetPerfData (poConf->acDevice, &oPerf); #else status = DevGetPerfData (&(poConf->st_rdev), &oPerf); *************** *** 206,213 **** --- 208,217 ---- " Write :%3.2f\n" " Total :%3.2f\n" "Busy time (%c)\n" + #if SEPARATE_BUSY_TIMES " Read : %3d\n" " Write : %3d\n" + #endif " Total : %3d", poConf->acTitle, arPerf[R_DATA], *************** *** 214,223 **** arPerf[W_DATA], arPerf[RW_DATA], '%', ! SEPARATE_BUSY_TIMES && (oPerf.qlen >= 0) ? (int) round(arBusy[R_DATA]) : -1, ! SEPARATE_BUSY_TIMES && (oPerf.qlen >= 0) ? (int) round(arBusy[W_DATA]) : -1, (oPerf.qlen >= 0) ? (int) round(arBusy[RW_DATA]) : -1); gtk_tooltips_set_tip (s_poToolTips, GTK_WIDGET (poMonitor->wEventBox), acToolTips, 0); --- 218,229 ---- arPerf[W_DATA], arPerf[RW_DATA], '%', ! #if SEPARATE_BUSY_TIMES ! (oPerf.qlen >= 0) ? (int) round(arBusy[R_DATA]) : -1, ! (oPerf.qlen >= 0) ? (int) round(arBusy[W_DATA]) : -1, + #endif (oPerf.qlen >= 0) ? (int) round(arBusy[RW_DATA]) : -1); gtk_tooltips_set_tip (s_poToolTips, GTK_WIDGET (poMonitor->wEventBox), acToolTips, 0); *************** *** 400,406 **** struct diskperf_t *poPlugin; struct param_t *poConf; struct monitor_t *poMonitor; ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) struct stat oStat; int status; #endif --- 406,412 ---- struct diskperf_t *poPlugin; struct param_t *poConf; struct monitor_t *poMonitor; ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__sun__) struct stat oStat; int status; #endif *************** *** 415,420 **** --- 421,429 ---- #if defined(__NetBSD__) || defined(__OpenBSD__) strncpy (poConf->acDevice, "wd0", 64); strncpy (poConf->acTitle, "wd0", 16); + #elif defined(__sun__) + strncpy (poConf->acDevice, "sd0", 64); + strncpy (poConf->acTitle, "sd0", 16); #else strncpy (poConf->acDevice, "/dev/sda", 64); status = stat (poConf->acDevice, &oStat); *************** *** 483,489 **** struct param_t *poConf = &(poPlugin->oConf.oParam); struct monitor_t *poMonitor = &(poPlugin->oMonitor); Widget_t *pw2ndBar = poPlugin->oMonitor.awProgressBar + 1; ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) struct stat oStat; int status; #endif --- 492,498 ---- struct param_t *poConf = &(poPlugin->oConf.oParam); struct monitor_t *poMonitor = &(poPlugin->oMonitor); Widget_t *pw2ndBar = poPlugin->oMonitor.awProgressBar + 1; ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__sun__) struct stat oStat; int status; #endif *************** *** 500,506 **** if ((value = xfce_rc_read_entry (rc, (CONF_DEVICE), NULL))) { memset (poConf->acDevice, 0, sizeof (poConf->acDevice)); strncpy (poConf->acDevice, value, sizeof (poConf->acDevice) - 1); ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) status = stat (poConf->acDevice, &oStat); poConf->st_rdev = (status == -1 ? 0 : oStat.st_rdev); #endif --- 509,515 ---- if ((value = xfce_rc_read_entry (rc, (CONF_DEVICE), NULL))) { memset (poConf->acDevice, 0, sizeof (poConf->acDevice)); strncpy (poConf->acDevice, value, sizeof (poConf->acDevice) - 1); ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__sun__) status = stat (poConf->acDevice, &oStat); poConf->st_rdev = (status == -1 ? 0 : oStat.st_rdev); #endif *************** *** 624,630 **** struct diskperf_t *poPlugin = (diskperf_t *) p_pvPlugin; struct param_t *poConf = &(poPlugin->oConf.oParam); const char *pcDevice = gtk_entry_get_text (GTK_ENTRY (p_wTF)); ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) struct stat oStat; int status; --- 633,639 ---- struct diskperf_t *poPlugin = (diskperf_t *) p_pvPlugin; struct param_t *poConf = &(poPlugin->oConf.oParam); const char *pcDevice = gtk_entry_get_text (GTK_ENTRY (p_wTF)); ! #if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__sun__) struct stat oStat; int status; *************** *** 879,892 **** /**************************************************************/ static void About (Widget_t w, void *unused) ! /* Called back when the About button in clicked */ { xfce_info (_("%s %s - Disk Performance Monitor\n" ! "Display instantaneous disk I/O transfer rates and busy times " ! "on Linux and NetBSD systems\n\n" "(c) 2003, 2004 Roger Seguin \n" "NetBSD statistics collection: (c) 2003 Benedikt Meurer\n" ! "\t"), PACKAGE, VERSION); } /* About() */ --- 888,902 ---- /**************************************************************/ static void About (Widget_t w, void *unused) ! /* Called back when the About button is clicked */ { xfce_info (_("%s %s - Disk Performance Monitor\n" ! "Display disk I/O transfer rates and busy times\n\n" "(c) 2003, 2004 Roger Seguin \n" "NetBSD statistics collection: (c) 2003 Benedikt Meurer\n" ! "\t\n" ! "Solaris statistics collection: (c) 2011 Peter Tribble\n" ! "\t"), PACKAGE, VERSION); } /* About() */