File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ func NewCmdX() *cobra.Command {
3131 }
3232 cmd .AddCommand (NewCmdXGetSDRs ())
3333 cmd .AddCommand (NewCmdXGetSensors ())
34+ cmd .AddCommand (NewCmdXGetSensorsFilterFans ())
3435 cmd .AddCommand (NewCmdXGetDeviceSDRs ())
3536 cmd .AddCommand (NewCmdXGetPayloadActivationStatus ())
3637 cmd .AddCommand (NewCmdXGetDeviceGUID ())
@@ -137,6 +138,24 @@ func NewCmdXGetSensors() *cobra.Command {
137138 return cmd
138139}
139140
141+ func NewCmdXGetSensorsFilterFans () * cobra.Command {
142+ cmd := & cobra.Command {
143+ Use : "get-sensors-filter-fans" ,
144+ Short : "get-sensors-filter-fans" ,
145+ Run : func (cmd * cobra.Command , args []string ) {
146+ ctx := context .Background ()
147+ res , err := client .GetSensors (ctx , ipmi .SensorFilterOptionIsSensorType (ipmi .SensorTypeFan ))
148+ if err != nil {
149+ fmt .Printf ("GetSensors failed, err: %s" , err )
150+ return
151+ }
152+ fmt .Printf ("GetSensors succeeded, %d records\n " , len (res ))
153+ fmt .Println (ipmi .FormatSensors (true , res ... ))
154+ },
155+ }
156+ return cmd
157+ }
158+
140159func NewCmdXGetDeviceSDRs () * cobra.Command {
141160 var show bool
142161
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ func SensorFilterOptionIsSensorType(sensorTypes ...SensorType) func(sensor *Sens
3636// passed all filter options, that means the filter options are logically ANDed.
3737//
3838// If you want the filter options are logically ORed, use `GetSensorsAny`
39+ //
40+ // Example:
41+ //
42+ // // get all sensors with fan type
43+ // sensors, err := client.GetSensors(ctx, ipmi.SensorFilterOptionIsSensorType(ipmi.SensorTypeFan))
3944func (c * Client ) GetSensors (ctx context.Context , filterOptions ... SensorFilterOption ) ([]* Sensor , error ) {
4045 var out = make ([]* Sensor , 0 )
4146
You can’t perform that action at this time.
0 commit comments