96065cd6 by Yashwant

Channel Log cron file

1 parent 4a9f4561
1 #!/usr/bin/php
2
3 <?php
4
5 exec("/usr/sbin/asterisk -rx 'sip show channels'",$runCalls);
6
7 $asteriskChannels = print_r($runCalls,true);
8
9 $channels = 0;$peer ="";
10
11 foreach($runCalls as $runCall){
12
13 $runCallArr = explode(" ",$runCall);
14
15 $numRunCallArr = end($runCallArr);
16
17 if(is_Numeric($numRunCallArr)){
18 $channels++;
19 }
20 $peer .= "'".$numRunCallArr."',";
21 }
22 $channels = $channels;
23
24 $db = new mysqli("localhost", "root", "yb9738z", "fullerton");
25 $activeUsers = $db->query("select * from sipids where status=1");
26 $db->close();
27
28 $users = 0;$sip = "";$usersOutput = [];
29 while($row = $activeUsers->fetch_assoc()){
30 $users++;
31 $sip .= $row["id"].",";
32 $usersOutput[] = $row;
33 }
34
35 $applicationUsers = print_r($usersOutput,true);
36
37 $input = date('y-m-d h:m:s')." Total Asterisk Channels - ".$channels." , Total Application Users - ".$users."\n\n";
38 $input .= $peer."\n\n";
39 $input .= $sip."\n\n";
40 $input .= $asteriskChannels."\n";
41 $input .= $applicationUsers."\n";
42
43 $logFile = fopen("/home/192.168.3.252/ChannelLog.txt", "a+");
44 fwrite($logFile, $input);
45 fclose($logFile);
46
47 ?>
...\ No newline at end of file ...\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!