LinuxÏÂÓýű¾Ð´¼à¿Ø´úÀí³ÌÐò
LinuxÏÂÓýű¾Ð´¼à¿Ø´úÀí³ÌÐò
Îâ旻
Ì©ÑÒÍøÂ繤×÷ÊÒ
Òò¹¤×÷ÐèÒª£¬ÎÒÐèÒª¼à¿Ø¼¸Ì¨·þÎñÆ÷µÄ³ÌÐò״̬£¬SNMP(¼òµ¥ÍøÂç¹ÜÀíÐÒé)¿ÉÒÔÓ㬵«²¢²»ÄÜÂú×ãÎÒµÄÒªÇ󣬶øÇÒ²¢²»¼òµ¥¡£ÎÒÏ£ÍûʵʱµÃµ½ÖîÈç½ø³ÌµÄÐÅÏ¢¡¢CPUʹÓá¢ÄÚ´æʹÓá¢ÍøÂçÁ÷Á¿¡¢ÍøÂç¶Ë¿Ú¡¢´ÅÅÌÐÅϢʹÓõÈÖÚ¶à²ÎÊý¡£
ÎҺܿìдºÃÁ˼à¿Ø·þÎñ¶ËºÍ¿Í»§¶Ë³ÌÐò£¬µ«¶Ô´úÀí¶Ë³ÌÐòȴһʱÄÑÒÔÈ·¶¨¼¼Êõ·½°¸¡£ÓÃÈκÎÒ»ÖÖÓïÑÔ»ñµÃÕâЩ²ÎÊý¶¼ÐèÒªÉîÈëÁ˽â²Ù×÷ϵͳ£¬ºÃÔÚLinuxÏÂÓзḻµÄÃüÁî³ÌÐò£¬¹À¼Æ¿ÉÒÔ°ïÎÒ¾¡¿ì½â¾öÎÊÌâ¡£
Ò»¡¢¸÷ÖÖÊý¾ÝµÄÊÕ¼¯¡£
Õâ¸öÄѶȲ»Ì«´ó£¬ÒòΪLinuxÏÂÃüÁî·á¸»£¬ËùÒÔ¿ÉÒԺܿì¸ã¶¨¡£±ÈÈ磬ÎÒÏëÖªµÀµ±Ç°ÓÐûÓгÌÐòʹÓÃÍøÂç¶Ë¿Ú8888£¬ÓÃÈçÏÂÃüÁî¼´¿É½â¾ö£º
netstat -ant | grep :8888
»òÕßÀàËÆÎÒÏÂÃæµÄ£¬½«µÃµ½µÄÊý¾Ý¸ü¾ßÌåһЩ£º
netstat -ant | grep 192.168.10.22:8888 | awk '{print $5,$4}'
¶þ¡¢¸ñʽ»¯±£´æ
ÍøÂçÊý¾ÝÒ»°ã¶¼ÊÇÓй̶¨¸ñʽ£¬ÉõÖÁ°üÀ¨Ð£ÑéÖµµÈ¹¦ÄÜ¡£ÎÒµÄÕâ¸öûÄÇô¸´ÔÓ£¬µ«Ò²Í¬ÑùÒªÓаü±êʶ·û¡¢°üÏûÏ¢ID¡¢°üÏûÏ¢Ì峤¶ÈµÈÖµ¡£ÎÒÊÇÕâÑùʵÏֵģº MonitorMsg="\xff\xff\xff\xff" # msg_flag = 0xFFFFFFFF MonitorMsg=$MonitorMsg"\x01\x00\x00\x00" # msg_id = 1
MonitorMsg=$MonitorMsg"\x44\x00\x00\x00" # msg_len = 68 Bytes
ÏûÏ¢ÌåµÄ¾ßÌåÄÚÈݾÍÍêÈ«ÊǸöÐÔ»¯Êý¾ÝÁË£¬±ÈÈ磬ÎÒÏë¼ÓÈ뵱ǰ²Ù×÷ϵͳʱ¼ä£º
timeNow=`date +%H%M%S`
MonitorMsg=$MonitorMsg$timeNow"\x00\x00"
ÒòΪʱ¼äÊÇHH:MM:SS£¬ÎªÁËÄÚ´æ¶ÔÆ룬ºóÃæÓÖ²¹ÁË2×Ö½ÚµÄ0x00¡£
ÔÙÏÂÃæÒª×öµÄ¾ÍÊǽ«ÕâЩÊý¾Ý±£´æµ½ÎļþÖС£echoÃüÁîÍê³ÉÁËÕâÒ»¹¤×÷£º
echo -ne $MonitorMsg >> /usr/montor.dat
ʹÓòÎÊý –ne ÊÇÒòΪĬÈÏÇé¿öÏÂecho»á×Ô¶¯¼ÓÉϻسµ£¬´Ó¶øµ¼ÖÂÊý¾Ý¶Ô²»Æë¡£
Èý¡¢½«±£´æºóµÄÊý¾Ý·¢Ë͵
Ïà¹ØÎĵµ£º
ÐźÅÊÇLinux±à³ÌÖзdz£ÖØÒªµÄ²¿·Ö£¬±¾ÎĽ«Ïêϸ½éÉÜÐźŻúÖƵĻù±¾¸ÅÄî¡¢Linux¶ÔÐźŻúÖƵĴóÖÂʵÏÖ·½·¨¡¢ÈçºÎʹÓÃÐźţ¬ÒÔ¼°ÓйØÐźŵļ¸¸öϵͳ
µ÷Óá£
ÐźŻúÖÆÊǽø³ÌÖ®¼äÏ໥´«µÝÏûÏ¢µÄÒ»ÖÖ·½·¨£¬ÐźÅÈ«³ÆΪÈíÖжÏÐźţ¬Ò²ÓÐÈ˳Æ×÷ÈíÖжϡ£´ÓËüµÄÃüÃû¿ÉÒÔ¿´³ö£¬ËüµÄʵÖʺ ......
4¡¢alarmºÍ setitimerϵͳµ÷ÓÃ
ϵͳµ÷ÓÃalarmµÄ¹¦ÄÜÊÇÉèÖÃÒ»¸ö¶¨Ê±Æ÷£¬µ±¶¨Ê±Æ÷¼Æʱµ½´ïʱ£¬½«·¢³öÒ»¸öÐźŸø½ø³Ì¡£¸Ãµ÷ÓõÄÉùÃ÷¸ñʽÈçÏ£º
unsigned int alarm(unsigned int seconds);
&n ......
Õ⼸ÌìÎÒ°²×°ÁËÒ»¸öLinuxϵͳ£¬ÏëÔÚÀïÃæѧһÏÂCÓïÑԵıàд£¬·¢ÏÖÔÚÀïÃæÔËÐÐÓÐÒ»¸öºÃÆæ¹ÖµÄÏÖÏó£ºÈçÏÂÃæ
#include<stdio.h>
void mian(){
printf("hello world!");
}
Êä³öûÓнá¹û£¡¸ãµÄÎÒ¿´ÁË°ëÌ죬³ÌÐòûÓдíÎó°¡£¡ÔõôÕâÑù£¡ºóÀ´ÎҰѳÌÐò¸ÄΪ
#include<stdio.h>
void mian(){
printf("hello ......
[root@localhost root]# ls -l
»áÏÔʾĿ¼»òÎļþÐÅÏ¢£ºdrwxr-xr-x 2 root root 4096 06-29 14:30 Test
-rwxr--r-- 2 root roo ......
cat awk '{print}'
cat -s awk '{blank = NF == 0 ? ++blan ......