Skip to content

Commit 805f911

Browse files
committed
update examples to use the latest API
1 parent ffb62cc commit 805f911

File tree

8 files changed

+27
-38
lines changed

8 files changed

+27
-38
lines changed

examples/Smdn.Net.MuninNode.Hosting/getting-started/Program.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ static async Task Main(string[] args)
6262
],
6363
// Configures the 'attributes' of the graph when drawn data as a graph.
6464
// See: https://guide.munin-monitoring.org/en/latest/reference/plugin.html#global-attributes
65-
graphAttributes: new PluginGraphAttributes(
66-
category: "sensors",
67-
title: "Temperature",
68-
verticalLabel: "Degree Celsius",
69-
scale: false,
70-
arguments: "--base 1000 --lower-limit 0 --upper-limit 50"
71-
)
65+
graphAttributes: new PluginGraphAttributesBuilder(title: "Temperature")
66+
.WithCategory(WellKnownCategory.Sensor)
67+
.WithVerticalLabel("Degree Celsius")
68+
.WithGraphLimit(0, 50)
69+
.Build()
7270
)
7371
);
7472
// One or more plug-ins can be added.
@@ -90,4 +88,4 @@ static async Task Main(string[] args)
9088

9189
await app.RunAsync();
9290
}
93-
}
91+
}

examples/Smdn.Net.MuninNode.Hosting/getting-started/Program.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SPDX-License-Identifier: MIT
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
1212
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
13+
<PackageReference Include="Smdn.Net.MuninNode" Version="2.3.0" />
1314
<PackageReference Include="Smdn.Net.MuninNode.Hosting" Version="3.0.0" />
1415
</ItemGroup>
1516
</Project>

examples/Smdn.Net.MuninNode/getting-started/Program.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ static async Task Main()
5757
],
5858
// Configures the 'attributes' of the graph when drawn data as a graph.
5959
// See: https://guide.munin-monitoring.org/en/latest/reference/plugin.html#global-attributes
60-
graphAttributes: new PluginGraphAttributes(
61-
category: "sensors",
62-
title: "Temperature",
63-
verticalLabel: "Degree Celsius",
64-
scale: false,
65-
arguments: "--base 1000 --lower-limit 0 --upper-limit 50"
66-
)
60+
graphAttributes: new PluginGraphAttributesBuilder(title: "Temperature")
61+
.WithCategory(WellKnownCategory.Sensor)
62+
.WithVerticalLabel("Degree Celsius")
63+
.WithGraphLimit(0, 50)
64+
.Build()
6765
)
6866
)
6967
// One or more plug-ins can be added.
@@ -101,4 +99,4 @@ static async Task Main()
10199
Console.WriteLine("stopped");
102100
}
103101
}
104-
}
102+
}

examples/Smdn.Net.MuninNode/getting-started/Program.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ SPDX-License-Identifier: MIT
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
1212
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
13-
<PackageReference Include="Smdn.Net.MuninNode" Version="2.2.0" />
13+
<PackageReference Include="Smdn.Net.MuninNode" Version="2.3.0" />
1414
</ItemGroup>
1515
</Project>

examples/Smdn.Net.MuninNode/local-node-uptime/Program.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,12 @@
2626
// Set the number of minutes elapsed from the start time of the process as the 'uptime' value.
2727
fetchFieldValue: () => (DateTime.Now - startAt).TotalMinutes,
2828
// Configure the drawing on the graph for this plugin.
29-
graphAttributes: new PluginGraphAttributes(
30-
// 'Well known categories' are defined by Munin.
31-
// See https://guide.munin-monitoring.org/en/latest/reference/graph-category.html
32-
category: "system",
33-
title: $"Uptime of {NodeHostName}",
34-
verticalLabel: "Uptime [minutes]",
35-
scale: false,
36-
// Specify arguments for graph drawing. See below for more information about graph arguments:
37-
// https://guide.munin-monitoring.org/en/latest/reference/plugin.html#graph-args
38-
// https://guide.munin-monitoring.org/en/latest/example/graph/graph_args.html
39-
arguments: "--base 1000 --lower-limit 0"
40-
)
29+
graphAttributes: new PluginGraphAttributesBuilder(title: $"Uptime of {NodeHostName}")
30+
.WithCategory(WellKnownCategory.System)
31+
.WithVerticalLabel("Uptime [minutes]")
32+
.WithGraphDecimalBase()
33+
.WithGraphLowerLimit(0)
34+
.Build()
4135
),
4236
// You can also run multiple plugins for one single node.
4337
// PluginFactory.CreatePlugin(name: "sensor1", ...),

examples/Smdn.Net.MuninNode/local-node-uptime/Program.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ SPDX-License-Identifier: MIT
99
</PropertyGroup>
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
12-
<PackageReference Include="Smdn.Net.MuninNode" Version="2.2.0" />
12+
<PackageReference Include="Smdn.Net.MuninNode" Version="2.3.0" />
1313
</ItemGroup>
1414
</Project>

examples/Smdn.Net.MuninNode/multiple-fields/Program.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
PluginFactory.CreateField(label: "value2", graphStyle: PluginFieldGraphStyle.LineStack, fetchValue: FetchValue2),
2727
PluginFactory.CreateField(label: "value3", graphStyle: PluginFieldGraphStyle.LineWidth2, fetchValue: FetchValue3),
2828
},
29-
graphAttributes: new PluginGraphAttributes(
30-
category: "system",
31-
title: "random numbers",
32-
verticalLabel: "number",
33-
scale: false,
34-
arguments: "--base 1000 --lower-limit 0 --upper-limit 10"
35-
)
29+
graphAttributes: new PluginGraphAttributesBuilder(title: "random numbers")
30+
.WithCategory(WellKnownCategory.System)
31+
.WithVerticalLabel("number")
32+
.WithGraphLimit(0, 10)
33+
.Build()
3634
),
3735
};
3836

examples/Smdn.Net.MuninNode/multiple-fields/Program.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ SPDX-License-Identifier: MIT
99
</PropertyGroup>
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
12-
<PackageReference Include="Smdn.Net.MuninNode" Version="2.2.0" />
12+
<PackageReference Include="Smdn.Net.MuninNode" Version="2.3.0" />
1313
</ItemGroup>
1414
</Project>

0 commit comments

Comments
 (0)