Skip to content

Commit 8f36f5b

Browse files
authored
info API minor enhancements
Return 503 instead of 400 when netdata hasnt started yet, move struct definitions in .c, swagger update (netdata#5891)
1 parent 0e54203 commit 8f36f5b

5 files changed

Lines changed: 171 additions & 12 deletions

File tree

web/api/formatters/charts2json.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ void charts2json(RRDHOST *host, BUFFER *wb) {
136136
buffer_sprintf(wb, "\n\t]\n}\n");
137137
}
138138

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+
139151
int print_collector(void *entry, void *data) {
140152
struct array_printer *ap = (struct array_printer *)data;
141153
BUFFER *wb = ap->wb;

web/api/formatters/charts2json.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55

66
#include "rrd2json.h"
77

8-
struct collector {
9-
char *plugin;
10-
char *module;
11-
};
12-
13-
struct array_printer {
14-
int c;
15-
BUFFER *wb;
16-
};
17-
188
extern void charts2json(RRDHOST *host, BUFFER *wb);
199
extern void chartcollectors2json(RRDHOST *host, BUFFER *wb);
2010

web/api/netdata-swagger.json

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
"/info": {
1919
"get": {
2020
"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",
2222
"responses": {
2323
"200": {
2424
"description": "netdata basic information",
2525
"schema": {
2626
"$ref": "#/definitions/info"
2727
}
28+
},
29+
"503": {
30+
"description": "netdata daemon not ready (used for health checks)"
2831
}
2932
}
3033
}
@@ -706,6 +709,90 @@
706709
"host2.example.com"
707710
]
708711
},
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+
},
709796
"alarms": {
710797
"type": "object",
711798
"description": "number of alarms in the server.",

web/api/netdata-swagger.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ paths:
2020
* netdata version
2121
* netdata unique id
2222
* list of hosts mirrored (includes itself)
23+
* Operating System, Virtualization and Container technology information
24+
* List of active collector plugins and modules
2325
* number of alarms in the host
2426
* number of alarms in normal state
2527
* number of alarms in warning state
@@ -29,6 +31,8 @@ paths:
2931
description: netdata basic information
3032
schema:
3133
$ref: '#/definitions/info'
34+
'503':
35+
description: netdata daemon not ready (used for health checks)
3236
/charts:
3337
get:
3438
summary: 'Get a list of all charts available at the server'
@@ -460,6 +464,72 @@ definitions:
460464
example:
461465
- host1.example.com
462466
- 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
463533
alarms:
464534
type: object
465535
description: number of alarms in the server.

web/api/web_api_v1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ static inline void web_client_api_request_v1_info_mirrored_hosts(BUFFER *wb) {
717717

718718
inline int web_client_api_request_v1_info(RRDHOST *host, struct web_client *w, char *url) {
719719
(void)url;
720-
if (!netdata_ready) return 400;
720+
if (!netdata_ready) return 503;
721721

722722
BUFFER *wb = w->response.data;
723723
buffer_flush(wb);

0 commit comments

Comments
 (0)