/* DESC: This script sends status values to a remote UDP server. * Copyright (C) 2012 NetModule AG, Switzerland */ void usage() { printf("usage: status2udp.are \n"); exit(1); } if (argc < 4) { usage(); } SERVER = argv[1]; PORT = (int) argv[2]; FREQ = (int) argv[3]; sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) { printf("Unable to open socket\n"); exit(1); } for(;;) { sleep(FREQ); status = nb_status("wwan"); // see status.are for more staus names // dump(status); /* uncommend to see the fields */ MSG = sprintf("Service:%s signal: %s", status.MOBILE1_SERVICE_TYPE, status.MOBILE1_RSRQ); if (sendto(sock, MSG, SERVER, PORT) != strlen(MSG)) printf("ERROR: dtatus2udp sending failed"); // nb_syslog(sprintf("Message: <%s> to <%s> port <%s> send.\n", MSG, SERVER, PORT)); } /* * nb_stats() arguments * "summary", "Short status summary", * "system", "System information", * "license", "License information", * "wwan", "WWAN module status", * "wlan", "WLAN module status", * "gnss", "GNSS (GPS) module status", * "lan", "LAN interface status", * "wan", "WAN interface status", * "openvpn", "OpenVPN connection status", * "ipsec", "IPsec connection status", * "dio", "Digital IO status" */