Add New functions to initialize cmds and cmpnent

This CL added New functions to commands.go and components.go in order
for other packages to initialize unexported fields of command and
components struct from the profiler package.

Change-Id: If9b5086b4593a91d9f51d6a5cd58f5590140803a
Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/19170
Reviewed-by: Dexter Rivera <riverade@google.com>
Tested-by: Dexter Rivera <riverade@google.com>
Cloud-Build: GCB Service account <228075978874@cloudbuild.gserviceaccount.com>
diff --git a/src/pkg/nodeprofiler/profiler/commands.go b/src/pkg/nodeprofiler/profiler/commands.go
index 54ef931..ca0452e 100644
--- a/src/pkg/nodeprofiler/profiler/commands.go
+++ b/src/pkg/nodeprofiler/profiler/commands.go
@@ -26,6 +26,16 @@
 	titles []string
 }
 
+// NewVMStat function helps to initialize a vmstat structure.
+func NewVMStat(name string, delay int, count int, titles []string) *vmstat {
+	return &vmstat{
+		name:   name,
+		delay:  delay,
+		count:  count,
+		titles: titles,
+	}
+}
+
 // Name returns the name for vmstat command.
 func (v *vmstat) Name() string {
 	return v.name
@@ -71,6 +81,14 @@
 	titles []string
 }
 
+// NewLscpu function helps to initialize a lscpu structure.
+func NewLscpu(name string, titles []string) *lscpu {
+	return &lscpu{
+		name:   name,
+		titles: titles,
+	}
+}
+
 // Name returns the name for the lscpu command.
 func (l *lscpu) Name() string {
 	return l.name
@@ -98,6 +116,14 @@
 	titles []string
 }
 
+// NewFree function helps to initialize a free structure.
+func NewFree(name string, titles []string) *free {
+	return &free{
+		name:   name,
+		titles: titles,
+	}
+}
+
 // Name returns the name for the free command.
 func (f *free) Name() string {
 	return f.name
@@ -133,6 +159,17 @@
 	titles []string
 }
 
+// NewIOStat function helps to initialize a iostat structure.
+func NewIOStat(name string, flags string, delay int, count int, titles []string) *iostat {
+	return &iostat{
+		name:   name,
+		flags:  flags,
+		delay:  delay,
+		count:  count,
+		titles: titles,
+	}
+}
+
 // Name returns the name for the iostat command.
 func (i *iostat) Name() string {
 	return i.name
diff --git a/src/pkg/nodeprofiler/profiler/components.go b/src/pkg/nodeprofiler/profiler/components.go
index 9c0b2d0..195d009 100644
--- a/src/pkg/nodeprofiler/profiler/components.go
+++ b/src/pkg/nodeprofiler/profiler/components.go
@@ -30,7 +30,7 @@
 	CollectUSEMetrics(cmdOutputs map[string]utils.ParsedOutput) error
 	// USEMetrics returns the USEMetrics of the component.
 	USEMetrics() *USEMetrics
-	// Name retuns the name of the component.
+	// Name returns the name of the component.
 	Name() string
 }
 
@@ -41,6 +41,27 @@
 	metrics *USEMetrics
 }
 
+// NewCPU holds information about the CPU component:
+// this can be used to initialize CPU outside of the
+// profiler package.
+func NewCPU(name string) *CPU {
+
+	return &CPU{
+		name:    name,
+		metrics: &USEMetrics{},
+	}
+}
+
+// Name returns the name of the CPU component.
+func (c *CPU) Name() string {
+	return c.name
+}
+
+// USEMetrics returns USEMetrics for the CPU component.
+func (c *CPU) USEMetrics() *USEMetrics {
+	return c.metrics
+}
+
 // CollectUtilization calculates the utilization score for the CPU Component.
 // It does this by summing the time spent running non-kernel code (user time),
 // time spent running kernel code (system time), and time stolen from a vitual
@@ -137,16 +158,6 @@
 	return nil
 }
 
-// USEMetrics returns the USE Metrics for the CPU Component.
-func (c *CPU) USEMetrics() *USEMetrics {
-	return c.metrics
-}
-
-// Name returns the name of the CPU component.
-func (c *CPU) Name() string {
-	return c.name
-}
-
 // CollectUSEMetrics collects USE Metrics for the CPU component.
 func (c *CPU) CollectUSEMetrics(outputs map[string]utils.ParsedOutput) error {
 	metrics := c.metrics
@@ -180,6 +191,27 @@
 	metrics *USEMetrics
 }
 
+// NewMemCap holds information about the Memory capacity component:
+// this can be used to initialize MemCap outside of the
+// profiler package.
+func NewMemCap(name string) *MemCap {
+
+	return &MemCap{
+		name:    name,
+		metrics: &USEMetrics{},
+	}
+}
+
+// Name returns the name of the Memory capacity component.
+func (m *MemCap) Name() string {
+	return m.name
+}
+
+// USEMetrics returns USEMetrics for the Memory capacity component.
+func (m *MemCap) USEMetrics() *USEMetrics {
+	return m.metrics
+}
+
 // CollectUtilization calculates the utilization score for Memory Capacity.
 // It does this by getting the quotient of used memory (main and virtual)
 // and total memory (main and virtual). The values for main memory can be
@@ -297,16 +329,6 @@
 	return nil
 }
 
-// USEMetrics returns the USE Metrics for the Memory Capacity Component.
-func (m *MemCap) USEMetrics() *USEMetrics {
-	return m.metrics
-}
-
-// Name returns the name of the Memory Capacity component.
-func (m *MemCap) Name() string {
-	return m.name
-}
-
 // CollectUSEMetrics collects USE Metrics for the MemCap component.
 func (m *MemCap) CollectUSEMetrics(outputs map[string]utils.ParsedOutput) error {
 	metrics := m.metrics
@@ -340,6 +362,27 @@
 	metrics *USEMetrics
 }
 
+// NewStorageDevIO holds information about the Storage device I/O component:
+// this can be used to initialize Storage device I/O outside of the
+// profiler package.
+func NewStorageDevIO(name string) *StorageDevIO {
+
+	return &StorageDevIO{
+		name:    name,
+		metrics: &USEMetrics{},
+	}
+}
+
+// Name returns the name of the Storage device I/O component.
+func (d *StorageDevIO) Name() string {
+	return d.name
+}
+
+// USEMetrics returns USEMetrics for the Storage Device I/O Component.
+func (d *StorageDevIO) USEMetrics() *USEMetrics {
+	return d.metrics
+}
+
 // CollectUtilization collects the utilization score for the StorageDevIO component.
 // It does this by getting the percentage of elapsed time during which I/O requests
 // were issued to the devices. This value can be found on iostat's '%util' column.
@@ -372,11 +415,11 @@
 	cmd := "iostat"
 	parsedOutput, ok := outputs[cmd]
 	if !ok {
-		return fmt.Errorf("missig output for iostat")
+		return fmt.Errorf("missing output for iostat")
 	}
 	queue, ok := parsedOutput["aqu-sz"]
 	if !ok {
-		return fmt.Errorf("mising iostat column 'aqu-sz'")
+		return fmt.Errorf("missing iostat column 'aqu-sz'")
 	}
 	total, err := utils.SumParseFloat(queue)
 	if err != nil {
@@ -394,16 +437,6 @@
 	return nil
 }
 
-// USEMetrics returns the USE Metrics for the Storage Device I/O Component.
-func (d *StorageDevIO) USEMetrics() *USEMetrics {
-	return d.metrics
-}
-
-// Name returns the name of the Storage Device I/O component.
-func (d *StorageDevIO) Name() string {
-	return d.name
-}
-
 // CollectUSEMetrics collects USE Metrics for the Storage Device I/O component.
 func (d *StorageDevIO) CollectUSEMetrics(outputs map[string]utils.ParsedOutput) error {
 	metrics := d.metrics