info API minor enhancements
Return 503 instead of 400 when netdata hasnt started yet, move struct definitions in .c, swagger update (#5891)
Chris Akritidis committed
May 2, 2019 at 13:04 UTC
8f36f5bcee2c467b0ea2b71d205cef44d6c0de52
5 files changed
+171
-12
web/api/formatters/charts2json.c
+12
@@ -136,6 +136,18 @@ void charts2json(RRDHOST *host, BUFFER *wb) {
136
buffer_sprintf(wb, "\n\t]\n}\n");
137
}
138
139
+// generate collectors list for the api/v1/info call
140
+
141
+struct collector {
142
+ char *plugin;
143
+ char *module;
144
+};
145
+
146
+struct array_printer {
147
+ int c;
148
+ BUFFER *wb;
149
+};
150
+
151
int print_collector(void *entry, void *data) {
152
struct array_printer *ap = (struct array_printer *)data;
153
BUFFER *wb = ap->wb;
web/api/formatters/charts2json.h
-10
@@ -5,16 +5,6 @@
5
6
#include "rrd2json.h"
7
8
-struct collector {
9
- char *plugin;
10
- char *module;
11
-};
12
-
13
-struct array_printer {
14
- int c;
15
- BUFFER *wb;
16
-};
17
-
8
extern void charts2json(RRDHOST *host, BUFFER *wb);
9
extern void chartcollectors2json(RRDHOST *host, BUFFER *wb);
10
web/api/netdata-swagger.json
+88
-1
@@ -18,13 +18,16 @@
18
"/info": {
19
"get": {
20
"summary": "Get netdata basic information",
21
- "description": "The info endpoint returns basic information about netdata. It provides:\n* netdata version\n* netdata unique id\n* list of hosts mirrored (includes itself)\n* number of alarms in the host\n * number of alarms in normal state\n * number of alarms in warning state\n * number of alarms in critical state\n",
21
+ "description": "The info endpoint returns basic information about netdata. It provides:\n* netdata version\n* netdata unique id\n* list of hosts mirrored (includes itself)\n* Operating System, Virtualization and Container technology information\n* List of active collector plugins and modules\n* number of alarms in the host\n * number of alarms in normal state\n * number of alarms in warning state\n * number of alarms in critical state\n",
22
"responses": {
23
"200": {
24
"description": "netdata basic information",
25
"schema": {
26
"$ref": "#/definitions/info"
27
}
28
+ },
29
+ "503": {
30
+ "description": "netdata daemon not ready (used for health checks)"
31
}
32
}
33
}
@@ -706,6 +709,90 @@
709
"host2.example.com"
710
]
711
},
712
+ "os_name": {
713
+ "type": "string",
714
+ "description": "Operating System Name",
715
+ "example": "Manjaro Linux"
716
+ },
717
+ "os_id": {
718
+ "type": "string",
719
+ "description": "Operating System ID",
720
+ "example": "manjaro"
721
+ },
722
+ "os_id_like": {
723
+ "type": "string",
724
+ "description": "Known OS similar to this OS",
725
+ "example": "arch"
726
+ },
727
+ "os_version": {
728
+ "type": "string",
729
+ "description": "Operating System Version",
730
+ "example": "18.0.4"
731
+ },
732
+ "os_version_id": {
733
+ "type": "string",
734
+ "description": "Operating System Version ID",
735
+ "example": "unknown"
736
+ },
737
+ "os_detection": {
738
+ "type": "string",
739
+ "description": "OS parameters detection method",
740
+ "example": "Mixed"
741
+ },
742
+ "kernel_name": {
743
+ "type": "string",
744
+ "description": "Kernel Name",
745
+ "example": "Linux"
746
+ },
747
+ "kernel_version": {
748
+ "type": "string",
749
+ "description": "Kernel Version",
750
+ "example": "4.19.32-1-MANJARO"
751
+ },
752
+ "architecture": {
753
+ "type": "string",
754
+ "description": "Kernel architecture",
755
+ "example": "x86_64"
756
+ },
757
+ "virtualization": {
758
+ "type": "string",
759
+ "description": "Virtualization Type",
760
+ "example": "kvm"
761
+ },
762
+ "virt_detection": {
763
+ "type": "string",
764
+ "description": "Virtualization detection method",
765
+ "example": "systemd-detect-virt"
766
+ },
767
+ "container": {
768
+ "type": "string",
769
+ "description": "Container technology",
770
+ "example": "docker"
771
+ },
772
+ "container_detection": {
773
+ "type": "string",
774
+ "description": "Container technology detection method",
775
+ "example": "dockerenv"
776
+ },
777
+ "collectors": {
778
+ "type": "array",
779
+ "items": {
780
+ "type": "object",
781
+ "description": "Array of collector plugins and modules",
782
+ "properties": {
783
+ "plugin": {
784
+ "type": "string",
785
+ "description": "Collector plugin",
786
+ "example": "python.d.plugin"
787
+ },
788
+ "module": {
789
+ "type": "string",
790
+ "description": "Module of the collector plugin",
791
+ "example": "dockerd"
792
+ }
793
+ }
794
+ }
795
+ },
796
"alarms": {
797
"type": "object",
798
"description": "number of alarms in the server.",
web/api/netdata-swagger.yaml
+70
@@ -20,6 +20,8 @@ paths:
20
* netdata version
21
* netdata unique id
22
* list of hosts mirrored (includes itself)
23
+ * Operating System, Virtualization and Container technology information
24
+ * List of active collector plugins and modules
25
* number of alarms in the host
26
* number of alarms in normal state
27
* number of alarms in warning state
@@ -29,6 +31,8 @@ paths:
31
description: netdata basic information
32
schema:
33
$ref: '#/definitions/info'
34
+ '503':
35
+ description: netdata daemon not ready (used for health checks)
36
/charts:
37
get:
38
summary: 'Get a list of all charts available at the server'
@@ -460,6 +464,72 @@ definitions:
464
example:
465
- host1.example.com
466
- host2.example.com
467
+ os_name:
468
+ type: string
469
+ description: Operating System Name
470
+ example: Manjaro Linux
471
+ os_id:
472
+ type: string
473
+ description: Operating System ID
474
+ example: manjaro
475
+ os_id_like:
476
+ type: string
477
+ description: Known OS similar to this OS
478
+ example: arch
479
+ os_version:
480
+ type: string
481
+ description: Operating System Version
482
+ example: 18.0.4
483
+ os_version_id:
484
+ type: string
485
+ description: Operating System Version ID
486
+ example: unknown
487
+ os_detection:
488
+ type: string
489
+ description: OS parameters detection method
490
+ example: Mixed
491
+ kernel_name:
492
+ type: string
493
+ description: Kernel Name
494
+ example: Linux
495
+ kernel_version:
496
+ type: string
497
+ description: Kernel Version
498
+ example: 4.19.32-1-MANJARO
499
+ architecture:
500
+ type: string
501
+ description: Kernel architecture
502
+ example: x86_64
503
+ virtualization:
504
+ type: string
505
+ description: Virtualization Type
506
+ example: kvm
507
+ virt_detection:
508
+ type: string
509
+ description: Virtualization detection method
510
+ example: systemd-detect-virt
511
+ container:
512
+ type: string
513
+ description: Container technology
514
+ example: docker
515
+ container_detection:
516
+ type: string
517
+ description: Container technology detection method
518
+ example: dockerenv
519
+ collectors:
520
+ type: array
521
+ items:
522
+ type: object
523
+ description: Array of collector plugins and modules
524
+ properties:
525
+ plugin:
526
+ type: string
527
+ description: Collector plugin
528
+ example: python.d.plugin
529
+ module:
530
+ type: string
531
+ description: Module of the collector plugin
532
+ example: dockerd
533
alarms:
534
type: object
535
description: number of alarms in the server.
web/api/web_api_v1.c
+1
-1
@@ -717,7 +717,7 @@ static inline void web_client_api_request_v1_info_mirrored_hosts(BUFFER *wb) {
717
718
inline int web_client_api_request_v1_info(RRDHOST *host, struct web_client *w, char *url) {
719
(void)url;
720
- if (!netdata_ready) return 400;
720
+ if (!netdata_ready) return 503;
721
722
BUFFER *wb = w->response.data;
723
buffer_flush(wb);