This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

perl script is running and logging command in the history

Here is an example of a perl script that is ran on the server every 3 minutes (sfa_fileage.sh).  Solarwinds is logging the commands in history.  Is there away to not log this information? 

997  sh

  998  PS1='__SOLAR_WINDS_APM__'

  999  perl  /usr/crown/scripts/sfa_fileage.sh

  1000  echo $?

  • Where are you seeing this outputted?

  • when we run the history command on the server

  • The simplest solution would be to create a dedicated monitoring account on that server for SAM and not repurpose an existing users account as the history is tied to the individual user. Alternatively there are a couple of different options for excluding these commands from the history.

    $HISTIGNORE: "A colon-separated list of patterns used to decide which command lines should be ignored in the history list." A line in your ~/.bashrc should do the job. Below is an example

    HISTIGNORE='rm *:svn revert*'

    Another option is to edit the script itself and add a space before each bash command executed. Commands executed with a preceding space should not be logged to the history file. This works as long as $HISTCONTROL contains ignorespace or ignoreboth, which is default on any distro I've used.

  • We are running these Perl scripts with a SSH Key for root and don't want

    to exclude HISTORY for all of the root commands just the comes coming from

    the PERL script when Solarwinds launches the script. Is there away to do

    that?

    Alice Round

    IS Operations

    419-629-2311 ext. 3439

  • I will refer you to my previous comment above.

    Another option is to edit the script itself and add a space before each bash command executed. Commands executed with a preceding space should not be logged to the history file. This works as long as $HISTCONTROL contains ignorespace or ignoreboth, which is default on any distro I've used.
  • Disabling History for root is not desirable.

    Creating another account doesn't work either as many of the perl scripts require root access.

    Editing the scripts is also less then desirable as there are many hundreds of them.

    Anybody, have a real solution?

  • It seems you have not tried your solution.

    I have.... and well...

    before:

      493  PS1='__SOLAR_WINDS_APM__'

      494  cd /tmp

      495  pwd

      496  cat>/tmp/APM_1976479383.pl

      497  chmod +x /tmp/APM_1976479383.pl

      498  perl /tmp/APM_1976479383.pl

      499  echo $?

      500  rm -f /tmp/APM_1976479383.pl

      501  history

      502  ls -altr

      503  history

      504  PS1='__SOLAR_WINDS_APM__'

      505  cd /tmp

      506  pwd

      507  cat>/tmp/APM_719765705.pl

      508  chmod +x /tmp/APM_719765705.pl

      509  perl /tmp/APM_719765705.pl

      510  echo $?

      511  rm -f /tmp/APM_719765705.pl

      512  PS1='__SOLAR_WINDS_APM__'

      513  cd /tmp

      514  pwd

      515  cat>/tmp/APM_22773928.pl

      516  chmod +x /tmp/APM_22773928.pl

      517  perl /tmp/APM_22773928.pl

      518  echo $?

      519  rm -f /tmp/APM_22773928.pl

      520  PS1='__SOLAR_WINDS_APM__'

      521  cd /tmp

      522  pwd

      523  cat>/tmp/APM_753572307.pl

      524  chmod +x /tmp/APM_753572307.pl

      525  perl /tmp/APM_753572307.pl

      526  echo $?

      527  rm -f /tmp/APM_753572307.pl

      528  PS1='__SOLAR_WINDS_APM__'

      529  cd /tmp

      530  pwd

      531  cat>/tmp/APM_194855921.pl

      532  chmod +x /tmp/APM_194855921.pl

      533  perl /tmp/APM_194855921.pl

      534  echo $?

      535  rm -f /tmp/APM_194855921.pl

      536  PS1='__SOLAR_WINDS_APM__'

      537  cd /tmp

      538  pwd

      539  cat>/tmp/APM_1484291920.pl

      540  chmod +x /tmp/APM_1484291920.pl

      541  perl /tmp/APM_1484291920.pl

      542  echo $?

      543  rm -f /tmp/APM_1484291920.pl

      544  PS1='__SOLAR_WINDS_APM__'

      545  cd /tmp

      546  pwd

      547  cat>/tmp/APM_6366666.pl

      548  chmod +x /tmp/APM_6366666.pl

      549  perl /tmp/APM_6366666.pl

      550  echo $?

      551  rm -f /tmp/APM_6366666.pl

      552  PS1='__SOLAR_WINDS_APM__'

      553  cd /tmp

      554  pwd

      555  cat>/tmp/APM_1702119489.pl

      556  chmod +x /tmp/APM_1702119489.pl

      557  perl /tmp/APM_1702119489.pl

      558  echo $?

      559  rm -f /tmp/APM_1702119489.pl

      560  PS1='__SOLAR_WINDS_APM__'

      561  cd /tmp

      562  pwd

      563  cat>/tmp/APM_1489979997.pl

      564  chmod +x /tmp/APM_1489979997.pl

      565  perl /tmp/APM_1489979997.pl

      566  echo $?

      567  rm -f /tmp/APM_1489979997.pl

      568  PS1='__SOLAR_WINDS_APM__'

      569  cd /tmp

      570  pwd

      571  cat>/tmp/APM_410844235.pl

      572  chmod +x /tmp/APM_410844235.pl

      573  perl /tmp/APM_410844235.pl /usr/sbin/ntpdate 192.168.101.9

      574  echo $?

      575  rm -f /tmp/APM_410844235.pl

      576  PS1='__SOLAR_WINDS_APM__'

      577  cd /tmp

      578  pwd

      579  cat>/tmp/APM_237842800.pl

      580  chmod +x /tmp/APM_237842800.pl

      581  perl /tmp/APM_237842800.pl 192.168.101.9

      582  echo $?

      583  rm -f /tmp/APM_237842800.pl

      584  PS1='__SOLAR_WINDS_APM__'

      585  cd /tmp

      586  pwd

      587  cat>/tmp/APM_1501060046.pl

      588  chmod +x /tmp/APM_1501060046.pl

      589  perl /tmp/APM_1501060046.pl

      590  echo $?

      591  rm -f /tmp/APM_1501060046.pl

      592  PS1='__SOLAR_WINDS_APM__'

      593  cd /tmp

      594  pwd

      595  cat>/tmp/APM_2094511809.pl

      596  chmod +x /tmp/APM_2094511809.pl

      597  perl /tmp/APM_2094511809.pl

      598  echo $?

      599  rm -f /tmp/APM_2094511809.pl

    after:

      699  PS1='__SOLAR_WINDS_APM__'

      700  cd /tmp

      701  pwd

      702  cat>/tmp/APM_659600651.pl

      703  chmod +x /tmp/APM_659600651.pl

      704  perl /tmp/APM_659600651.pl /usr/sbin/ntpdate 192.168.101.9

      705  echo $?

      706  rm -f /tmp/APM_659600651.pl

      707  PS1='__SOLAR_WINDS_APM__'

      708  cd /tmp

      709  pwd

      710  cat>/tmp/APM_1451913812.pl

      711  chmod +x /tmp/APM_1451913812.pl

      712  perl /tmp/APM_1451913812.pl 192.168.101.9

      713  echo $?

      714  rm -f /tmp/APM_1451913812.pl

      715  PS1='__SOLAR_WINDS_APM__'

      716  cd /tmp

      717  pwd

      718  cat>/tmp/APM_1117346234.pl

      719  chmod +x /tmp/APM_1117346234.pl

      720  perl /tmp/APM_1117346234.pl

      721  echo $?

      722  rm -f /tmp/APM_1117346234.pl

      723  PS1='__SOLAR_WINDS_APM__'

      724  cd /tmp

      725  pwd

      726  cat>/tmp/APM_1129663945.pl

      727  chmod +x /tmp/APM_1129663945.pl

      728  perl /tmp/APM_1129663945.pl

      729  echo $?

      730  rm -f /tmp/APM_1129663945.pl

      731  PS1='__SOLAR_WINDS_APM__'

      732  cd /tmp

      733  pwd

      734  cat>/tmp/APM_741815028.pl

      735  chmod +x /tmp/APM_741815028.pl

      736  perl /tmp/APM_741815028.pl

      737  echo $?

      738  rm -f /tmp/APM_741815028.pl

      739  PS1='__SOLAR_WINDS_APM__'

      740  cd /tmp

      741  pwd

      742  cat>/tmp/APM_367851740.pl

      743  chmod +x /tmp/APM_367851740.pl

      744  perl /tmp/APM_367851740.pl

      745  echo $?

      746  rm -f /tmp/APM_367851740.pl

      747  PS1='__SOLAR_WINDS_APM__'

      748  cd /tmp

      749  pwd

      750  cat>/tmp/APM_1233473781.pl

      751  chmod +x /tmp/APM_1233473781.pl

      752  perl /tmp/APM_1233473781.pl

      753  echo $?

      754  rm -f /tmp/APM_1233473781.pl

      755  PS1='__SOLAR_WINDS_APM__'

      756  cd /tmp

      757  pwd

      758  cat>/tmp/APM_1628876267.pl

      759  chmod +x /tmp/APM_1628876267.pl

      760  perl /tmp/APM_1628876267.pl

      761  echo $?

      762  rm -f /tmp/APM_1628876267.pl

      763  PS1='__SOLAR_WINDS_APM__'

      764  cd /tmp

      765  pwd

      766  cat>/tmp/APM_1876979480.pl

      767  chmod +x /tmp/APM_1876979480.pl

      768  perl /tmp/APM_1876979480.pl

      769  echo $?

      770  rm -f /tmp/APM_1876979480.pl

      771  PS1='__SOLAR_WINDS_APM__'

      772  cd /tmp

      773  pwd

      774  cat>/tmp/APM_374894992.pl

      775  chmod +x /tmp/APM_374894992.pl

      776  perl /tmp/APM_374894992.pl

      777  echo $?

      778  rm -f /tmp/APM_374894992.pl

      779  PS1='__SOLAR_WINDS_APM__'

      780  cd /tmp

      781  pwd

      782  cat>/tmp/APM_733946067.pl

      783  chmod +x /tmp/APM_733946067.pl

      784  perl /tmp/APM_733946067.pl

      785  echo $?

      786  rm -f /tmp/APM_733946067.pl

      787  PS1='__SOLAR_WINDS_APM__'

      788  cd /tmp

      789  pwd

      790  cat>/tmp/APM_1747687265.pl

      791  chmod +x /tmp/APM_1747687265.pl

      792  perl /tmp/APM_1747687265.pl

      793  echo $?

      794  rm -f /tmp/APM_1747687265.pl

      795  PS1='__SOLAR_WINDS_APM__'

      796  cd /tmp

      797  pwd

      798  cat>/tmp/APM_1488649455.pl

      799  chmod +x /tmp/APM_1488649455.pl

      800  perl /tmp/APM_1488649455.pl

      801  echo $?

      802  rm -f /tmp/APM_1488649455.pl

      803  PS1='__SOLAR_WINDS_APM__'

      804  cd /tmp

      805  pwd

      806  cat>/tmp/APM_1995397357.pl

      807  chmod +x /tmp/APM_1995397357.pl

      808  perl /tmp/APM_1995397357.pl

      809  echo $?

      810  rm -f /tmp/APM_1995397357.pl

      811  PS1='__SOLAR_WINDS_APM__'

      812  cd /tmp

      813  pwd

      814  cat>/tmp/APM_68352260.pl

      815  chmod +x /tmp/APM_68352260.pl

      816  perl /tmp/APM_68352260.pl

      817  echo $?

      818  rm -f /tmp/APM_68352260.pl

      819  PS1='__SOLAR_WINDS_APM__'

      820  cd /tmp

      821  pwd

      822  cat>/tmp/APM_236473461.pl

      823  chmod +x /tmp/APM_236473461.pl

      824  perl /tmp/APM_236473461.pl

      825  echo $?

      826  rm -f /tmp/APM_236473461.pl

      827  PS1='__SOLAR_WINDS_APM__'

      828  cd /tmp

      829  pwd

      830  cat>/tmp/APM_1387222431.pl

      831  chmod +x /tmp/APM_1387222431.pl

      832  perl /tmp/APM_1387222431.pl

      833  echo $?

      834  rm -f /tmp/APM_1387222431.pl

      835  PS1='__SOLAR_WINDS_APM__'

      836  cd /tmp

      837  pwd

      838  cat>/tmp/APM_384032079.pl

      839  chmod +x /tmp/APM_384032079.pl

      840  perl /tmp/APM_384032079.pl

      841  echo $?

      842  rm -f /tmp/APM_384032079.pl

      843  PS1='__SOLAR_WINDS_APM__'

      844  cd /tmp

      845  pwd

      846  cat>/tmp/APM_266357407.pl

      847  chmod +x /tmp/APM_266357407.pl

      848  perl /tmp/APM_266357407.pl

      849  echo $?

      850  rm -f /tmp/APM_266357407.pl

      851  PS1='__SOLAR_WINDS_APM__'

      852  cd /tmp

      853  pwd

      854  cat>/tmp/APM_938369782.pl

      855  chmod +x /tmp/APM_938369782.pl

      856  perl /tmp/APM_938369782.pl

      857  echo $?

      858  rm -f /tmp/APM_938369782.pl

      859  PS1='__SOLAR_WINDS_APM__'

      860  cd /tmp

      861  pwd

      862  cat>/tmp/APM_1643361757.pl

      863  chmod +x /tmp/APM_1643361757.pl

      864  perl /tmp/APM_1643361757.pl /usr/sbin/ntpdate 192.168.101.9

      865  echo $?

      866  rm -f /tmp/APM_1643361757.pl

      867  PS1='__SOLAR_WINDS_APM__'

      868  cd /tmp

      869  pwd

      870  cat>/tmp/APM_2020596421.pl

      871  chmod +x /tmp/APM_2020596421.pl

      872  echo $?

      873  rm -f /tmp/APM_2020596421.pl

      874  PS1='__SOLAR_WINDS_APM__'

      875  cd /tmp

      876  pwd

      877  cat>/tmp/APM_2064800387.pl

      878  chmod +x /tmp/APM_2064800387.pl

      879  perl /tmp/APM_2064800387.pl

      880  echo $?

      881  rm -f /tmp/APM_2064800387.pl

      882  PS1='__SOLAR_WINDS_APM__'

      883  cd /tmp

      884  pwd

      885  cat>/tmp/APM_8740102.pl

      886  chmod +x /tmp/APM_8740102.pl

      887  perl /tmp/APM_8740102.pl

      888  echo $?

      889  rm -f /tmp/APM_8740102.pl

      890  PS1='__SOLAR_WINDS_APM__'

      891  cd /tmp

      892  pwd

      893  cat>/tmp/APM_118444692.pl

      894  chmod +x /tmp/APM_118444692.pl

      895  echo $?

      896  rm -f /tmp/APM_118444692.pl

      897  PS1='__SOLAR_WINDS_APM__'

      898  cd /tmp

      899  pwd

      900  cat>/tmp/APM_894246580.pl

      901  chmod +x /tmp/APM_894246580.pl

      902  echo $?

      903  rm -f /tmp/APM_894246580.pl

      904  PS1='__SOLAR_WINDS_APM__'

      905  cd /tmp

      906  pwd

      907  cat>/tmp/APM_1708078451.pl

      908  chmod +x /tmp/APM_1708078451.pl

      909  perl /tmp/APM_1708078451.pl

      910  echo $?

      911  rm -f /tmp/APM_1708078451.pl

      912  PS1='__SOLAR_WINDS_APM__'

      913  cd /tmp

      914  pwd

      915  cat>/tmp/APM_1453666724.pl

      916  chmod +x /tmp/APM_1453666724.pl

      917  perl /tmp/APM_1453666724.pl

      918  echo $?

      919  rm -f /tmp/APM_1453666724.pl

    It would seem SAM kindly removes the spaces for you.

  • This is a function or the Linux operating system, not of SAM. The easiest solution is to utilize a different user account, granting the permissions necessary using the chmod command for the scripts to execute properly.

  • I'm new to this product and I'm trying like mad to do this as well.  What I can say, if I put in my bash profile to find root logged in from orion server, then it would run:  shopt -u -o history

    This works and ssh debug doesn't show any errors but it still continues.  I'm with you dennyj and I will continue to work on this.  While it's the way Linux is, ridiculous to clobber the history file.  Best thing, implement scripts by default with sudo, that's the nature of Linux, securing, managing and ......  best practice.