Check-in [55d476abf5]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:First cut at the /logsummary page. Provides a count of the various error log message types. Need to gather more examples in order to figure out how to deduce more types. Access by admins only.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 55d476abf5ab6cb1a98f5bda43506849c64b79b3031e19dcefae56bc70698af9
User & Date: drh 2025-03-09 23:04:22.996
Context
2025-03-10
07:56
(Typos) Corrected two phrases, one for American spelling. check-in: b33f0d55ec user: brickviking tags: trunk
2025-03-09
23:04
First cut at the /logsummary page. Provides a count of the various error log message types. Need to gather more examples in order to figure out how to deduce more types. Access by admins only. check-in: 55d476abf5 user: drh tags: trunk
19:28
Add the "min" query parameter to /timeline. Other minor bug fixes found while working on the new feature. The priority queue implementation was rewritten. Minimum SQLite increased to 3.49.0. check-in: 4e23c2a91a user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/security_audit.c.
1017
1018
1019
1020
1021
1022
1023























































































      @ %h(z)\
    }
  }
  fclose(in);
  @ </pre>
  style_finish_page();
}






























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
      @ %h(z)\
    }
  }
  fclose(in);
  @ </pre>
  style_finish_page();
}

/*
** WEBPAGE: logsummary
**
** Scan the error log and count the various kinds of entries.
*/
void logsummary_page(void){
  i64 szFile;
  char *zLog;
  FILE *in;
  int prevWasTime = 0;
  int nHack = 0;
  int nPanic = 0;
  int nOther = 0;
  int nTotal = 0;
  char z[10000];

  login_check_credentials();
  if( !g.perm.Admin ){
    login_needed(0);
    return;
  }
  style_header("Server Hack Log");
  style_submenu_element("Log-Menu", "%R/setup-logmenu");

  if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
    no_error_log_available();
    style_finish_page();
    return;
  }
  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable to open that file for reading!</p>
    style_finish_page();
    return;
  }
  szFile = file_size(g.zErrlog, ExtFILE);
  zLog = file_canonical_name_dup(g.zErrlog);
  @ Summary of messages contained within the %lld(szFile)-byte 
  @ <a href="%R/errorlog?all">error log</a> found at
  @ "%h(zLog)".
  fossil_free(zLog);
  @ <hr>
  while( fgets(z, sizeof(z), in) ){
    if( prevWasTime 
     && (strncmp(z,"possible hack attempt - 418 ", 27)==0)
    ){
      nHack++;
      prevWasTime = 0;
      continue;
    }
    if( prevWasTime
     && (strncmp(z,"panic: ", 7)==0 || strstr(z," assertion fault ")!=0)
    ){
      nPanic++;
      prevWasTime = 0;
      continue;
    }
    if( prevWasTime ) nOther++;
    if( strncmp(z, "--------", 8)==0 ){
      nTotal++;
      prevWasTime = 1;
      continue;
    }
    prevWasTime = 0;
  }
  fclose(in);
  @ <p><table border="a" cellspacing="0" cellpadding="5">
  @ <tr><td align="right">%d(nPanic)</td>
  if( nPanic>0 ){
    @     <td><a href="./paniclog">Panics</a></td>
  } else {
    @     <td>Panics</td>
  }
  @ <tr><td align="right">%d(nHack)</td>
  if( nHack>0 ){
    @     <td><a href="./hacklog">Hack Attempts</a></td>
  }else{
    @     <td>Hack Attempts</td>
  }
  @ <tr><td align="right">%d(nOther)</td>
  @     <td>Other</td>
  @ <tr><td align="right">%d(nTotal)</td>
  @     <td>Total Messages</td>
  @ </table>
  style_finish_page();
}
Changes to src/setup.c.
268
269
270
271
272
273
274



275
276
277
278
279
280
281

  @ <tr><td><td><td>
  @ &mdash;&mdash;
  @ <i>The remaining links are subsets of the Error Log</i>
  @ &mdash;&mdash;
  @ </td>  




  setup_menu_entry("Panic Log", bErrLog ? "paniclog" : 0,
    "Only the most important messages in the Error Log:\n"
    "assertion faults, segmentation faults, and similar malfunctions.\n"
  );
  setup_menu_entry("Hack Log", bErrLog ? "hacklog" : 0,
    "All code-418 hack attempts in the Error Log"
  );







>
>
>







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284

  @ <tr><td><td><td>
  @ &mdash;&mdash;
  @ <i>The remaining links are subsets of the Error Log</i>
  @ &mdash;&mdash;
  @ </td>  

  setup_menu_entry("Error Summary", bErrLog ? "logsummary" : 0,
    "Counts of the various message types seen in the Error Log.\n"
  );
  setup_menu_entry("Panic Log", bErrLog ? "paniclog" : 0,
    "Only the most important messages in the Error Log:\n"
    "assertion faults, segmentation faults, and similar malfunctions.\n"
  );
  setup_menu_entry("Hack Log", bErrLog ? "hacklog" : 0,
    "All code-418 hack attempts in the Error Log"
  );