automation, monitoring, scripting, Uncategorized

How to send attachment from Linux

There are some cases when its needed to send via email many scripts output results from Linux command line.  Here is an working example to achieve this.

It is expected that email options have been already configured so that mail command is working.

Below is the example of command which will zip all related logs  from /tmp folder into a .zip file “WLCs_logs.zip”

zip -r /tmp/WLCs_logs.zip /tmp/WLCs-peers-*.log.filtered

next command will send email with .zip attachment to me@mymail.com

mpack -s “AVC and other data from WLCs” /tmp/WLCs_logs.zip me@mymail.com

Mentioned commands can be executed from cron on a regular basis.

monitoring, Uncategorized, wireless topics

monitor amount of users on Cisco access points

At this stage of wifi technology development high density of clients and access points can be seen quite often. Now is a task to avoid too much clients per access point (once I saw a report with ~90 clients on one access point) to offer reliable wifi service.

Amount of users per access points in certain moments of time can be gained via Cisco prime (PI – prime infrastructure, as it called by vendor). In my case this system is monitored by other persons and when they will restore its functionality is unclear. For such case or if someone don’t want to invest in Cisco prime, Bash script and SQL can be used to monitor amount of users per access points during the time:

1) login with Expect/Perl/Python script to WLC and monitor all output

2) issue command “show ap summary” and following result will be achieved (some columns are deleted for brevity):

(Cisco Controller) >show ap summary

Number of APs……………………………… 101

Global AP User Name………………………… mgmt
Global AP Dot1x User Name…………………… Not Configured

AP Name          AP Model                  Location           IP Address         Clients
——————    ——————–            —————-         —————        ——————–
235AP           AIR-CAP2702E-Z-K9    Stores               10.10.47.235          1
234AP           AIR-CAP2702E-Z-K9    Gnd F               10.10.47.234           1
233AP           AIR-CAP2702E-Z-K9    KP                     10.10.47.233           1
7213AP         AIR-CAP2702E-Z-K9    Aisle 4 – H5     10.105.82.26           0
7208AP         AIR-CAP2702E-Z-K9    Above Bench  10.105.82.33          3

3) this output can be saved in file, which afterwards can be used by a Bash and Perl scripts to push such data into MySQL on regular basis with help of cron on Linux.

4) the result looks good:

mysql> select dt,tm, sum(users_amount) from APs_users GROUP BY dt,tm;
+——————+————-+———————————+
|        dt            |        tm      | sum(users_amount) |
+——————+————-+————- ——————-+
| 2018-12-28  | 09:05:31 |              21                    |
| 2018-12-29  | 07:05:32 |              18                    |
| 2018-12-29  | 08:05:32 |              18                    |
+——————-+————+———————————+
3 rows in set (0.00 sec)