이럴수가 asdf 마구 치다가 우연히 찾은 명령어다.

아직 자세하게 뭔지는 모르기에 man page 가져다 붙여두고

좀 봐야겠다. 


SADF(1)                       Linux User's Manual                      SADF(1)


NAME

       sadf - Display data collected by sar in multiple formats.


SYNOPSIS

       sadf [ -d | -D | -H | -p | -x ] [ -t ] [ -V ] [ -P { cpu | ALL } ] [ -s

       [ hh:mm:ss ] ] [ -e [ hh:mm:ss ] ] [ -- sar_options...  ] [ interval  [

       count ] ] [ datafile ]


DESCRIPTION

       The sadf command is used for displaying the contents of data files cre-

       ated by the sar(1) command. But unlike sar, sadf can write its data  in

       many  different  formats.  The default format is one that can easily be

       handled by pattern processing commands like awk (see option -p).


       The sadf command extracts and writes to standard output  records  saved

       in  the datafile file. This file must have been created by a version of

       sar which is compatible with that of sadf.   If  datafile  is  omitted,

       sadf uses the standard system activity file, the /var/log/sa/sadd file,

       where the dd parameter indicates the current day.


       The interval and count parameters are used to tell sadf to select count

       records  at  interval  second  intervals. If the count parameter is not

       set, then all the records saved in the data file will be displayed.


       All the activity flags of sar may be entered on  the  command  line  to

       indicate  which  activities are to be reported. Before specifying them,

       put a pair of dashes (--) on the command line in order not  to  confuse

       the  flags  with  those of sadf.  Not specifying any flags selects only

       CPU activity.



실행 결과

------------------------------------------


$ sadf
TEST    604 1343229001  all %user   0.50
TEST    604 1343229001  all %nice   0.00
TEST    604 1343229001  all %system 1.75
TEST    604 1343229001  all %iowait 0.01
TEST    604 1343229001  all %steal  0.00
TEST    604 1343229001  all %idle   97.74
TEST    604 1343229601  all %user   0.46
TEST    604 1343229601  all %nice   0.04
TEST    604 1343229601  all %system 1.72
TEST    604 1343229601  all %iowait 0.00
TEST    604 1343229601  all %steal  0.00
TEST    604 1343229601  all %idle   97.77
TEST    603 1343230201  all %user   0.48
TEST    603 1343230201  all %nice   0.00
TEST    603 1343230201  all %system 1.74
TEST    603 1343230201  all %iowait 0.00
TEST    603 1343230201  all %steal  0.00
TEST    603 1343230201  all %idle   97.79
TEST    604 1343230801  all %user   0.47
TEST    604 1343230801  all %nice   0.00
TEST    604 1343230801  all %system 1.72
TEST    604 1343230801  all %iowait 0.00
TEST    604 1343230801  all %steal  0.00
TEST    604 1343230801  all %idle   97.80
TEST    605 1343231401  all %user   0.47
TEST    605 1343231401  all %nice   0.00
TEST    605 1343231401  all %system 1.73
TEST    605 1343231401  all %iowait 0.00
TEST    605 1343231401  all %steal  0.00
TEST    605 1343231401  all %idle   97.79
TEST    604 1343232001  all %user   0.47
TEST    604 1343232001  all %nice   0.00
TEST    604 1343232001  all %system 1.74
TEST    604 1343232001  all %iowait 0.01
TEST    604 1343232001  all %steal  0.00
TEST    604 1343232001  all %idle   97.78


------------------------------------------

반응형

출처 : http://liverpooh.tistory.com/1

   

  • 디스크 사용량 확인하기

    #df -mh

    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
                           73G  7.0G   62G  11% /
    /dev/hda1              99M   12M   82M  13% /boot
    none                  251M     0  251M   0% /dev/shm
  • CPU 정보 확인하기

    # more /proc/cpuinfo

    processor       : 0
    vendor_id       : GenuineIntel
    cpu family      : 15
    model           : 2
    model name      : Intel(R) Pentium(R) 4 CPU 3.20GHz
    stepping        : 9
    cpu MHz         : 3208.132
    cache size      : 512 KB
    physical id     : 0
    siblings        : 2
    fdiv_bug        : no
    hlt_bug         : no
    f00f_bug        : no
    coma_bug        : no
    fpu             : yes
    fpu_exception   : yes
    cpuid level     : 2
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat
    pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid xtpr
    bogomips        : 6340.60
    ...
  • 디렉토리 크기 확인하기

    # du -sh ./foo
    80M     ./foo
반응형

mkfifo(const char *pathname, mode_t mode)

- 2개의 매개 변수가 필요하네.

- mkfifo(파이프사용할 파일명, 모드)

- 이걸로 FIFO 파일을 생성하면 이후로는 이파일을 가지고 파이프로 이동할 수 있다.

- 동일한 fd를 이용한다면 다른 프로세스에서도 메시지를 받을 수 있다.

- 주고 받는 양방향 불가.

 

수신하는 곳

#include 
#include 
#include 
#include 
#include 

#define  FIFO_FILE   "/tmp/fifo"
#define  BUFF_SIZE   1024

int main( void)
{
    int   counter = 0;
    int   fd;
    char  buff[BUFF_SIZE];

    if(mkfifo(FIFO_FILE, 0666) == -1)
    {
        perror( "mkfifo() failed\n");
        return -1;
    }

    if (( fd = open( FIFO_FILE, O_RDWR)) == -1)
    {
        perror( "open() failed\n");
        return -2;
    }
    printf("FD=%d\n", fd);

    while( 1 )
    {
        memset( buff, 0x00, BUFF_SIZE);
        read( fd, buff, BUFF_SIZE);
        printf( "%d: %s\n", counter++, buff);
    }
    close(fd);
    return 0;
}
/* The end of function */
송신하는 곳

#include 
#include 
#include 
#include 
#include 

#define  FIFO_FILE   "/tmp/fifo"

int main( void)
{
    int   fd;
    char *str   = "TEST FIFO IPC";

    if ( -1 == ( fd = open( FIFO_FILE, O_WRONLY)))
    {
        perror( "open() failed\n");
        return -1;
    }
    printf("FD=%d\n", fd);

    write(fd, str, strlen(str));
    close(fd);
    return 0;
}
/* The end of function */

수신쪽 결과 
$ ./recv 
FD=3
0: TEST FIFO IPC
1: TEST FIFO IPC
2: TEST FIFO IPC

송신쪽 결과
$ ./send 
FD=3
$ ./send 
FD=3
$ ./send 
FD=3

 

=============================================

open함수는 파일 열고 fd를 반환한다.

write함수는 바로 그 fd에다가 쓴다.

같은 시스템에서 같은 파일을 열면

동일한 fd를 가지게 되므로 위와 같이 쓸 수 있다.

=============================================

출처 http://forum.falinux.com/zbxe/?document_srl=420145

반응형

'Language > C' 카테고리의 다른 글

C FAQ (malloc 오류)  (7) 2012.07.12
C FAQ (포인터 선언 에러)  (7) 2012.07.12
popen 함수 pclose 함수 예제  (175) 2012.07.06
pipe 함수 예제  (451) 2012.07.06
다차원 배열을 1차원 배열로 변경하고자 할 때  (161) 2011.08.11

+ Recent posts