Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cgi/analyst.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from pandas.compat import StringIO
import os
from pathlib import Path
import subprocess
import re

filepath = '/var/www/wou/tmp/'

Expand All @@ -14,6 +16,11 @@

lastfilename = last_line

cmd_output = subprocess.Popen(['tail', '-n1', '/var/log/apache2/access.log'], stdout=subprocess.PIPE)
out, err = cmd_output.communicate()

print(out)

file_to_open = filepath + lastfilename.rstrip()

f = open(file_to_open, 'r')
Expand Down
78 changes: 78 additions & 0 deletions cgi/analyst_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/python3

import pandas as pd
from pandas.compat import StringIO
import os
from pathlib import Path
import subprocess
import re

filepath = '/var/www/wou/tmp/'

with open("/var/www/wou/data/filelist.txt", "r") as file:
for last_line in file:
pass
file.close()

lastfilename = last_line

rc = subprocess.call('/var/www/wou/cgi/get_info.sh')

with open("/var/www/wou/data/client_info.txt", "r") as file:
for last_access_line in file:
pass
file.close()

#r1 = re.findall(r"^[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}\s", last_access_line)

command_output = os.popen('tail -n1 /var/www/wou/data/client_info.log')
#r1 = re.findall(r"^[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}\s", command_output.read())
r2 = re.findall(r" [lLwW].{4,11}", command_output.read())

file_to_open = filepath + lastfilename.rstrip()

f = open(file_to_open, 'r')
datainfo = f.readlines(3)

lines = list(f)
f.close()

df = pd.read_csv(file_to_open, names=['Time','Severity','Text'], engine='python')
df.to_html('../output.html', justify='center')

print("Content-Type: text/html\n")
print("<html>\n")
print("""\

<head>
<meta charset="utf-8">
<title>Data Analytic Output</title>
<meta name="description" content="Basic Data output">
<meta name="author" content="vasikadedomena">
<link rel="stylesheet" href="../css/styles.css">
</head>
""")
print("<body>\n")
print("<p>You are using a {} system</p>".format(r2))
print("\n")
print("<p>Returns of your data filename: {}</p>".format(lastfilename))
print("""\

<object data="/tmp/{}" type="text/plain" width="500" style="height: 150px"></object>

""".format(lastfilename))

print("""\

<div class="box-1">
<iframe src="https://www.vasikadedomena.site/output.html" style="border: none; width: 600px; height: 300px;" ></iframe>
</div>

<div class="box-2">
<button onclick="window.location.href='https://www.vasikadedomena.site';">Back To Main Page</button>

</div>

</body>
</html>
""")
92 changes: 92 additions & 0 deletions cgi/analyst_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/python3

import pandas as pd
from pandas.compat import StringIO
import os
from pathlib import Path
import subprocess
import re
import matplotlib.pyplot as plt

filepath = '/var/www/wou/tmp/'

with open("/var/www/wou/data/filelist.txt", "r") as file:
for last_line in file:
pass
file.close()

lastfilename = last_line

rc = subprocess.call('/var/www/wou/cgi/get_info.sh')

with open("/var/www/wou/data/client_info.txt", "r") as file:
for last_access_line in file:
pass
file.close()

#r1 = re.findall(r"^[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}\s", last_access_line)

command_output = os.popen('tail -n1 /var/www/wou/data/client_info.log')
#r1 = re.findall(r"^[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}.[0-9]{2,3}\s", command_output.read())

r2 = re.findall(r" [lLwW][iI][nN].{4,11} ", command_output.read())

file_to_open = filepath + lastfilename.rstrip()

f = open(file_to_open, 'r')
datainfo = f.readlines(3)

lines = list(f)
f.close()

Data = {'Tasks': [300,500,700]}
df = DataFrame(Data,columns=['Tasks'],index = ['Tasks Pending','Tasks Ongoing','Tasks Completed'])

df.plot.pie(y='Tasks',figsize=(5, 5),autopct='%1.1f%%', startangle=90)

plt.savefig('foo.png')

df = pd.read_csv(file_to_open, names=['Time','Severity','Text'], engine='python')
df['Severity'].value_counts()

df.plot.pie(y='Severity',figsize=(10,10),autopct='%1.1f%%', startangle=90)
plt.savefig('../foo.png')

df.to_html('../output.html', justify='center')

print("Content-Type: text/html\n")
print("<html>\n")
print("""\

<head>
<meta charset="utf-8">
<title>Data Analytic Output</title>
<meta name="description" content="Basic Data output">
<meta name="author" content="vasikadedomena">
<link rel="stylesheet" href="../css/styles.css">
</head>
""")
print("<body>\n")
print("<p>You are using a {} system</p>".format(r2))
print("\n")
print("<p>Returns of your data filename: {}</p>".format(lastfilename))
print("""\

<object data="/tmp/{}" type="text/plain" width="500" style="height: 150px"></object>

""".format(lastfilename))

print("""\

<div class="box-1">
<iframe src="https://www.vasikadedomena.site/output.html" style="border: none; width: 600px; height: 300px;" ></iframe>
</div>

<div class="box-2">
<button onclick="window.location.href='https://www.vasikadedomena.site';">Back To Main Page</button>

</div>

</body>
</html>
""")
91 changes: 91 additions & 0 deletions cgi/analyst_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/python3

import pandas as pd
from pandas.compat import StringIO
import os
from pathlib import Path
import subprocess
import re
import matplotlib

matplotlib.use('Agg')

import matplotlib.pyplot as plt


filepath = '/var/www/wou/tmp/'

with open("/var/www/wou/data/filelist.txt", "r") as file:
for last_line in file:
pass
file.close()

lastfilename = last_line

rc = subprocess.call('/var/www/wou/cgi/get_info.sh')

with open("/var/www/wou/data/client_info.txt", "r") as file:
for last_access_line in file:
pass
file.close()

command_output = os.popen('tail -n1 /var/www/wou/data/client_info.log')

r2 = re.findall(r" [lLwW][iI][nN].{4,11} ", command_output.read())

file_to_open = filepath + lastfilename.rstrip()

f = open(file_to_open, 'r')
datainfo = f.readlines(3)

lines = list(f)
f.close()

df = pd.read_csv(file_to_open, names=['Time','Severity','Text'], engine='python')

df.to_html('../output.html', justify='center')

df.Severity.value_counts().plot.pie(y='Severities', figsize=(5, 5),autopct='%1.1f%%', startangle=90)
plt.savefig('../images/chart_output.png')


print("Content-Type: text/html\n")
print("<html>\n")
print("""\

<head>
<meta charset="utf-8">
<title>Data Analytic Output</title>
<meta name="description" content="Basic Data output">
<meta name="author" content="vasikadedomena">
<link rel="stylesheet" href="../css/styles.css">
</head>
""")
print("<body>\n")
print("<p>You are using a {} system</p>".format(r2))
print("\n")
print("<p>Returns of your data filename: {}</p>".format(lastfilename))
print("""\

<object data="/tmp/{}" type="text/plain" width="500" style="height: 150px"></object>

""".format(lastfilename))

print("""\

<div class="box-1">
<iframe src="https://www.vasikadedomena.site/output.html" style="border: none; width: 600px; height: 300px;" ></iframe>
</div>

<div class="image-box-1">
<img src='../images/chart_output.png'>
</div>

<div class="box-2">
<button onclick="window.location.href='https://www.vasikadedomena.site';">Back To Main Page</button>

</div>

</body>
</html>
""")
45 changes: 45 additions & 0 deletions cgi/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from pandas import DataFrame

import matplotlib

matplotlib.use('Agg')

import matplotlib.pyplot as plt
import pandas as pd

# Data = {'Tasks': [300,500,700]}
# df = DataFrame(Data,columns=['Tasks'],index = ['Tasks Pending','Tasks Ongoing','Tasks Completed'])

sevs = {}

df = pd.read_csv('../tmp/log.txt', names=['Time','Severity','Text'], engine='python')

print(df)

sd = df['Severity']

cf = pd.value_counts(df['Severity'].values)


print(cf)


df.Severity.value_counts().plot.pie(y='Severities', figsize=(5, 5),autopct='%1.1f%%', startangle=90)
plt.savefig('foo_1.png')

#print(sd)
# plt.title('severities dataset')
# plt.axis('severities')



# df.plot.pie(y='Severity')

# plt.show()


#sd.plot.pie(y='Severity',figsize=(5, 5),autopct='%1.1f%%', startangle=90)

# # df.plot.pie(y='Tasks',figsize=(5, 5),autopct='%1.1f%%', startangle=90)
# # #plt.show()
# plt.savefig('foo_1.png')
Binary file added cgi/foo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cgi/foo_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 17 additions & 3 deletions cgi/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cgi, os
import cgitb; cgitb.enable()
import webbrowser

form = cgi.FieldStorage()

Expand All @@ -20,14 +21,27 @@
ap_file.close()

message = 'The file "' + fn + '" was uploaded successfully'


elif not (fn == ('.txt') or ('.log') or ('.csv')):
message = 'uploaded file type is not supported'

else:
message = 'No file was uploaded'

with open("/var/log/apache2/access.log", "r") as file:
for last_access_line in file:
pass
file.close()



print """\
Content-Type: text/html\n
<html>
<body>



<p>%s</p>

<div>
Expand All @@ -36,8 +50,8 @@
</form>
</div>

<button onclick="window.location.href='https://www.vasikadedomena.site';">Back To Main Page</button
<button onclick="window.location.href='https://www.vasikadedomena.site';">Back To Main Page</button>

</body>
</html>
""" % (message,)
""" % (message,)
Loading