ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcbWATCHDOG.hpp
Go to the documentation of this file.
1
8#ifndef ngcbWATCHDOG_H
9#define ngcbWATCHDOG_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16#include <ngc/core/ngcb.h>
17
22{
23public:
24
26 ngcbWATCHDOG(int verbose = 0) {
27 erms_[0] = '\0';
28 wd_ = ngcbWatchdogOpen(verbose, erms_);
29 }
30
33
35 int Initialized() {return (wd_ != NULL);}
36
38 const char *ErrMsg() {return (erms_);}
39
41 FILE *Watchdog() {return (wd_);}
42
44 void Add(int pid) {ngcbWatchdogAddProc(wd_, NULL, pid);}
45
47 void Add(const char *host, int pid) {ngcbWatchdogAddProc(wd_, host, pid);}
48
50 void Add(const char *cmd) {ngcbWatchdogAddCmd(wd_, NULL, cmd);}
51
53 void Add(const char *host, const char *cmd) {
54 ngcbWatchdogAddCmd(wd_, host, cmd);
55 }
56
58 void DB(const char *attr, const char *value) {
59 ngcbWatchdogDbWrite(wd_, NULL, attr, value);
60 }
61
63 void DB(const char *host, const char *attr, const char *value) {
64 ngcbWatchdogDbWrite(wd_, host, attr, value);
65 }
66
68 void Remove(int pid) {ngcbWatchdogRemoveProc(wd_, NULL, pid);}
69
71 void Remove(const char *host, int pid) {
72 ngcbWatchdogRemoveProc(wd_, host, pid);
73 }
74
76 void Remove(const char *cmd) {ngcbWatchdogRemoveCmd(wd_, NULL, cmd);}
77
79 void Remove(const char *host, const char *cmd) {
80 ngcbWatchdogRemoveCmd(wd_, host, cmd);
81 }
82
84 void Clear() {
85 ngcbWatchdogClearProc(wd_, NULL);
86 ngcbWatchdogClearCmd(wd_, NULL);
87 }
88
90 void Clear(const char *host) {
91 ngcbWatchdogClearProc(wd_, host);
92 ngcbWatchdogClearCmd(wd_, host);
93 }
94
96 void ClearLocal() {
97 ngcbWatchdogClearProc(wd_, ".");
98 ngcbWatchdogClearCmd(wd_, ".");
99 }
100
102 void Send(const char *msg) {fprintf(wd_, "%s", msg); fflush(wd_);}
103
104protected:
106 void Watchdog(FILE *wd) {wd_ = wd;}
107
108private:
110 char erms_[256];
111
113 FILE *wd_;
114};
115
116#endif
void Add(const char *host, const char *cmd)
Add command to instruction list for host.
Definition ngcbWATCHDOG.hpp:53
void Add(const char *cmd)
Add command to local instruction list.
Definition ngcbWATCHDOG.hpp:50
const char * ErrMsg()
Return error message, if initialization has failed.
Definition ngcbWATCHDOG.hpp:38
void Clear(const char *host)
Clear all instructions for host.
Definition ngcbWATCHDOG.hpp:90
void Add(int pid)
Add process to local kill-list.
Definition ngcbWATCHDOG.hpp:44
void DB(const char *attr, const char *value)
Add DB-update to local instruction list.
Definition ngcbWATCHDOG.hpp:58
void Remove(const char *cmd)
Remove command from local instruction list.
Definition ngcbWATCHDOG.hpp:76
FILE * Watchdog()
Return watchdog stream for direct access.
Definition ngcbWATCHDOG.hpp:41
void ClearLocal()
Clear all local instructions.
Definition ngcbWATCHDOG.hpp:96
void Send(const char *msg)
Send message to watchdog.
Definition ngcbWATCHDOG.hpp:102
void Remove(int pid)
Remove process from local kill-list.
Definition ngcbWATCHDOG.hpp:68
void Watchdog(FILE *wd)
Set watchdog stream for direct access.
Definition ngcbWATCHDOG.hpp:106
void Remove(const char *host, int pid)
Remove process from kill-list for host.
Definition ngcbWATCHDOG.hpp:71
void Clear()
Clear all instructions.
Definition ngcbWATCHDOG.hpp:84
void DB(const char *host, const char *attr, const char *value)
Add DB-update to instruction list for host.
Definition ngcbWATCHDOG.hpp:63
void Remove(const char *host, const char *cmd)
Remove command from instruction list for host.
Definition ngcbWATCHDOG.hpp:79
~ngcbWATCHDOG()
Destructor.
Definition ngcbWATCHDOG.hpp:32
int Initialized()
Watchdog properly initialized.
Definition ngcbWATCHDOG.hpp:35
void Add(const char *host, int pid)
Add process to kill-list for host.
Definition ngcbWATCHDOG.hpp:47
ngcbWATCHDOG(int verbose=0)
Constructor.
Definition ngcbWATCHDOG.hpp:26
void ngcbWatchdogAddCmd(FILE *wd, const char *host, const char *cmd)
Definition ngcbMon.c:164
void ngcbWatchdogRemoveCmd(FILE *wd, const char *host, const char *cmd)
Definition ngcbMon.c:179
void ngcbWatchdogClearCmd(FILE *wd, const char *host)
Definition ngcbMon.c:194
void ngcbWatchdogClearProc(FILE *wd, const char *host)
Definition ngcbMon.c:149
void ngcbWatchdogClose(FILE *wd)
Definition ngcbMon.c:106
FILE * ngcbWatchdogOpen(int verbose, char *erms)
Definition ngcbMon.c:31
void ngcbWatchdogDbWrite(FILE *wd, const char *host, const char *attr, const char *value)
Definition ngcbMon.c:209
void ngcbWatchdogRemoveProc(FILE *wd, const char *host, int pid)
Definition ngcbMon.c:134
void ngcbWatchdogAddProc(FILE *wd, const char *host, int pid)
Definition ngcbMon.c:119