mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 13:45:10 +00:00
This is still unstable(and I still need to design/document the exposed API)! Do(n't) go and use it!
74 lines
1.9 KiB
C
74 lines
1.9 KiB
C
#include <Cytoplasm/HashMap.h>
|
|
#include <Cytoplasm/Memory.h>
|
|
#include <Cytoplasm/Json.h>
|
|
#include <Cytoplasm/Util.h>
|
|
#include <Cytoplasm/Str.h>
|
|
#include <Cytoplasm/Log.h>
|
|
|
|
#include <XMPPFormTool.h>
|
|
#include <XMPPCommand.h>
|
|
#include <Parsee.h>
|
|
#include <XMPP.h>
|
|
#include <XML.h>
|
|
|
|
void
|
|
StatusCallback(XMPPCommandManager *m, char *from, XMLElement *form, XMLElement *out, char *node)
|
|
{
|
|
char *trimmed = ParseeTrimJID(from);
|
|
size_t alloc = MemoryAllocated();
|
|
size_t kb = alloc >> 10;
|
|
size_t mb = kb >> 10;
|
|
size_t gb = mb >> 10;
|
|
size_t min = gb ? gb : (mb ? mb : (kb ? kb : alloc));
|
|
char *unit = gb ? "GB" : (mb ? "MB" : (kb ? "KB" : "B"));
|
|
|
|
XMLElement *x;
|
|
XMLElement *title, *txt;
|
|
|
|
Free(trimmed);
|
|
x = XMLCreateTag("x");
|
|
title = XMLCreateTag("title");
|
|
|
|
{
|
|
XMLElement *title_text = XMLCreateText("Parsee statistics");
|
|
XMLAddChild(title, title_text);
|
|
}
|
|
XMLAddChild(x, title);
|
|
|
|
XMLAddAttr(x, "xmlns", "jabber:x:data");
|
|
XMLAddAttr(x, "type", "result");
|
|
{
|
|
XMLElement *reported, *item, *field, *value;
|
|
reported = XMLCreateTag("reported");
|
|
XMLAddChild(x, reported);
|
|
|
|
/* Report */
|
|
Report("mem-alloc", "Heap allocated with Cytoplasm");
|
|
Report("xml-congest", "Unprocessed stanzas(congestion)");
|
|
Report("uptime", "Parsee uptime");
|
|
|
|
/* Set */
|
|
BeginItem();
|
|
{
|
|
char *min_str = StrInt(min);
|
|
char *congest = StrInt(ParseeCongestion());
|
|
char *alloc = StrConcat(3, min_str, " ", unit);
|
|
char *up = ParseeStringifyDate(ParseeUptime());
|
|
|
|
SetField("mem-alloc", alloc);
|
|
SetField("xml-congest", congest);
|
|
SetField("uptime", up);
|
|
|
|
Free(congest);
|
|
Free(min_str);
|
|
Free(alloc);
|
|
Free(up);
|
|
}
|
|
EndItem();
|
|
}
|
|
XMLAddChild(out, x);
|
|
|
|
(void) form;
|
|
(void) node;
|
|
(void) m;
|
|
}
|