Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf8 -*-
  3. # Monitoring Tool
  4. # Python 2.7
  5. # __author__ = 'camoufl4g3'
  6.  
  7. print """
  8. ##########################################################
  9. # #
  10. # Linux server monitoring tool #
  11. # #camoufl4g3 #
  12. # #
  13. # #
  14. ##########################################################
  15.  
  16. """
  17.  
  18.  
  19. import socket
  20.  
  21. import urllib,os,platform,netifaces,ipgetter,subprocess
  22.  
  23. ## Internet Connection
  24.  
  25. try :
  26. stri = "https://www.google.com"
  27. data = urllib.urlopen(stri)
  28. print "Internet: Connected"
  29. except e:
  30. print "Internet: not connected" ,e
  31.  
  32. print '-----------------------------------------------------------------------------'
  33.  
  34. ## Os
  35.  
  36. print "OS name: ", platform.uname()[0]
  37.  
  38. print '-----------------------------------------------------------------------------'
  39.  
  40. #Architecture
  41.  
  42. print "Architecture:" , platform.uname()[4]
  43.  
  44. print '-----------------------------------------------------------------------------'
  45.  
  46. ## Kernel Release
  47.  
  48.  
  49. print "Kernel Release:" , platform.uname()[2]
  50.  
  51. print '-----------------------------------------------------------------------------'
  52.  
  53. ## Hostname
  54.  
  55. print "Hostname: ",socket.gethostname()
  56.  
  57. netifaces.ifaddresses('eth0')
  58. ip = netifaces.ifaddresses('eth0')[2][0]['addr']
  59.  
  60. print '-----------------------------------------------------------------------------'
  61.  
  62. print "Local Ip : ",ip
  63.  
  64. print '-----------------------------------------------------------------------------'
  65.  
  66.  
  67.  
  68. ## Internal Ip
  69.  
  70. print "External Ip: ",ipgetter.myip()
  71.  
  72. print '-----------------------------------------------------------------------------'
  73.  
  74. #print platform.uname()
  75.  
  76. ## Logged Users
  77.  
  78. print "Logged Users: " + " \n ",subprocess.check_output("who")
  79.  
  80.  
  81. print '-----------------------------------------------------------------------------'
  82.  
  83. ##RAM and SWAP Usages
  84.  
  85. print "Check RAM and SWAP Usages: ","\n"
  86.  
  87. print '-----------------------------------------------------------------------------'
  88.  
  89. print subprocess.call(['free', '-h'])
  90.  
  91.  
  92. print '-----------------------------------------------------------------------------'
  93.  
  94. ## Disk usage
  95.  
  96. print "Disk usage: ","\n"
  97.  
  98. print '-----------------------------------------------------------------------------'
  99.  
  100. print subprocess.call(['df', '-h'])
  101.  
  102.  
  103. print '-----------------------------------------------------------------------------'
  104.  
  105.  
  106. ## Uptime
  107.  
  108. print "Uptime: ","\n"
  109.  
  110. print '-----------------------------------------------------------------------------'
  111.  
  112. print subprocess.call(['uptime'])
  113.  
  114.  
  115. print '-----------------------------------------------------------------------------'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement