Skip to content

Commit c5572d0

Browse files
committed
updated docs; nut.chart.sh now autodetects multiple UPSes, web and cache directories are chowned; charts.d is now enabled by default
1 parent 1b68ee4 commit c5572d0

13 files changed

Lines changed: 332 additions & 243 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Here is a screenshot:
7777
- `/proc/meminfo` (memory information)
7878
- `/proc/vmstat` (system performance)
7979
- `/proc/net/rpc/nfsd` (NFS server statistics for both v3 and v4 NFS)
80-
- `tc` classes (QoS classes)
80+
- `tc` classes (QoS classes - [with FireQOS class names](http://firehol.org/tutorial/fireqos-new-user/))
8181

8282
- It supports **plugins** for collecting information from other sources!
8383

@@ -89,20 +89,21 @@ Here is a screenshot:
8989

9090
- `charts.d.plugin` provides a simple way to script data collection in BASH. It includes example plugins that collect values from:
9191

92-
- `nut` (UPS load, frequency, voltage, etc)
92+
- `nut` (UPS load, frequency, voltage, etc, for multiple UPSes)
9393
- `sensors` (temperature, voltage, current, power, humidity, fans rotation sensors)
94-
- `cpufreq` (current CPU clock frequency)
94+
- `cpufreq` (current CPU clock frequency, for all CPUs)
9595
- `postfix` (e-mail queue size)
9696
- `squid` (web proxy statistics)
9797
- `mysql` (mysql global statistics)
98+
- `opensips` (opensips statistics)
9899

99100
Of course, you can write your own using BASH scripting.
100101

101102
- netdata is a web server, supporting gzip compression
102103

103104
It serves its own static files and dynamic files for rendering the site.
104105
It does not support authentication or SSL - limit its access using your firewall.
105-
It does not allow ` .. ` or ` / ` in the files requested (so it can only serve files stored in the `web/` directory).
106+
It does not allow ` .. ` or ` / ` in the files requested (so it can only serve files stored in the web directory `/usr/share/netdata/web`).
106107

107108

108109
# How it works

charts.d/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
55

66
dist_charts_SCRIPTS = \
7+
README.md \
78
airsearches.chart.sh \
89
cpu_apps.chart.sh \
910
cpufreq.chart.sh \

charts.d/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

charts.d/mysql.chart.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
# This statement does not require any privilege.
88
# It requires only the ability to connect to the server.
99

10-
mysql_cmd_opts=""
10+
mysql_cmd_opts=
1111
mysql_update_every=5
1212

1313
mysql_get_stats() {
1414
mysql "${mysql_cmd_opts}" -s -e "show global status;"
1515
}
1616

1717
mysql_check() {
18+
require_cmd mysql || exit 1
19+
require_cmd egrep || exit 1
20+
require_cmd sed || exit 1
21+
1822
# check once if the url works
1923
local x="$(mysql_get_stats | grep "^Connections[[:space:]]")"
2024
if [ ! $? -eq 0 -o -z "$x" ]

charts.d/nut.chart.sh

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,70 @@ nut_ups=
44
nut_update_every=2
55

66
nut_check() {
7-
if [ -z "${nut_ups}" ]
7+
local x all
8+
9+
require_cmd upsc || return 1
10+
require_cmd awk || return 1
11+
12+
all="$nut_ups"
13+
[ -z "$all" ] && all="$(upsc -l)"
14+
15+
nut_ups=
16+
for x in $all
17+
do
18+
upsc "$x" >/dev/null
19+
[ $? -eq 0 ] && nut_ups="$nut_ups $x" && continue
20+
echo >&2 "nut: ERROR: Cannot get information for NUT UPS '$x'."
21+
done
22+
23+
if [ -z "$nut_ups" ]
824
then
925
echo >&2 "nut: Please set nut_ups='ups_name' in $confd/nut.conf"
1026
return 1
1127
fi
1228

13-
upsc "${nut_ups}" >/dev/null
14-
if [ ! $? -eq 0 ]
15-
then
16-
echo >&2 "nut: failed to fetch info for ups '$nut_ups'. Please set nut_ups='ups_name' in $confd/nut.conf"
17-
return 1
18-
fi
19-
2029
return 0
2130
}
2231

2332
nut_create() {
2433
# create the charts
25-
cat <<EOF
26-
CHART nut.charge '' "UPS Charge" "percentage" nut '' area 21001 $nut_update_every
34+
local x
35+
36+
for x in $nut_ups
37+
do
38+
cat <<EOF
39+
CHART nut_$x.charge '' "UPS Charge" "percentage" $x nut area 21001 $nut_update_every
2740
DIMENSION battery_charge charge absolute 1 100
2841
29-
CHART nut.battery_voltage '' "UPS Battery Voltage" "Volts" nut '' line 21002 $nut_update_every
42+
CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" $x nut line 21002 $nut_update_every
3043
DIMENSION battery_voltage voltage absolute 1 100
3144
DIMENSION battery_voltage_high high absolute 1 100
3245
DIMENSION battery_voltage_low low absolute 1 100
3346
DIMENSION battery_voltage_nominal nominal absolute 1 100
3447
35-
CHART nut.input_voltage '' "UPS Input Voltage" "Volts" nut '' line 21003 $nut_update_every
48+
CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" $x nut line 21003 $nut_update_every
3649
DIMENSION input_voltage voltage absolute 1 100
3750
DIMENSION input_voltage_fault fault absolute 1 100
3851
DIMENSION input_voltage_nominal nominal absolute 1 100
3952
40-
CHART nut.input_current '' "UPS Input Current" "Ampere" nut '' line 21004 $nut_update_every
53+
CHART nut_$x.input_current '' "UPS Input Current" "Ampere" $x nut line 21004 $nut_update_every
4154
DIMENSION input_current_nominal nominal absolute 1 100
4255
43-
CHART nut.input_frequency '' "UPS Input Frequency" "Hz" nut '' line 21005 $nut_update_every
56+
CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" $x nut line 21005 $nut_update_every
4457
DIMENSION input_frequency frequency absolute 1 100
4558
DIMENSION input_frequency_nominal nominal absolute 1 100
4659
47-
CHART nut.output_voltage '' "UPS Output Voltage" "Volts" nut '' line 21006 $nut_update_every
60+
CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" $x nut line 21006 $nut_update_every
4861
DIMENSION output_voltage voltage absolute 1 100
4962
50-
CHART nut.load '' "UPS Load" "percentage" nut '' area 21000 $nut_update_every
63+
CHART nut_$x.load '' "UPS Load" "percentage" $x nut area 21000 $nut_update_every
5164
DIMENSION load load absolute 1 100
5265
53-
CHART nut.temp '' "UPS Temperature" "temperature" nut '' line 21007 $nut_update_every
66+
CHART nut_$x.temp '' "UPS Temperature" "temperature" $x nut line 21007 $nut_update_every
5467
DIMENSION temp temp absolute 1 100
5568
EOF
56-
69+
done
70+
5771
return 0
5872
}
5973

@@ -66,7 +80,11 @@ nut_update() {
6680
# for each dimension
6781
# remember: KEEP IT SIMPLE AND SHORT
6882

69-
upsc "${nut_ups}" | awk "
83+
local x
84+
85+
for x in $nut_ups
86+
do
87+
upsc "$x" | awk "
7088
BEGIN {
7189
battery_charge = 0;
7290
battery_voltage = 0;
@@ -98,45 +116,47 @@ BEGIN {
98116
/^ups.load: .*/ { load = \$2 * 100 };
99117
/^ups.temperature: .*/ { temp = \$2 * 100 };
100118
END {
101-
print \"BEGIN nut.charge $1\";
119+
print \"BEGIN nut_$x.charge $1\";
102120
print \"SET battery_charge = \" battery_charge;
103121
print \"END\"
104122
105-
print \"BEGIN nut.battery_voltage $1\";
123+
print \"BEGIN nut_$x.battery_voltage $1\";
106124
print \"SET battery_voltage = \" battery_voltage;
107125
print \"SET battery_voltage_high = \" battery_voltage_high;
108126
print \"SET battery_voltage_low = \" battery_voltage_low;
109127
print \"SET battery_voltage_nominal = \" battery_voltage_nominal;
110128
print \"END\"
111129
112-
print \"BEGIN nut.input_voltage $1\";
130+
print \"BEGIN nut_$x.input_voltage $1\";
113131
print \"SET input_voltage = \" input_voltage;
114132
print \"SET input_voltage_fault = \" input_voltage_fault;
115133
print \"SET input_voltage_nominal = \" input_voltage_nominal;
116134
print \"END\"
117135
118-
print \"BEGIN nut.input_current $1\";
136+
print \"BEGIN nut_$x.input_current $1\";
119137
print \"SET input_current_nominal = \" input_current_nominal;
120138
print \"END\"
121139
122-
print \"BEGIN nut.input_frequency $1\";
140+
print \"BEGIN nut_$x.input_frequency $1\";
123141
print \"SET input_frequency = \" input_frequency;
124142
print \"SET input_frequency_nominal = \" input_frequency_nominal;
125143
print \"END\"
126144
127-
print \"BEGIN nut.output_voltage $1\";
145+
print \"BEGIN nut_$x.output_voltage $1\";
128146
print \"SET output_voltage = \" output_voltage;
129147
print \"END\"
130148
131-
print \"BEGIN nut.load $1\";
149+
print \"BEGIN nut_$x.load $1\";
132150
print \"SET load = \" load;
133151
print \"END\"
134152
135-
print \"BEGIN nut.temp $1\";
153+
print \"BEGIN nut_$x.temp $1\";
136154
print \"SET temp = \" temp;
137155
print \"END\"
138156
}
139157
"
158+
done
159+
140160
return 0
141161
}
142162

conf.d/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
55

66
dist_config_DATA = \
7+
charts.d.conf \
78
apps_groups.conf \
89
$(NULL)

conf.d/charts.d.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
nut=yes
2+
squid=yes
3+
postfix=yes
4+
sensors=yes
5+
cpufreq=yes
6+
mysql=yes
7+
#example=yes
8+
#load_average=yes

plugins.d/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
MAINTAINERCLEANFILES= $(srcdir)/Makefile.in
55

66
dist_plugins_DATA = \
7-
README \
8-
loopsleepms.sh.inc \
7+
README.md \
98
$(NULL)
109

1110
dist_plugins_SCRIPTS = \
1211
charts.d.dryrun-helper.sh \
1312
charts.d.plugin \
1413
tc-qos-helper.sh \
14+
loopsleepms.sh.inc \
1515
$(NULL)

0 commit comments

Comments
 (0)