This commit is contained in:
Jonathan Wyss 2024-09-11 15:21:20 +02:00
parent 9673555dd9
commit 43c206b4e7
2 changed files with 8 additions and 8 deletions

4
config
View File

@ -1,6 +1,2 @@
/org/freedesktop/systemd1/unit/NetworkManager_2dwait_2donline_2eservice /org/freedesktop/systemd1/unit/NetworkManager_2dwait_2donline_2eservice
/org/freedesktop/systemd1/unit/NetworkManager_2eservice /org/freedesktop/systemd1/unit/NetworkManager_2eservice
/systemd/blalbla/1
/systemd/blalbla/2
/systemd/blalbla/3
/systemd/blalbla/4

12
main.c
View File

@ -27,6 +27,7 @@ typedef struct service
char *name; char *name;
char *targetPath; char *targetPath;
bool alert; bool alert;
int priority;
} Service; } Service;
int main(int argc,char *argv[]) int main(int argc,char *argv[])
@ -75,7 +76,7 @@ int main(int argc,char *argv[])
{ {
if(argc>2) if(argc>2)
{ {
Service service1; Service service1[64];
char *str_entry[64]={'\0'}; char *str_entry[64]={'\0'};
int i=0; int i=0;
@ -177,7 +178,7 @@ int checkState(char *ServiceName,char *result)
printf("\n\nresult systemdUnitCall: %s\n",result); printf("\n\nresult systemdUnitCall: %s\n",result);
for(i=0;i<(sizeof(error_strings)/sizeof(error_strings[0]));i++) for(i=0;i<(sizeof(error_strings)/sizeof(error_strings[0]));i++)
{ {
printf("%s %ld\n",error_strings[i],sizeof(error_strings)/sizeof(error_strings[0])); //printf("%s %ld\n",error_strings[i],sizeof(error_strings)/sizeof(error_strings[0]));
if(strcmp(result,error_strings[i])==0) if(strcmp(result,error_strings[i])==0)
{ {
gotify_message("https://5ccppi.org:4433",ServiceName,"is not running"); gotify_message("https://5ccppi.org:4433",ServiceName,"is not running");
@ -198,7 +199,8 @@ int gotify_message(char *url,char *title,char *message)
CURL *curl; CURL *curl;
CURLcode res; CURLcode res;
char post_buffer[128]; char post_buffer[128];
char url_buffer[128]; char url_buffer[128];
long response_code;
curl = curl_easy_init(); curl = curl_easy_init();
@ -224,7 +226,7 @@ int gotify_message(char *url,char *title,char *message)
ret = snprintf(post_buffer,sizeof(post_buffer),"title=%s&message=%s&priority=6",title,message); ret = snprintf(post_buffer,sizeof(post_buffer),"title=%s&message=%s&priority=6",title,message);
if(ret < sizeof(post_buffer)) if(ret < sizeof(post_buffer))
{ {
printf("%s %d",post_buffer,ret); printf("%s %d\n",post_buffer,ret);
if(curl) if(curl)
{ {
@ -237,6 +239,8 @@ int gotify_message(char *url,char *title,char *message)
{ {
fprintf(stderr,"curl_easy_perform failed: %s\n",curl_easy_strerror(res)); fprintf(stderr,"curl_easy_perform failed: %s\n",curl_easy_strerror(res));
} }
curl_easy_getinfo(curl,CURLINFO_RESPONSE_CODE,&response_code);
printf("Server returned:%ld\n",response_code);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }
} }