Guest User

TSergey, 2015-01-22, OS.FreeBSD.get_config

a guest
Jan 22nd, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. ##----------------------------------------------------------------------
  3. ## OS.FreeBSD.get_config
  4. ##----------------------------------------------------------------------
  5. ## Copyright (C) 2007-2015 The NOC Project
  6. ## See LICENSE for details
  7. ##----------------------------------------------------------------------
  8.  
  9. ## Python modules
  10. import noc.sa.script
  11. ## NOC modules
  12. from noc.sa.interfaces import IGetConfig
  13.  
  14.  
  15. class Script(noc.sa.script.Script):
  16. name = "OS.FreeBSD.get_config"
  17. implements = [IGetConfig]
  18.  
  19. def execute(self):
  20. config = ''
  21. config += "==[ hostname ]=="
  22. config += "\n"
  23. config += self.cli("hostname")
  24. config += "\n"
  25.  
  26. config += "==[ uname -r -m ]=="
  27. config += "\n"
  28. config += self.cli("uname -r -m")
  29. config += "\n"
  30.  
  31. config += "==[ ifconfig -v ]=="
  32. config += "\n"
  33. config += self.cli("ifconfig -v")
  34. config += "\n"
  35.  
  36. config += "==[ netstat -nr -f inet ]=="
  37. config += "\n"
  38. config += self.cli("netstat -nr -f inet | awk '{ printf(\"%-20s %-20s %-10s %-10s\\n\", $1, $2, $3, $6)}'")
  39. config += "\n"
  40.  
  41. config += "==[ /bin/cat /etc/crontab | grep -v '^#' ]=="
  42. config += "\n"
  43. config += self.cli("/bin/cat /etc/crontab | grep -v '^#'")
  44. config += "\n"
  45.  
  46. config += "==[ /bin/cat /etc/rc.conf | grep -v '^#' | grep \"YES\" ]=="
  47. config += "\n"
  48. config += self.cli("/bin/cat /etc/rc.conf | grep -v '^#' | grep \"YES\"")
  49. config += "\n"
  50.  
  51. if not config:
  52. raise Exception("Not implemented")
  53. config = self.cleaned_config(config)
  54. if self.encoding:
  55. config = unicode(config, self.encoding).encode("utf8", "ignore")
  56. return config
Add Comment
Please, Sign In to add comment