Add support for process count
This commit is contained in:
parent
2d675dbf40
commit
bbc9ff99cb
|
@ -48,6 +48,8 @@ static int _refresh_status_parse_diskusage_volume(DaMon * damon,
|
||||||
char const * hostname, char const * volume, json_t * json);
|
char const * hostname, char const * volume, json_t * json);
|
||||||
static int _refresh_status_parse_loadavg(DaMon * damon, char const * hostname,
|
static int _refresh_status_parse_loadavg(DaMon * damon, char const * hostname,
|
||||||
json_t * json);
|
json_t * json);
|
||||||
|
static int _refresh_status_parse_procs(DaMon * damon, char const * hostname,
|
||||||
|
json_t * json);
|
||||||
static int _refresh_status_parse_w(DaMon * damon, char const * hostname,
|
static int _refresh_status_parse_w(DaMon * damon, char const * hostname,
|
||||||
json_t * json);
|
json_t * json);
|
||||||
|
|
||||||
|
@ -127,6 +129,9 @@ static int _refresh_status_parse(DaMon * damon, json_t * json)
|
||||||
else if(strcmp("loadavg", status) == 0)
|
else if(strcmp("loadavg", status) == 0)
|
||||||
_refresh_status_parse_loadavg(damon, hostname,
|
_refresh_status_parse_loadavg(damon, hostname,
|
||||||
value);
|
value);
|
||||||
|
else if(strcmp("procs", status) == 0)
|
||||||
|
_refresh_status_parse_procs(damon, hostname,
|
||||||
|
value);
|
||||||
else if(strcmp("w", status) == 0)
|
else if(strcmp("w", status) == 0)
|
||||||
_refresh_status_parse_w(damon, hostname, value);
|
_refresh_status_parse_w(damon, hostname, value);
|
||||||
}
|
}
|
||||||
|
@ -225,6 +230,30 @@ static int _refresh_status_parse_loadavg(DaMon * damon, char const * hostname,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _refresh_status_parse_procs(DaMon * damon, char const * hostname,
|
||||||
|
json_t * json)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
uint64_t count = 0;
|
||||||
|
size_t index;
|
||||||
|
json_t * value;
|
||||||
|
char * rrd;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s(\"%s\", %d)\n", __func__, hostname,
|
||||||
|
json_typeof(json));
|
||||||
|
#endif
|
||||||
|
if(!json_is_array(json))
|
||||||
|
return -1;
|
||||||
|
json_array_foreach(json, index, value)
|
||||||
|
count++;
|
||||||
|
if((rrd = string_new_append(hostname, "/procs.rrd", NULL)) == NULL)
|
||||||
|
return -1;
|
||||||
|
ret = damon_update(damon, RRDTYPE_PROCS, rrd, 1, count);
|
||||||
|
string_delete(rrd);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int _refresh_status_parse_w(DaMon * damon, char const * hostname,
|
static int _refresh_status_parse_w(DaMon * damon, char const * hostname,
|
||||||
json_t * json)
|
json_t * json)
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,6 +81,15 @@ int rrd_create(RRDType type, char const * filename)
|
||||||
argv[12] = RRD_AVERAGE_4WEEK;
|
argv[12] = RRD_AVERAGE_4WEEK;
|
||||||
argv[13] = NULL;
|
argv[13] = NULL;
|
||||||
break;
|
break;
|
||||||
|
case RRDTYPE_PROCS:
|
||||||
|
argv[5] = "--step";
|
||||||
|
argv[6] = "300";
|
||||||
|
argv[7] = "DS:procs:GAUGE:600:0:U";
|
||||||
|
argv[8] = RRD_AVERAGE_DAY;
|
||||||
|
argv[9] = RRD_AVERAGE_WEEK;
|
||||||
|
argv[10] = RRD_AVERAGE_4WEEK;
|
||||||
|
argv[11] = NULL;
|
||||||
|
break;
|
||||||
case RRDTYPE_USERS:
|
case RRDTYPE_USERS:
|
||||||
argv[5] = "--step";
|
argv[5] = "--step";
|
||||||
argv[6] = "300";
|
argv[6] = "300";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user