[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bigsister-general] plugin for environmental variables


Thanks Stefan,
 
But that does not work either and I don't feel to waste my time any longer in trying to find out how things work.
Unfortunately I've realized that I'm not going to manage it unless a proper development documentation
is made available.
 
For as much as I would have liked to avoid it, I'm considering to use the SNMP module as Niels suggested.
 
  Costa
-----Original Message-----
From: stefan steimann [mailto:suppressed
Sent: 01 October 2007 18:52
To: Software Forums
Subject: Re: [Bigsister-general] plugin for environmental variables

Hi Costa,
 
as i told you before you have to use getinfo() for returning values. When programming requesters for the first time i also ran into those troubles. Rename it getinfo and it may work.
 
Best Regards
 
Stefan Steimann
 
2007/9/28, Software Forums <suppressed>:
Tom,

I followed your advice and finally got to write the plugin, although not in
its final version yet. I've copied the flow of the solswap.pm and adapted it
to my needs.

I do not yet do anything with the lines output of the "sensors" shell command
I've got just enough code to test the communication mechanism + the syntax.

UXMON can load the plugin but I can not get the requester to pass the value I set.

The CPU report status shows the "C" (for Celsius) that I want it to print
out but does not show the value of the temperature (I have hardcoded it at 43,
just for the test).

The same happens with the comment string "The temperature of CPU 1 is:"
It is shown without the value after it.

Evidently I do not pass the value correctly from the requester.
I've compared my code with solswap.pm but I fail to see the error.
Can you?

Thanks,

Costantino
-------------------------------------------------
HERE ARE THE TWO FILES

lmsensors.cfg
-------------
#
# Get environmental data using "sensors" (lm_sensors package)
#
test sensors_environment {
   static set name "sensors";
   static set features unix linux local;
   static set description "Monitor environmental variables using sensors";
   static set arguments
      "perf:int:report perf data every perf minutes"
      "item:string:Item as which to report.";
   pernode set report_item "cpu";
   pernode monitor {
      get sensors.ywCPU1Temperature[0];
      pernode set CPU1Temp ${sensors.ywCPU1Temperature[0]};
   }
   report {
      status green 1 "&green" " " ${CPU1Temp} "C";
      comment "html" "<hr /><strong>"
      "The temperature of CPU 1 is:"
      "</strong>" ${CPU1Temp};
   }
}


lmsensors.pm
------------
package Requester::sensors;

use Requester::SlowRequester;

my $oldproto_warned = {};

our( @ISA );
@ISA = qw(Requester::SlowRequester);

my $requester = new Requester::sensors();

sub new {
   my ($this, $args ) = @_;
   my  $class = ref($this) || $this;
   my  $self = {};

   bless($self, $class);
   $self->command( "sensors" );
   $self->register( "sensors" );
   return $self;
}

sub do {
   my( $self, $srq ) = @_;

   $line = $srq->readln();
   return unless( $line );
   my $info = $srq->{"Test.info"};
   $info->{0} = {
       "ywCPU1Temperature" => 43
   };
   $srq->status( 3, "finished OK" );
}

sub available {
   my $test = `sensors`;
   return( ($test =~ /available/) );
}

1;

-----Original Message-----
From: suppressed
[mailto: suppressed]On Behalf Of
Thomas Aeby
Sent: 20 September 2007 18:32
To: Software Forums
Cc: BigSister General Forum
Subject: Re: [Bigsister-general] plugin for environmental variables


On Thu, 2007-09-20 at 11:46 +0200, Software Forums wrote:

> I'm using the VMSTAT function as a template for the sensors function I
> want to write.
> I reckon It is simple and functionally close to it.

Yes, it is pretty close. However, I'd suggest you take a look at
"solswap". The difference is that vmstat bases on CommandWatchRequester
which is good for things like vmstat or sar, which need to run some time
in order to gather data. CommandWatchRequester will start a command in
a cycle and reaps the results in the next cycle only.

The SlowRequester class solswap is based on however expects the
requester to deliver data within a shorter time (usually a few seconds).

The real work in your case is to parse the output of the sensors
command line by line in do() (NOTE that you must be prepared for do()
to be called multiple times as soon as output is ready for parsing and
should return if no output is left - like solswap does) and fill the
data into the "info" hash.

The info hash looks quite strange on the first spot but isn't that
difficult to understand. The keys are always an index (as in

  get lmsensors.somegroup.somevar.0

where the index is "0"), the value another hash with the keys being
names (like the "somegroup.somevar") and the values the actual figures.
So, in order to provide figures for the above "get" you would set

  $info->{0}->{'somegroup.somevar'} = 1234;

I hope this gave you some hints.

Best regards,
Tom

--
----------------------------------------------------------------------------
Thomas Aeby, Kirchweg 52, 1735 Giffers, Switzerland, Tel: (+41)264180040
Internet: suppressed                       PGP public key available
----------------------------------------------------------------------------



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bigsister-general mailing list
suppressed
https://lists.sourceforge.net/lists/listinfo/bigsister-general


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bigsister-general mailing list
suppressed
https://lists.sourceforge.net/lists/listinfo/bigsister-general

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bigsister-general mailing list
suppressed
https://lists.sourceforge.net/lists/listinfo/bigsister-general

Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.