Added a new filter which can directly read the output
authorarjen <arjen>
Sat, 3 Nov 2007 10:26:13 +0000 (10:26 +0000)
committerarjen <arjen>
Sat, 3 Nov 2007 10:26:13 +0000 (10:26 +0000)
of the UNIX df command. A brief description is added in
the user manual.

doc/manual.xml
doc/psd-parameter-input.obj [new file with mode: 0644]
src/gcm_input/Makefile.am
src/gcm_input/Makefile.in
src/gcm_input/df_filter.cpp [new file with mode: 0644]
src/gcm_input/df_filter.h [new file with mode: 0644]
src/gcm_input/gcm_input.cpp

index ed8cbd1..153ac26 100644 (file)
@@ -6,7 +6,7 @@
 <!--
       Gnucomo - Gnu Computer Monitoring Tutorial
       Original author :  Peter Roozemaal
-      Version         : $Revision: 1.3 $
+      Version         : $Revision: 1.4 $
 
       This document is prepared for XMLDoc. Transform to HTML,
       LaTeX, Postscript or plain text with XMLDoc utilities and
@@ -742,6 +742,98 @@ The following sections explain how Gnucomo can help.
 </para>
 
 <section>
+<heading>System resources</heading>
+<para>
+By monitoring the resources of a system, such as memory, cpu, file systems and
+network interfaces, you can keep track on the system's performance and capacity.
+The utilization of these resources varies frequently over time.
+Viewing the values of resource properties provides an excelent insight in
+the system's behaviour.
+Gnucomo can maintain  a record of the system resources by using DYNAMIC properties
+in parameters.
+You can define classes of parameters with properties that will reflect the state
+of your systems and feed the numbers into the Gnucomo database by using scripts
+that extract the information from a system and convert this into XML format.
+</para>
+<para>
+As an example, consider the processing load of a system.
+Two metrics can be of interest to keep an eye on the system load:
+The total number of processes and the number of runnable processes.
+These numbers are easily obtained with standard UNIX commands <code>ps</code>
+and <code>uptime</code>.
+To maintain this in Gnucomo, a <emph>class</emph> is needed to define the
+properties we want to maintain.
+For this example, we create a class <strong>systemload</strong> with the properties
+<strong>processes</strong> and <strong>runqueue</strong>.
+Note that both these properties are DYNAMIC.
+The properties for the <strong>systemload</strong> class can be defined by using
+Gnucomo's web interface or typing SQL statements directly into the database:
+</para>
+<verbatim>
+INSERT INTO parameter_class (name, property_name, description, property_type, min, max, notify)
+  VALUES ('systemload', 'processes', 'Total number of processes', 'DYNAMIC', 0, 1000, 'f');
+INSERT INTO parameter_class (name, property_name, description, property_type, min, max, notify)
+  VALUES ('systemload', 'runqueue', '5 minute average length of the run queue', 'DYNAMIC', 0, 5.00, 'f');
+</verbatim>
+<para>
+When the class is defined in the Gnucomo database, we are ready to feed the
+information into Gnucomo through <code>gcm_input</code>.
+The following shell script will create the appropriate XML document with the
+parameter values:
+</para>
+<verbatim>
+#!/bin/sh
+#
+# Gnucomo system load report.
+#
+# Create a parameter report with two values:
+# The total number of processes and the 5-min load average.
+# 
+
+
+HOST=`hostname`
+TIME=`date`
+
+echo "&lt;?xml version='1.0'?&gt;"
+echo "&lt;gcmt:message xmlns:gcmt='http://gnucomo.org/transport/'&gt;"
+echo "  &lt;gcmt:header&gt;"
+echo "      &lt;gcmt:messagetype&gt;XML&lt;/gcmt:messagetype&gt;"
+echo "      &lt;gcmt:hostname&gt;$HOST&lt;/gcmt:hostname&gt;"
+echo "      &lt;gcmt:time&gt;$TIME&lt;/gcmt:time&gt;"
+echo "   &lt;/gcmt:header&gt;"
+echo "   &lt;gcmt:data&gt;"
+
+echo "   &lt;gcmt:parameters gcmt:class='systemload'&gt;"
+
+PROCESSES=`ps ax|wc -l`
+LOADAV=` uptime|cut -d ' ' -f 13|tr -d ,`
+
+echo "&lt;gcmt:parameter name='Load'&gt;"
+echo "   &lt;gcmt:description&gt;System processing load&lt;/gcmt:description&gt;"
+echo "   &lt;gcmt:property name='processes'&gt;$PROCESSES&lt;/gcmt:property&gt;"
+echo "   &lt;gcmt:property name='runqueue'&gt;$LOADAV&lt;/gcmt:property&gt;"
+echo "&lt;/gcmt:parameter&gt;"
+
+echo "    &lt;/gcmt:parameters&gt;"
+echo "   &lt;/gcmt:data&gt;"
+echo "&lt;/gcmt:message&gt;"
+</verbatim>
+<para>
+Filesystems are predefined in Gnucomo.
+Gcm_input understands the output of most <code>df</code> implementations directly.
+The following examples show how to feed filesystem information into Gnucomo:
+</para>
+<example>
+df -lPk -x tmpfs | gcm_input -h `hostname`
+df -lPi -x tmpfs | gcm_input -h `hostname`
+</example>
+<para>
+Make sure to add the <code>-k</code> option so <code>df</code> reports
+the filesystem sizes in kilobytes.
+</para>
+</section>
+
+<section>
 <heading>Installed packages</heading>
 
 <para>
diff --git a/doc/psd-parameter-input.obj b/doc/psd-parameter-input.obj
new file mode 100644 (file)
index 0000000..5812490
--- /dev/null
@@ -0,0 +1,430 @@
+%TGIF 4.1.45-QPL
+state(0,37,100.000,0,57,0,4,1,9,1,1,0,0,0,0,1,0,'Helvetica',0,69120,0,0,0,10,0,0,1,1,0,16,0,0,1,1,1,1,1088,1408,1,0,2880,0).
+%
+% @(#)$Header: /src/cvsroot/gnucomo/doc/psd-parameter-input.obj,v 1.1 2007-11-03 10:27:10 arjen Exp $
+% %W%
+%
+unit("1 pixel/pixel").
+color_info(19,65535,0,[
+       "magenta", 65535, 0, 65535, 65535, 0, 65535, 1,
+       "red", 65535, 0, 0, 65535, 0, 0, 1,
+       "green", 0, 65535, 0, 0, 65535, 0, 1,
+       "blue", 0, 0, 65535, 0, 0, 65535, 1,
+       "yellow", 65535, 65535, 0, 65535, 65535, 0, 1,
+       "pink", 65535, 49344, 52171, 65535, 49344, 52171, 1,
+       "cyan", 0, 65535, 65535, 0, 65535, 65535, 1,
+       "CadetBlue", 24415, 40606, 41120, 24415, 40606, 41120, 1,
+       "white", 65535, 65535, 65535, 65535, 65535, 65535, 1,
+       "black", 0, 0, 0, 0, 0, 0, 1,
+       "DarkSlateGray", 12079, 20303, 20303, 12079, 20303, 20303, 1,
+       "#00000000c000", 0, 0, 49344, 0, 0, 49152, 1,
+       "#820782070000", 33410, 33410, 0, 33287, 33287, 0, 1,
+       "#3cf3fbee34d2", 15420, 64507, 13364, 15603, 64494, 13522, 1,
+       "#3cf3fbed34d3", 15420, 64507, 13364, 15603, 64493, 13523, 1,
+       "#ffffa6990000", 65535, 42662, 0, 65535, 42649, 0, 1,
+       "#ffff0000fffe", 65535, 0, 65535, 65535, 0, 65534, 1,
+       "#fffe0000fffe", 65535, 0, 65535, 65534, 0, 65534, 1,
+       "#fffe00000000", 65535, 0, 0, 65534, 0, 0, 1
+]).
+script_frac("0.6").
+fg_bg_colors('black','White').
+dont_reencode("FFDingbests:ZapfDingbats").
+objshadow_info('#c0c0c0',2,2).
+page(1,"",1,'').
+box('black','',96,72,680,756,0,2,1,209,0,0,0,0,0,'2',0,[
+]).
+text('black',364,86,1,1,1,238,23,211,18,5,0,0,0,0,2,238,23,0,0,"",0,0,0,0,104,'',[
+minilines(238,23,0,0,1,0,0,[
+mini_line(238,18,5,0,0,0,[
+str_block(0,238,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,103680,238,18,5,0,0,0,0,0,0,0,
+       "Input of a parameter report")])
+])
+])]).
+box('black','',108,120,664,532,0,1,1,1292,0,0,0,0,0,'1',0,[
+]).
+text('black',116,128,1,0,1,159,15,1293,12,3,0,0,0,0,2,159,15,0,0,"",0,0,0,0,140,'',[
+minilines(159,15,0,0,0,0,0,[
+mini_line(159,12,3,0,0,0,[
+str_block(0,159,12,3,0,0,0,0,0,[
+str_seg('black','Helvetica',0,69120,159,12,3,0,0,0,0,0,0,0,
+       "Each parameter in the report")])
+])
+])]).
+box('black','',132,152,664,532,0,1,1,1356,0,0,0,0,0,'1',0,[
+]).
+box('black','',132,152,664,184,0,1,1,1357,0,0,0,0,0,'1',0,[
+]).
+text('black',140,160,1,0,1,174,15,1358,12,3,0,0,0,0,2,174,15,0,0,"",0,0,0,0,172,'',[
+minilines(174,15,0,0,0,0,0,[
+mini_line(174,12,3,0,0,0,[
+str_block(0,174,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,174,12,3,0,-1,0,0,0,0,0,
+       "Find parameter in the database")])
+])
+])]).
+box('black','',132,184,664,228,0,1,1,1361,0,0,0,0,0,'1',0,[
+]).
+text('black',444,192,1,0,1,91,15,1362,12,3,0,0,0,0,2,91,15,0,0,"",0,0,0,0,204,'',[
+minilines(91,15,0,0,0,0,0,[
+mini_line(91,12,3,0,0,0,[
+str_block(0,91,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,91,12,3,0,-1,0,0,0,0,0,
+       "Parameter found")])
+])
+])]).
+poly('black','',3,[
+       132,184,512,228,664,184],0,1,1,1364,0,0,0,0,0,0,0,'1',0,0,
+    "0","",[
+    0,8,3,0,'8','3','0'],[0,8,3,0,'8','3','0'],[
+]).
+text('black',148,202,1,0,1,11,23,1365,18,5,0,0,0,0,2,11,23,0,0,"",0,0,0,0,220,'',[
+minilines(11,23,0,0,0,0,0,[
+mini_line(11,18,5,0,0,0,[
+str_block(0,11,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,11,18,5,0,0,0,0,0,0,0,
+       "T")])
+])
+])]).
+text('black',636,202,1,0,1,12,23,1367,18,5,0,0,0,0,2,12,23,0,0,"",0,0,0,0,220,'',[
+minilines(12,23,0,0,0,0,0,[
+mini_line(12,18,5,0,0,0,[
+str_block(0,12,18,5,0,-1,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,12,18,5,0,-1,0,0,0,0,0,
+       "F")])
+])
+])]).
+box('black','',512,228,664,280,0,1,1,1386,0,0,0,0,0,'1',0,[
+]).
+text('black',520,236,2,0,1,123,30,1389,12,3,0,0,0,0,2,123,30,0,0,"",0,0,0,0,248,'',[
+minilines(123,30,0,0,0,0,0,[
+mini_line(123,12,3,0,0,0,[
+str_block(0,123,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,123,12,3,0,-1,0,0,0,0,0,
+       "Create parameter from")])
+]),
+mini_line(79,12,3,0,0,0,[
+str_block(0,79,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,79,12,3,0,-1,0,0,0,0,0,
+       "class template")])
+])
+])]).
+box('black','',512,280,664,324,0,1,1,1393,0,0,0,0,0,'1',0,[
+]).
+text('black',524,284,2,0,1,89,30,1394,12,3,0,0,0,0,2,89,30,0,0,"",0,0,0,0,296,'',[
+minilines(89,30,0,0,0,0,0,[
+mini_line(89,12,3,0,0,0,[
+str_block(0,89,12,3,0,0,0,0,0,[
+str_seg('black','Helvetica',0,69120,89,12,3,0,0,0,0,0,0,0,
+       "Insert parameter")])
+]),
+mini_line(75,12,3,0,0,0,[
+str_block(0,75,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,75,12,3,0,-1,0,0,0,0,0,
+       "into database")])
+])
+])]).
+box('black','',512,324,664,372,0,1,1,1396,0,0,0,0,0,'1',0,[
+]).
+text('black',524,328,1,0,1,101,15,1397,12,3,0,0,0,0,2,101,15,0,0,"",0,0,0,0,340,'',[
+minilines(101,15,0,0,0,0,0,[
+mini_line(101,12,3,0,0,0,[
+str_block(0,101,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,101,12,3,0,-1,0,0,0,0,0,
+       "Create notification")])
+])
+])]).
+box('black','',132,228,512,412,0,1,1,1399,0,0,0,0,0,'1',0,[
+]).
+box('black','',152,260,512,412,0,1,1,1400,0,0,0,0,0,'1',0,[
+]).
+text('black',140,232,1,0,1,223,15,1401,12,3,0,0,0,0,2,223,15,0,0,"",0,0,0,0,244,'',[
+minilines(223,15,0,0,0,0,0,[
+mini_line(223,12,3,0,0,0,[
+str_block(0,223,12,3,0,0,0,0,0,[
+str_seg('black','Helvetica',0,69120,223,12,3,0,0,0,0,0,0,0,
+       "Each reported property of the parameter")])
+])
+])]).
+box('black','',152,260,512,296,0,1,1,1403,0,0,0,0,0,'1',0,[
+]).
+poly('black','',3,[
+       152,260,196,296,512,260],0,1,1,1404,0,0,0,0,0,0,0,'1',0,0,
+    "0","",[
+    0,8,3,0,'8','3','0'],[0,8,3,0,'8','3','0'],[
+]).
+text('black',160,274,1,0,1,11,23,1405,18,5,0,0,0,0,2,11,23,0,0,"",0,0,0,0,292,'',[
+minilines(11,23,0,0,0,0,0,[
+mini_line(11,18,5,0,0,0,[
+str_block(0,11,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,11,18,5,0,0,0,0,0,0,0,
+       "T")])
+])
+])]).
+text('black',488,274,1,0,1,12,23,1406,18,5,0,0,0,0,2,12,23,0,0,"",0,0,0,0,292,'',[
+minilines(12,23,0,0,0,0,0,[
+mini_line(12,18,5,0,0,0,[
+str_block(0,12,18,5,0,-1,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,12,18,5,0,-1,0,0,0,0,0,
+       "F")])
+])
+])]).
+text('black',176,264,1,0,1,152,15,1407,12,3,0,0,0,0,2,152,15,0,0,"",0,0,0,0,276,'',[
+minilines(152,15,0,0,0,0,0,[
+mini_line(152,12,3,0,0,0,[
+str_block(0,152,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,152,12,3,0,-1,0,0,0,0,0,
+       "property == stored property")])
+])
+])]).
+box('black','',196,296,512,324,0,1,1,1411,0,0,0,0,0,'1',0,[
+]).
+text('black',200,304,1,0,1,162,15,1412,12,3,0,0,0,0,2,162,15,0,0,"",0,0,0,0,316,'',[
+minilines(162,15,0,0,0,0,0,[
+mini_line(162,12,3,0,0,0,[
+str_block(0,162,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,162,12,3,0,-1,0,0,0,0,0,
+       "Update stored property value")])
+])
+])]).
+box('black','',196,324,512,352,0,1,1,1414,0,0,0,0,0,'1',0,[
+]).
+text('black',200,332,1,0,1,137,15,1415,12,3,0,0,0,0,2,137,15,0,0,"",0,0,0,0,344,'',[
+minilines(137,15,0,0,0,0,0,[
+mini_line(137,12,3,0,0,0,[
+str_block(0,137,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,137,12,3,0,-1,0,0,0,0,0,
+       "Add to parameter history")])
+])
+])]).
+box('black','',196,352,512,388,0,1,1,1419,0,0,0,0,0,'1',0,[
+]).
+poly('black','',3,[
+       196,352,448,388,512,352],0,1,1,1420,0,0,0,0,0,0,0,'1',0,0,
+    "0","",[
+    0,8,3,0,'8','3','0'],[0,8,3,0,'8','3','0'],[
+]).
+text('black',200,366,1,0,1,11,23,1421,18,5,0,0,0,0,2,11,23,0,0,"",0,0,0,0,384,'',[
+minilines(11,23,0,0,0,0,0,[
+mini_line(11,18,5,0,0,0,[
+str_block(0,11,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,11,18,5,0,0,0,0,0,0,0,
+       "T")])
+])
+])]).
+text('black',488,366,1,0,1,12,23,1422,18,5,0,0,0,0,2,12,23,0,0,"",0,0,0,0,384,'',[
+minilines(12,23,0,0,0,0,0,[
+mini_line(12,18,5,0,0,0,[
+str_block(0,12,18,5,0,-1,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,12,18,5,0,-1,0,0,0,0,0,
+       "F")])
+])
+])]).
+text('black',324,352,1,0,1,122,15,1423,12,3,0,0,0,0,2,122,15,0,0,"",0,0,0,0,364,'',[
+minilines(122,15,0,0,0,0,0,[
+mini_line(122,12,3,0,0,0,[
+str_block(0,122,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,122,12,3,0,-1,0,0,0,0,0,
+       "property is DYNAMIC")])
+])
+])]).
+box('black','',196,388,448,412,0,1,1,1428,0,0,0,0,0,'1',0,[
+]).
+text('black',208,388,1,0,1,107,15,1429,12,3,0,0,0,0,2,107,15,0,0,"",0,0,0,0,400,'',[
+minilines(107,15,0,0,0,0,0,[
+mini_line(107,12,3,0,0,0,[
+str_block(0,107,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,107,12,3,0,-1,0,0,0,0,0,
+       "Check value range")])
+])
+])]).
+box('black','',132,412,512,448,0,1,1,1436,0,0,0,0,0,'1',0,[
+]).
+poly('black','',3,[
+       132,412,464,448,512,412],0,1,1,1437,0,0,0,0,0,0,0,'1',0,0,
+    "0","",[
+    0,8,3,0,'8','3','0'],[0,8,3,0,'8','3','0'],[
+]).
+text('black',140,426,1,0,1,11,23,1438,18,5,0,0,0,0,2,11,23,0,0,"",0,0,0,0,444,'',[
+minilines(11,23,0,0,0,0,0,[
+mini_line(11,18,5,0,0,0,[
+str_block(0,11,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,11,18,5,0,0,0,0,0,0,0,
+       "T")])
+])
+])]).
+text('black',496,426,1,0,1,12,23,1439,18,5,0,0,0,0,2,12,23,0,0,"",0,0,0,0,444,'',[
+minilines(12,23,0,0,0,0,0,[
+mini_line(12,18,5,0,0,0,[
+str_block(0,12,18,5,0,-1,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,12,18,5,0,-1,0,0,0,0,0,
+       "F")])
+])
+])]).
+text('black',332,416,1,0,1,146,15,1440,12,3,0,0,0,0,2,146,15,0,0,"",0,0,0,0,428,'',[
+minilines(146,15,0,0,0,0,0,[
+mini_line(146,12,3,0,0,0,[
+str_block(0,146,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,146,12,3,0,-1,0,0,0,0,0,
+       "STATIC property changed")])
+])
+])]).
+box('black','',132,448,464,472,0,1,1,1454,0,0,0,0,0,'1',0,[
+]).
+text('black',140,452,1,0,1,101,15,1455,12,3,0,0,0,0,2,101,15,0,0,"",0,0,0,0,464,'',[
+minilines(101,15,0,0,0,0,0,[
+mini_line(101,12,3,0,0,0,[
+str_block(0,101,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,101,12,3,0,-1,0,0,0,0,0,
+       "Create notification")])
+])
+])]).
+box('black','',132,472,512,508,0,1,1,1457,0,0,0,0,0,'1',0,[
+]).
+poly('black','',3,[
+       132,472,464,508,512,472],0,1,1,1458,0,0,0,0,0,0,0,'1',0,0,
+    "0","",[
+    0,8,3,0,'8','3','0'],[0,8,3,0,'8','3','0'],[
+]).
+text('black',140,486,1,0,1,11,23,1459,18,5,0,0,0,0,2,11,23,0,0,"",0,0,0,0,504,'',[
+minilines(11,23,0,0,0,0,0,[
+mini_line(11,18,5,0,0,0,[
+str_block(0,11,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,11,18,5,0,0,0,0,0,0,0,
+       "T")])
+])
+])]).
+text('black',496,486,1,0,1,12,23,1460,18,5,0,0,0,0,2,12,23,0,0,"",0,0,0,0,504,'',[
+minilines(12,23,0,0,0,0,0,[
+mini_line(12,18,5,0,0,0,[
+str_block(0,12,18,5,0,-1,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,12,18,5,0,-1,0,0,0,0,0,
+       "F")])
+])
+])]).
+text('black',332,476,1,0,1,152,15,1461,12,3,0,0,0,0,2,152,15,0,0,"",0,0,0,0,488,'',[
+minilines(152,15,0,0,0,0,0,[
+mini_line(152,12,3,0,0,0,[
+str_block(0,152,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,152,12,3,0,-1,0,0,0,0,0,
+       "property value out of range")])
+])
+])]).
+box('black','',132,508,464,532,0,1,1,1462,0,0,0,0,0,'1',0,[
+]).
+text('black',140,512,1,0,1,101,15,1463,12,3,0,0,0,0,2,101,15,0,0,"",0,0,0,0,524,'',[
+minilines(101,15,0,0,0,0,0,[
+mini_line(101,12,3,0,0,0,[
+str_block(0,101,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,101,12,3,0,-1,0,0,0,0,0,
+       "Create notification")])
+])
+])]).
+box('black','',512,372,664,532,0,1,1,1466,0,0,0,0,0,'1',0,[
+]).
+box('black','',108,532,664,576,0,1,1,1469,0,0,0,0,0,'1',0,[
+]).
+text('black',132,536,1,0,1,259,15,1470,12,3,0,0,0,0,2,259,15,0,0,"",0,0,0,0,548,'',[
+minilines(259,15,0,0,0,0,0,[
+mini_line(259,12,3,0,0,0,[
+str_block(0,259,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,259,12,3,0,-1,0,0,0,0,0,
+       "Parameter is DYNAMIC || report is incremental")])
+])
+])]).
+poly('black','',3,[
+       108,532,156,576,664,532],0,1,1,1471,0,0,0,0,0,0,0,'1',0,0,
+    "0","",[
+    0,8,3,0,'8','3','0'],[0,8,3,0,'8','3','0'],[
+]).
+text('black',112,554,1,0,1,11,23,1472,18,5,0,0,0,0,2,11,23,0,0,"",0,0,0,0,572,'',[
+minilines(11,23,0,0,0,0,0,[
+mini_line(11,18,5,0,0,0,[
+str_block(0,11,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,11,18,5,0,0,0,0,0,0,0,
+       "T")])
+])
+])]).
+text('black',648,550,1,0,1,12,23,1473,18,5,0,0,0,0,2,12,23,0,0,"",0,0,0,0,568,'',[
+minilines(12,23,0,0,0,0,0,[
+mini_line(12,18,5,0,0,0,[
+str_block(0,12,18,5,0,-1,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,12,18,5,0,-1,0,0,0,0,0,
+       "F")])
+])
+])]).
+box('black','',156,576,664,604,0,1,1,1478,0,0,0,0,0,'1',0,[
+]).
+text('black',168,580,1,0,1,300,15,1479,12,3,0,0,0,0,2,300,15,0,0,"",0,0,0,0,592,'',[
+minilines(300,15,0,0,0,0,0,[
+mini_line(300,12,3,0,0,0,[
+str_block(0,300,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,300,12,3,0,-1,0,0,0,0,0,
+       "Obtain list of parameters (object, class) from database")])
+])
+])]).
+box('black','',156,604,664,744,0,1,1,1481,0,0,0,0,0,'1',0,[
+]).
+box('black','',180,628,664,744,0,1,1,1483,0,0,0,0,0,'1',0,[
+]).
+text('black',164,608,1,0,1,170,15,1484,12,3,0,0,0,0,2,170,15,0,0,"",0,0,0,0,620,'',[
+minilines(170,15,0,0,0,0,0,[
+mini_line(170,12,3,0,0,0,[
+str_block(0,170,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,170,12,3,0,-1,0,0,0,0,0,
+       "Each parameter from database")])
+])
+])]).
+box('black','',180,628,664,672,0,1,1,1486,0,0,0,0,0,'1',0,[
+]).
+text('black',240,632,1,0,1,119,15,1487,12,3,0,0,0,0,2,119,15,0,0,"",0,0,0,0,644,'',[
+minilines(119,15,0,0,0,0,0,[
+mini_line(119,12,3,0,0,0,[
+str_block(0,119,12,3,0,0,0,0,0,[
+str_seg('black','Helvetica',0,69120,119,12,3,0,0,0,0,0,0,0,
+       "Parameter is in report")])
+])
+])]).
+poly('black','',3,[
+       180,628,228,672,664,628],0,1,1,1488,0,0,0,0,0,0,0,'1',0,0,
+    "0","",[
+    0,8,3,0,'8','3','0'],[0,8,3,0,'8','3','0'],[
+]).
+text('black',184,646,1,0,1,11,23,1489,18,5,0,0,0,0,2,11,23,0,0,"",0,0,0,0,664,'',[
+minilines(11,23,0,0,0,0,0,[
+mini_line(11,18,5,0,0,0,[
+str_block(0,11,18,5,0,0,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,11,18,5,0,0,0,0,0,0,0,
+       "T")])
+])
+])]).
+text('black',648,646,1,0,1,12,23,1490,18,5,0,0,0,0,2,12,23,0,0,"",0,0,0,0,664,'',[
+minilines(12,23,0,0,0,0,0,[
+mini_line(12,18,5,0,0,0,[
+str_block(0,12,18,5,0,-1,0,0,0,[
+str_seg('black','Helvetica-Bold',1,115200,12,18,5,0,-1,0,0,0,0,0,
+       "F")])
+])
+])]).
+box('black','',228,672,664,708,0,1,1,1496,0,0,0,0,0,'1',0,[
+]).
+text('black',240,688,1,0,1,104,15,1497,12,3,0,0,0,0,2,104,15,0,0,"",0,0,0,0,700,'',[
+minilines(104,15,0,0,0,0,0,[
+mini_line(104,12,3,0,0,0,[
+str_block(0,104,12,3,0,0,0,0,0,[
+str_seg('black','Helvetica',0,69120,104,12,3,0,0,0,0,0,0,0,
+       "Remove parameter")])
+])
+])]).
+box('black','',228,708,664,744,0,1,1,1499,0,0,0,0,0,'1',0,[
+]).
+text('black',244,716,1,0,1,101,15,1500,12,3,0,0,0,0,2,101,15,0,0,"",0,0,0,0,728,'',[
+minilines(101,15,0,0,0,0,0,[
+mini_line(101,12,3,0,0,0,[
+str_block(0,101,12,3,0,-1,0,0,0,[
+str_seg('black','Helvetica',0,69120,101,12,3,0,-1,0,0,0,0,0,
+       "Create notification")])
+])
+])]).
+box('black','',108,576,156,744,0,1,1,1504,0,0,0,0,0,'1',0,[
+]).
index a46f49b..863614e 100644 (file)
@@ -7,6 +7,6 @@ LDADD = ../lib/libgnucomo.a
 gcm_input_SOURCES = gcm_input.cpp message.cpp string_utils.cpp syslog_cooker.cpp \
                     irix_syslog_cooker.cpp access_cooker.cpp error_cooker.cpp \
                     xml_cooker.cpp \
-                    message_filter.cpp log_filter.cpp rpm_filter.cpp
+                    message_filter.cpp log_filter.cpp rpm_filter.cpp df_filter.cpp
 
 logrunner_SOURCES = logrunner.cpp string_utils.cpp
index 809dc0d..3325491 100644 (file)
@@ -53,7 +53,7 @@ am_gcm_input_OBJECTS = gcm_input.$(OBJEXT) message.$(OBJEXT) \
        irix_syslog_cooker.$(OBJEXT) access_cooker.$(OBJEXT) \
        error_cooker.$(OBJEXT) xml_cooker.$(OBJEXT) \
        message_filter.$(OBJEXT) log_filter.$(OBJEXT) \
-       rpm_filter.$(OBJEXT)
+       rpm_filter.$(OBJEXT) df_filter.$(OBJEXT)
 gcm_input_OBJECTS = $(am_gcm_input_OBJECTS)
 gcm_input_LDADD = $(LDADD)
 gcm_input_DEPENDENCIES = ../lib/libgnucomo.a
@@ -65,6 +65,7 @@ DEFAULT_INCLUDES = -I. -I$(srcdir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/access_cooker.Po \
+@AMDEP_TRUE@   ./$(DEPDIR)/df_filter.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/error_cooker.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/gcm_input.Po \
 @AMDEP_TRUE@   ./$(DEPDIR)/irix_syslog_cooker.Po \
@@ -182,7 +183,7 @@ LDADD = ../lib/libgnucomo.a
 gcm_input_SOURCES = gcm_input.cpp message.cpp string_utils.cpp syslog_cooker.cpp \
                     irix_syslog_cooker.cpp access_cooker.cpp error_cooker.cpp \
                     xml_cooker.cpp \
-                    message_filter.cpp log_filter.cpp rpm_filter.cpp
+                    message_filter.cpp log_filter.cpp rpm_filter.cpp df_filter.cpp
 
 logrunner_SOURCES = logrunner.cpp string_utils.cpp
 all: all-am
@@ -255,6 +256,7 @@ distclean-compile:
        -rm -f *.tab.c
 
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/access_cooker.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/df_filter.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error_cooker.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcm_input.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/irix_syslog_cooker.Po@am__quote@
diff --git a/src/gcm_input/df_filter.cpp b/src/gcm_input/df_filter.cpp
new file mode 100644 (file)
index 0000000..b0da126
--- /dev/null
@@ -0,0 +1,242 @@
+
+/**************************************************************************
+**  (c) Copyright 2007, Andromeda Technology & Automation
+** This is free software; you can redistribute it and/or modify it under the
+** terms of the GNU General Public License, see the file COPYING.
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+**      FILE NAME      : df_filter.cpp
+**      SYSTEM NAME    : 
+**      VERSION NUMBER : $Revision: 1.1 $
+**
+**  DESCRIPTION      :  Transform output of 'df' into a Gnucomo XML document
+**
+**  EXPORTED OBJECTS : 
+**  LOCAL    OBJECTS : 
+**  MODULES  USED    :
+***************************************************************************
+**  ADMINISTRATIVE INFORMATION *
+********************************
+**      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+**      CREATION DATE   : Oct 30, 2007
+**      LAST UPDATE     : Nov 02, 2007
+**      MODIFICATIONS   : 
+**************************************************************************/
+
+/*****************************
+   $Log: df_filter.cpp,v $
+   Revision 1.1  2007-11-03 10:26:13  arjen
+   Added a new filter which can directly read the output
+   of the UNIX df command. A brief description is added in
+   the user manual.
+
+*****************************/
+
+/* static const char *RCSID = "$Id: df_filter.cpp,v 1.1 2007-11-03 10:26:13 arjen Exp $"; */
+
+#include <ctype.h>
+#include <vector>
+
+#include "df_filter.h"
+
+
+std::vector<String> tokenize(String line)
+{
+   std::vector<String> words;
+   int    l;           //  letter index in line
+
+   l = 0;
+   while (l < ~line)
+   {
+      int start, length;
+
+      while (l < ~line && isspace(line[l]))
+      {
+         l++;
+      }
+      start = l;
+      length = 0;
+
+      while (l < ~line && !isspace(line[l]))
+      {
+         l++;
+         length++;
+      }
+      String w = line(start, length);
+      words.push_back(w);
+   }
+   return words;
+}
+
+//  Find a regular expression in a vector of Strings
+
+int  findword(const std::vector<String> &tokens, const regex &pattern)
+{
+   int   i;
+
+   i = 0;
+   while (i < tokens.size() && !(tokens[i] == pattern))
+   {
+      i++;
+   }
+
+   if (i == tokens.size())
+   {
+      std::cerr << "Token not found.\n";
+   }
+
+   return i;
+}
+
+/*=========================================================================
+**  NAME           : constructXML
+**  SYNOPSIS       : int constructXML(message_buffer &in, strstream &xml)
+**  PARAMETERS     : 
+**  RETURN VALUE   : Create an XML document from output of 'df -k'
+**
+**  DESCRIPTION    : 
+**
+**  VARS USED      :
+**  VARS CHANGED   :
+**  FUNCTIONS USED :
+**  SEE ALSO       :
+**  LAST MODIFIED  : Nov 02, 2007
+**=========================================================================
+*/
+
+static const regex re_df_header("^Filesystem.+[Uu]se.+[Aa]vail.+Mounted");
+static const regex re_df_i_header("^Filesystem +Inodes.+IUse.+Mounted");
+static const regex re_df_data(".+ [0-9]+ +[0-9]+ +[0-9]+");
+
+void df_filter::construct_XML(message_buffer &in, std::strstream &xml)
+{
+   String line;
+   enum   df_report_detection { NONE, BLOCKS, INODES };
+
+   df_report_detection  report_type = NONE;
+
+   int    field_position[4];  //  Mountpoint, blocks, used, available
+
+   std::vector<String>  tokens;
+
+   scan_email_header(in);
+   construct_header(xml);
+
+   xml << "  <gcmt:data>\n";
+   xml << "    <gcmt:parameters class='filesystem'>\n";
+
+   while (in >> line)
+   { 
+      String  mountpoint;
+      String  device;
+      String  blocks;
+      String  inodes;
+      String  used;
+      String  available;
+
+      switch (report_type)
+      {
+      case NONE:  //  Header.
+         if (line == re_df_header)
+         {
+            report_type = BLOCKS;
+            tokens = tokenize(line);
+            //  Make a map to find the fields we're interested in
+            field_position[0] = findword(tokens, regex("Mounted"));
+            field_position[1] = findword(tokens, regex("kbytes|-blocks"));
+            field_position[2] = findword(tokens, regex("[uU]se"));
+            field_position[3] = findword(tokens, regex("[aA]vail"));
+         }
+         if (line == re_df_i_header)
+         {
+            report_type = INODES;
+            tokens = tokenize(line);
+            //  Make a map to find the fields we're interested in
+            field_position[0] = findword(tokens, regex("Mounted"));
+            field_position[1] = findword(tokens, regex("Inodes"));
+            field_position[2] = findword(tokens, regex("IUsed"));
+            field_position[3] = findword(tokens, regex("IFree"));
+         }
+         break;
+
+      case BLOCKS: // df output lines.
+         tokens = tokenize(line);
+         if (tokens.size() > 4)
+         {
+            mountpoint = tokens[field_position[0]];
+            blocks     = tokens[field_position[1]];
+            used       = tokens[field_position[2]];
+            available  = tokens[field_position[3]];
+            device     = tokens[0];
+            if (mountpoint[0] == '/')
+            {
+
+               //   Create the XML element.
+
+               xml << "    <gcmt:parameter name='" << mountpoint << "'>\n";
+               xml << "      <gcmt:property name='device'>" << device << "</gcmt:property>\n";
+               xml << "      <gcmt:property name='size'>" << blocks << "</gcmt:property>\n";
+               xml << "      <gcmt:property name='used'>"   << used   << "</gcmt:property>\n";
+               xml << "      <gcmt:property name='available'>" << available << "</gcmt:property>\n";
+               xml << "    </gcmt:parameter>\n";
+            }
+         }
+         else
+         {
+            //cerr << "Mismatch on " << line << "\n";
+         }
+         break;
+
+      case INODES: // df output lines.
+         tokens = tokenize(line);
+         if (tokens.size() > 4)
+         {
+            mountpoint = tokens[field_position[0]];
+            inodes     = tokens[field_position[1]];
+            used       = tokens[field_position[2]];
+            available  = tokens[field_position[3]];
+            device     = tokens[0];
+            if (mountpoint[0] == '/')
+            {
+
+               //   Create the XML element.
+
+               xml << "    <gcmt:parameter name='" << mountpoint << "'>\n";
+               xml << "      <gcmt:property name='device'>" << device << "</gcmt:property>\n";
+               xml << "      <gcmt:property name='Inodes'>" << inodes << "</gcmt:property>\n";
+               xml << "      <gcmt:property name='Iused'>"   << used   << "</gcmt:property>\n";
+               xml << "      <gcmt:property name='Ifree'>" << available << "</gcmt:property>\n";
+               xml << "    </gcmt:parameter>\n";
+            }
+         }
+         else
+         {
+            //cerr << "Mismatch on " << line << "\n";
+         }
+         break;
+      }
+   }
+   xml << "    </gcmt:parameters>\n";
+   xml << "  </gcmt:data>\n";
+   xml << "</gcmt:message>\n";
+}
+
+bool df_cooker::check_pattern(String logline)
+{
+   if (df_detected)
+   {
+      df_detected = (logline == re_df_data);
+   }
+   else
+   {
+      df_detected = (logline == re_df_header || logline == re_df_i_header);
+   }
+
+   return df_detected;
+}
+
+bool df_cooker::cook_this(String logline, UTC arrival)
+{
+   return true;
+}
diff --git a/src/gcm_input/df_filter.h b/src/gcm_input/df_filter.h
new file mode 100644 (file)
index 0000000..48e8741
--- /dev/null
@@ -0,0 +1,110 @@
+
+/**************************************************************************
+**  (c) Copyright 2007, Andromeda Technology & Automation
+** This is free software; you can redistribute it and/or modify it under the
+** terms of the GNU General Public License, see the file COPYING.
+***************************************************************************
+** MODULE INFORMATION *
+***********************
+**      FILE NAME      : df_filter.h
+**      SYSTEM NAME    : 
+**      VERSION NUMBER : $Revision: 1.1 $
+**
+**  DESCRIPTION      :  
+**
+**  EXPORTED OBJECTS : 
+**  LOCAL    OBJECTS : 
+**  MODULES  USED    :
+***************************************************************************
+**  ADMINISTRATIVE INFORMATION *
+********************************
+**      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
+**      CREATION DATE   : Oct 31, 2007
+**      LAST UPDATE     : Oct 31, 2007
+**      MODIFICATIONS   : 
+**************************************************************************/
+
+/*****************************
+   $Log: df_filter.h,v $
+   Revision 1.1  2007-11-03 10:26:13  arjen
+   Added a new filter which can directly read the output
+   of the UNIX df command. A brief description is added in
+   the user manual.
+
+ *****************************/
+
+/* static const char *RCSID = "$Id: df_filter.h,v 1.1 2007-11-03 10:26:13 arjen Exp $"; */
+
+#include "message_filter.h"
+#include "line_cooker.h"
+
+/*
+///////////////////////////////////////////////////////////////////////////
+//  NAME           : df_filter
+//  BASECLASS      : 
+//  MEMBERS        :
+//  OPERATORS      :
+//  METHODS        : 
+//
+//  DESCRIPTION    : 
+//
+//  RELATIONS      :
+//  SEE ALSO       :
+//  LAST MODIFIED  : Oct 31, 2007
+///////////////////////////////////////////////////////////////////////////
+*/
+
+class df_filter : public message_filter
+{
+
+protected:
+
+public:
+
+   df_filter(String host, UTC arriv, String service) : message_filter(host, arriv, service)
+   {
+   }
+
+   virtual void construct_XML(message_buffer &in, std::strstream &xml);
+};
+
+/*
+///////////////////////////////////////////////////////////////////////////
+//  NAME           : df_cooker
+//  BASECLASS      : 
+//  MEMBERS        :
+//  OPERATORS      :
+//  METHODS        : 
+//
+//  DESCRIPTION    : 
+//
+//  RELATIONS      :
+//  SEE ALSO       :
+//  LAST MODIFIED  : Oct 31, 2007
+///////////////////////////////////////////////////////////////////////////
+*/
+
+class df_cooker : public line_cooker
+{
+
+   bool df_detected;
+
+protected:
+
+
+public:
+
+   df_cooker()
+   {
+      df_detected = false;
+   }
+
+   bool check_pattern(String logline);
+   bool cook_this(String logline, UTC arrival);
+
+   String message_type()
+   {
+      return "df report";
+   }
+
+};
index b1c50e6..bcce2e8 100644 (file)
@@ -7,7 +7,7 @@
 ***********************
 **      FILE NAME      : gcm_input.cpp
 **      SYSTEM NAME    : Gnucomo - Gnu Computer Monitoring
-**      VERSION NUMBER : $Revision: 1.13 $
+**      VERSION NUMBER : $Revision: 1.14 $
 **
 **  DESCRIPTION      :  Application to store client messages into the database
 **                      The client message contains a log file from one of the
 
 /*****************************
    $Log: gcm_input.cpp,v $
-   Revision 1.13  2003-12-22 10:20:21  arjen
+   Revision 1.14  2007-11-03 10:26:13  arjen
+   Added a new filter which can directly read the output
+   of the UNIX df command. A brief description is added in
+   the user manual.
+
+   Revision 1.13  2003/12/22 10:20:21  arjen
    Report if the message type can not be detected.
 
    Revision 1.12  2003/12/04 10:38:09  arjen
 
 *****************************/
 
-static const char *RCSID = "$Id: gcm_input.cpp,v 1.13 2003-12-22 10:20:21 arjen Exp $";
+static const char *RCSID = "$Id: gcm_input.cpp,v 1.14 2007-11-03 10:26:13 arjen Exp $";
 
 #include <fstream>
 
@@ -122,6 +127,7 @@ static const char *RCSID = "$Id: gcm_input.cpp,v 1.13 2003-12-22 10:20:21 arjen
 #include "message.h"
 #include "log_filter.h"
 #include "rpm_filter.h"
+#include "df_filter.h"
 
 #include "xml_cooker.h"
 #include "syslog_cooker.h"
@@ -134,7 +140,7 @@ bool testmode = false;
 bool incremental = false;
 std::ostream *Log = &std::cerr;
 
-static char *Version = "gcm_input version 0.0.9 - Dec 22, 2003";
+static char *Version = "gcm_input version 0.0.11 - Nov 22, 2007";
 
 
 /*=========================================================================
@@ -272,9 +278,12 @@ int main(int argc, char *argv[])
 
       client_message      msg(&std::cin, db);
 
+      double              message_probability;
+
       message_filter      shortcircuit(hostname, arrival, service);
       log_filter          lf(hostname, arrival, service);
       rpm_filter          rf(hostname, arrival, service);
+      df_filter           df(hostname, arrival, service);
 
       syslog_cooker       slc;
       irix_syslog_cooker  islc;
@@ -282,6 +291,7 @@ int main(int argc, char *argv[])
       error_cooker        elc;
       xml_cooker          xlc;
       rpm_cooker          rlc;
+      df_cooker           dlc;
 
       msg.add_cooker(&xlc,  &shortcircuit);
       msg.add_cooker(&slc,  &lf);
@@ -289,8 +299,11 @@ int main(int argc, char *argv[])
       msg.add_cooker(&alc,  &lf);
       msg.add_cooker(&elc,  &lf);
       msg.add_cooker(&rlc,  &rf);
+      msg.add_cooker(&dlc,  &df);
 
-      if (msg.classify(hostname, arrival, service) > 0.9)
+      message_probability = msg.classify(hostname, arrival, service);
+      *Log << "Message type probability = " << message_probability << "\n";
+      if (message_probability > 0.75)
       {
          try
          {