signal handling

git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@909 860744bd-22fc-0310-8c96-e9fe5004b5ca
This commit is contained in:
rixx committed 2003-05-08 21:13:41 +00:00
1 parent 4d874fc3fc
commit 2e311cecae
3 files changed
+28 -2

No files matched your search

+3 -1
View File
@@ -2,7 +2,9 @@
#include <sys/time.h>
#include <mysql.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
//For Net-SNMP (ver5)
#ifdef NETSNMP
+21
View File
@@ -4,8 +4,23 @@ target_t *targets = NULL;
target_t *current = NULL;
conf_t conf;
int entries;
int conf_changed;
void sighup(){
extern int conf_changed;
signal(SIGHUP,sighup); /* reset signal */
printf("SIGHUP\n");
conf_changed=1;
}
int main(void){
FILE *fp;
fp=fopen("/tmp/cactid.pid", "w");
fprintf(fp, "%i",getpid());
fclose(fp);
signal(SIGHUP,sighup);
printf("INIT: reading conf\n");
read_conf();
@@ -22,6 +37,12 @@ int main(void){
current=targets;
poller();
sleep(conf.interval);
if(conf_changed==1){
printf("conf changed\n");
entries=get_targets();
conf_changed=0;
}
}
}
+4 -1
View File
@@ -28,8 +28,11 @@ void *poller(){
switch(entry->action) {
case 0:
#ifdef TEST
entry->result=1;
#else
entry->result=snmp_get(entry->management_ip, entry->snmp_community, entry->snmp_version, entry->arg1,0);
//entry->result=1;
#endif
break;
case 1:
cmd_stdout=popen(entry->command, "r");