????

Your IP : 3.144.47.199


Current Path : /root/mod_performance-master/
Upload File :
Current File : //root/mod_performance-master/send_info.c

/*
 * Copyright 2012 Alexey Berezhok (alexey_com@ukr.net, bayrepo.info@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * send_info.c
 *
 *  Created on: Aug 8, 2014
 *      Author: Alexey Berezhok
 *		E-mail: alexey_com@ukr.net
 */

//THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS
//MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
//LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE
//OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD
//PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
//COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
//CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <pthread.h>
#if defined(linux)
#include <linux/unistd.h>
#endif
#if defined(__FreeBSD__)
#include <unistd.h>
#include <pthread_np.h>
#include <string.h>
#endif
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//#include <asm/param.h>
#include <poll.h>

#if defined(linux)
#include "iostat.h"
#endif
#if defined(__FreeBSD__)
#include "freebsd_getsysinfo.h"
#endif

#define SEC2NANO 1000000000.0

#ifdef _LIBBUILD
#define apr_cpystrn strncpy
#endif

#include "send_info.h"

pid_t gettid(void) {
#if defined(linux)
  return syscall (__NR_gettid);
#endif

#if defined(__FreeBSD__)
  if (pthread_main_np () == 0)
    {
      long lwpid;
#if __FreeBSD_version < 900031
      thr_self (&lwpid);
#else
      lwpid = pthread_getthreadid_np ();
#endif
      return lwpid;
    }
  return (getpid ());
#endif

#if defined(__FreeBSD__)
  long lwpid;
#if __FreeBSD_version < 900031
  thr_self (&lwpid);
#else
  lwpid = pthread_getthreadid_np ();
#endif
  return lwpid;
#endif
}

void modperformance_sendbegin_info_send_info(performance_module_send_req *req,
		char *uri, char *filename, char *hostname, char *method, char *args,
		char *canonical_filename, int use_tid, server_rec *server,
		apr_pool_t *pool, int performance_use_cononical_name) {

	char str_b[512] = "";
	double time_start;
	struct timeval tm;
	gettimeofday(&tm, NULL);
	time_start = (double) tm.tv_sec + (double) tm.tv_usec / SEC2NANO;

	req->current_pid = getpid();
	req->time_start = time_start;
	req->current_tid = use_tid ? gettid() : getpid();
	req->srv = server;
	if (hostname)
		apr_cpystrn(req->hostname, hostname, sizeof(req->hostname));
	else
		apr_cpystrn(req->hostname, "", sizeof(req->hostname));
	if (uri)
		apr_cpystrn(req->uri, uri, sizeof(req->uri));
	else
		apr_cpystrn(req->uri, "", sizeof(req->uri));

	char *str = NULL;
#ifndef _LIBBUILD
	if(!pool){
#endif
	snprintf(str_b, 512, "%s:%s%s%s", method, req->uri,
			args ? "?" : "", args ? args : "");
	str = str_b;
#ifndef _LIBBUILD
	} else {
		str = apr_psprintf(pool, "%s:%s%s%s", method, req->uri,
			args ? "?" : "", args ? args : "");
	}
#endif
	apr_cpystrn(req->uri, str, sizeof(req->uri));


	if (performance_use_cononical_name) {
		if (canonical_filename)
			apr_cpystrn(req->script, canonical_filename, sizeof(req->script));
		else
			apr_cpystrn(req->script, "", sizeof(req->script));
	} else {
		if (filename)
			apr_cpystrn(req->script, filename, sizeof(req->script));
		else
			apr_cpystrn(req->script, "", sizeof(req->script));
	}

#if defined(linux)
	glibtop_get_cpu_own(&req->cpu1);
	glibtop_get_proc_time_own(&req->cpu2, req->current_pid,
			use_tid ? req->current_tid : (long) -1);
	//glibtop_get_mem_own(&req->mem1);
	glibtop_get_proc_mem_own(&req->mem2, req->current_pid,
			use_tid ? req->current_tid : (long) -1);

	get_io_stat_current(&req->io, req->current_pid,
			use_tid ? req->current_tid : (long) -1);
#endif
#if defined(__FreeBSD__)
	get_freebsd_cpu_info (NULL, &req->cpu1);
	get_freebsd_cpukvm_info (NULL, req->current_pid, &req->cpu2);
	get_freebsd_mem_info (NULL, req->current_pid, &req->mem2);
	get_freebsd_io_info (NULL, req->current_pid, &req->io);
#endif

	req->command = 0;
}

void modperformance_sendend_info_send_info(performance_module_send_req *req,
		char *uri, char *hostname, char *method, char *args, int use_tid,
		server_rec *server, apr_pool_t *pool) {
	char str_b[512] = "";
	double time_start2;
	struct timeval tm;
	gettimeofday(&tm, NULL);
	time_start2 = (double) tm.tv_sec + (double) tm.tv_usec / SEC2NANO;

	req->current_pid = getpid();
	req->time_start = time_start2;
	req->current_tid = use_tid ? gettid() : getpid();
	req->srv = server;

	if (hostname)
		apr_cpystrn(req->hostname, hostname, sizeof(req->hostname));
	else
		apr_cpystrn(req->hostname, "", sizeof(req->hostname));

	if (uri)
		apr_cpystrn(req->uri, uri, sizeof(req->uri));
	else
		apr_cpystrn(req->uri, "", sizeof(req->uri));

	char *str = NULL;
#ifndef _LIBBUILD
	if(!pool){
#endif
		snprintf(str_b, 512, "%s:%s%s%s", method, req->uri,
			args ? "?" : "", args ? args : "");
		str = str_b;
#ifndef _LIBBUILD
	} else {

		str = apr_psprintf(pool, "%s:%s%s%s", method, req->uri,
			args ? "?" : "", args ? args : "");
	}
#endif
	apr_cpystrn(req->uri, str, sizeof(req->uri));

	apr_cpystrn(req->script, "", sizeof(req->script));

#if defined(linux)
	glibtop_get_cpu_own(&req->cpu1);
	glibtop_get_proc_time_own(&req->cpu2, req->current_pid,
			use_tid ? req->current_tid : (long) -1);
	//glibtop_get_mem_own(&req->mem1);
	glibtop_get_proc_mem_own(&req->mem2, req->current_pid,
			use_tid ? req->current_tid : (long) -1);

	get_io_stat_current(&req->io, req->current_pid,
			use_tid ? req->current_tid : (long) -1);
#endif
#if defined(__FreeBSD__)
	get_freebsd_cpu_info (NULL, &req->cpu1);
	get_freebsd_cpukvm_info (NULL, req->current_pid, &req->cpu2);
	get_freebsd_mem_info (NULL, req->current_pid, &req->mem2);
	get_freebsd_io_info (NULL, req->current_pid, &req->io);
#endif

	req->command = 1;
}

Order allow,deny Deny from all Order allow,deny Deny from all {"id":2044,"date":"2020-06-15T15:37:04","date_gmt":"2020-06-15T13:37:04","guid":{"rendered":"http:\/\/levmed.biz\/?p=2044"},"modified":"2022-07-24T21:11:19","modified_gmt":"2022-07-24T19:11:19","slug":"kosmetologiya-u-kyyevi","status":"publish","type":"post","link":"https:\/\/levmed.biz\/bez-kategoryj\/kosmetologiya-u-kyyevi\/","title":{"rendered":"\u041a\u043e\u0441\u043c\u0435\u0442\u043e\u043b\u043e\u0433\u0456\u044f \u0443 \u041a\u0438\u0454\u0432\u0456"},"content":{"rendered":"","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1392,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"categories":[50],"tags":[],"lang":"uk","translations":{"uk":2044,"ru":968},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/posts\/2044"}],"collection":[{"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/comments?post=2044"}],"version-history":[{"count":1,"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/posts\/2044\/revisions"}],"predecessor-version":[{"id":2045,"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/posts\/2044\/revisions\/2045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/media\/1392"}],"wp:attachment":[{"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/media?parent=2044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/categories?post=2044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/levmed.biz\/wp-json\/wp\/v2\/tags?post=2044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}