Astaro useful shell commands.

Hi to All.
I'm opening this thread so any of you which happens to run into useful Shell commands, can add it in here.
My goal is to create a document with many Astaro useful shell commands.
You are welcome to add, remark or reject any of the commands in here.
[:)]



This thread was automatically locked due to age.
[unlocked by: BAlfson at 2:53 PM (GMT -7) on 4 Jun 2021]
Parents
  • @goldy, there are some simpler ways to reset passwords than what is listed. Rather than:
    cc
    RAW
    system_password_reset
    Ctrl c

    you can simply run:
    cc system_password_reset

    or even better:
    cc passwd [mynewpassword]

    this one changes the admin password in a single line, and does not reset shell password info. no need to set all password on the next system login.

    @ximera, you can view tunnel status with:
     cc get_ipsec_status

    This outputs the status info in perl style data structures, and if you have many tunnels, becomes harder to read. Here's a sample output:

    'REF_IpsSitFaketunnel' => {
                                          0 => {
                                                 0 => {
                                                        'established' => 0,
                                                        'ike_auth' => 'psk',
                                                        'ike_lifetime' => '7800s',
                                                        'ike_natt' => 0,
                                                        'ipsec_lifetime' => '3600s',
                                                        'ipsec_sa' => 0,
                                                        'isakmp_sa' => 0,
                                                        'left' => '192.168.0.2',
                                                        'leftid' => '192.168.0.2',
                                                        'leftsubnet' => '192.168.25.0/24',
                                                        'right' => '10.0.0.1',
                                                        'rightid' => '10.0.0.1',
                                                        'rightsubnet' => '7.7.7.0/24'
                                                      }
                                               },
                                          'all_established' => 0,
                                          'established' => 0,
                                          'expected' => 1
                                        }
            }

    The bold items show you the status of each SA, and of the entire tunnel. 

    My absolute favorite command line tool is grep. Specifically, grep -oP can be used to pull specific data out of log lines, for summary. This requires being familiar with perl regex, but is extremely powerful. For example, how do you find out what errors have been seen most commonly in the web security log today?

    try this:
    grep -oP 'error=".*?"' /var/log/http.log

    That pulls a list of every error="{anything}" instance out of the http log. Pipe this to some sorting commands, and we can get a nice sorted list of the most popular errors being returned by web servers:
    grep -oP 'error=".*?"' /var/log/http.log|sort -n|uniq -c|sort -n

    That will return something like this:
          1 error="Connection refused"
          4 error="DNS resolution timeout"
          5 error="Host not found"
         23 error="Connection timed out"
         48 error="Timeout while reading response from Server"
      43703 error=""


    This specific example can be helpful in identifying specific problems, like DNS problems. it also puts problems in perspective. 4 DNS timeouts out of 43k requests indicates that this probably isn't a local problem.  

    The same commandscan be used in other ways, limited by your imagination (and regex knowledge). Be careful though, on extremely high volume systems, that may have problems from disk IO bottlenecks. searching like this will not help that situation improve [:)]
  • Thanks Alan - I used your example to retrieve categoryname data.

    grep -oP 'error=".*?"' /var/log/http.log


    If I were to add a cron job to run the task nightly, would I nullify the support contract on my ASG320?

    The websecurity portion of our daily report has been broken since our upgrade to v8.3x.  Support told us our problem is fixed in v9.  It would be helpful to have this dump the category list on a daily basis to see if our users are going to inappropriate sites.
Reply
  • Thanks Alan - I used your example to retrieve categoryname data.

    grep -oP 'error=".*?"' /var/log/http.log


    If I were to add a cron job to run the task nightly, would I nullify the support contract on my ASG320?

    The websecurity portion of our daily report has been broken since our upgrade to v8.3x.  Support told us our problem is fixed in v9.  It would be helpful to have this dump the category list on a daily basis to see if our users are going to inappropriate sites.
Children
No Data