| 94 | | /* Get system information */ |
| 95 | | if (!sysinfo(&si)) { |
| 96 | | owi_headline(1, SYSINFO_HEADLINE); |
| 97 | | owi_headline(2, SYSINFO_DESCRIPTION); |
| 98 | | printf("<table class=\"%s\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n" |
| 99 | | "<thead>\n" |
| 100 | | "<tr>\n" |
| 101 | | "<th>Load (1 / 5 / 15 minute load avarage)</th>\n" |
| 102 | | "<th>Memory (All / Free / Shared)</th>\n" |
| 103 | | "<th>Speicher in Puffern:</t>\n" |
| 104 | | "<th>Swap (All / Free):</th>\n" |
| 105 | | "<th>Tasks</th>\n" |
| 106 | | "</tr>\n" |
| 107 | | "</thead>\n" |
| 108 | | "<tr onmouseover=\"this.className='%s';\"" |
| 109 | | " onmouseout=\"this.className='%s';\">\n" |
| 110 | | "<td>%u / %u / %u</td>\n" |
| 111 | | "<td>%u MB / %u MB / %u MB</td>\n" |
| 112 | | "<td>%u</td>\n" |
| 113 | | "<td>%u MB / %u MB</td>\n" |
| 114 | | "<td>%d</td>\n" |
| 115 | | "</tr>\n" |
| 116 | | "</table>\n", |
| 117 | | CONTENT_TABLE_BOX_CLASS, |
| 118 | | CONTENT_TABLE_CLASS_MOUSEOVER, |
| 119 | | CONTENT_TABLE_CLASS_MOUSEOUT, |
| 120 | | (unsigned int)si.loads[0], (unsigned int)si.loads[1], |
| 121 | | (unsigned int)si.loads[2], (unsigned int)(si.totalram / 1024 / 1024), |
| 122 | | (unsigned int)(si.freeram / 1024 / 1024), |
| 123 | | (unsigned int)(si.sharedram / 1024 / 1024), |
| 124 | | (unsigned int)si.bufferram, |
| 125 | | (unsigned int)(si.totalswap / 1024 / 1024), |
| 126 | | (unsigned int)(si.freeswap / 1024 / 1024), |
| 127 | | (unsigned int)si.procs); |
| 128 | | } |
| | 86 | sysinfo(&si); |
| | 87 | |
| | 88 | printf("<h4>%s</h4>\n" |
| | 89 | "<table class=\"detail\">\n" |
| | 90 | "<thead>\n" |
| | 91 | "<tr>\n" |
| | 92 | "<th colspan=\"2\">%s</th>\n" |
| | 93 | "</tr>\n" |
| | 94 | "</thead>\n" |
| | 95 | "<tbody>\n" |
| | 96 | "<tr>\n" |
| | 97 | "<td class=\"description\">Name</td>\n" |
| | 98 | "<td class=\"value\">%s</td>\n" |
| | 99 | "</tr>\n" |
| | 100 | "<tr>\n" |
| | 101 | "<td class=\"description\">Version</td>\n" |
| | 102 | "<td class=\"value\">%s</td>\n" |
| | 103 | "</tr>\n" |
| | 104 | "<tr>\n" |
| | 105 | "<td class=\"description\">OS Version</td>\n" |
| | 106 | "<td class=\"value\">%s</td>\n" |
| | 107 | "</tr>\n" |
| | 108 | "<tr>\n" |
| | 109 | "<td class=\"description\">Date</td>\n" |
| | 110 | "<td class=\"value\">%s</td>\n" |
| | 111 | "</tr>\n" |
| | 112 | "<tr>\n" |
| | 113 | "<td class=\"description\">Uptime</td>\n" |
| | 114 | "<td class=\"value\">%s</td>\n" |
| | 115 | "</tr>\n" |
| | 116 | "<tr>\n" |
| | 117 | "<td class=\"description\">Memory Usage</td>\n" |
| | 118 | "<td class=\"value\">%ld %%</td>\n" |
| | 119 | "</tr>\n" |
| | 120 | "<tr>\n" |
| | 121 | "<td class=\"description\">Diskspace Usage</td>\n" |
| | 122 | "<td class=\"value\">%s</td>\n" |
| | 123 | "</tr>\n" |
| | 124 | "</tbody>\n" |
| | 125 | "</table>\n", |
| | 126 | SYSINFO_HEADLINE, |
| | 127 | SYSINFO_HEADLINE_BOX, |
| | 128 | hostname, |
| | 129 | version, |
| | 130 | osversion, |
| | 131 | date, |
| | 132 | uptime, |
| | 133 | (si.totalram - si.freeram) / (si.totalram * 100), |
| | 134 | "0"); |
| 130 | | |
| 131 | | /* \fn sysinfo_filesystems() |
| 132 | | * Display information about mounted devices (like filesystem, diskspace ...) |
| 133 | | */ |
| 134 | | void sysinfo_filesystems() { |
| 135 | | /* File handler */ |
| 136 | | FILE *fp = NULL; |
| 137 | | /* Mount information */ |
| 138 | | char device[256], mountpoint[256], fs[256]; |
| 139 | | |
| 140 | | /* Try to open mount information file */ |
| 141 | | fp = fopen("/proc/mounts", "r"); |
| 142 | | /* Ok? */ |
| 143 | | if (fp) { |
| 144 | | owi_headline(1, SYSINFO_FILESYSTEMS); |
| 145 | | owi_headline(2, SYSINFO_FILESYSTEMS_DESCRIPTION); |
| 146 | | printf("<table class=\"%s\" cellpadding=\"0\" cellspacing=\"0\" align=\"left\">\n" |
| 147 | | "<thead>\n" |
| 148 | | "<tr>\n" |
| 149 | | "<th>Gerät</th>\n" |
| 150 | | "<th>Eingehängt auf</th>\n" |
| 151 | | "<th>Dateisystem</th>\n" |
| 152 | | "</tr>\n" |
| 153 | | "</thead>\n", |
| 154 | | CONTENT_TABLE_BOX_CLASS); |
| 155 | | /* Read until file end reached */ |
| 156 | | while (fscanf(fp, "%s %s %s", device, mountpoint, fs) == 3) { |
| 157 | | if (strcasecmp(fs, "0")) { |
| 158 | | printf("<tr onmouseover=\"this.className='%s';\"" |
| 159 | | " onmouseout=\"this.className='%s';\">\n" |
| 160 | | "<td>%s</td>\n" |
| 161 | | "<td>%s</td>\n" |
| 162 | | "<td>%s</td>\n" |
| 163 | | "</tr>\n", |
| 164 | | CONTENT_TABLE_CLASS_MOUSEOVER, |
| 165 | | CONTENT_TABLE_CLASS_MOUSEOUT, |
| 166 | | device, |
| 167 | | mountpoint, |
| 168 | | fs); |
| 169 | | } |
| 170 | | } |
| 171 | | printf("</table>\n"); |
| 172 | | /* Close */ |
| 173 | | fclose(fp); |
| 174 | | } |
| 175 | | } |
| 176 | | |
| 177 | | /* \fn sysinfo_network() |
| 178 | | * Display network devices information |
| 179 | | */ |
| 180 | | void sysinfo_network() { |
| 181 | | /* File handler */ |
| 182 | | FILE *fp = NULL; |
| 183 | | /* Device information */ |
| 184 | | char device[1024], line[1024]; |
| 185 | | /* Trafic information */ |
| 186 | | int in, out; |
| 187 | | |
| 188 | | /* Try to open network information file */ |
| 189 | | fp = fopen("/proc/net/dev", "r"); |
| 190 | | /* Ok? */ |
| 191 | | if (fp) { |
| 192 | | owi_headline(1, SYSINFO_NETWORK_DEVICES); |
| 193 | | owi_headline(2, SYSINFO_NETWORK_DEVICES_DESCRIPTION); |
| 194 | | printf("<table class=\"%s\" cellpadding=\"0\" cellspacing=\"0\" align=\"left\">\n" |
| 195 | | "<thead>\n" |
| 196 | | "<tr>\n" |
| 197 | | "<th>Interface</th>\n" |
| 198 | | "<th>In</th>\n" |
| 199 | | "<th>Out</th>\n" |
| 200 | | "</tr>\n" |
| 201 | | "</thead>\n", |
| 202 | | CONTENT_TABLE_BOX_CLASS); |
| 203 | | /* Skip first line */ |
| 204 | | fgets(line, sizeof(line) - 1, fp); |
| 205 | | /* Read while not end of file */ |
| 206 | | while (fgets(line, sizeof(line) - 1, fp)) { |
| 207 | | /* : found? */ |
| 208 | | if (strchr(line, ':')) { |
| 209 | | sscanf(line, "%*[ ]%[^:]:%d %*s %*s %*s %*s %*s %*s %*s %d", device, &in, &out); |
| 210 | | /* printf("[%s]<>[%s]\n", device, p->ifa_name); */ |
| 211 | | printf("<tr onmouseover=\"this.className='%s';\"" |
| 212 | | " onmouseout=\"this.className='%s';\">\n" |
| 213 | | "<td>%s</td>\n" |
| 214 | | "<td>%d MB</td>\n" |
| 215 | | "<td>%d MB</td>\n" |
| 216 | | "</tr>\n", |
| 217 | | CONTENT_TABLE_CLASS_MOUSEOVER, |
| 218 | | CONTENT_TABLE_CLASS_MOUSEOUT, |
| 219 | | device, |
| 220 | | in / 1024 / 1024, |
| 221 | | out / 1024 / 1024); |
| 222 | | } |
| 223 | | } |
| 224 | | |
| 225 | | printf("</table>\n"); |
| 226 | | /* Close */ |
| 227 | | fclose(fp); |
| 228 | | } |
| 229 | | } |