#include #include "status.h" #include "status.m" #include #include #include static HELP_FILE help_stats ("status","diskstats"); static CONFIG_FILE fstats ("/proc/diskstats",help_stats,CONFIGF_OPTIONAL); const int NBTITLE=4; struct DISKSTATS{ SSTRING dev; int vals[NBTITLE]; DISKSTATS(){ reset(); } DISKSTATS(const DISKSTATS &v){ dev = v.dev; memcpy (vals,v.vals,sizeof(vals)); } void reset(){ memset (vals,0,sizeof(vals)); } }; struct DISKSTATS_UI: public DISKSTATS{ int diffs[20]; int gauges[20]; DISKSTATS_UI(){ reset(); memset (diffs,0,sizeof(diffs)); memset (gauges,0,sizeof(gauges)); } }; void diskstats_show() { if (!fstats.exist()){ xconf_error (MSG_U(E_DISKSTATS ,"No disk statistic files available on this system.\n" "Linuxconf was looking for file %s") ,fstats.getpath()); return; } glocal DISKSTATS stats; DIALOG dia; (); (fstats,true); SSTRINGS ws; int n = str_splitline (line,' ',ws); if (n >= 7){ const char *dev = ws.getitem(2)->get(); glocal.stats.dev = dev; if (strncmp(dev,"ram",3)!=0 && strncmp (dev,"fd",2)!=0){ glocal.stats.reset(); int vals[n]; for (int i=3; igetval(); } glocal.stats.vals[0] = vals[0]; if (n >= 9){ glocal.stats.vals[1] = vals[2]; glocal.stats.vals[2] = vals[3]; glocal.stats.vals[3] = vals[5]; }else{ glocal.stats.vals[1] = vals[1]; glocal.stats.vals[2] = vals[2]; glocal.stats.vals[3] = vals[3]; } glocal.COROUTINE.yield(); } } return 0; int nbdisk = 0; co.restart(); while(co.next()) nbdisk++; DISKSTATS_UI tbstats[nbdisk]; { co.restart(); int no = 0; while(co.next()){ tbstats[no].dev = glocal.stats.dev; memcpy (tbstats[no].vals,glocal.stats.vals,sizeof(glocal.stats.vals)); no++; } } int maxdiff[NBTITLE] = {100,100,100,100}; for (int i=0; i