Call this v1.0
commit
43cc3eb21a
|
@ -0,0 +1,16 @@
|
|||
--- SpeedyParse
|
||||
SpeedyParse is a simple configurable bash script that parses lighttpd
|
||||
access.log files and generates static HTML files in a specific location
|
||||
|
||||
--- Usage
|
||||
* Modify "config" do your needs.
|
||||
* Run speedyparse as root (if log files are owned by root, or web server)
|
||||
* View generated HTML file!
|
||||
|
||||
--- Changelog
|
||||
* v1.0
|
||||
* Generates HTML file after parsing access.log files within lighttpd log file
|
||||
* Working as it does, will be added to after I get more time.
|
||||
|
||||
--- License
|
||||
SpeedyParse is released under CC-BY-SA-NC 3.0
|
|
@ -0,0 +1,13 @@
|
|||
# SpeedyParse configuration file
|
||||
# Chris Dorman, 2020 - CC-BY-SA-NC 3.0
|
||||
|
||||
### Search parameters ###
|
||||
# Domain to parse hits, and connections from
|
||||
DOMAIN="hosting.cddo.cf"
|
||||
# Where to put [domain name]-[date].html when generated
|
||||
OUTPUTDIR="/opt/htdocs" # Where the parsed HTML log file will go
|
||||
# String to search for; great for finding individual page
|
||||
# hits, default searches for root hits from [domain name]
|
||||
SEARCHSTRING="GET / "
|
||||
# Secondary string for a more strict search, leave unset for no use
|
||||
SECONDARYSEARCH=""
|
|
@ -0,0 +1,88 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Parse lighttpd access logs for website hits
|
||||
# Chris Dorman, 2020 - CC-BY-SA-NC 3.0
|
||||
#
|
||||
|
||||
# Include configuartion file
|
||||
. config
|
||||
|
||||
# Date string for html generation
|
||||
datestring=`date +"%Y%m%d-%H%M"`
|
||||
|
||||
# Project information
|
||||
PROJTITLE="SpeedyParse"
|
||||
PROJVERSION="1.0"
|
||||
|
||||
cd /var/log/lighttpd
|
||||
|
||||
if [ -f access.*.gz ]; then
|
||||
echo "Extracting access.log files"
|
||||
tar -xzf *.gz
|
||||
fi
|
||||
|
||||
# Parse latest access.log and put within log file in HTML format.
|
||||
|
||||
if [ -z "$SECONDARYSEARCH" ]; then
|
||||
catchcount=`grep $DOMAIN access.log | grep "${SEARCHSTRING}" | wc -l`
|
||||
catchlog=`grep $DOMAIN access.log | grep "${SEARCHSTRING}" | sort`
|
||||
else
|
||||
catchcount=`grep $DOMAIN access.log | grep "${SEARCHSTRING}" | grep "${SECONDARYSEARCH}" | wc -l`
|
||||
catchlog=`grep $DOMAIN access.log | grep "${SEARCHSTRING}" | grep "${SECONDARYSEARCH}" | sort`
|
||||
fi
|
||||
|
||||
catchtotal=$catchcount
|
||||
|
||||
echo "<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lighttpd access logs ~ $date</title>
|
||||
<style type='text/css' rel='stylesheet'>
|
||||
html { background-color: #454545; color: #bbbbbb; padding: 10px; }
|
||||
body { background-color: #313131; padding: 20px; border-radius: 8px; border: solid 1px #222222; margin: 0 auto; }
|
||||
h1, h2, h3, h4, h5, h6 { color: #ffffff; padding: 4px; width: 100%; text-align: center; margin: auto; }
|
||||
code { white-space: pre-wrap; padding: 5px; color: #00ff00; text-align: left; }
|
||||
.footer { width: 100%; text-align: center;
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Access.log information ~ ${datestring}</h3>
|
||||
<code>
|
||||
Searching through lighttpd logs with these parameters:
|
||||
"${SEARCHSTRING}"" > $OUTPUTDIR/$DOMAIN-${datestring}.html
|
||||
|
||||
if [ ! -z "$SECONDARYSEARCH" ]; then
|
||||
echo ""${SECONDARYSEARCH}"" >> $OUTPUTDIR/$DOMAIN-${datestring}.html
|
||||
fi
|
||||
|
||||
echo "
|
||||
</code>
|
||||
<b>access.log ~ ${catchcount} hits</b><br />
|
||||
<code>
|
||||
${catchlog}
|
||||
</code>
|
||||
<br /><br />
|
||||
" >> $OUTPUTDIR/$DOMAIN-${datestring}.html
|
||||
|
||||
# Parse old .log files and output within HTML
|
||||
for file in access.log.*
|
||||
do
|
||||
if [ -z "$SECONDARYSEARCH" ]; then
|
||||
addition=`grep $DOMAIN $file | grep "${SEARCHSTRING}" | wc -l`
|
||||
catchlog=`grep $DOMAIN $file | grep "${SEARCHSTRING}" | sort`
|
||||
else
|
||||
addition=`grep $DOMAIN $file | grep "${SEARCHSTRING}" | grep "${SECONDARYSEARCH}" | wc -l`
|
||||
catchlog=`grep $DOMAIN $file | grep "${SEARCHSTRING}" | grep "${SECONDARYSEARCH}" | sort`
|
||||
fi
|
||||
|
||||
doaddition=$(( $catchcount + $addition ))
|
||||
|
||||
export catchcount=$doaddition
|
||||
|
||||
echo "<b>$file ~ ${addition} hits</b><br />" >> $OUTPUTDIR/$DOMAIN-${datestring}.html
|
||||
echo "<code>${catchlog}</code><br /><br />" >> $OUTPUTDIR/$DOMAIN-${datestring}.html
|
||||
done
|
||||
|
||||
echo "<b>${doaddition} hits total on ${DOMAIN} using above search parameters.</b><br /><br />" >> $OUTPUTDIR/$DOMAIN-${datestring}.html
|
||||
|
||||
echo "<div class='footer'>Generated by ${PROJTITLE} ${PROJVERSION}</div></body></html>" >> $OUTPUTDIR/$DOMAIN-${datestring}.html
|
Loading…
Reference in New Issue