22 changed files with 718 additions and 120 deletions
@ -0,0 +1,28 @@ |
|||||||
|
#!/usr/bin/expect -f |
||||||
|
set path [lindex $argv 0] |
||||||
|
set date [lindex $argv 1] |
||||||
|
|
||||||
|
#Lala |
||||||
|
spawn ssh -p4848 ditolak@lala.cayangqu.com python3.8 './twitmonitor/monitor.py' $path $date |
||||||
|
expect "password:" |
||||||
|
send "2020 Rahasia123!\r" |
||||||
|
interact |
||||||
|
sleep 2 |
||||||
|
spawn scp -P4848 ditolak@lala.cayangqu.com:/home/ditolak/twitmonitor/twit_monitor.txt ./monitoring/lala.txt |
||||||
|
expect "password:" |
||||||
|
send "2020 Rahasia123!\r" |
||||||
|
interact |
||||||
|
|
||||||
|
#Anin |
||||||
|
spawn ssh -p4848 biasa@anin.cayangqu.com python3.8 './twitmonitor/monitor.py' $path $date |
||||||
|
expect "password:" |
||||||
|
send "2020 seperti kemarin\r" |
||||||
|
interact |
||||||
|
sleep 2 |
||||||
|
spawn scp -P4848 biasa@anin.cayangqu.com:/home/biasa/twitmonitor/twit_monitor.txt ./monitoring/anin.txt |
||||||
|
expect "password:" |
||||||
|
send "2020 seperti kemarin\r" |
||||||
|
interact |
||||||
|
|
||||||
|
spawn ./monitoring/devi.py |
||||||
|
interact |
@ -0,0 +1,84 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
import subprocess |
||||||
|
import datetime |
||||||
|
import json |
||||||
|
import sys |
||||||
|
|
||||||
|
now = datetime.datetime.now() |
||||||
|
date = now.strftime('%Y%m%d') |
||||||
|
|
||||||
|
server_name = 'devi.cayangqu.com' |
||||||
|
|
||||||
|
try: |
||||||
|
nama_log = f"auto_replytoaccNretweet.log.{sys.argv[2]}" |
||||||
|
except: |
||||||
|
nama_log = "auto_replytoaccNretweet.log" |
||||||
|
|
||||||
|
def twit_sent(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/bsmqris/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit sent with text"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit sent: {output}" |
||||||
|
|
||||||
|
def twit_failed(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/bsmqris/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit failed: {output}" |
||||||
|
|
||||||
|
def quote_tweet(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/bsmqris/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "quote twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit quoted: {output}" |
||||||
|
|
||||||
|
def reply_tweet(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/bsmqris/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "reply twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit replied: {output}" |
||||||
|
|
||||||
|
def twit_failed2(): |
||||||
|
with open(f"/home/bsmqris/twitmonitor/twit_failed.txt", 'w') as f: |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/bsmqris/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = grep_process.communicate() |
||||||
|
#print(output) |
||||||
|
f.write(output) |
||||||
|
f = open("/home/bsmqris/twitmonitor/twit_failed.txt", "r") |
||||||
|
result = { |
||||||
|
"error_401":0, |
||||||
|
"error_403":0, |
||||||
|
"error_400":0, |
||||||
|
"error_429":0, |
||||||
|
"error_503":0, |
||||||
|
} |
||||||
|
for x in f: |
||||||
|
error=x.split() |
||||||
|
raw_error=error[14] |
||||||
|
clean_error = raw_error[1:4] |
||||||
|
if(int(clean_error) == 401): |
||||||
|
result["error_401"]+=1 |
||||||
|
elif(int(clean_error) == 403): |
||||||
|
result["error_403"]+=1 |
||||||
|
elif(int(clean_error) == 400): |
||||||
|
result["error_400"]+=1 |
||||||
|
elif(int(clean_error) == 429): |
||||||
|
result["error_429"]+=1 |
||||||
|
else: |
||||||
|
result["error_503"]+=1 |
||||||
|
return result |
||||||
|
|
||||||
|
with open(f"/home/bsmqris/twitmonitor/twit_monitor.txt", 'w') as f: |
||||||
|
f.write(quote_tweet()) |
||||||
|
f.write(reply_tweet()) |
||||||
|
error = twit_failed2() |
||||||
|
f.write(f"Error 401: {error['error_401']}\n") |
||||||
|
f.write(f"Error 403: {error['error_403']}\n") |
||||||
|
f.write(f"Error 400: {error['error_400']}\n") |
||||||
|
f.write(f"Error 429: {error['error_429']}\n") |
||||||
|
f.write(f"Error 503: {error['error_503']}\n") |
@ -0,0 +1,224 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
import subprocess |
||||||
|
import datetime |
||||||
|
import json |
||||||
|
import sys |
||||||
|
|
||||||
|
now = datetime.datetime.now() |
||||||
|
date = now.strftime('%Y%m%d') |
||||||
|
|
||||||
|
server_name = 'freya.cayangqu.com' |
||||||
|
|
||||||
|
try: |
||||||
|
nama_log = f"auto_replytoaccNretweet.log.{sys.argv[2]}" |
||||||
|
except: |
||||||
|
nama_log = "auto_replytoaccNretweet.log" |
||||||
|
|
||||||
|
def twit_sent(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit sent with text"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit sent: {output}" |
||||||
|
|
||||||
|
def twit_sent_2(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log2/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit sent with text"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit sent: {output}" |
||||||
|
|
||||||
|
def twit_sent_3(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log3/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit sent with text"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit sent: {output}" |
||||||
|
|
||||||
|
def twit_failed(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit failed: {output}" |
||||||
|
|
||||||
|
def twit_failed_2(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log2/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit failed: {output}" |
||||||
|
|
||||||
|
def twit_failed_3(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log3/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit failed: {output}" |
||||||
|
|
||||||
|
def quote_tweet(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "quote twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit quoted: {output}" |
||||||
|
|
||||||
|
def quote_tweet2(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log2/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "quote twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit quoted: {output}" |
||||||
|
|
||||||
|
def quote_tweet3(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log3/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "quote twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit quoted: {output}" |
||||||
|
|
||||||
|
def reply_tweet(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "reply twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit replied: {output}" |
||||||
|
|
||||||
|
def reply_tweet2(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log2/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "reply twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit replied: {output}" |
||||||
|
|
||||||
|
def reply_tweet3(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log3/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "reply twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit replied: {output}" |
||||||
|
|
||||||
|
def twit_failed2(): |
||||||
|
with open(f"/home/telakses/twitmonitor/twit_failed.txt", 'w') as f: |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = grep_process.communicate() |
||||||
|
#print(output) |
||||||
|
f.write(output) |
||||||
|
f = open("/home/telakses/twitmonitor/twit_failed.txt", "r") |
||||||
|
result = { |
||||||
|
"error_401":0, |
||||||
|
"error_403":0, |
||||||
|
"error_400":0, |
||||||
|
"error_429":0, |
||||||
|
"error_503":0, |
||||||
|
} |
||||||
|
for x in f: |
||||||
|
error=x.split() |
||||||
|
raw_error=error[14] |
||||||
|
clean_error = raw_error[1:4] |
||||||
|
if(int(clean_error) == 401): |
||||||
|
result["error_401"]+=1 |
||||||
|
elif(int(clean_error) == 403): |
||||||
|
result["error_403"]+=1 |
||||||
|
elif(int(clean_error) == 400): |
||||||
|
result["error_400"]+=1 |
||||||
|
elif(int(clean_error) == 429): |
||||||
|
result["error_429"]+=1 |
||||||
|
else: |
||||||
|
result["error_503"]+=1 |
||||||
|
return result |
||||||
|
|
||||||
|
def twit_failed2_2(): |
||||||
|
with open(f"/home/telakses/twitmonitor/twit_failed_log2.txt", 'w') as f: |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log2/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = grep_process.communicate() |
||||||
|
#print(output) |
||||||
|
f.write(output) |
||||||
|
f = open("/home/telakses/twitmonitor/twit_failed_log2.txt", "r") |
||||||
|
result = { |
||||||
|
"error_401":0, |
||||||
|
"error_403":0, |
||||||
|
"error_400":0, |
||||||
|
"error_429":0, |
||||||
|
"error_503":0, |
||||||
|
} |
||||||
|
for x in f: |
||||||
|
error=x.split() |
||||||
|
raw_error=error[14] |
||||||
|
clean_error = raw_error[1:4] |
||||||
|
if(int(clean_error) == 401): |
||||||
|
result["error_401"]+=1 |
||||||
|
elif(int(clean_error) == 403): |
||||||
|
result["error_403"]+=1 |
||||||
|
elif(int(clean_error) == 400): |
||||||
|
result["error_400"]+=1 |
||||||
|
elif(int(clean_error) == 429): |
||||||
|
result["error_429"]+=1 |
||||||
|
else: |
||||||
|
result["error_503"]+=1 |
||||||
|
return result |
||||||
|
|
||||||
|
def twit_failed2_3(): |
||||||
|
with open(f"/home/telakses/twitmonitor/twit_failed_log3.txt", 'w') as f: |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/telakses/buzz/{sys.argv[1]}/log3/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = grep_process.communicate() |
||||||
|
#print(output) |
||||||
|
f.write(output) |
||||||
|
f = open("/home/telakses/twitmonitor/twit_failed_log3.txt", "r") |
||||||
|
result = { |
||||||
|
"error_401":0, |
||||||
|
"error_403":0, |
||||||
|
"error_400":0, |
||||||
|
"error_429":0, |
||||||
|
"error_503":0, |
||||||
|
} |
||||||
|
for x in f: |
||||||
|
error=x.split() |
||||||
|
raw_error=error[14] |
||||||
|
clean_error = raw_error[1:4] |
||||||
|
if(int(clean_error) == 401): |
||||||
|
result["error_401"]+=1 |
||||||
|
elif(int(clean_error) == 403): |
||||||
|
result["error_403"]+=1 |
||||||
|
elif(int(clean_error) == 400): |
||||||
|
result["error_400"]+=1 |
||||||
|
elif(int(clean_error) == 429): |
||||||
|
result["error_429"]+=1 |
||||||
|
else: |
||||||
|
result["error_503"]+=1 |
||||||
|
return result |
||||||
|
|
||||||
|
with open(f"/home/telakses/twitmonitor/twit_monitor.txt", 'w') as f: |
||||||
|
f.write("\n") |
||||||
|
f.write("Freya Log1:\n") |
||||||
|
f.write(quote_tweet()) |
||||||
|
f.write(reply_tweet()) |
||||||
|
error = twit_failed2() |
||||||
|
f.write(f"Error 401: {error['error_401']}\n") |
||||||
|
f.write(f"Error 403: {error['error_403']}\n") |
||||||
|
f.write(f"Error 400: {error['error_400']}\n") |
||||||
|
f.write(f"Error 429: {error['error_429']}\n") |
||||||
|
f.write(f"Error 503: {error['error_503']}\n") |
||||||
|
f.write("\n") |
||||||
|
f.write("Freya Log2:\n") |
||||||
|
f.write(quote_tweet2()) |
||||||
|
f.write(reply_tweet2()) |
||||||
|
error2 = twit_failed2_2() |
||||||
|
f.write(f"Error 401: {error2['error_401']}\n") |
||||||
|
f.write(f"Error 403: {error2['error_403']}\n") |
||||||
|
f.write(f"Error 400: {error2['error_400']}\n") |
||||||
|
f.write(f"Error 429: {error2['error_429']}\n") |
||||||
|
f.write(f"Error 503: {error2['error_503']}\n") |
||||||
|
f.write("\n") |
||||||
|
f.write("Freya Log3:\n") |
||||||
|
f.write(quote_tweet3()) |
||||||
|
f.write(reply_tweet3()) |
||||||
|
error3 = twit_failed2_3() |
||||||
|
f.write(f"Error 401: {error3['error_401']}\n") |
||||||
|
f.write(f"Error 403: {error3['error_403']}\n") |
||||||
|
f.write(f"Error 400: {error3['error_400']}\n") |
||||||
|
f.write(f"Error 429: {error3['error_429']}\n") |
||||||
|
f.write(f"Error 503: {error3['error_503']}\n") |
@ -0,0 +1,84 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
import subprocess |
||||||
|
import datetime |
||||||
|
import json |
||||||
|
import sys |
||||||
|
|
||||||
|
now = datetime.datetime.now() |
||||||
|
date = now.strftime('%Y%m%d') |
||||||
|
|
||||||
|
server_name = 'lala.cayangqu.com' |
||||||
|
|
||||||
|
try: |
||||||
|
nama_log = f"auto_replytoaccNretweet.log.{sys.argv[2]}" |
||||||
|
except: |
||||||
|
nama_log = "auto_replytoaccNretweet.log" |
||||||
|
|
||||||
|
def twit_sent(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/ditolak/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit sent with text"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit sent: {output}" |
||||||
|
|
||||||
|
def twit_failed(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/ditolak/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit failed: {output}" |
||||||
|
|
||||||
|
def quote_tweet(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/ditolak/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "quote twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit quoted: {output}" |
||||||
|
|
||||||
|
def reply_tweet(): |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/ditolak/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "reply twit sent"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
wc_process = subprocess.Popen(["wc", "-l"], stdin=grep_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = wc_process.communicate() |
||||||
|
return f"Twit replied: {output}" |
||||||
|
|
||||||
|
def twit_failed2(): |
||||||
|
with open(f"/home/ditolak/twitmonitor/twit_failed.txt", 'w') as f: |
||||||
|
ls_process = subprocess.Popen(["cat",f"/home/ditolak/buzz/{sys.argv[1]}/log/{nama_log}"], stdout=subprocess.PIPE, text=True) |
||||||
|
grep_process = subprocess.Popen(["grep", "twit failed"], stdin=ls_process.stdout, stdout=subprocess.PIPE, text=True) |
||||||
|
output, error = grep_process.communicate() |
||||||
|
#print(output) |
||||||
|
f.write(output) |
||||||
|
f = open("/home/ditolak/twitmonitor/twit_failed.txt", "r") |
||||||
|
result = { |
||||||
|
"error_401":0, |
||||||
|
"error_403":0, |
||||||
|
"error_400":0, |
||||||
|
"error_429":0, |
||||||
|
"error_503":0, |
||||||
|
} |
||||||
|
for x in f: |
||||||
|
error=x.split() |
||||||
|
raw_error=error[14] |
||||||
|
clean_error = raw_error[1:4] |
||||||
|
if(int(clean_error) == 401): |
||||||
|
result["error_401"]+=1 |
||||||
|
elif(int(clean_error) == 403): |
||||||
|
result["error_403"]+=1 |
||||||
|
elif(int(clean_error) == 400): |
||||||
|
result["error_400"]+=1 |
||||||
|
elif(int(clean_error) == 429): |
||||||
|
result["error_429"]+=1 |
||||||
|
else: |
||||||
|
result["error_503"]+=1 |
||||||
|
return result |
||||||
|
|
||||||
|
with open(f"/home/ditolak/twitmonitor/twit_monitor.txt", 'w') as f: |
||||||
|
f.write(quote_tweet()) |
||||||
|
f.write(reply_tweet()) |
||||||
|
error = twit_failed2() |
||||||
|
f.write(f"Error 401: {error['error_401']}\n") |
||||||
|
f.write(f"Error 403: {error['error_403']}\n") |
||||||
|
f.write(f"Error 400: {error['error_400']}\n") |
||||||
|
f.write(f"Error 429: {error['error_429']}\n") |
||||||
|
f.write(f"Error 503: {error['error_503']}\n") |
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 195 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 195 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 193 |
|
||||||
Twit failed: 2 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 2 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -0,0 +1,17 @@ |
|||||||
|
#!/usr/bin/env python3 |
||||||
|
import datetime |
||||||
|
import os |
||||||
|
import glob |
||||||
|
|
||||||
|
now = datetime.datetime.now() |
||||||
|
date = now.strftime('%Y%m%d') |
||||||
|
|
||||||
|
cwd = os.getcwd() |
||||||
|
|
||||||
|
with open(f"{cwd}/monitoring/lala.txt") as f: |
||||||
|
print("Lala") |
||||||
|
print(f.read()) |
||||||
|
|
||||||
|
with open(f"{cwd}/monitoring/anin.txt") as f: |
||||||
|
print("Anin") |
||||||
|
print(f.read()) |
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 185 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 195 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 195 |
|
||||||
Twit failed: 2 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 2 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 195 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 192 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 193 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 182 |
|
||||||
Twit failed: 2 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 2 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 185 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -0,0 +1,22 @@ |
|||||||
|
import glob |
||||||
|
|
||||||
|
def readfile(): |
||||||
|
read_path = glob.glob(f"*.txt") |
||||||
|
return read_path |
||||||
|
|
||||||
|
nama_log = f"{readfile()}" |
||||||
|
|
||||||
|
#print(nama_log) |
||||||
|
|
||||||
|
with open(nama_log, 'r') as f: |
||||||
|
lines = f.read().splitlines() |
||||||
|
|
||||||
|
for line in lines: |
||||||
|
x1 = line.split(": ") |
||||||
|
twit_sent = x1[1] |
||||||
|
sum += int(twit_sent) |
||||||
|
print(f"{twit_sent}") |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#print(list) |
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 196 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
@ -1,7 +0,0 @@ |
|||||||
Twit sent: 196 |
|
||||||
Twit failed: 0 |
|
||||||
Error 401: 0 |
|
||||||
Error 403: 0 |
|
||||||
Error 400: 0 |
|
||||||
Error 429: 0 |
|
||||||
Error 503: 0 |
|
Loading…
Reference in new issue