2010-02-11 21:56:52 +01:00
|
|
|
/*
|
|
|
|
* This file is a part of CMSLU -- Content Management System like Unix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008-2010, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
#include "templates.h"
|
|
|
|
#include "../core/data.h"
|
|
|
|
#include "../core/request.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace TemplatesFunctions
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void winix_cur_time(Info & i)
|
|
|
|
{
|
|
|
|
static char buffer[100];
|
|
|
|
|
|
|
|
time_t t = time(0);
|
|
|
|
tm * ptm = localtime(&t);
|
|
|
|
|
|
|
|
sprintf(buffer, "%02d:%02d:%02d", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
|
|
|
i.out << buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void winix_users_logged(Info & i)
|
|
|
|
{
|
|
|
|
i.out << data.how_many_logged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void winix_function_is(Info & i)
|
|
|
|
{
|
|
|
|
if( !request.pfunction || !i.is )
|
|
|
|
return;
|
|
|
|
|
|
|
|
i.result = (request.pfunction->item.url == *i.is);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winix_function_param_is(Info & i)
|
|
|
|
{
|
|
|
|
if( !i.is )
|
|
|
|
return;
|
|
|
|
|
|
|
|
i.result = request.IsParam(i.is->c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-13 21:12:15 +01:00
|
|
|
void winix_loadavg_now(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.LoadAvgNow());
|
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winix_loadavg_1(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.LoadAvg1());
|
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winix_loadavg_5(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.LoadAvg5());
|
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winix_loadavg_15(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.LoadAvg15());
|
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winix_req_per_sec_now(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSecNow());
|
2010-02-13 21:12:15 +01:00
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winix_req_per_sec_1(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSec1());
|
2010-02-13 21:12:15 +01:00
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
|
2010-02-13 21:12:15 +01:00
|
|
|
void winix_req_per_sec_5(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSec5());
|
2010-02-13 21:12:15 +01:00
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winix_req_per_sec_15(Info & i)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
|
2010-02-15 01:31:14 +01:00
|
|
|
sprintf(buf, "%.2f", (double)data.load_avg.ReqPerSec15());
|
2010-02-13 21:12:15 +01:00
|
|
|
i.out << buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-11 21:56:52 +01:00
|
|
|
} // namespace
|