@@ -597,11 +597,17 @@ private static void WriteConfigDataSourceAttributes(
597
597
List < string > responseLines
598
598
)
599
599
{
600
+ var shouldHandleNegativeFields = dataSource
601
+ . Fields
602
+ . Any ( static f => ! string . IsNullOrEmpty ( f . Attributes . NegativeFieldName ) ) ;
603
+
600
604
// The fields referenced by {fieldname}.negative must be defined ahread of others,
601
605
// and thus lists the negative field settings first.
602
606
// Otherwise, the following error occurs when generating the graph.
603
607
// "[RRD ERROR] Unable to graph /var/cache/munin/www/XXX.png : undefined v name XXXXXXXXXXXXXX"
604
- var orderedFields = dataSource . Fields . OrderBy ( f => IsNegativeField ( f , dataSource . Fields ) ? 0 : 1 ) ;
608
+ IEnumerable < IPluginField > orderedFields = shouldHandleNegativeFields
609
+ ? dataSource . Fields . OrderBy ( f => IsNegativeField ( f , dataSource . Fields ) ? 0 : 1 )
610
+ : dataSource . Fields ;
605
611
606
612
foreach ( var field in orderedFields ) {
607
613
var fieldAttrs = field . Attributes ;
@@ -618,7 +624,7 @@ List<string> responseLines
618
624
if ( FormatNormalValueRange ( fieldAttrs . NormalRangeForCritical ) is string attrCritical )
619
625
responseLines . Add ( $ "{ field . Name } .critical { attrCritical } ") ;
620
626
621
- if ( ! string . IsNullOrEmpty ( fieldAttrs . NegativeFieldName ) ) {
627
+ if ( shouldHandleNegativeFields && ! string . IsNullOrEmpty ( fieldAttrs . NegativeFieldName ) ) {
622
628
var negativeField = dataSource . Fields . FirstOrDefault (
623
629
f => string . Equals ( fieldAttrs . NegativeFieldName , f . Name , StringComparison . Ordinal )
624
630
) ;
@@ -628,7 +634,7 @@ List<string> responseLines
628
634
}
629
635
630
636
// this field is defined as the negative field of other field, so should not be graphed
631
- if ( IsNegativeField ( field , dataSource . Fields ) )
637
+ if ( shouldHandleNegativeFields && IsNegativeField ( field , dataSource . Fields ) )
632
638
graph = false ;
633
639
634
640
if ( graph is bool drawGraph )
0 commit comments