+sub get_sensors {
+ my $slist= _cmd("sensorlist");
+ my @sensors;
+
+ if ($slist->{RC} ne '0x0') {
+ print "Error getting sensorlist: ".$slist->{RC}."\n";
+ return;
+ }
+
+ my $req = '<REQ CMD="sensorpropget"><HANDLE>'.$slist->{HANDLE}.'</HANDLE><SENSORLIST>';
+ foreach my $s (@{$slist->{SENSORLIST}->{SENSOR}}) {
+ $req .= '<SENSOR KEY="'.$s->{KEY}.'"/>';
+ }
+ $req .= '</SENSORLIST></REQ>';
+
+ my $sprop = _req($req);
+ foreach my $s (@{$sprop->{SENSORLIST}->{SENSOR}}) {
+ my $sensor = {};
+ foreach my $sp (@{$s->{PROP}}) {
+ $sensor->{$sp->{NAME}} = $sp->{VAL};
+ }
+
+ next if (!defined($sensor->{NAME}));
+ $sensor->{VAL} = '0' if ($sensor->{VAL} eq '');
+ push @sensors, $sensor;
+ }
+ @sensors;
+}
+
+sub show_sensors {
+ my @sensors = get_sensors();
+
+ foreach my $sensor (@sensors) {
+ print $sensor->{NAME}.": ".$sensor->{VAL}.$sensor->{UNITS};
+
+ my @info = ();
+ foreach my $field qw(MIN MAX LOW_NON_CRITICAL UPPER_NON_CRITICAL LOW_CRITICAL UPPER_CRITICAL) {
+ if ($sensor->{$field} ne '') {
+ push @info, "${field}: ".$sensor->{$field}.$sensor->{UNITS};
+ }
+ }
+
+ print "\t(".join(", ",@info).")" if (@info);
+
+ print "\n";
+ }
+}
+