From cde121726fc1d69c0c3b25795b65cdbfd4218695 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Wed, 15 May 2013 15:02:27 +0200 Subject: [PATCH] Clean fieldnames, to allow filesystems and pools containing "-" to be graphed. --- plugins/zfs/zfs_usage_ | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/zfs/zfs_usage_ b/plugins/zfs/zfs_usage_ index c1edcd87..9f605c10 100755 --- a/plugins/zfs/zfs_usage_ +++ b/plugins/zfs/zfs_usage_ @@ -172,11 +172,12 @@ sub do_config_fs { ($fs_slash =~ s/_/\//g); if ( $fs ne $zpool ) { - print "multigraph zfs_usage_$zpool.$fs\n"; + printf( "multigraph zfs_usage_%s.%s\n", + clean_fieldname($zpool), clean_fieldname($fs) ); print "graph_title ZFS usage for $filesystems->{$fs}->{type} $fs_slash\n"; print "graph_info This graph shows used bytes of $filesystems->{$fs}->{type} $fs_slash\n"; } else { - print "multigraph zfs_usage_$zpool\n"; + printf( "multigraph zfs_usage_%s\n", clean_fieldname($zpool) ); print "graph_title ZFS usage for zpool $zpool\n"; print "graph_info This graph shows used bytes of zpool $zpool\n"; } @@ -212,9 +213,10 @@ sub do_fetch_fs { my ($fs) = @_; if ( $fs ne $zpool ) { - print "multigraph zfs_usage_$zpool.$fs\n"; + printf( "multigraph zfs_usage_%s.%s\n", + clean_fieldname($zpool), clean_fieldname($fs) ); } else { - print "multigraph zfs_usage_$zpool\n"; + printf( "multigraph zfs_usage_%s\n", clean_fieldname($zpool) ); } foreach my $key ( keys %{$filesystems->{$fs}}) {