Browse Source

ping service

master
paulussimanjuntak 5 years ago
parent
commit
b4e6583a6e
3 changed files with 82 additions and 0 deletions
  1. +1
    -0
      ping-service/README.md
  2. +77
    -0
      ping-service/ping-service.py
  3. +4
    -0
      ping-service/start.sh

+ 1
- 0
ping-service/README.md View File

@ -0,0 +1 @@
ping-service.py

+ 77
- 0
ping-service/ping-service.py View File

@ -0,0 +1,77 @@
#!/usr/bin/python
import sys, subprocess, re
from os import system as MaManX
def make_secure():
unsafe_word = ['__import__', 'eval', 'execfile', 'file', 'input', 'compile', 'reload']
for unsafe in unsafe_word:
del __builtins__.__dict__[unsafe]
class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def writelines(self, datas):
self.stream.writelines(datas)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout = Unbuffered(sys.stdout)
def banner():
return '''
\033[1;32mWELCOME TO MAMANX PINX SERVICE\033[1;m\033[1;31m
_ __ _____ _ _____ _____ _ _ _____ _____ _____ _____ _ _ _____ _____ _____
| | / // ___|| | | ___ \|_ _|| \ | || __ \ / ___|| ___|| ___ \| | | ||_ _|/ __ \| ___|
| |/ / \ `--. | | | |_/ / | | | \| || | \/ \ `--. | |__ | |_/ /| | | | | | | / \/| |__
| \ `--. \| | | __/ | | | . ` || | __ `--. \| __| | / | | | | | | | | | __|
| |\ \/\__/ /| |____ | | _| |_ | |\ || |_\ \ /\__/ /| |___ | |\ \ \ \./ / _| |_ | \__/\| |___
\_| \_/\____/ \_____/ \_| \___/ \_| \_/ \____/ \____/ \____/ \_| \_| \___/ \___/ \_____/\____/
\033[1;m
\033[1;32mversion [beta 1.1 MAMANK]\033[1;m
'''
def displayMenu():
return '''
Choose a ksl ping service:
1. Ping only one time
2. Ping multiple times
3. Exit MaManX
'''
def main():
make_secure()
print banner()
print displayMenu()
userNumber = raw_input("Masukkan pilihan (1-3): ")
if userNumber == "1" :
host = raw_input("\nMasukkan alamat host : ")
p1 = subprocess.Popen(['ping','-c 5', host], stdout=subprocess.PIPE)
output = p1.communicate()[0]
print output
exit()
elif userNumber == "2" :
user = int(raw_input("\nMasukkan jumlah host: "))
while user <= 1:
user = int(raw_input("\nMasukkan host lebih dari 1 MaManX: "))
for o in range(user):
host = raw_input("Masukkan alamat host ke " +str(o+1) +" : ")
hosts= re.sub('[|,;]', '', host)
pings = MaManX('ping -c 5 ' + hosts )
if (pings == 0):
print host.upper(), "IS UP MAMANX"
else :
print host.upper(), "IS LOST MAMANX"
print ""
elif userNumber == "3" :
print "\nTerimakasih telah menggunakan jasa kami MaManX"
exit()
else :
print "\nMaManX salah masukkin acchh :("
exit()
main()

+ 4
- 0
ping-service/start.sh View File

@ -0,0 +1,4 @@
#!/bin/bash
#nc ip port
socat TCP-LISTEN:5000,reuseaddr,fork EXEC:./ping-service.py

Loading…
Cancel
Save