svn merge -r523:547 branches/config-step trunk
[collectd.git] / contrib / collection.cgi
index 5684475..392c62b 100755 (executable)
@@ -53,6 +53,47 @@ our $GraphDefs;
        
        $GraphDefs =
        {
+               apache_bytes => ['DEF:min_raw={file}:count:MIN',
+                       'DEF:avg_raw={file}:count:AVERAGE',
+                       'DEF:max_raw={file}:count:MAX',
+                       'CDEF:min=min_raw,8,*',
+                       'CDEF:avg=avg_raw,8,*',
+                       'CDEF:max=max_raw,8,*',
+                       'CDEF:mytime=avg_raw,TIME,TIME,IF',
+                       'CDEF:sample_len_raw=mytime,PREV(mytime),-',
+                       'CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF',
+                       'CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*',
+                       'CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+',
+                       "AREA:avg#$HalfBlue",
+                       "LINE1:avg#$FullBlue:Bit/s",
+                       'GPRINT:min:MIN:%5.1lf%s Min,',
+                       'GPRINT:avg:AVERAGE:%5.1lf%s Avg,',
+                       'GPRINT:max:MAX:%5.1lf%s Max,',
+                       'GPRINT:avg:LAST:%5.1lf%s Last',
+                       'GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
+               ],
+               apache_requests => ['DEF:min={file}:count:MIN',
+                       'DEF:avg={file}:count:AVERAGE',
+                       'DEF:max={file}:count:MAX',
+                       "AREA:max#$HalfBlue",
+                       "AREA:min#$Canvas",
+                       "LINE1:avg#$FullBlue:Requests/s",
+                       'GPRINT:min:MIN:%6.2lf Min,',
+                       'GPRINT:avg:AVERAGE:%6.2lf Avg,',
+                       'GPRINT:max:MAX:%6.2lf Max,',
+                       'GPRINT:avg:LAST:%6.2lf Last'
+               ],
+               apache_scoreboard => ['DEF:min={file}:count:MIN',
+                       'DEF:avg={file}:count:AVERAGE',
+                       'DEF:max={file}:count:MAX',
+                       "AREA:max#$HalfBlue",
+                       "AREA:min#$Canvas",
+                       "LINE1:avg#$FullBlue:Processes",
+                       'GPRINT:min:MIN:%6.2lf Min,',
+                       'GPRINT:avg:AVERAGE:%6.2lf Avg,',
+                       'GPRINT:max:MAX:%6.2lf Max,',
+                       'GPRINT:avg:LAST:%6.2lf Last'
+               ],
                charge => [
                        'DEF:avg={file}:charge:AVERAGE',
                        'DEF:min={file}:charge:MIN',
@@ -718,7 +759,87 @@ our $GraphDefs;
                        'GPRINT:avg:AVERAGE:%5.1lf%sV Avg,',
                        'GPRINT:max:MAX:%5.1lf%sV Max,',
                        'GPRINT:avg:LAST:%5.1lf%sV Last\l'
-               ]
+               ],
+               threads => [
+                       "DEF:total_avg={file}:total:AVERAGE",
+                       "DEF:total_min={file}:total:MIN",
+                       "DEF:total_max={file}:total:MAX",
+                       "DEF:running_avg={file}:running:AVERAGE",
+                       "DEF:running_min={file}:running:MIN",
+                       "DEF:running_max={file}:running:MAX",
+                       "DEF:uninterruptible_avg={file}:uninterruptible:AVERAGE",
+                       "DEF:uninterruptible_min={file}:uninterruptible:MIN",
+                       "DEF:uninterruptible_max={file}:uninterruptible:MAX",
+                       "DEF:onhold_avg={file}:onhold:AVERAGE",
+                       "DEF:onhold_min={file}:onhold:MIN",
+                       "DEF:onhold_max={file}:onhold:MAX",
+                       "LINE1:total_avg#$FullYellow:Total   ",
+                       'GPRINT:total_min:MIN:%5.1lf Min,',
+                       'GPRINT:total_avg:AVERAGE:%5.1lf Avg.,',
+                       'GPRINT:total_max:MAX:%5.1lf Max,',
+                       'GPRINT:total_avg:LAST:%5.1lf Last\l',
+                       "LINE1:running_avg#$FullRed:Running ",
+                       'GPRINT:running_min:MIN:%5.1lf Min,',
+                       'GPRINT:running_avg:AVERAGE:%5.1lf Avg.,',          
+                       'GPRINT:running_max:MAX:%5.1lf Max,',
+                       'GPRINT:running_avg:LAST:%5.1lf Last\l',
+                       "LINE1:uninterruptible_avg#$FullGreen:Unintr  ",
+                       'GPRINT:uninterruptible_min:MIN:%5.1lf Min,',
+                       'GPRINT:uninterruptible_avg:AVERAGE:%5.1lf Avg.,',
+                       'GPRINT:uninterruptible_max:MAX:%5.1lf Max,',
+                       'GPRINT:uninterruptible_avg:LAST:%5.1lf Last\l',
+                       "LINE1:onhold_avg#$FullBlue:Onhold  ",
+                       'GPRINT:onhold_min:MIN:%5.1lf Min,',
+                       'GPRINT:onhold_avg:AVERAGE:%5.1lf Avg.,',
+                       'GPRINT:onhold_max:MAX:%5.1lf Max,',
+                       'GPRINT:onhold_avg:LAST:%5.1lf Last\l'
+               ],
+               vs_memory => [
+                       'DEF:vm_avg={file}:vm:AVERAGE',
+                       'DEF:vm_min={file}:vm:MIN',
+                       'DEF:vm_max={file}:vm:MAX',
+                       'DEF:vml_avg={file}:vml:AVERAGE',
+                       'DEF:vml_min={file}:vml:MIN',
+                       'DEF:vml_max={file}:vml:MAX',
+                       'DEF:rss_avg={file}:rss:AVERAGE',
+                       'DEF:rss_min={file}:rss:MIN',
+                       'DEF:rss_max={file}:rss:MAX',
+                       'DEF:anon_avg={file}:anon:AVERAGE',
+                       'DEF:anon_min={file}:anon:MIN',
+                       'DEF:anon_max={file}:anon:MAX',
+                       "LINE1:vm_avg#$FullYellow:VM     ",
+                       'GPRINT:vm_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:vm_avg:AVERAGE:%5.1lf%s Avg.,',
+                       'GPRINT:vm_max:MAX:%5.1lf%s Avg.,',
+                       'GPRINT:vm_avg:LAST:%5.1lf%s Last\l',
+                       "LINE1:vml_avg#$FullRed:Locked ",
+                       'GPRINT:vml_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:vml_avg:AVERAGE:%5.1lf%s Avg.,',
+                       'GPRINT:vml_max:MAX:%5.1lf%s Avg.,',
+                       'GPRINT:vml_avg:LAST:%5.1lf%s Last\l',
+                       "LINE1:rss_avg#$FullGreen:RSS    ",
+                       'GPRINT:rss_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:rss_avg:AVERAGE:%5.1lf%s Avg.,',
+                       'GPRINT:rss_max:MAX:%5.1lf%s Avg.,',
+                       'GPRINT:rss_avg:LAST:%5.1lf%s Last\l',
+                       "LINE1:anon_avg#$FullBlue:Anon.  ",
+                       'GPRINT:anon_min:MIN:%5.1lf%s Min,',
+                       'GPRINT:anon_avg:AVERAGE:%5.1lf%s Avg.,',
+                       'GPRINT:anon_max:MAX:%5.1lf%s Avg.,',
+                       'GPRINT:anon_avg:LAST:%5.1lf%s Last\l',
+               ],
+               vs_processes => [
+                       'DEF:proc_avg={file}:total:AVERAGE',
+                       'DEF:proc_min={file}:total:MIN',
+                       'DEF:proc_max={file}:total:MAX',
+                       "AREA:proc_max#$HalfBlue",
+                       "AREA:proc_min#$Canvas",
+                       "LINE1:proc_avg#$FullBlue:Processes",
+                       'GPRINT:proc_min:MIN:%4.1lf Min,',
+                       'GPRINT:proc_avg:AVERAGE:%4.1lf Avg.,',
+                       'GPRINT:proc_max:MAX:%4.1lf Max,',
+                       'GPRINT:proc_avg:LAST:%4.1lf Last\l'
+               ],
        };
        $GraphDefs->{'disk'} = $GraphDefs->{'partition'};
        $GraphDefs->{'meminfo'} = $GraphDefs->{'memory'};
@@ -726,6 +847,9 @@ our $GraphDefs;
 
 our $GraphArgs =
 {
+       apache_bytes => ['-t', 'apache traffic', '-v', 'Bit/s'],
+       apache_requests => ['-t', 'apache requests', '-v', 'Requests/s'],
+       apache_scoreboard => ['-t', 'apache scoreboard {inst}', '-v', 'Processes'],
        charge => ['-t', '{host} charge', '-v', 'Ampere hours'],
        cpu => ['-t', '{host} cpu{inst} usage', '-v', 'Percent', '-l', '0'],
        cpufreq => ['-t', '{host} cpu{inst} usage', '-v', 'Mhz'],
@@ -749,11 +873,15 @@ our $GraphArgs =
        swap => ['-t', '{host} swap usage', '-v', 'Bytes', '-b', '1024', '-l', '0'],
        traffic => ['-t', '{host} {inst} traffic', '-v', 'Bit/s'],
        users => ['-t', '{host} users', '-v', 'Users'],
-       voltage => ['-t', '{host} voltage', '-v', 'Volts']
+       voltage => ['-t', '{host} voltage', '-v', 'Volts'],
+       threads => ['-t', '{host} threads', '-v', 'Threads'],
+       vs_memory => ['-t', '{host} memory usage', '-v', 'Bytes'],
+       vs_processes => ['-t', '{host} processes', '-v', 'Processes'],
 };
 
 our $GraphMulti =
 {
+       apache_scoreboard => \&output_graph_apache_scoreboard,
        cpu     => \&output_graph_cpu,
        cpufreq => 1,
        disk    => 1,
@@ -856,6 +984,49 @@ sub output_graph_cpu
        return (@ret);
 }
 
+sub output_graph_apache_scoreboard
+{
+       my @inst = @_;
+       my @ret = ();
+
+       die if (@inst < 2);
+
+       my @colors = get_n_colors (scalar (@inst));
+
+       for (my $i = 0; $i < scalar (@inst); $i++)
+       {
+               my $inst = $inst[$i];
+               push (@ret,
+                       "DEF:avg_$i=$AbsDir/apache_scoreboard-$inst.rrd:count:AVERAGE",
+                       "DEF:min_$i=$AbsDir/apache_scoreboard-$inst.rrd:count:MIN",
+                       "DEF:max_$i=$AbsDir/apache_scoreboard-$inst.rrd:count:MAX");
+       }
+
+       for (my $i = 0; $i < scalar (@inst); $i++)
+       {
+               my $inst = $inst[$i];
+               my $color = $colors[$i];
+
+               if (length ($inst) > 15)
+               {
+                       $inst = substr ($inst, 0, 12) . '...';
+               }
+               else
+               {
+                       $inst = sprintf ('%-15s', $inst);
+               }
+
+               push (@ret,
+                       "LINE1:avg_$i#$color:$inst",
+                       "GPRINT:min_$i:MIN:%6.2lf Min,",
+                       "GPRINT:avg_$i:AVERAGE:%6.2lf Avg,",
+                       "GPRINT:max_$i:MAX:%6.2lf Max,",
+                       "GPRINT:avg_$i:LAST:%6.2lf Last\\l");
+       }
+
+       return (@ret);
+}
+
 sub output_graph_ping
 {
        my @inst = @_;