Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf8 -*-
- # Monitoring Tool
- # Python 2.7
- # __author__ = 'camoufl4g3'
- print """
- ##########################################################
- # #
- # Linux server monitoring tool #
- # #camoufl4g3 #
- # #
- # #
- ##########################################################
- """
- import socket
- import urllib,os,platform,netifaces,ipgetter,subprocess
- ## Internet Connection
- try :
- stri = "https://www.google.com"
- data = urllib.urlopen(stri)
- print "Internet: Connected"
- except e:
- print "Internet: not connected" ,e
- print '-----------------------------------------------------------------------------'
- ## Os
- print "OS name: ", platform.uname()[0]
- print '-----------------------------------------------------------------------------'
- #Architecture
- print "Architecture:" , platform.uname()[4]
- print '-----------------------------------------------------------------------------'
- ## Kernel Release
- print "Kernel Release:" , platform.uname()[2]
- print '-----------------------------------------------------------------------------'
- ## Hostname
- print "Hostname: ",socket.gethostname()
- netifaces.ifaddresses('eth0')
- ip = netifaces.ifaddresses('eth0')[2][0]['addr']
- print '-----------------------------------------------------------------------------'
- print "Local Ip : ",ip
- print '-----------------------------------------------------------------------------'
- ## Internal Ip
- print "External Ip: ",ipgetter.myip()
- print '-----------------------------------------------------------------------------'
- #print platform.uname()
- ## Logged Users
- print "Logged Users: " + " \n ",subprocess.check_output("who")
- print '-----------------------------------------------------------------------------'
- ##RAM and SWAP Usages
- print "Check RAM and SWAP Usages: ","\n"
- print '-----------------------------------------------------------------------------'
- print subprocess.call(['free', '-h'])
- print '-----------------------------------------------------------------------------'
- ## Disk usage
- print "Disk usage: ","\n"
- print '-----------------------------------------------------------------------------'
- print subprocess.call(['df', '-h'])
- print '-----------------------------------------------------------------------------'
- ## Uptime
- print "Uptime: ","\n"
- print '-----------------------------------------------------------------------------'
- print subprocess.call(['uptime'])
- print '-----------------------------------------------------------------------------'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement