master
md 64 lines 1.53 KB
Rendered Raw
1 # Shell exporter
2
3 Shell scripts can now query Netdata:
4
5 ```sh
6 eval "$(curl -s 'http://localhost:19999/api/v3/allmetrics')"
7 ```
8
9 after this command, all the Netdata metrics are exposed to shell. Check:
10
11 ```sh
12 # source the metrics
13 eval "$(curl -s 'http://localhost:19999/api/v3/allmetrics')"
14
15 # let's see if there are variables exposed by Netdata for system.cpu
16 set | grep "^NETDATA_SYSTEM_CPU"
17
18 NETDATA_SYSTEM_CPU_GUEST=0
19 NETDATA_SYSTEM_CPU_GUEST_NICE=0
20 NETDATA_SYSTEM_CPU_IDLE=95
21 NETDATA_SYSTEM_CPU_IOWAIT=0
22 NETDATA_SYSTEM_CPU_IRQ=0
23 NETDATA_SYSTEM_CPU_NICE=0
24 NETDATA_SYSTEM_CPU_SOFTIRQ=0
25 NETDATA_SYSTEM_CPU_STEAL=0
26 NETDATA_SYSTEM_CPU_SYSTEM=1
27 NETDATA_SYSTEM_CPU_USER=4
28 NETDATA_SYSTEM_CPU_VISIBLETOTAL=5
29
30 # let's see the total cpu utilization of the system
31 echo ${NETDATA_SYSTEM_CPU_VISIBLETOTAL}
32 5
33
34 # what about alerts?
35 set | grep "^NETDATA_ALARM_SYSTEM_SWAP_"
36 NETDATA_ALARM_SYSTEM_SWAP_USED_SWAP_STATUS=CLEAR
37 NETDATA_ALARM_SYSTEM_SWAP_USED_SWAP_VALUE=51
38
39 # let's get the current status of the alert 'used swap'
40 echo ${NETDATA_ALARM_SYSTEM_SWAP_USED_SWAP_STATUS}
41 CLEAR
42
43 # is it fast?
44 time curl -s 'http://localhost:19999/api/v3/allmetrics' >/dev/null
45
46 real 0m0,070s
47 user 0m0,000s
48 sys 0m0,007s
49
50 # it is...
51 # 0.07 seconds for curl to be loaded, connect to Netdata and fetch the response back...
52 ```
53
54 The `_VISIBLETOTAL` variable sums up all the dimensions of each chart.
55
56 The format of the variables is:
57
58 ```sh
59 NETDATA_${chart_id^^}_${dimension_id^^}="${value}"
60 ```
61
62 The value is rounded to the closest integer, since shell script cannot process decimal numbers.
63
64