[Ngms-svn] SVN-Commit: [47] coding 規約準拠

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 11月 30日 (月) 17:21:14 JST


Revision: 47
          http://sourceforge.jp/projects/ngms/svn/view?view=rev&revision=47
Author:   tatsuro
Date:     2009-11-30 17:21:14 +0900 (Mon, 30 Nov 2009)

Log Message:
-----------
  coding 規約準拠

Modified Paths:
--------------
    trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/CactiConfig.scala
    trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/ExecCmd.scala
    trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/NagiosConfig.scala

Property Changed:
----------------
    trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/CactiConfig.scala
    trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/ExecCmd.scala
    trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/NagiosConfig.scala

Modified: trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/CactiConfig.scala
===================================================================
--- trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/CactiConfig.scala	2009-11-27 10:04:54 UTC (rev 46)
+++ trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/CactiConfig.scala	2009-11-30 08:21:14 UTC (rev 47)
@@ -15,27 +15,27 @@
     val cactiDir = "/usr/local/cacti"
 
     // php add_device.php --description=hostname --ip=address --template=1 \
-    //		          --avail=snmp --version=2 --community=public
+    //                          --avail=snmp --version=2 --community=public
     //
     // host-template: Generic SNMP-enabled Host
    
     def addDevice(hostname:String, address:String) = {
-	val cmd =
-	    "php %s/cli/add_device.php --description=%s --ip=%s ".format(cactiDir, hostname, address) +
+        val cmd =
+            "php %s/cli/add_device.php --description=%s --ip=%s ".format(cactiDir, hostname, address) +
             "--quiet --template=1 --avail=snmp --version=2 --community=public"
-	val proc = new execCmd(cmd)
-	proc.exec
+        val proc = new ExecCmd(cmd)
+        proc.exec
     }
 
     def getHostID(address:String) = {
-	val cmd = "php %s/cli/add_graphs.php --list-hosts".format(cactiDir)
-	val proc = new execCmd(cmd)
-	val result = proc.exec
-	val lines = result.split("\\n").filter(_.contains(address)).toList
-	if (lines.isEmpty)
-	   ""
-	else
-	    lines.head.split("\\s+").toList.head
+        val cmd = "php %s/cli/add_graphs.php --list-hosts".format(cactiDir)
+        val proc = new ExecCmd(cmd)
+        val result = proc.exec
+        val lines = result.split("\\n").filter(_.contains(address)).toList
+        if (lines.isEmpty)
+            ""
+        else
+            lines.head.split("\\s+").toList.head
     }
 
     //php add_graphs.php --graph-type=ds --graph-template-id=2 --host-id=?? \
@@ -45,20 +45,19 @@
     // snmp-query-id:      SNMP - Interface Statistics
     // snmp-query-type-id: In/Out Bits
     def addGraph(hostid:String) = {
-	val cmd = "php %s/cli/add_graphs.php ".format(cactiDir) +
-	          "--graph-type=ds --graph-template-id=2 --host-id=%s ".format(hostid) +
-	          "--quiet --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifOperStatus --snmp-value=Up"
-	val proc = new execCmd(cmd)
-	proc.exec
+        val cmd = "php %s/cli/add_graphs.php ".format(cactiDir) +
+                  "--graph-type=ds --graph-template-id=2 --host-id=%s ".format(hostid) +
+                  "--quiet --snmp-query-id=1 --snmp-query-type-id=13 --snmp-field=ifOperStatus --snmp-value=Up"
+        val proc = new ExecCmd(cmd)
+        proc.exec
     }
 }
 
 /*
-val cmd = new execCmd("date")
+val cmd = new ExecCmd("date")
 cmd.setEnv("LANG", "C")
 cmd.setDir("/tmp")
 //cmd.setEnv("LANG", "ja_JP.UTF-8")
 val result = cmd.exec
 println(result)
 */
-


Property changes on: trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/CactiConfig.scala
___________________________________________________________________
Added: svn:keywords
   + Date Id

Modified: trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/ExecCmd.scala
===================================================================
--- trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/ExecCmd.scala	2009-11-27 10:04:54 UTC (rev 46)
+++ trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/ExecCmd.scala	2009-11-30 08:21:14 UTC (rev 47)
@@ -14,36 +14,36 @@
 import scala.io.Source
 import java.io.File
 
-class execCmd(cmd:String) {
+class ExecCmd(cmd:String) {
     def toJavaList[T](ary: Array[T]): java.util.List[T] = {
-	val lst = new java.util.ArrayList[T];
-	ary.map(lst.add)
-	lst
+        val lst = new java.util.ArrayList[T];
+        ary.map(lst.add)
+        lst
     }
     val pb = new ProcessBuilder(toJavaList(cmd.split("\\s+")))
 
     def setEnv(env:java.lang.String, value:java.lang.String) = {
-	val e = pb.environment()
-	e.put(env, value)
+        val e = pb.environment()
+        e.put(env, value)
     }
 
     def setDir(dir:String) = {
-	pb.directory(new File(dir))
+        pb.directory(new File(dir))
     }
 
     def exec = {
-	val p = pb.start()
-	val ret = p.waitFor()
-	val is = p.getInputStream()
-	val result = Source.fromInputStream(is).getLines.mkString.trim
-	    is.close
-	result
+        val p = pb.start()
+        val ret = p.waitFor()
+        val is = p.getInputStream()
+        val result = Source.fromInputStream(is).getLines.mkString.trim
+        is.close
+        result
     }
 }
 
 /*
-//val cmd = new execCmd("date")
-val cmd = new execCmd("ls -lRta")
+//val cmd = new ExecCmd("date")
+val cmd = new ExecCmd("ls -lRta")
 cmd.setEnv("LANG", "C")
 cmd.setDir("/tmp")
 //cmd.setEnv("LANG", "ja_JP.UTF-8")


Property changes on: trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/ExecCmd.scala
___________________________________________________________________
Added: svn:keywords
   + Date Id

Modified: trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/NagiosConfig.scala
===================================================================
--- trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/NagiosConfig.scala	2009-11-27 10:04:54 UTC (rev 46)
+++ trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/NagiosConfig.scala	2009-11-30 08:21:14 UTC (rev 47)
@@ -18,32 +18,32 @@
     val NagiosDir = "/usr/local/nagios"
 
     def writeConfig(hostname:String, addr:String) = {
-	val fmt = """define host {
-	use             NGMS_host
-	host_name       %s
-	alias           %s
-	address         %s
+        val fmt = """define host {
+        use             NGMS_host
+        host_name       %s
+        alias           %s
+        address         %s
 }
 
 define service {
-	use             NGMS_service_ping
-	host_name       %s
+        use             NGMS_service_ping
+        host_name       %s
 }
 """
-	printf(fmt, hostname, hostname, addr, hostname)
+        printf(fmt, hostname, hostname, addr, hostname)
         val filename = "%s/etc/NGMS/%s.cfg".format(NagiosDir, hostname)
-	val file = new java.io.FileWriter(filename)
-	file.write(fmt.format(hostname, hostname, addr, hostname))
-	file.close
+        val file = new java.io.FileWriter(filename)
+        file.write(fmt.format(hostname, hostname, addr, hostname))
+        file.close
     }
 
     def sendHUP = {
-	val lockFile = "%s/var/nagios.lock".format(NagiosDir)
-	val pid = Source.fromFile(lockFile).getLines.mkString.trim
-	val cmd = "kill -1 %s".format(pid)
-	printf("send HUP signal to Nagios: %s\n",cmd)
-	val proc = new execCmd(cmd)
-	proc.exec
+        val lockFile = "%s/var/nagios.lock".format(NagiosDir)
+        val pid = Source.fromFile(lockFile).getLines.mkString.trim
+        val cmd = "kill -1 %s".format(pid)
+        printf("send HUP signal to Nagios: %s\n",cmd)
+        val proc = new ExecCmd(cmd)
+        proc.exec
     }
 }
 
@@ -62,7 +62,7 @@
 # host
 #
 define host {
-	name			NGMS_host_common
+        name                    NGMS_host_common
         check_command           check-host-alive
         max_check_attempts      4
         contact_groups          admins
@@ -71,7 +71,7 @@
 }
 
 define host {
-	use			NGMS_host_common
+        use                     NGMS_host_common
         name                    NGMS_host
         check_period            24x7
         notification_period     24x7
@@ -80,8 +80,8 @@
 }
 
 define host {
-	use			NGMS_host_common
-	name			NGMS_switch
+        use                     NGMS_host_common
+        name                    NGMS_switch
         check_period            24x7
         notification_period     24x7
         notification_options    d,r
@@ -92,21 +92,21 @@
 # service
 #
 define service {
-	name				NGMS_service_common
-        max_check_attempts              4
-	check_interval			5
-	retry_interval			2
-	check_period			24x7
-	notification_period		24x7
-	contact_groups			admins
-        register                        0
+        name                    NGMS_service_common
+        max_check_attempts      4
+        check_interval          5
+        retry_interval          2
+        check_period            24x7
+        notification_period     24x7
+        contact_groups          admins
+        register                0
 }
 
 define service {
-	use				NGMS_service_common
-	name				NGMS_service_ping
-	service_description		PING
-	check_command			check_ping!100.0,20%!500.0,60%
-	register			0
+        use                     NGMS_service_common
+        name                    NGMS_service_ping
+        service_description     PING
+        check_command           check_ping!100.0,20%!500.0,60%
+        register                0
 }
 */


Property changes on: trunk/source/NMNetWalker/src/info/ngms/nmnetwalker/NagiosConfig.scala
___________________________________________________________________
Added: svn:keywords
   + Date Id




Ngms-svn メーリングリストの案内
Back to archive index