linux lua
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "include/lua.hpp"
bool g_bQuit = false;
void SignalHandler(int signal)
{
printf("nanny thread was interrupt by signal\n");
g_bQuit = true;
}
//for lua
//Ö´Ðд«À´µÄ×Ö·û´®,·µ»Ø½á¹û
static int NannyCreateProcess(lua_State* L)
{
const char* param = lua_tostring(L,1);
int ret = system(param);
lua_pushnumber(L, ret);
return 1;
}
void DoLuaCheck(lua_State* L, char* szBuf)
{
lua_getglobal(L, "NannyCheckPsString");
lua_pushstring(L, szBuf);
lua_call(L, 1, 0);
}
void DoLuaReset(lua_State* L)
{
lua_getglobal(L, "NannyTryReloadProcess");
lua_call(L, 0, 0);
}
lua_State* InitLua()
{
lua_State* L = lua_open();
luaopen_base(L);
luaL_openlibs(L);
lua_register(L, "NannyCreateProcess", NannyCreateProcess);
luaL_dofile(L, "nanny.lua");
return L;
}
bool DoCheck()
{
int fd[2];
if( pipe(fd) < 0 )
{
fprintf(stderr, "failed to create pipe! (%s)\n", strerror(errno));
return false;
}
int nRet = fork();
if( nRet > 0 )
{
//¶ÁÈ¡¹ÜµÀÖÐpsÊä³ö
lua_State* L = InitLua();
if( L == NULL )
return false;
close(fd[1]);
FILE* fp = fdopen(fd[0], "r");
if( fp == NULL )
{
lua_close(L);
return false;
}
char szBuf[2048] = { 0 };
while( fgets(szBuf, 2048, fp) != NULL )
{
DoLuaCheck(L, szBuf);
//fprintf(stderr, "-----------%s",szBuf);
memset(szBuf, 0, 2048);
Ïà¹ØÎĵµ£º
£¨L2CAPÐÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPÐÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼Á¬½Ó¿ØÖƺÍÊÊÅäÐÒé (L2CAP) ΪÉϲãÐÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àÐÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãÐÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......
½âÊÍÒ»:
¸ß¶ËÄÚ´æÊÇÖ¸ÎïÀíµØÖ·´óÓÚ 896M µÄÄÚ´æ¡£
¶ÔÓÚÕâÑùµÄÄڴ棬ÎÞ·¨ÔÚ“ÄÚºËÖ±½ÓÓ³Éä¿Õ¼ä”½øÐÐÓ³Éä¡£
Ϊʲô£¿
ÒòΪ“ÄÚºËÖ±½ÓÓ³Éä¿Õ¼ä”×î¶àÖ»ÄÜ´Ó 3G µ½ 4G£¬Ö»ÄÜÖ±½ÓÓ³Éä 1G ÎïÀíÄڴ棬¶ÔÓÚ´óÓÚ 1G µÄÎïÀíÄڴ棬ÎÞÄÜΪÁ¦¡£
ʵ¼ÊÉÏ£¬“ÄÚºËÖ±½ÓÓ³Éä¿Õ¼ä”Ò²´ï²»µ½ 1G£¬ »¹µÃÁôµã ......
Linuxϲ鿴CPUʹÓÃÂÊ!
2008Äê03ÔÂ20ÈÕ ÐÇÆÚËÄ ÏÂÎç 07:02
¡¡¡¡ÔÚϵͳά»¤µÄ¹ý³ÌÖУ¬Ëæʱ¿ÉÄÜÓÐÐèÒª²é¿´ CPU ʹÓÃÂÊ£¬²¢¸ù¾ÝÏàÓ¦ÐÅÏ¢·ÖÎöϵͳ״¿öµÄÐèÒª¡£ÔÚ CentOS ÖУ¬¿ÉÒÔͨ¹ý top ÃüÁîÀ´²é¿´ CPU ʹÓÃ×´¿ö¡£ÔËÐÐ top ÃüÁîºó£¬CPU ʹÓÃ״̬»áÒÔÈ«ÆÁµÄ·½Ê½ÏÔʾ£¬²¢ÇһᴦÔÚ¶Ô»°µÄģʽ -- ÓûùÓÚ top µÄÃüÁ¿ÉÒÔ¿ØÖÆÏÔ ......
ÕâÁ½Ìì¿´ÁËÒ»±¾fedora 6µÄʵ¼ù½Ì³Ì£¬ÏÂÃæÊÇÓйØlinuxÎļþϵͳ֪ʶµÄѧϰ±Ê¼Ç£º
1¡¢linuxÎļþϵͳ·ÖÅä²ßÂÔ£º
¿é·ÖÅä( block allocation ) ºÍ À©Õ¹·ÖÅä ( extent allocation )
¿é·ÖÅ䣺´ÅÅÌÉϵÄÎļþ¿é¸ù¾ÝÐèÒª·ÖÅä¸øÎļþ£¬±ÜÃâÁË´æ´¢¿Õ¼äµÄÀË·Ñ¡£µ«µ±ÎļþÀ©³äʱ£¬»áÔì³ÉÎļþÖÐÎļþ ......
LinuxÖг£ÓõĹػúºÍÖØÐÂÆô¶¯ÃüÁîÓÐshutdown¡¢halt¡¢rebootÒÔ¼°init£¬ËüÃǶ¼¿ÉÒÔ´ïµ½¹Ø»úºÍÖØÐÂÆô¶¯µÄÄ¿µÄ£¬µ«ÊÇÿ¸öÃüÁîµÄÄÚ²¿¹¤×÷¹ý³ÌÊDz»Í¬µÄ£¬ÏÂÃ潫ÖðÒ»½øÐнéÉÜ¡£
1. shutdown
shutdownÃüÁîÓÃÓÚ°²È«¹Ø±ÕLinuxϵͳ¡£ÓÐЩÓû§»áʹÓÃÖ±½Ó¶ÏµôµçÔ´µÄ·½Ê½À´¹Ø±ÕLinux£¬ÕâÊÇÊ®·ÖΣÏյġ£ÒòΪLinuxÓëWindows²»Í¬£¬Æäºǫ́ ......