ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcbWATCHDOG.hpp
Go to the documentation of this file.
1
7#ifndef ngcbWATCHDOG_H
8#define ngcbWATCHDOG_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15#include <ngc/core/ngcb.h>
16
21{
22public:
23
25 ngcbWATCHDOG(int verbose = 0) {
26 erms_[0] = '\0';
27 wd_ = ngcbWatchdogOpen(verbose, erms_);
28 }
29
32
34 int Initialized() {return (wd_ != NULL);}
35
37 const char *ErrMsg() {return (erms_);}
38
40 FILE *Watchdog() {return (wd_);}
41
43 void Add(int pid) {ngcbWatchdogAddProc(wd_, NULL, pid);}
44
46 void Add(const char *host, int pid) {ngcbWatchdogAddProc(wd_, host, pid);}
47
49 void Add(const char *cmd) {ngcbWatchdogAddCmd(wd_, NULL, cmd);}
50
52 void Add(const char *host, const char *cmd) {
53 ngcbWatchdogAddCmd(wd_, host, cmd);
54 }
55
57 void DB(const char *attr, const char *value) {
58 ngcbWatchdogDbWrite(wd_, NULL, attr, value);
59 }
60
62 void DB(const char *host, const char *attr, const char *value) {
63 ngcbWatchdogDbWrite(wd_, host, attr, value);
64 }
65
67 void Remove(int pid) {ngcbWatchdogRemoveProc(wd_, NULL, pid);}
68
70 void Remove(const char *host, int pid) {
71 ngcbWatchdogRemoveProc(wd_, host, pid);
72 }
73
75 void Remove(const char *cmd) {ngcbWatchdogRemoveCmd(wd_, NULL, cmd);}
76
78 void Remove(const char *host, const char *cmd) {
79 ngcbWatchdogRemoveCmd(wd_, host, cmd);
80 }
81
83 void Clear() {
84 ngcbWatchdogClearProc(wd_, NULL);
85 ngcbWatchdogClearCmd(wd_, NULL);
86 }
87
89 void Clear(const char *host) {
90 ngcbWatchdogClearProc(wd_, host);
91 ngcbWatchdogClearCmd(wd_, host);
92 }
93
95 void ClearLocal() {
96 ngcbWatchdogClearProc(wd_, ".");
97 ngcbWatchdogClearCmd(wd_, ".");
98 }
99
101 void Send(const char *msg) {fprintf(wd_, "%s", msg); fflush(wd_);}
102
103protected:
105 void Watchdog(FILE *wd) {wd_ = wd;}
106
107private:
109 char erms_[256];
110
112 FILE *wd_;
113};
114
115#endif
void Add(const char *host, const char *cmd)
Add command to instruction list for host.
Definition ngcbWATCHDOG.hpp:52
void Add(const char *cmd)
Add command to local instruction list.
Definition ngcbWATCHDOG.hpp:49
const char * ErrMsg()
Return error message, if initialization has failed.
Definition ngcbWATCHDOG.hpp:37
void Clear(const char *host)
Clear all instructions for host.
Definition ngcbWATCHDOG.hpp:89
void Add(int pid)
Add process to local kill-list.
Definition ngcbWATCHDOG.hpp:43
void DB(const char *attr, const char *value)
Add DB-update to local instruction list.
Definition ngcbWATCHDOG.hpp:57
void Remove(const char *cmd)
Remove command from local instruction list.
Definition ngcbWATCHDOG.hpp:75
FILE * Watchdog()
Return watchdog stream for direct access.
Definition ngcbWATCHDOG.hpp:40
void ClearLocal()
Clear all local instructions.
Definition ngcbWATCHDOG.hpp:95
void Send(const char *msg)
Send message to watchdog.
Definition ngcbWATCHDOG.hpp:101
void Remove(int pid)
Remove process from local kill-list.
Definition ngcbWATCHDOG.hpp:67
void Watchdog(FILE *wd)
Set watchdog stream for direct access.
Definition ngcbWATCHDOG.hpp:105
void Remove(const char *host, int pid)
Remove process from kill-list for host.
Definition ngcbWATCHDOG.hpp:70
void Clear()
Clear all instructions.
Definition ngcbWATCHDOG.hpp:83
void DB(const char *host, const char *attr, const char *value)
Add DB-update to instruction list for host.
Definition ngcbWATCHDOG.hpp:62
void Remove(const char *host, const char *cmd)
Remove command from instruction list for host.
Definition ngcbWATCHDOG.hpp:78
~ngcbWATCHDOG()
Destructor.
Definition ngcbWATCHDOG.hpp:31
int Initialized()
Watchdog properly initialized.
Definition ngcbWATCHDOG.hpp:34
void Add(const char *host, int pid)
Add process to kill-list for host.
Definition ngcbWATCHDOG.hpp:46
ngcbWATCHDOG(int verbose=0)
Constructor.
Definition ngcbWATCHDOG.hpp:25
void ngcbWatchdogAddCmd(FILE *wd, const char *host, const char *cmd)
Definition ngcbMon.c:163
void ngcbWatchdogRemoveCmd(FILE *wd, const char *host, const char *cmd)
Definition ngcbMon.c:178
void ngcbWatchdogClearCmd(FILE *wd, const char *host)
Definition ngcbMon.c:193
void ngcbWatchdogClearProc(FILE *wd, const char *host)
Definition ngcbMon.c:148
void ngcbWatchdogClose(FILE *wd)
Definition ngcbMon.c:105
FILE * ngcbWatchdogOpen(int verbose, char *erms)
Definition ngcbMon.c:30
void ngcbWatchdogDbWrite(FILE *wd, const char *host, const char *attr, const char *value)
Definition ngcbMon.c:208
void ngcbWatchdogRemoveProc(FILE *wd, const char *host, int pid)
Definition ngcbMon.c:133
void ngcbWatchdogAddProc(FILE *wd, const char *host, int pid)
Definition ngcbMon.c:118