📄 monitor.c
字号:
/*
**通用监控程序:
**其它程序只需把监控信息'O_APPEND|O_SYNC'写入日志文件即可
**program by gwq on 2001.10.29
*/
#include <curses.h>
#include <stdio.h>
#include <time.h>
main(int argv,char * argc[])
{
FILE * fp;
char buff[100],time[20];
WINDOW *win,*win1;
int y,x;
void get_systime1(char *buff);
if( argv!=4){
printf("Usage: monitor <日志文件全路径名> <头信息> <行标题>\n");
exit(1);
}
if( (fp=fopen(argc[1],"r"))==NULL ){
printf("Open log file [%s] fail!!!\n",argc[1]);
exit(1);
}
initscr();
curs_set(0);
standout();
mvprintw(0,(80-strlen(argc[2]))/2, "%s",argc[2]);
standend();
mvprintw(2,0,"%s", "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
mvprintw(3,0,"%s",argc[3]);
mvprintw(4,0,"%s", "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
mvprintw(22,0,"%s","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
refresh();
win=newwin(17,80,5,0);
win1=newwin(1,80,1,0);
scrollok(win,TRUE);
//start_color();
//init_pair(3,COLOR_YELLOW,COLOR_BLACK);
//wattron(win1,COLOR_PAIR(3));
//移动指针到文件尾
while( fgets(buff,100,fp)!=NULL );
while(1)
{
get_systime1(time);
mvwprintw(win1,0,65,"%s",time);
touchwin(win1);
wrefresh(win1);
if( fgets(buff,100,fp)!=NULL )
{
wprintw(win,"%s",buff);
touchwin(win);
wrefresh(win);
}
else
sleep(1);
}
curs_set(1);
delwin(win);
delwin(win1);
endwin();
}
/*************************************************************
* 取系统时间b (6位字符串:小时+分钟+秒钟)
*************************************************************/
void get_systime1(char *buff)
{
long t;
struct tm *t1;
time(&t);
t1=localtime(&t);
sprintf(buff,"%02d时%02d分%02d秒",t1->tm_hour,t1->tm_min,t1->tm_sec);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -