My script in C to make a send sms file:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma GCC diagnostic ignored "-Wwrite-strings"
void process(char v1[], char v2[], char v3[]){
FILE *fp1;
fp1 = fopen("sms_script.sh", "w+");
fprintf(fp1,"count=$( cat countmess)\ncount=$((count+1))\n");
fprintf(fp1,"sshpass -p "12345678" ssh -o StrictHostKeyChecking=no [email protected] sudo mmcli -m 1 --messaging-create-sms="text=\'%s-%s\',number=\'%s\'"\n",v2,v3,v1);
fprintf(fp1,"sshpass -p "12345678" ssh -o StrictHostKeyChecking=no [email protected] sudo mmcli -s $count --send exit\n");
fprintf(fp1,"rm -f countmess\necho "$count" >> countmess\nexit");
fclose(fp1);
system("./sms_script.sh");
return;
}
int main(int argc, char *argv[]){
process(argv[1],argv[2],argv[3]);
return 0;
}
==========================
My run.sh file to receive parameter from zabbix then pass it to script above:
#!/bin/bash
/usr/lib/zabbix/alertscripts/editScript $1 $2 $3
=========================
2 files above are put in: "/usr/lib/zabbix/alertscripts/" with full x+ permission
then I go to to Admin => Media Type and create new:

then I go to tab user and config user media:

but when trigger on, zabbix throw the error that "segment fault. core dumped at run.sh line 2: "/usr/lib/zabbix/alertscripts/editScript $1 $2 $3"
I change to use remote command in action => operation with fixed phone number and macros {HOST.NAME} and {TRIGGER.NAME} but zabbix return "killed by signal 11"
- Anyone have solutions for that?
- How to choose and send parameters to shellscript?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#pragma GCC diagnostic ignored "-Wwrite-strings"
void process(char v1[], char v2[], char v3[]){
FILE *fp1;
fp1 = fopen("sms_script.sh", "w+");
fprintf(fp1,"count=$( cat countmess)\ncount=$((count+1))\n");
fprintf(fp1,"sshpass -p "12345678" ssh -o StrictHostKeyChecking=no [email protected] sudo mmcli -m 1 --messaging-create-sms="text=\'%s-%s\',number=\'%s\'"\n",v2,v3,v1);
fprintf(fp1,"sshpass -p "12345678" ssh -o StrictHostKeyChecking=no [email protected] sudo mmcli -s $count --send exit\n");
fprintf(fp1,"rm -f countmess\necho "$count" >> countmess\nexit");
fclose(fp1);
system("./sms_script.sh");
return;
}
int main(int argc, char *argv[]){
process(argv[1],argv[2],argv[3]);
return 0;
}
==========================
My run.sh file to receive parameter from zabbix then pass it to script above:
#!/bin/bash
/usr/lib/zabbix/alertscripts/editScript $1 $2 $3
=========================
2 files above are put in: "/usr/lib/zabbix/alertscripts/" with full x+ permission
then I go to to Admin => Media Type and create new:
then I go to tab user and config user media:
but when trigger on, zabbix throw the error that "segment fault. core dumped at run.sh line 2: "/usr/lib/zabbix/alertscripts/editScript $1 $2 $3"
I change to use remote command in action => operation with fixed phone number and macros {HOST.NAME} and {TRIGGER.NAME} but zabbix return "killed by signal 11"
- Anyone have solutions for that?
- How to choose and send parameters to shellscript?
Comment