/* * DAHDI Monitoring E1 * * Written by vahid abdi * * Copyright © 2000-2008 Saeian Ertebat Corporation, All Rights Reserved * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this manual; if not, see * . */ #include #include #include #include #include #include #include #include static int ctl = -1; static struct dahdi_spaninfo s[DAHDI_MAX_SPANS]; static const char *prog_name; void print_usage(FILE *stream) { extern const char *prog_name; fprintf (stream, "%s [-s span_number]\n", prog_name); exit (EXIT_FAILURE); } int main(int argc, char *argv[]) { int res; int c; int span_no; prog_name = argv[0]; if (argc == 1) print_usage(stderr); while (( c = getopt(argc, argv, "s:")) != -1) { switch (c) { case 's': span_no = atoi(optarg); break; default: print_usage(stderr); break; } } ctl = open("/dev/dahdi/ctl", O_RDWR | O_NONBLOCK); if (ctl < 0) { fprintf(stderr, "Unable to open /dev/dahdi/ctl: %s\n", strerror(errno)); exit(1); } s[span_no].spanno = span_no; res = ioctl(ctl, DAHDI_SPANSTAT, &s[span_no]); if (res) fprintf(stderr, "Unable to get span info on span %d: %s\n", span_no, strerror(errno)); printf ("\n***** E1 Alarms (Framer) *****\n"); printf ("LOS:\t%s\n", s[span_no].alarms & DAHDI_ALARM_LOS?"ON": "OFF"); printf ("RED:\t%s\t| AIS:\t%s\n", s[span_no].alarms & DAHDI_ALARM_RED?"ON": "OFF", \ s[span_no].alarms & DAHDI_ALARM_BLUE?"ON": "OFF"); printf ("LOF:\t%s\n", s[span_no].alarms & DAHDI_ALARM_LFA?"ON": "OFF"); printf ("\nIRQ Missess\t%d\n", s[span_no].irqmisses); printf ("\n***** E1 Performance Monitoring Counters *****\n\n"); printf ("Framing error counter: %d\n", s[span_no].fecount); printf ("Coding violations counter: %d\n", s[span_no].cvcount); printf ("current FAS error count: %d\n", s[span_no].fascount); printf ("current CRC4 error count: %d\n\n", s[span_no].crc4count); return 0; }