Project

General

Profile

« Previous | Next » 

Revision 9afdb02d

Added by Hamish Coleman over 15 years ago

  • ID 9afdb02d94beaa0ce9cb4f9564ede36d68ce983e

Add tags to each graph, export all time ranges for each graph, json beautification

View differences:

indexmrtg.cgi
# TODO - determine correct URL prefix
# TODO - change the filename based on the displayed period
my $filename = $graphname . "-day." . $mrtg->{_imagetype};
$graph->{img}{URL} = $filename;
$graph->{img}{URL}{day} = $filename;
$graph->{img}{URL}{week} = $graphname."-week.".$mrtg->{_imagetype};
$graph->{img}{URL}{month} = $graphname."-month.".$mrtg->{_imagetype};
$graph->{img}{URL}{year} = $graphname."-year.".$mrtg->{_imagetype};
my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime,$mtime,$ctime,$blksize,$blocks)
......
next;
}
$db->{graph}->{$name}->{_hosttype} = $hosttype;
$db->{graph}{$name}{tag}{hosttype} = $hosttype;
$db->{hosttype}->{$hosttype}->{$host}++;
}
......
# a valid hosttype both:
# defined($db->{graph}->{$name}->{hosttype}) &&
# defined($db->{hosttype}->{$hosttype})
my $hosttype = $db->{graph}->{$name}->{_hosttype};
my $hosttype = $db->{graph}{$name}{tag}{hosttype};
if (defined($hosttype) && !defined($db->{hosttype}->{$hosttype})) {
$hosttype=undef;
}
......
# Look through the name database and create tree entries for each cfgfile
#
sub maketree() {
maketree_find_hosttypes();
for my $name (keys %{$db->{graph}}) {
my $sequence = $db->{graph}->{$name}->{sequence};
......
# childless and prune the child
}
sub maketags() {
maketree_find_hosttypes();
for my $name (keys %{$db->{graph}}) {
my $graph = $db->{graph}->{$name};
my ($group,$host,$test) = extract_grouphosttest($name);
$graph->{tag}{group}=$group if $group;
$graph->{tag}{host}=$host if $host;
$graph->{tag}{test}=$test if $test;
}
}
my $this_host = hostname;
print header,
......
config_load_file(@config_files);
config_read_filesystem();
maketree();
maketags();
#maketree();
# Time the next update to occur a little while after the next interval completes
my $interval = 300; # 5 min update interval
......
print "\n",Dumper(\$db),"\n";
}
print "\n",JSON->new->utf8(1)->pretty(1)->encode($db),"\n";
print "\n",JSON->new->utf8(1)->pretty(1)->canonical(1)->encode($db),"\n";

Also available in: Unified diff