Development/Tutorials/Sensors: Difference between revisions

From KDE TechBase
(New page: Implementing KSysGuard sensors simple example. Prequesities: KDE, Perl, nc Imagine you have a program that monitors some value important for you. You want the value to be plotted <s>or d...)
 
No edit summary
Line 4: Line 4:


Imagine you have a program that monitors some value important for you.
Imagine you have a program that monitors some value important for you.
You want the value to be plotted <s>or displayed in the KDE systray</s>.
You want the value to be plotted or displayed in the KDE systray.


The most _____ way is to add it to KSysGuard as a sensor.
The most _____ way is to add it to KSysGuard as a sensor.
Line 35: Line 35:


You will see your sensor (random value from 0 to 100 in this case).
You will see your sensor (random value from 0 to 100 in this case).
If you want to see the plot is your systray, follow this:
Step 1: Add "KSysGuard applet to the desktop".
Step 2: In there's no spare displays, choose "Configure System Guard" in the context menu of the applet and increase "Number of displays".
Step 3: Launch KSysGuard, follow previous example to get access to your sensor.
Step 4: Drag and drop from "random Integer Value" to the free display in the systray.
Step 5: "Signal plotter", then you will be asked again to provide the data source. Choose "Custom Command" with the same script.
[Step 6: Open properties and remove grids and lines to clean up the plot]

Revision as of 00:12, 20 September 2008

Implementing KSysGuard sensors simple example.

Prequesities: KDE, Perl, nc

Imagine you have a program that monitors some value important for you. You want the value to be plotted or displayed in the KDE systray.

The most _____ way is to add it to KSysGuard as a sensor.

Step 1. Create, for example, "/home/vi/code/sensor/sensor.pl" with the following content: #!/usr/bin/perl -w $|=1;

print "ksysguardd 1.2.0\n"; print "ksysguardd> ";

while(<>){

   if(/monitors/){

print "random\tinteger\n";

   }
   if(/random/){

if(/\?/){ print "Random Value\t0\t100\n"; }else{ print int(rand()*100),"\n"; }

   }
   print "ksysguardd> ";

}

Step 2: Launch KSysGuard, File->Connect Host->Custom Command, enter "/home/vi/code/sensor/sensor.pl" in the Command field, OK.

Step 3: Open "127.0.0.1", find "random Integer Value", drag it to some sheet.

You will see your sensor (random value from 0 to 100 in this case).

If you want to see the plot is your systray, follow this:

Step 1: Add "KSysGuard applet to the desktop".

Step 2: In there's no spare displays, choose "Configure System Guard" in the context menu of the applet and increase "Number of displays".

Step 3: Launch KSysGuard, follow previous example to get access to your sensor.

Step 4: Drag and drop from "random Integer Value" to the free display in the systray.

Step 5: "Signal plotter", then you will be asked again to provide the data source. Choose "Custom Command" with the same script.

[Step 6: Open properties and remove grids and lines to clean up the plot]