| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #include "apps_plugin.h" |
| 4 | |
| 5 | static inline void send_BEGIN(const char *type, const char *name,const char *metric, usec_t usec) { |
| 6 | fprintf(stdout, "BEGIN %s.%s_%s %" PRIu64 "\n", type, name, metric, usec); |
| 7 | } |
| 8 | |
| 9 | static inline void send_SET(const char *name, kernel_uint_t value) { |
| 10 | fprintf(stdout, "SET %s = " KERNEL_UINT_FORMAT "\n", name, value); |
| 11 | } |
| 12 | |
| 13 | static inline void send_END(void) { |
| 14 | fprintf(stdout, "END\n\n"); |
| 15 | } |
| 16 | |
| 17 | void send_resource_usage_to_netdata(usec_t dt) { |
| 18 | static struct timeval last = { 0, 0 }; |
| 19 | static struct rusage me_last; |
| 20 | |
| 21 | struct timeval now; |
| 22 | struct rusage me; |
| 23 | |
| 24 | usec_t cpuuser; |
| 25 | usec_t cpusyst; |
| 26 | |
| 27 | if(!last.tv_sec) { |
| 28 | now_monotonic_timeval(&last); |
| 29 | getrusage(RUSAGE_SELF, &me_last); |
| 30 | |
| 31 | cpuuser = 0; |
| 32 | cpusyst = 0; |
| 33 | } |
| 34 | else { |
| 35 | now_monotonic_timeval(&now); |
| 36 | getrusage(RUSAGE_SELF, &me); |
| 37 | |
| 38 | cpuuser = me.ru_utime.tv_sec * USEC_PER_SEC + me.ru_utime.tv_usec; |
| 39 | cpusyst = me.ru_stime.tv_sec * USEC_PER_SEC + me.ru_stime.tv_usec; |
| 40 | |
| 41 | memmove(&last, &now, sizeof(struct timeval)); |
| 42 | memmove(&me_last, &me, sizeof(struct rusage)); |
| 43 | } |
| 44 | |
| 45 | static char created_charts = 0; |
| 46 | if(unlikely(!created_charts)) { |
| 47 | created_charts = 1; |
| 48 | |
| 49 | fprintf(stdout, |
| 50 | "CHART netdata.apps_cpu '' 'Apps Plugin CPU' 'milliseconds/s' apps.plugin netdata.apps_cpu stacked 140000 %1$d\n" |
| 51 | "DIMENSION user '' incremental 1 1000\n" |
| 52 | "DIMENSION system '' incremental 1 1000\n" |
| 53 | "CHART netdata.apps_sizes '' 'Apps Plugin Files' 'files/s' apps.plugin netdata.apps_sizes line 140001 %1$d\n" |
| 54 | "DIMENSION calls '' incremental 1 1\n" |
| 55 | "DIMENSION files '' incremental 1 1\n" |
| 56 | "DIMENSION filenames '' incremental 1 1\n" |
| 57 | "DIMENSION inode_changes '' incremental 1 1\n" |
| 58 | "DIMENSION link_changes '' incremental 1 1\n" |
| 59 | "DIMENSION pids '' absolute 1 1\n" |
| 60 | "DIMENSION fds '' absolute 1 1\n" |
| 61 | "DIMENSION targets '' absolute 1 1\n" |
| 62 | "DIMENSION new_pids 'new pids' incremental 1 1\n" |
| 63 | , update_every |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | fprintf(stdout, |
| 68 | "BEGIN netdata.apps_cpu %"PRIu64"\n" |
| 69 | "SET user = %"PRIu64"\n" |
| 70 | "SET system = %"PRIu64"\n" |
| 71 | "END\n" |
| 72 | "BEGIN netdata.apps_sizes %"PRIu64"\n" |
| 73 | "SET calls = %zu\n" |
| 74 | "SET files = %zu\n" |
| 75 | "SET filenames = %zu\n" |
| 76 | "SET inode_changes = %zu\n" |
| 77 | "SET link_changes = %zu\n" |
| 78 | "SET pids = %zu\n" |
| 79 | "SET fds = %"PRIu32"\n" |
| 80 | "SET targets = %zu\n" |
| 81 | "SET new_pids = %zu\n" |
| 82 | "END\n" |
| 83 | , dt |
| 84 | , cpuuser |
| 85 | , cpusyst |
| 86 | , dt |
| 87 | , calls_counter |
| 88 | , file_counter |
| 89 | , filenames_allocated_counter |
| 90 | , inodes_changed_counter |
| 91 | , links_changed_counter |
| 92 | , all_pids_count() |
| 93 | , all_files_len_get() |
| 94 | , apps_groups_targets_count |
| 95 | , targets_assignment_counter |
| 96 | ); |
| 97 | } |
| 98 | |
| 99 | void send_collected_data_to_netdata(struct target *root, const char *type, usec_t dt) { |
| 100 | struct target *w; |
| 101 | |
| 102 | for (w = root; w ; w = w->next) { |
| 103 | if (unlikely(!w->exposed)) |
| 104 | continue; |
| 105 | |
| 106 | send_BEGIN(type, string2str(w->clean_name), "processes", dt); |
| 107 | send_SET("processes", w->values[PDF_PROCESSES]); |
| 108 | send_END(); |
| 109 | |
| 110 | send_BEGIN(type, string2str(w->clean_name), "threads", dt); |
| 111 | send_SET("threads", w->values[PDF_THREADS]); |
| 112 | send_END(); |
| 113 | |
| 114 | if (unlikely(!w->values[PDF_PROCESSES])) |
| 115 | continue; |
| 116 | |
| 117 | #if (PROCESSES_HAVE_CPU_CHILDREN_TIME) |
| 118 | send_BEGIN(type, string2str(w->clean_name), "cpu_utilization", dt); |
| 119 | send_SET("user", (kernel_uint_t)(w->values[PDF_UTIME] * utime_fix_ratio) + (include_exited_childs ? ((kernel_uint_t)(w->values[PDF_CUTIME] * cutime_fix_ratio)) : 0ULL)); |
| 120 | send_SET("system", (kernel_uint_t)(w->values[PDF_STIME] * stime_fix_ratio) + (include_exited_childs ? ((kernel_uint_t)(w->values[PDF_CSTIME] * cstime_fix_ratio)) : 0ULL)); |
| 121 | send_END(); |
| 122 | #else |
| 123 | send_BEGIN(type, string2str(w->clean_name), "cpu_utilization", dt); |
| 124 | send_SET("user", (kernel_uint_t)(w->values[PDF_UTIME] * utime_fix_ratio)); |
| 125 | send_SET("system", (kernel_uint_t)(w->values[PDF_STIME] * stime_fix_ratio)); |
| 126 | send_END(); |
| 127 | #endif |
| 128 | |
| 129 | #if (PROCESSES_HAVE_CPU_GUEST_TIME == 1) |
| 130 | if (enable_guest_charts) { |
| 131 | send_BEGIN(type, string2str(w->clean_name), "cpu_guest_utilization", dt); |
| 132 | send_SET("guest", (kernel_uint_t)(w->values[PDF_GTIME] * gtime_fix_ratio) |
| 133 | #if (PROCESSES_HAVE_CPU_CHILDREN_TIME == 1) |
| 134 | + (include_exited_childs ? ((kernel_uint_t)(w->values[PDF_CGTIME] * cgtime_fix_ratio)) : 0ULL) |
| 135 | #endif |
| 136 | ); |
| 137 | send_END(); |
| 138 | } |
| 139 | #endif |
| 140 | |
| 141 | #ifndef OS_WINDOWS |
| 142 | send_BEGIN(type, string2str(w->clean_name), "mem_private_usage", dt); |
| 143 | #if (PROCESSES_HAVE_VMSHARED == 1) |
| 144 | send_SET("mem", (w->values[PDF_VMRSS] > w->values[PDF_VMSHARED])?(w->values[PDF_VMRSS] - w->values[PDF_VMSHARED]) : 0ULL); |
| 145 | #else |
| 146 | send_SET("mem", w->values[PDF_VMRSS]); |
| 147 | #endif |
| 148 | send_END(); |
| 149 | #endif //OS_WINDOWS |
| 150 | |
| 151 | #if (PROCESSES_HAVE_VOLCTX == 1) || (PROCESSES_HAVE_NVOLCTX == 1) |
| 152 | send_BEGIN(type, string2str(w->clean_name), "cpu_context_switches", dt); |
| 153 | #if (PROCESSES_HAVE_VOLCTX == 1) |
| 154 | send_SET("voluntary", w->values[PDF_VOLCTX]); |
| 155 | #endif |
| 156 | #if (PROCESSES_HAVE_NVOLCTX == 1) |
| 157 | send_SET("involuntary", w->values[PDF_NVOLCTX]); |
| 158 | #endif |
| 159 | send_END(); |
| 160 | #endif |
| 161 | |
| 162 | #if (PROCESSES_HAVE_SMAPS_ROLLUP == 1) |
| 163 | if(pss_refresh_period > 0) { |
| 164 | send_BEGIN(type, string2str(w->clean_name), "estimated_mem_usage", dt); |
| 165 | send_SET("mem", w->values[PDF_MEM_ESTIMATED]); |
| 166 | send_END(); |
| 167 | } |
| 168 | #endif |
| 169 | |
| 170 | send_BEGIN(type, string2str(w->clean_name), "mem_usage", dt); |
| 171 | send_SET("rss", w->values[PDF_VMRSS]); |
| 172 | send_END(); |
| 173 | |
| 174 | send_BEGIN(type, string2str(w->clean_name), "vmem_usage", dt); |
| 175 | send_SET("vmem", w->values[PDF_VMSIZE]); |
| 176 | send_END(); |
| 177 | |
| 178 | send_BEGIN(type, string2str(w->clean_name), "mem_page_faults", dt); |
| 179 | send_SET("minor", (kernel_uint_t)(w->values[PDF_MINFLT] * minflt_fix_ratio) |
| 180 | #if (PROCESSES_HAVE_CHILDREN_FLTS == 1) |
| 181 | + (include_exited_childs ? ((kernel_uint_t)(w->values[PDF_CMINFLT] * cminflt_fix_ratio)) : 0ULL) |
| 182 | #endif |
| 183 | ); |
| 184 | #if (PROCESSES_HAVE_MAJFLT == 1) |
| 185 | send_SET("major", (kernel_uint_t)(w->values[PDF_MAJFLT] * majflt_fix_ratio) |
| 186 | #if (PROCESSES_HAVE_CHILDREN_FLTS == 1) |
| 187 | + (include_exited_childs ? ((kernel_uint_t)(w->values[PDF_CMAJFLT] * cmajflt_fix_ratio)) : 0ULL) |
| 188 | #endif |
| 189 | ); |
| 190 | #endif |
| 191 | send_END(); |
| 192 | |
| 193 | #if (PROCESSES_HAVE_VMSWAP == 1) |
| 194 | send_BEGIN(type, string2str(w->clean_name), "swap_usage", dt); |
| 195 | send_SET("swap", w->values[PDF_VMSWAP]); |
| 196 | send_END(); |
| 197 | #endif |
| 198 | |
| 199 | send_BEGIN(type, string2str(w->clean_name), "uptime", dt); |
| 200 | send_SET("uptime", w->uptime_max); |
| 201 | send_END(); |
| 202 | |
| 203 | if (enable_detailed_uptime_charts) { |
| 204 | send_BEGIN(type, string2str(w->clean_name), "uptime_summary", dt); |
| 205 | send_SET("min", w->uptime_min); |
| 206 | send_SET("avg", w->values[PDF_PROCESSES] > 0 ? w->values[PDF_UPTIME] / w->values[PDF_PROCESSES] : 0); |
| 207 | send_SET("max", w->uptime_max); |
| 208 | send_END(); |
| 209 | } |
| 210 | |
| 211 | #if (PROCESSES_HAVE_PHYSICAL_IO == 1) |
| 212 | send_BEGIN(type, string2str(w->clean_name), "disk_physical_io", dt); |
| 213 | send_SET("reads", w->values[PDF_PREAD]); |
| 214 | send_SET("writes", w->values[PDF_PWRITE]); |
| 215 | send_END(); |
| 216 | #endif |
| 217 | |
| 218 | #if (PROCESSES_HAVE_LOGICAL_IO == 1) |
| 219 | send_BEGIN(type, string2str(w->clean_name), "disk_logical_io", dt); |
| 220 | send_SET("reads", w->values[PDF_LREAD]); |
| 221 | send_SET("writes", w->values[PDF_LWRITE]); |
| 222 | send_END(); |
| 223 | #endif |
| 224 | |
| 225 | if (enable_file_charts) { |
| 226 | #if (PROCESSES_HAVE_FDS == 1) |
| 227 | send_BEGIN(type, string2str(w->clean_name), "fds_open_limit", dt); |
| 228 | send_SET("limit", w->max_open_files_percent * 100.0); |
| 229 | send_END(); |
| 230 | #endif |
| 231 | |
| 232 | send_BEGIN(type, string2str(w->clean_name), "fds_open", dt); |
| 233 | #if (PROCESSES_HAVE_FDS == 1) |
| 234 | send_SET("files", w->openfds.files); |
| 235 | send_SET("sockets", w->openfds.sockets); |
| 236 | send_SET("pipes", w->openfds.pipes); |
| 237 | send_SET("inotifies", w->openfds.inotifies); |
| 238 | send_SET("event", w->openfds.eventfds); |
| 239 | send_SET("timer", w->openfds.timerfds); |
| 240 | send_SET("signal", w->openfds.signalfds); |
| 241 | send_SET("eventpolls", w->openfds.eventpolls); |
| 242 | send_SET("other", w->openfds.other); |
| 243 | #endif |
| 244 | #if (PROCESSES_HAVE_HANDLES == 1) |
| 245 | send_SET("handles", w->values[PDF_HANDLES]); |
| 246 | #endif |
| 247 | send_END(); |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | |
| 253 | // ---------------------------------------------------------------------------- |
| 254 | // generate the charts |
| 255 | |
| 256 | static void send_file_charts_to_netdata(struct target *w, const char *type, const char *lbl_name, const char *title, bool obsolete) { |
| 257 | #if (PROCESSES_HAVE_FDS == 1) |
| 258 | fprintf(stdout, "CHART %s.%s_fds_open_limit '' '%s open file descriptors limit' '%%' fds %s.fds_open_limit line 20200 %d %s\n", |
| 259 | type, string2str(w->clean_name), title, type, update_every, obsolete ? "obsolete" : ""); |
| 260 | |
| 261 | if(!obsolete) { |
| 262 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 263 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 264 | fprintf(stdout, "DIMENSION limit '' absolute 1 100\n"); |
| 265 | } |
| 266 | #endif |
| 267 | |
| 268 | #if (PROCESSES_HAVE_FDS == 1) || (PROCESSES_HAVE_HANDLES == 1) |
| 269 | fprintf(stdout, "CHART %s.%s_fds_open '' '%s open files descriptors' 'fds' fds %s.fds_open stacked 20210 %d %s\n", |
| 270 | type, string2str(w->clean_name), title, type, update_every, obsolete ? "obsolete" : ""); |
| 271 | |
| 272 | if(!obsolete) { |
| 273 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 274 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 275 | #if (PROCESSES_HAVE_FDS == 1) |
| 276 | fprintf(stdout, "DIMENSION files '' absolute 1 1\n"); |
| 277 | fprintf(stdout, "DIMENSION sockets '' absolute 1 1\n"); |
| 278 | fprintf(stdout, "DIMENSION pipes '' absolute 1 1\n"); |
| 279 | fprintf(stdout, "DIMENSION inotifies '' absolute 1 1\n"); |
| 280 | fprintf(stdout, "DIMENSION event '' absolute 1 1\n"); |
| 281 | fprintf(stdout, "DIMENSION timer '' absolute 1 1\n"); |
| 282 | fprintf(stdout, "DIMENSION signal '' absolute 1 1\n"); |
| 283 | fprintf(stdout, "DIMENSION eventpolls '' absolute 1 1\n"); |
| 284 | fprintf(stdout, "DIMENSION other '' absolute 1 1\n"); |
| 285 | #endif // PROCESSES_HAVE_FDS |
| 286 | #if (PROCESSES_HAVE_HANDLES == 1) |
| 287 | fprintf(stdout, "DIMENSION handles '' absolute 1 1\n"); |
| 288 | #endif // PROCESSES_HAVE_HANDLES |
| 289 | } |
| 290 | #endif // PROCESSES_HAVE_FDS || PROCESSES_HAVE_HANDLES |
| 291 | } |
| 292 | |
| 293 | void send_charts_updates_to_netdata(struct target *root, const char *type, const char *lbl_name, const char *title) { |
| 294 | struct target *w; |
| 295 | |
| 296 | bool disable_file_charts_on_this_run = obsolete_file_charts; |
| 297 | obsolete_file_charts = false; |
| 298 | |
| 299 | for (w = root; w; w = w->next) { |
| 300 | if (likely(w->exposed || (!w->values[PDF_PROCESSES]))) { |
| 301 | if(w->exposed && disable_file_charts_on_this_run) |
| 302 | send_file_charts_to_netdata(w, type, lbl_name, title, true); |
| 303 | continue; |
| 304 | } |
| 305 | |
| 306 | w->exposed = true; |
| 307 | |
| 308 | fprintf(stdout, "CHART %s.%s_cpu_utilization '' '%s CPU utilization (100%% = 1 core)' 'percentage' cpu %s.cpu_utilization stacked 20001 %d\n", |
| 309 | type, string2str(w->clean_name), title, type, update_every); |
| 310 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 311 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 312 | fprintf(stdout, "DIMENSION user '' absolute 1 %llu\n", NSEC_PER_SEC / 100ULL); |
| 313 | fprintf(stdout, "DIMENSION system '' absolute 1 %llu\n", NSEC_PER_SEC / 100ULL); |
| 314 | |
| 315 | #if (PROCESSES_HAVE_CPU_GUEST_TIME == 1) |
| 316 | if (enable_guest_charts) { |
| 317 | fprintf(stdout, "CHART %s.%s_cpu_guest_utilization '' '%s CPU guest utlization (100%% = 1 core)' 'percentage' cpu %s.cpu_guest_utilization line 20005 %d\n", |
| 318 | type, string2str(w->clean_name), title, type, update_every); |
| 319 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 320 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 321 | fprintf(stdout, "DIMENSION guest '' absolute 1 %llu\n", NSEC_PER_SEC / 100ULL); |
| 322 | } |
| 323 | #endif |
| 324 | |
| 325 | #ifndef OS_WINDOWS |
| 326 | fprintf(stdout, "CHART %s.%s_mem_private_usage '' '%s memory usage without shared' 'MiB' mem %s.mem_private_usage area 20050 %d\n", |
| 327 | type, string2str(w->clean_name), title, type, update_every); |
| 328 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 329 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 330 | fprintf(stdout, "DIMENSION mem '' absolute %ld %ld\n", 1L, 1024L * 1024L); |
| 331 | #endif //OS_WINDOWS |
| 332 | |
| 333 | #if (PROCESSES_HAVE_VOLCTX == 1) || (PROCESSES_HAVE_NVOLCTX == 1) |
| 334 | fprintf(stdout, "CHART %s.%s_cpu_context_switches '' '%s CPU context switches' 'switches/s' cpu %s.cpu_context_switches stacked 20010 %d\n", |
| 335 | type, string2str(w->clean_name), title, type, update_every); |
| 336 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 337 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 338 | #if (PROCESSES_HAVE_VOLCTX == 1) |
| 339 | fprintf(stdout, "DIMENSION voluntary '' absolute 1 %llu\n", RATES_DETAIL); |
| 340 | #endif |
| 341 | #if (PROCESSES_HAVE_NVOLCTX == 1) |
| 342 | fprintf(stdout, "DIMENSION involuntary '' absolute 1 %llu\n", RATES_DETAIL); |
| 343 | #endif |
| 344 | #endif |
| 345 | |
| 346 | #if (PROCESSES_HAVE_SMAPS_ROLLUP == 1) |
| 347 | if(pss_refresh_period > 0) { |
| 348 | fprintf(stdout, "CHART %s.%s_estimated_mem_usage '' '%s estimated memory usage (RSS with shared scaling)' 'MiB' mem %s.estimated_mem_usage area 20055 %d\n", |
| 349 | type, string2str(w->clean_name), title, type, update_every); |
| 350 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 351 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 352 | fprintf(stdout, "DIMENSION mem '' absolute %ld %ld\n", 1L, 1024L * 1024L); |
| 353 | } |
| 354 | #endif |
| 355 | |
| 356 | fprintf(stdout, "CHART %s.%s_mem_usage '' '%s memory RSS usage' 'MiB' mem %s.mem_usage area 20055 %d\n", |
| 357 | type, string2str(w->clean_name), title, type, update_every); |
| 358 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 359 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 360 | fprintf(stdout, "DIMENSION rss '' absolute %ld %ld\n", 1L, 1024L * 1024L); |
| 361 | |
| 362 | fprintf(stdout, "CHART %s.%s_vmem_usage '' '%s virtual memory size' 'MiB' mem %s.vmem_usage line 20065 %d\n", |
| 363 | type, string2str(w->clean_name), title, type, update_every); |
| 364 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 365 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 366 | fprintf(stdout, "DIMENSION vmem '' absolute %ld %ld\n", 1L, 1024L * 1024L); |
| 367 | |
| 368 | fprintf(stdout, "CHART %s.%s_mem_page_faults '' '%s memory page faults' 'pgfaults/s' mem %s.mem_page_faults stacked 20060 %d\n", |
| 369 | type, string2str(w->clean_name), title, type, update_every); |
| 370 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 371 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 372 | fprintf(stdout, "DIMENSION minor '' absolute 1 %llu\n", RATES_DETAIL); |
| 373 | #if (PROCESSES_HAVE_MAJFLT == 1) |
| 374 | fprintf(stdout, "DIMENSION major '' absolute 1 %llu\n", RATES_DETAIL); |
| 375 | #endif |
| 376 | |
| 377 | #if (PROCESSES_HAVE_VMSWAP == 1) |
| 378 | fprintf(stdout, "CHART %s.%s_swap_usage '' '%s swap usage' 'MiB' mem %s.swap_usage area 20065 %d\n", |
| 379 | type, string2str(w->clean_name), title, type, update_every); |
| 380 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 381 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 382 | fprintf(stdout, "DIMENSION swap '' absolute %ld %ld\n", 1L, 1024L * 1024L); |
| 383 | #endif |
| 384 | |
| 385 | #if (PROCESSES_HAVE_PHYSICAL_IO == 1) |
| 386 | fprintf(stdout, "CHART %s.%s_disk_physical_io '' '%s disk physical IO' 'KiB/s' disk %s.disk_physical_io area 20100 %d\n", |
| 387 | type, string2str(w->clean_name), title, type, update_every); |
| 388 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 389 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 390 | fprintf(stdout, "DIMENSION reads '' absolute 1 %llu\n", 1024LLU * RATES_DETAIL); |
| 391 | fprintf(stdout, "DIMENSION writes '' absolute -1 %llu\n", 1024LLU * RATES_DETAIL); |
| 392 | #endif |
| 393 | |
| 394 | #if (PROCESSES_HAVE_LOGICAL_IO == 1) |
| 395 | fprintf(stdout, "CHART %s.%s_disk_logical_io '' '%s disk logical IO' 'KiB/s' disk %s.disk_logical_io area 20105 %d\n", |
| 396 | type, string2str(w->clean_name), title, type, update_every); |
| 397 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 398 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 399 | fprintf(stdout, "DIMENSION reads '' absolute 1 %llu\n", 1024LLU * RATES_DETAIL); |
| 400 | fprintf(stdout, "DIMENSION writes '' absolute -1 %llu\n", 1024LLU * RATES_DETAIL); |
| 401 | #endif |
| 402 | |
| 403 | fprintf(stdout, "CHART %s.%s_processes '' '%s processes' 'processes' processes %s.processes line 20150 %d\n", |
| 404 | type, string2str(w->clean_name), title, type, update_every); |
| 405 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 406 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 407 | fprintf(stdout, "DIMENSION processes '' absolute 1 1\n"); |
| 408 | |
| 409 | fprintf(stdout, "CHART %s.%s_threads '' '%s threads' 'threads' processes %s.threads line 20155 %d\n", |
| 410 | type, string2str(w->clean_name), title, type, update_every); |
| 411 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 412 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 413 | fprintf(stdout, "DIMENSION threads '' absolute 1 1\n"); |
| 414 | |
| 415 | if (enable_file_charts) |
| 416 | send_file_charts_to_netdata(w, type, lbl_name, title, false); |
| 417 | |
| 418 | fprintf(stdout, "CHART %s.%s_uptime '' '%s uptime' 'seconds' uptime %s.uptime line 20250 %d\n", |
| 419 | type, string2str(w->clean_name), title, type, update_every); |
| 420 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 421 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 422 | fprintf(stdout, "DIMENSION uptime '' absolute 1 1\n"); |
| 423 | |
| 424 | if (enable_detailed_uptime_charts) { |
| 425 | fprintf(stdout, "CHART %s.%s_uptime_summary '' '%s uptime summary' 'seconds' uptime %s.uptime_summary area 20255 %d\n", |
| 426 | type, string2str(w->clean_name), title, type, update_every); |
| 427 | fprintf(stdout, "CLABEL '%s' '%s' 1\n", lbl_name, string2str(w->name)); |
| 428 | fprintf(stdout, "CLABEL_COMMIT\n"); |
| 429 | fprintf(stdout, "DIMENSION min '' absolute 1 1\n"); |
| 430 | fprintf(stdout, "DIMENSION avg '' absolute 1 1\n"); |
| 431 | fprintf(stdout, "DIMENSION max '' absolute 1 1\n"); |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | #if (PROCESSES_HAVE_STATE == 1) |
| 437 | void send_proc_states_count(usec_t dt __maybe_unused) { |
| 438 | static bool chart_added = false; |
| 439 | // create chart for count of processes in different states |
| 440 | if (!chart_added) { |
| 441 | fprintf( |
| 442 | stdout, |
| 443 | "CHART system.processes_state '' 'System Processes State' 'processes' processes system.processes_state line %d %d\n", |
| 444 | NETDATA_CHART_PRIO_SYSTEM_PROCESS_STATES, |
| 445 | update_every); |
| 446 | for (proc_state i = PROC_STATUS_RUNNING; i < PROC_STATUS_END; i++) { |
| 447 | fprintf(stdout, "DIMENSION %s '' absolute 1 1\n", proc_states[i]); |
| 448 | } |
| 449 | chart_added = true; |
| 450 | } |
| 451 | |
| 452 | // send process state count |
| 453 | fprintf(stdout, "BEGIN system.processes_state %" PRIu64 "\n", dt); |
| 454 | for (proc_state i = PROC_STATUS_RUNNING; i < PROC_STATUS_END; i++) { |
| 455 | send_SET(proc_states[i], proc_state_count[i]); |
| 456 | } |
| 457 | send_END(); |
| 458 | } |
| 459 | #endif |