]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Revert "collection.cgi: parse types.db to discover DS names"
authorPavel Rochnyak <pavel2000@ngs.ru>
Tue, 3 Mar 2020 19:47:13 +0000 (02:47 +0700)
committerGitHub <noreply@github.com>
Tue, 3 Mar 2020 19:47:13 +0000 (02:47 +0700)
contrib/collection.cgi

index 6b0665af868c6f18412ed5580bae6d7f3de77392..5ff259ff0fce178a0bb47bccc5f9a68cf41c155e 100755 (executable)
@@ -33,7 +33,6 @@ use RRDs ();
 use Data::Dumper ();
 
 our $Config = "/etc/collection.conf";
-our $TypesDB = "/usr/share/collectd/types.db";
 our @DataDirs = ();
 our @DontShowTypes = ();
 our $LibDir;
@@ -51,9 +50,6 @@ our @RRDDefaultArgs = ('-w', '400');
 
 our $Args = {};
 
-our $Types = {};
-read_types_db();
-
 our $GraphDefs;
 our $MetaGraphDefs = {};
 load_graph_definitions ();
@@ -65,27 +61,6 @@ for (qw(action host plugin plugin_instance type type_instance timespan))
 
 exit (main ());
 
-sub read_types_db
-{
-       my $fh;
-       open ($fh, "< $TypesDB") or confess ("open ($TypesDB): $!");
-       while (my $line = <$fh>)
-       {
-               chomp ($line);
-               $line =~ s/\s*(?:#.*)?$//;
-               next if (!$line);
-               my ($type, $specs) = split(m/\s+/, $line, 2);
-               my @specs = split(m/,?\s+/, $specs);
-               $Types->{$type} = [];
-               foreach my $spec (@specs)
-               {
-                       my ($name, $ds_type, $min, $max) = split(m/:/, $spec);
-                       push (@{$Types->{$type}}, $name);
-               }
-       }
-       close ($fh);
-} # read_types_db
-
 sub read_config
 {
        my $fh;
@@ -834,7 +809,6 @@ sub action_show_graph
 
     $file =~ s/:/\\:/g;
     s/{file}/$file/ for (@rrd_args);
-    s/{ds(\d+)}/$Types->{$gtype}[$1]/ for (@rrd_args);
 
     RRDs::graph ('-', '-a', 'PNG', '-s', $start_time, '-t', $title, @RRDDefaultArgs, @rrd_args);
     if (my $err = RRDs::error ())
@@ -1395,9 +1369,9 @@ sub load_graph_definitions
     'GPRINT:avg:LAST:%4.0lf Last\l'
     ],
     entropy => ['-v', 'Bits',
-    'DEF:avg={file}:{ds0}:AVERAGE',
-    'DEF:min={file}:{ds0}:MIN',
-    'DEF:max={file}:{ds0}:MAX',
+    'DEF:avg={file}:entropy:AVERAGE',
+    'DEF:min={file}:entropy:MIN',
+    'DEF:max={file}:entropy:MAX',
     "AREA:max#$HalfBlue",
     "AREA:min#$Canvas",
     "LINE1:avg#$FullBlue:Bits",
@@ -1431,9 +1405,9 @@ sub load_graph_definitions
     'GPRINT:avg:LAST:%4.1lf Last\l'
     ],
     frequency_offset => [ # NTPd
-    'DEF:ppm_avg={file}:{ds0}:AVERAGE',
-    'DEF:ppm_min={file}:{ds0}:MIN',
-    'DEF:ppm_max={file}:{ds0}:MAX',
+    'DEF:ppm_avg={file}:ppm:AVERAGE',
+    'DEF:ppm_min={file}:ppm:MIN',
+    'DEF:ppm_max={file}:ppm:MAX',
     "AREA:ppm_max#$HalfBlue",
     "AREA:ppm_min#$Canvas",
     "LINE1:ppm_avg#$FullBlue:{inst}",
@@ -2506,9 +2480,9 @@ sub load_graph_definitions
     'GPRINT:avg:LAST:%5.1lf%s Last\l'
     ],
     time_offset => [ # NTPd
-    'DEF:s_avg={file}:{ds0}:AVERAGE',
-    'DEF:s_min={file}:{ds0}:MIN',
-    'DEF:s_max={file}:{ds0}:MAX',
+    'DEF:s_avg={file}:seconds:AVERAGE',
+    'DEF:s_min={file}:seconds:MIN',
+    'DEF:s_max={file}:seconds:MAX',
     "AREA:s_max#$HalfBlue",
     "AREA:s_min#$Canvas",
     "LINE1:s_avg#$FullBlue:{inst}",
@@ -2578,9 +2552,9 @@ sub load_graph_definitions
     'GPRINT:multimeter_avg:LAST:%4.1lf Last\l'
     ],
     users => ['-v', 'Users',
-    'DEF:users_avg={file}:{ds0}:AVERAGE',
-    'DEF:users_min={file}:{ds0}:MIN',
-    'DEF:users_max={file}:{ds0}:MAX',
+    'DEF:users_avg={file}:users:AVERAGE',
+    'DEF:users_min={file}:users:MIN',
+    'DEF:users_max={file}:users:MAX',
     "AREA:users_max#$HalfBlue",
     "AREA:users_min#$Canvas",
     "LINE1:users_avg#$FullBlue:Users",