Here is a Perl script which show the IP to every process

Discuss usability issues, general maintenance, and general support issues for a grsecurity-enabled system.

Here is a Perl script which show the IP to every process

Postby msi » Sat Apr 24, 2004 9:01 am

Hello,

i've wrote a perl script, which shows the ps ax output with one further field: the ip address. It is much slower then the ps command, but I don't mind.

Code: Select all
#!/usr/bin/perl

$a = `ps ax`;
@r = split(/\n/, $a);

$co=0;
foreach $_(@r) {
        $co++;
        /^([0-9]+)\s/;
        $c = `cat /proc/$1/ipaddr 2>/dev/null`;
        chomp($c);
        if ($co==1) {
                printf ("%-15s ", "       IP");
        } else {
                if ( $c != "") {
                        printf ("%15s ",$c);
                } else {
                        printf ("%15s ","-");
                }
        }
        print;
        print "\n";
}


have fun!

Markus
msi
 
Posts: 29
Joined: Fri Sep 13, 2002 2:37 pm

Return to grsecurity support