Changeset 468
- Timestamp:
- 10/03/07 16:43:01 (4 years ago)
- Location:
- trunk/openmct/packages/system/owi/src
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/openmct/packages/system/owi/src/file.c
r421 r468 261 261 /* Reallocate new index array */ 262 262 file_line = (char**)realloc(file_line, 263 sizeof(char *) *264 (file_line_counter + 1));263 sizeof(char *) * 264 (file_line_counter + 1)); 265 265 /* Move pointers */ 266 266 for (i = file_line_counter - 1; i > line_index; i--) { … … 289 289 return (strstr(string, match) - string) + strlen(match); 290 290 } 291 292 /* \fn proc_read_line(command, index) 293 * \param[in] proc command to execute 294 * \param[in] index return this line 295 * \return string 296 */ 297 char *proc_read_line(char *command, int index) { 298 int lines = proc_open(command); 299 char *line = NULL; 300 301 if (lines >= 0) { 302 if (index <= lines) { 303 line = (char*)malloc(strlen(file_line_get(index)) + 1); 304 if (line) { 305 strcpy(line, file_line_get(index)); 306 } 307 } 308 file_free(); 309 } 310 311 return line; 312 } 313 314 /* \fn file_read_line(command, index) 315 * \param[in] file to be read 316 * \param[in] index return this line 317 * \return string 318 */ 319 char *file_read_line(char *file, int index) { 320 int lines = file_open(file); 321 char *line = NULL; 322 323 if (lines >= 0) { 324 if (index <= lines) { 325 line = (char*)malloc(strlen(file_line_get(index)) + 1); 326 if (line) { 327 strcpy(line, file_line_get(index)); 328 } 329 } 330 file_free(); 331 } 332 333 return line; 334 } -
trunk/openmct/packages/system/owi/src/ftp.c
r465 r468 75 75 } else { 76 76 /* Print error message */ 77 owi_headline( 1, FTP_HEADLINE);77 owi_headline(3, FTP_HEADLINE); 78 78 owi_headline(2, FTP_FILE_FAILED); 79 79 } … … 98 98 99 99 /* Print external table for design */ 100 printf("<table class=\"%s\">\n" 101 "<tr>\n" 102 "<td>\n" 103 "<h1>%s</h1>\n" 104 "<br />%s<br /><br />\n" 100 printf("<h3>%s</h3>\n" 105 101 "<form action=\"%s\" method=\"post\">\n" 106 102 "<input type=\"hidden\" name=\"module\" value=\"%s\" />\n" 107 103 "<input type=\"hidden\" name=\"command\" value=\"update\" />\n" 108 "<table class=\" %s\" width=\"100%%\" cellspacing=\"0\" cellpading=\"0\">\n"104 "<table class=\"detail\">\n" 109 105 "<thead>\n" 110 106 "<tr>\n" 111 "<th colspan=\"2\"> FTP Konfiguration</th>\n"107 "<th colspan=\"2\">%s</th>\n" 112 108 "</tr>\n" 113 109 "</thead>\n", 114 CONTENT_TABLE_CLASS,115 110 FTP_HEADLINE, 116 FTP_DETAIL,117 111 getenv("SCRIPT_NAME"), 118 112 variable_get("module"), 119 CONTENT_TABLE_BOX_CLASS);113 FTP_HEADLINE_BOX); 120 114 121 115 /* Loop through config file */ … … 135 129 for (i = 0; ftp_ini[i].variable != NULL; i++) { 136 130 printf("<tr>\n" 137 "<td width=\"250\">%s</td>\n"138 "<td >", ftp_ini[i].description);131 "<td class=\"description\">%s</td>\n" 132 "<td class=\"value\">", ftp_ini[i].description); 139 133 /* valid set? */ 140 134 if (ftp_ini[i].valid) { -
trunk/openmct/packages/system/owi/src/includes/file.h
r428 r468 16 16 int file_get_pad(char *string, char *match); 17 17 int proc_open(char *command); 18 char *proc_read_line(char *command, int index); 19 char *file_read_line(char *file, int index); 18 20 19 21 extern int file_line_counter; -
trunk/openmct/packages/system/owi/src/includes/language.h
r430 r468 44 44 45 45 /* sysinfo */ 46 #define SYSINFO_HEADLINE "Systeminformation" 47 #define SYSINFO_DESCRIPTION "Anbei finden Sie aktuelle Informationen zum laufenden System" 48 #define SYSINFO_NETWORK_DEVICES "Netzwerkgeräte" 49 #define SYSINFO_NETWORK_DEVICES_DESCRIPTION "Folgende Netzwerkkomponenten sind derzeit auf dem System konfiguriert" 50 #define SYSINFO_FILESYSTEMS "Dateisysteme" 51 #define SYSINFO_FILESYSTEMS_DESCRIPTION "Anbei finden Sie alle aktuell verwendeten Dateisysteme" 52 #define SYSINFO_NAV_DESCRIPTION "System" 46 #define SYSINFO_HEADLINE "OpenMCT" 47 #define SYSINFO_HEADLINE_BOX "Systeminformation" 48 #define SYSINFO_NAV_SYSTEM "System" 49 #define SYSINFO_NAV_DESCRIPTION "DESC" 53 50 54 51 /* nfs */ … … 70 67 71 68 /* ftp */ 72 #define FTP_HEADLINE "FTP (File Transfer Protocol) Verwaltung" 73 #define FTP_DESCRIPTION "Diese Einstellungsbereich erlaubt Ihnen die Einstellungen Ihres FTP Servers zu ändern. Nachdem die Einstellungen mit dem <i>Speichern</i> Button bestätigt werden, wird die Konfiguration des FTP Servers automatisch neu geladen." 74 #define FTP_DETAIL "Sie befinden Sich nun im Detailbereich für ihren FTP Server. Hier können Sie globale Einstellungen einsehen und aktualisieren. Die Einstellungen werden mit dem Betätigen des <i>Speichern</i> Buttons sofort übernommen." 75 #define FTP_FILE_FAILED "FTP (File Transfer Protocol) Konfiguration konnte nicht geöffnet werden" 69 #define FTP_HEADLINE "Services: FTP" 70 #define FTP_HEADLINE_BOX "FTP Server" 71 #define FTP_FILE_FAILED "FTP Konfiguration konnte nicht geöffnet werden" 76 72 77 73 #define FTP_TABLE_LISTEN "Listen" -
trunk/openmct/packages/system/owi/src/includes/modules.h
r463 r468 14 14 int (*main)(int, char **); 15 15 char *description; 16 char *style;16 int level; 17 17 } modules[] = { 18 { "sysinfo", sysinfo_main, SYSINFO_NAV_DESCRIPTION, SYSINFO_NAV_CLASS }, 19 { "interface", interface_main, INTERFACE_NAV_DESCRIPTION, INTERFACE_NAV_CLASS }, 20 { "nfs", nfs_main, NFS_NAV_DESCRIPTION, NFS_NAV_CLASS }, 21 { "ftp", ftp_main, FTP_NAV_DESCRIPTION, FTP_NAV_CLASS }, 22 { "user", user_main, USER_NAV_DESCRIPTION, USER_NAV_CLASS }, 23 { "group", group_main, GROUP_NAV_DESCRIPTION, GROUP_NAV_CLASS }, 18 { "system", NULL, SYSINFO_NAV_SYSTEM, 0 }, 19 { "sysinfo", sysinfo_main, SYSINFO_NAV_DESCRIPTION, 1}, 20 { "interface", interface_main, INTERFACE_NAV_DESCRIPTION, 1 }, 21 { "nfs", nfs_main, NFS_NAV_DESCRIPTION, 1 }, 22 { "ftp", ftp_main, FTP_NAV_DESCRIPTION, 1 }, 23 { "user", user_main, USER_NAV_DESCRIPTION, 1 }, 24 { "group", group_main, GROUP_NAV_DESCRIPTION, 1 }, 24 25 #ifdef SECURITY 25 { "shell", shell_main, SHELL_NAV_DESCRIPTION, SHELL_NAV_CLASS},26 { "shell", shell_main, SHELL_NAV_DESCRIPTION, 1 }, 26 27 #endif 27 { NULL, NULL, NULL, NULL}28 { NULL, NULL, NULL, 0 } 28 29 }; -
trunk/openmct/packages/system/owi/src/owi.c
r465 r468 46 46 "</head>\n" 47 47 "<body>\n" 48 "<div id=\"navigation-outer\">Navigation</div>\n" 49 "<div id=\"navigation-inner\">\n" 50 "<ul id=\"navigation\">\n", title); 51 for (i = 0; modules[i].name != NULL; i++) { 52 printf("<li class=\"navigation %s\"><a href=\"%s?module=%s\">%s</a></li>\n", 53 modules[i].style, 54 getenv("SCRIPT_NAME"), 55 modules[i].name, 56 modules[i].description); 48 "<table class=\"main\">\n" 49 "<tr>\n" 50 "<td class=\"logo\"><h1>OpenMCT</h1></td>\n" 51 "<td class=\"description\"><h2>Administration Interface</h2></td>\n" 52 "<td class=\"domain\" align=\"right\">domainname</td>\n" 53 "</tr>\n" 54 "<tr>\n" 55 "<td class=\"navigation\">\n" 56 "<table>\n", 57 title); 58 for (i = 0; modules[i].description != NULL; i++) { 59 printf("<tr><td>\n"); 60 if (modules[i].main) { 61 printf("<a href=\"%s?module=%s\">%s</a>\n", 62 getenv("SCRIPT_NAME"), 63 modules[i].name, 64 modules[i].description); 65 } else { 66 printf("%s", modules[i].description); 67 } 68 printf("</td></tr>\n"); 57 69 } 58 printf("</ul>\n" 59 "</div>\n" 60 /*"<div id=\"toolbar\">\n" 61 "<a href=\"user.cgi?command=new\">Neu</a>\n" 62 "<a href=\"user.cgi?command=csv\">CSV</a>\n" 63 "</div>\n"*/ 64 "<div id=\"taskbar\">\n" 65 "<a class=\"button-internet\" target=\"_blank\" href=\"http://www.openmct.org\">OpenMCT Homepage</a>\n" 66 "<a class=\"button-community\" target=\"_blank\" href=\"http://forum.openmct.org\">OpenMCT Forum</a>\n" 67 "<a class=\"button-contact\" href=\"mailto:dev@openmct.org\">OpenMCT Kontakt</a>\n" 68 "</div>\n" 69 "<div id=\"content\">\n"); 70 printf("</table>\n" 71 "</td>\n" 72 "<td class=\"content\">\n"); 70 73 } 71 74 72 75 void owi_footer() { 73 printf("</div>\n" 74 "</body>\n" 76 printf("</td>\n" 77 "</tr>\n" 78 "</table>\n" 79 "<table class=\"footer\">\n" 80 "<tr>\n" 81 "<td>OpenMCT. All rights reserved.</td>\n" 82 "</tr>\n" 83 "</table>\n" 75 84 "</html>\n"); 76 85 } -
trunk/openmct/packages/system/owi/src/sysinfo.c
r429 r468 34 34 #include <sys/sysinfo.h> 35 35 #include "includes/argument.h" 36 #include "includes/file.h" 36 37 #include "includes/language.h" 37 38 #include "includes/template.h" … … 70 71 */ 71 72 void sysinfo_list() { 72 sysinfo_general();73 74 printf("<table>\n"75 "<tr><td valign=\"top\">\n");76 77 sysinfo_filesystems();78 79 printf("</td><td> </td><td valign=\"top\">\n");80 81 sysinfo_network();82 83 printf("</td></tr>\n"84 "</table>\n");85 }86 87 /* \fn sysinfo_general()88 * Display general system information like swap, ram, uptime ...89 */90 void sysinfo_general() {91 73 /* System information */ 92 74 struct sysinfo si; 75 /* Hostname */ 76 char *hostname = proc_read_line("/bin/hostname -f", 0); 77 /* Version */ 78 char *version = file_read_line("/etc/openmct.release", 0); 79 /* OS Version */ 80 char *osversion = proc_read_line("/bin/uname -a", 0); 81 /* Datum */ 82 char *date = proc_read_line("date", 0); 83 /* Uptime */ 84 char *uptime = proc_read_line("uptime", 0); 93 85 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"); 129 135 } 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 information179 */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 } -
trunk/openmct/packages/system/owi/src/user.c
r465 r468 111 111 "<th>%s</th>\n" 112 112 "<th>%s</th>\n" 113 "<th>%s</th>\n"114 "<th>%s</th>\n"115 "<th>%s</th>\n"116 113 "</tr>\n" 117 114 "</thead>\n" … … 125 122 CONTENT_TABLE_LIST_CLASS, 126 123 USER_TABLE_DESCRIPTION, 127 USER_TABLE_GECOS,128 USER_TABLE_DIRECTORY,129 USER_TABLE_SHELL,130 124 USER_TABLE_ACTION); 131 125 … … 147 141 " onmouseout=\"this.className='%s';\">\n" 148 142 "<td width=\"80\">%s</td>\n" 149 "<td width=\"160\">%s</td>\n"150 "<td width=\"160\">%s</td>\n"151 "<td width=\"160\">%s</td>\n"152 143 "<td width=\"160\">" 153 144 "<input type=\"button\" onClick=\"location='%s?module=%s&command=detail&id=%s'\" value=\"%s\" /> " … … 158 149 CONTENT_TABLE_CLASS_MOUSEOUT, 159 150 argument_get_part(passwd, 0), 160 argument_get_part(passwd, 4),161 argument_get_part(passwd, 5),162 argument_get_part(passwd, 6),163 151 getenv("SCRIPT_NAME"), 164 152 variable_get("module"),
