A new in vitro and in vivo solid-phase microextraction (SPME) sampling method using pencil lead fiber coupled with gas chromatography was developed for a fast, easy and reliable monitoring and recognition of volatile defensive chemical of scent gland of Graphosoma Lineatum (L.) ( Heteroptera Pentatomidae). The efficiency of three methods: (1) in vitro surgical sampling and direct injection in GC analysis known as a classical method, (2) in vitro surgical sampling, SPME/GC analysis and (3) in vivo SPME/GC method were investigated. The efficiency and reliability of homemade pencil lead fiber was evaluated and compared by commercial polydimethylsiloxane (PDMS) fiber. Some effective and experimental parameters, such as extraction time, chromatographic conditions were examined and optimized. The obtained results reveal that the in vivo SPME/GC is much better than in vitro pentane extraction of volatile compounds followed by either headspace SPME or direct injection and GC analysis. From the results obtained, for the studied chemicals, the extraction capacity of pencil lead fiber is about 1000-fold more than commercial PDMS fiber.