Neokernel Demos

C# Log Viewer Page Demo

Download LogViewerPage.zip and uncompress it inside the demos\C# Projects\ folder.

Open LogViewerPage.sln using Visual Studio.

Make sure the reference to the Neokernel.dll is correct (in case you installed Neokernel in a different directory) under "References", then press F6 to build the demo.

Double click on the file start_nk.bat to start Neokernel.

This example shows a more complex agent. The handleRequest() method generates online reports about httpd log files, and the wakeup() method executes at the intervals specified in this agents schedule property; when the agent wakes up, it updates its memory cache of log file data so the files don't need to be re-parsed everytime someone asks for the page.

This agent parses each files in the specified directory ( treating each as a log file ) and uses a mapping that provides information about how the log files should be displayed. This mapping file maps Report Namesto text search patterns; the agent lets users choose from the list of names and displays the matching lines from the log files.

To see it in action, go to http://localhost/logviewer.agent.

LogViewerPage supports the following Props:

  1. log_dir - This property tells the LogViewerPage where to look for the log files. Defaults to ./logs
  2. log_map_file - This is the path to a file describing the "views" that will be displayed to users who are browsing the logs. This file should contain names mapped to text patterns. For example, a map file may look like this:

    GET requests=GET LogViewer requests=/logviewer.agent

    When the LogViewerPage is brought up on a browser, the "Summaries" page will show hit-counts for each report. The number of lines that match the specified report's search pattern will be counted and included in the report.
  3. check_interval - All requests to view the actual lines of log files are processed in real time, that is to say, the log files are searched when a request to view certain lines of all the log files are received. However, the ?hit counts? displayed on the menu page are recorded at intervals. This property tells this agent how often to update these values in seconds. The default value is 600000.
  4. service_name - The name that this agent will register with in the ServiceManager. Default value is /logviewer.agent
  5. is_logger_output - If this property is set to ?true?, the LogViewerPage will assume that the log files are generated by the neokernel.exe WebServer so the formatting of multiple line log entries will be a little more readable. The default value is true.
  6. max_show_log_length - This is the maximum length of data that will be shown when a request to view log output is received. Since there may possibly be megabytes of log files, if a request to show all logged requests is given, the LogViewerPage will only show the number of bytes given by this property. Default value is 50000.
  7. show_memory_usage - If this is set to true, the agent will print memory usage information. Defaults to false.

Updated: 7/12/10 7:44 PM